GDPR consent
The Flare client can run behind a cookie consent or GDPR banner. Use consent to control new error, log and trace sends. Automatic breadcrumb collection has a separate setting, so control both when your application's policy requires consent before collection.
The Flare client never sets cookies, but it does read cookies when attaching context to an error. Asking the user's consent is mostly about the data the client sends to Flare.
Turning the client on and off
By default the consent configuration setting starts at true. Enabling/disabling consent is one method:
flare.setConsent(true); // allow sending
flare.setConsent(false); // stop sending, and drop buffered logs and spans
setConsent(false) blocks new sends and clears buffered logs and spans. It cannot recall requests already sent. setConsent(true) allows sending again.
In client version 2.13.0, withdrawing consent does not clear automatic breadcrumbs or stop their collection while enableBreadcrumbs remains true. A later grant can include those breadcrumbs in a new error report. Set enableBreadcrumbs to false on withdrawal to clear them and remove the browser listeners. Consent is a sending control, not a general purge of every kind of client context.
Recommended setup
Start with consent and breadcrumbs off. Call flare.light() only when the visitor accepts the consent banner, and enable breadcrumbs at that point if you want them. The Cookiebot example below shows where to connect your banner's acceptance and withdrawal callbacks; apply your own consent-category policy when wiring them.
import { flare } from '@flareapp/js';
flare.configure({ hasConsent: false, enableBreadcrumbs: false });
// Cookiebot example. OneTrust exposes OptanonWrapper; the idea is the same.
window.addEventListener('CookiebotOnAccept', () => {
flare.setConsent(true); // allow sending
flare.light('YOUR PROJECT KEY'); // first grant: start the client
flare.configure({ enableBreadcrumbs: true });
});
window.addEventListener('CookiebotOnDecline', () => {
flare.configure({ enableBreadcrumbs: false });
flare.setConsent(false); // withdrawal: stop sending, drop buffered logs and spans
});
Starting with consent off
If you already call flare.light() at boot, start with consent off instead, then turn it on when the
visitor accepts:
import { flare } from '@flareapp/js';
flare.configure({ hasConsent: false, enableBreadcrumbs: false }); // start off, before anything can send
flare.light('YOUR PROJECT KEY');
window.addEventListener('CookiebotOnAccept', () => {
flare.setConsent(true);
flare.configure({ enableBreadcrumbs: true });
});
window.addEventListener('CookiebotOnDecline', () => {
flare.configure({ enableBreadcrumbs: false });
flare.setConsent(false);
});
Put configure() first, immediately after the import, so consent and breadcrumbs are off before initialization. Prefer the recommended setup when you can delay initialization until consent is granted. Neither example replaces deciding which data your application may collect or send.
See the configuration reference for hasConsent, and the
API reference for setConsent().