Prevent server / client click ID mismatch#60
Merged
steven-tey merged 2 commits intomainfrom May 26, 2025
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This PR updates the click-tracking logic to detect and skip on mismatches between the click ID returned from the server and the ID provided by the client (e.g., from a query parameter).
- Extended
trackClickto accept a second parameter (serverClickId) for comparison. - Added a check that logs a warning and aborts cookie setting when IDs differ.
- Updated the call site to pass through the click ID for validation.
Comments suppressed due to low confidence (3)
packages/script/src/base.js:90
- [nitpick] The parameter name
serverClickIdis misleading—it's actually the expected click ID from the query parameter. Consider renaming it toexpectedClickIdorqueryParamClickIdfor clarity.
function trackClick(identifier, serverClickId) {
packages/script/src/base.js:109
- The variable
queryParamClickIdis undefined in this scope; it should reference theserverClickIdparameter instead.
Client-tracked click ID ${data.clickId} does not match server-tracked click ID ${queryParamClickId}, skipping...
packages/script/src/base.js:152
- The variable
clickIdis not defined in this scope. You likely meant to pass the parsed query parameter value (e.g.,queryParamClickId).
trackClick(QUERY_PARAM_VALUE, clickId);
There was a problem hiding this comment.
Pull Request Overview
This PR adds a server/client click ID validation in the click tracking function to prevent mismatches between client-tracked and server-tracked IDs.
- Modified the trackClick function to accept an additional serverClickId parameter and added a warning when the IDs do not match.
- Updated the invocation of trackClick to include the server-side clickId in its arguments.
Comments suppressed due to low confidence (1)
packages/script/src/base.js:152
- Ensure that 'clickId' is defined and holds the intended server-side click ID value before passing it to trackClick; an undefined clickId could cause the new validation check to be ineffective.
trackClick(QUERY_PARAM_VALUE, clickId);
devkiran
approved these changes
May 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.