Where should a meditation app's analytics consent gate and personal-data scrubbing sit, and why before events reach the queue, for users in many countries?
answer
- one gate at the front
- on disk is one step from sent
- consent saved with its version
- withdrawal empties the unsent queue
- allow-list, not deny-list
basics
~20 sBoth belong in the single entry point every event passes, before anything is written to the queue, because whatever is queued will be uploaded. Check the stored consent first, then keep only the typed properties the event's schema allows.
solid answer
~50 sI'd put both at the front of the pipeline, inside the one `track()` call every event goes through, before anything is persisted. The consent check reads a stored record: the purposes allowed, the policy version the user saw, and when. Where the law requires consent first, nothing is recorded until the user agrees, and analytics SDKs are not started in a collecting mode either, since they record and send on their own. Withdrawing consent stops recording, deletes the unsent queue and resets the analytics id. Scrubbing then keeps only the properties the event's schema allows, as typed values: no free text from the mood journal, no email in a deep-link URL, a country instead of coordinates. A deny-list of patterns is only a backstop. Both stores require a disclosure of what the app and its SDKs collect, and this gate is what keeps that disclosure true.
code
json · 12 lines{
"consent": {
"policy_version": "2026-09",
"mode": "prior_consent_required",
"purposes": {
"product_analytics": "granted",
"ad_attribution": "denied"
},
"decided_at": "2026-10-07T21:14:09Z",
"source": "first_launch_prompt"
}
}go deeper
Recall that consent is checked and personal data removed before an event is saved, and that free text and precise location stay on the phone.
Explain the consent record's fields, what grant and withdrawal do to the queue and the analytics id, and why an allow-list fails closed.
Handle the regional modes, the offline first launch with an unknown region, SDKs that send on their own, and identity reset at sign-out.
Own the rule that every event property is registered and reviewed for personal data, and that the store disclosures are generated from that registry.
## Why the gate goes at the front An event passes through a short pipeline: **track → consent gate → scrub → queue → upload**. Putting the checks at upload time is too late: - events can sit on disk for days, and can be copied into a device backup; - a bug or an SDK can upload them before the check runs; - the user can change their mind while events wait. One store's disclosure rules define collecting as transmitting data off the user's device, and both stores hold the app responsible for what its SDKs collect. The only point where nothing has been stored or sent is the moment the event is created, so that is where both checks run. ## The consent record The client keeps a small consent record and consults it on every `track` call: - **Purposes**, separately: product analytics, advertising attribution, and any other use. - **Policy version**: when the privacy text changes materially, the app asks again. - **Mode**: whether this user's region requires consent before collection, or allows collection with an opt-out. Which rule applies where is a legal decision made per region; the client must support both modes and switch by a remotely configured map. - **Unknown region**: on an offline first launch the region may be unknown, so the client uses the strictest mode until it knows. The consent version also travels in every event's envelope, so the server can prove which choice each event was collected under. ## Gating, step by step 1. **Before a choice**, in a region that requires prior consent: no analytics events are recorded, no analytics id is minted, and no analytics SDK is started in a mode that collects, because those libraries record and send on their own once running. 2. **On grant**: recording starts from that moment. Nothing from before is backfilled, because nothing was recorded. 3. **On withdrawal**: recording stops, the unsent queue is deleted and the analytics install id is replaced, so later data cannot be joined to earlier data. Purging is the usual design choice because the user expects nothing more to leave the phone; deleting what the server already holds is a server-side request. 4. **Tracking across other companies' apps** is separate again: one platform requires its own system permission before an app tracks a user across other companies' apps and websites or reads the advertising identifier, and that answer must be respected even when the app's own consent screen says yes. ## Scrubbing on the device Scrubbing works from an **allow-list**: the schema says which properties each event may carry and of which type, and everything else is removed. | Risk in this app | Rule | |---|---| | Mood-journal text | no free-text property exists in the schema | | A deep link such as `/redeem?email=...` | send the route template, never the query string | | Location used for local reminder times | country or region code, not coordinates | | A user-named playlist | the playlist id, not its title | | An error message echoing user input | an error code from an enum | A deny-list of patterns (emails, phone numbers) catches only what someone predicted, and fails open: a new property is sent until someone notices. An allow-list fails closed: a new property is dropped until it is registered and reviewed. A pattern scan still runs as a backstop that drops and counts any match. Deciding which data is personal belongs to the data governance process; the client enforces its result. ## Identity - The **install id** is a random UUID minted after consent, never a hardware identifier. - The **account id** is attached only when the user is signed in and has allowed it. A pseudonymous id is still personal data: one store states that data collected pseudonymously must still be disclosed. - **At sign-out**, the account id is detached and a new install-level analytics id begins, so the next person on a shared device is not joined to the last. ## Keeping the store disclosure true Both stores require the app to declare what it collects, SDKs included, and one store's declaration covers the sum of every version still distributed. The registry's allow-list is the list that declaration should be written from, and a property added to it is a change to the declaration as well.
- Can the app queue events before consent and send them only if the user agrees?Not where the law requires consent before collection: recording and storing the events is already processing, and a stored queue is exactly what the gate exists to prevent. Where the rules allow collection with an opt-out, recording before a choice may be permitted, so the client supports both modes by region rather than baking in one.
- What should happen to analytics identity when a user signs out on a shared tablet?Stop attaching the account id and start a fresh install-level analytics id, so the next person's events are not joined to the previous account. Events already queued were recorded under the first user's consent and identity, so they can still be sent as they are.
- Record everything on the device and check consent at the server.
- A deny-list of email and phone patterns keeps personal data out.
- Hashing an email makes it anonymous, so it can be the analytics user id.
- Analytics SDKs can start collecting at launch and hear about consent later.
- The store disclosure only covers data the team's own code sends.