Default-on, but the user can switch it off
Privacy law (GDPR and friends) requires you to honour what a user agrees to collect. Crossdeck's stance is collect by default — so you don't lose data to a forgotten config — paired with one switch to drop categories the moment a user opts out. You get full signal for the users who consent, and a clean, honest off-state for those who don't.
One call, per category
Pass any subset of the categories to consent() — the ones you set change, the rest stay as they were:
// user opted out of analytics but is fine with crash reporting
Crossdeck.consent({ analytics: false, errors: true });
// honour the browser's Do Not Track signal automatically, at init
Crossdeck.init({ publishableKey: "cd_pub_…", appId: "app_…", respectDnt: true });
Categories map to event families
Each consent category gates a family of events. Analytics consent gates your track() events and the auto-captured analytics; errors consent gates the error.* and webvitals.* families (crashes and performance). That separation is deliberate and useful: a user can decline analytics while still letting you capture the crash that's breaking their session — a reasonable, common choice.
respectDnt: true reads the browser's Do Not Track signal once at init and applies it as the starting consent, so you honour DNT without wiring anything yourself. The one rule of thumb: set consent before user-meaningful events fire, so a user's choice is in effect from the first event, not retroactively.
Collection that respects the choice
With consent wired, every event checks the user's current consent before it ships — analytics stop when analytics are declined, crash reports continue if the user allowed them, and Do Not Track is honoured from the first page view. Full data where you're allowed it, nothing where you're not.
This user's track() events are dropped at the boundary; their crash reports still flow — exactly the consent they gave.