Whats the correct way to opt in tracing after Cookie consent is given? #6211
Unanswered
Speedy1991
asked this question in
Q&A
Replies: 2 comments 2 replies
-
BrowserTracing should not be adding any cookies - any reason why you need this logic? Interesting this is a problem though, |
Beta Was this translation helpful? Give feedback.
2 replies
-
I ran into a similar problem for an internal project and went with a custom transport that waits for a promise to resolve before events are actually sent. It could look like this: import { makeXHRTransport } from '@sentry/browser';
async function waitForConsent() { ... };
const hasConsentPromise = waitForConsent();
Sentry.getCurrentHub().bindClient(
new BrowserClient({
transport: (transportOptions) => {
const xhrTransport = makeXHRTransport(transportOptions);
return {
flush: (timeout) => xhrTransport.flush(timeout),
send: async (request) => {
const hasConsent = await hasConsentPromise;
if (hasConsent) {
return xhrTransport.send(request);
} else {
return undefined;
}
},
};
},
})
);
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, I'm doing something similar to this:
With
SENTRY_OPTIONS
asBrowserOptions
But after upgrading to
7.19.0
this code errors, because theBrowserclient
want'sBrowserClientOptions
which is obviously not the same object as I call in mySentry.init
(BrowserOptions
)So is this even the right approach? Or is there a completely different way to correctly opt-in
BrowserTracing
?Beta Was this translation helpful? Give feedback.
All reactions