Repository navigation
feat(server): add url option to report another page URL - #213
Merged
Merged
Conversation
The server senders report the URL of the incoming request in the `o` field, taken from the request context or the referer. Callers that sanitize that URL (credentials, emails in callback queries) had no way to replace it. `track`, `identify`, `group` and `trackExposure` now accept `options.url`, which wins over both. An invalid value fails the send instead of falling back to the URL the caller meant to replace.
|
Your Vercel team Analytics Test Projects is not permitted to deploy from this git repository. Contact an administrator to add github organization vercel as a Protected Git Scope in Analytics Test Projects on Vercel. Once added, commit again to see your changes. Learn more: https://vercel.com/docs/security/protected-git-scopes |
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.
🖖 What's in there?
Adds an optional
urlto the options of the server senders (track,identify,group,trackExposure).Server events report the URL of the incoming request in their
ofield, taken from the request context or from therefererheader. Callers had no way to replace it, so a URL carrying a token or an email in its query (OAuth callbacks, magic links) was sent as is. Withurl, the caller reports the page URL it wants, for example after stripping sensitive query parameters.An invalid
url(relative, non-http) fails the send with an error in the console, instead of falling back to the URL the caller wanted to replace.🤺 How to test?
pnpm --filter @vercel/analytics exec vitest run src/serverNew cases cover:
urlwins over therefererheader and over the request-context URL (none of the original query parameters survive in the payload)urlis not passed/relative,not a url,ftp://…, empty string) do not send🔬 Notes to reviewers
resolveUrl(): expliciturl→ request-context URL →referer→ endpoint origin. Only the first step is new.Optionsinterface, so all four senders get it and the type shows up indist/server/index.d.ts.