chore(mcp-adoption-value-discovery): Adding docs traffic sources attrs#1002
Conversation
| integrations: [Sentry.browserTracingIntegration()], | ||
| }); | ||
|
|
||
| resolveAttribution(); |
There was a problem hiding this comment.
beforeSendSpan might be a good alternative here, removes the assumption that the pageload span is active when resolveAttribution runs.
Something like:
const utmSource = resolveUtmSource(
new URLSearchParams(window.location.search).get("utm_source"),
);
const referrerFamily = resolveReferrerFamily(document.referrer);
Sentry.init({
// ...
integrations: [Sentry.browserTracingIntegration()],
beforeSendSpan(span) {
if (span.op === "pageload") {
span.data = {
...span.data,
...(utmSource && { "app.utm_source": utmSource }),
...(referrerFamily && { "app.referrer.family": referrerFamily }),
};
}
return span;
},
});There was a problem hiding this comment.
@jaydgoss great callout, pushed the change thanks 💯
There was a problem hiding this comment.
fwiw im not a fan of beforeSendSpan and that kind of magic behavior. its way too brittle. much safer to just bind it explicitly where its needed so it doesnt randomly break in the future when e.g. op gets renamed or something like that
There was a problem hiding this comment.
yeah I understand ^, beforeSendSpan + op filter does end up coupled to internal SDK strings.
Reverting to explicit getActiveSpan + setAttribute right after init in the next push
| beforeSendSpan: attributionBeforeSendSpan, | ||
| environment: | ||
| import.meta.env.VITE_SENTRY_ENVIRONMENT ?? import.meta.env.NODE_ENV, | ||
| integrations: [Sentry.browserTracingIntegration()], |
There was a problem hiding this comment.
i think i had this disabled because the data is mostly inactionable/junk. we can see how it goes but i want to make sure the quality of the telemetry stays as high as it can on this project
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3020473. Configure here.

Enables Sentry browser tracing on the SPA so we get pageload transactions for mcp.sentry.dev/ traffic. Added two attrs for traffic source tracking:
app.utm_source— sanitized in-product utm_source query param from window.location. Used to group by in-app sources as we surface mcp doc links more in Sentry.app.referrer.family— low-cardinality bucket of the Referer header host: google, github, sentry, sentry-docs, or other for now. Used to see where external traffic is arriving from.