Repository navigation
feat(analytics): add restricted audience measurement - #226
francoischalifour wants to merge 4 commits into
Conversation
Use method-call notation consistently in adapter and dropped-call diagnostics. Format the queue limit for readability.
Add an initialization-only audience tracking mode while preserving the track() and page() APIs. Each event requests audience processing and omits identity fields after caller transforms. Keep identity, consent, and event buffers in memory; reduce automatic URL context; and omit credentials and referrers across retries and exit delivery. Reject analytics adapters and invalid mode changes before replacing the active client. Keep analytics policy in the client and pass request options to the transport. Cover behavior through public APIs and validate the exported configuration and payload types from packed packages.
Document audience collection, persistence, consent, transforms, and initialization-only mode changes. Distinguish transform inputs from the restricted audience wire payload and explain the adapter restriction.
Document that Audience mode removes search query parameters from automatic page tracking and show how to track search usage and result counts explicitly. Note that collecting search terms requires reviewing them for personal data.
albert20260301
left a comment
There was a problem hiding this comment.
No blocking SDK findings. Audience mode applies the wire contract after transforms, omits identity fields and persistent storage, rejects adapters and mode changes through configure(), and preserves the transport restrictions through retry and exit delivery. Product-mode defaults remain covered.
Local build/types/lint/Knip/format, all 716 unit tests, bundle budgets and packed React 16/current consumers pass. The packed-consumer check required an isolated temporary directory because of the host's shared /tmp TypeScript configuration. Required CI, including integration and both native compatibility lanes, is green.
This verifies the SDK-side opt-in contract only. The backend processing/enrichment/logging work listed in the PR remains required for end-to-end audience-processing guarantees; custom event properties and URL paths remain application-owned.
What
Add
trackingMode: 'audience'for aggregate usage measurement without persistent client identifiers.Usage
Automatic page views and custom events carry
processing_mode: 'audience'. React hooks use the shared client without API changes.Audience mode:
identify(),alias(), andupdateTraits().trackingConsentstill controls delivery. Pending or dismissed events wait in memory; denied events are discarded. Unsent events are lost on reload.Search usage can be measured explicitly with events such as
Search Performedand reviewed properties such ascategoryandresult_count. Search terms require review before collection because they can contain personal data.Why
Provide a collection mode designed for audience measurement with a simple setup and enforceable event contract. Cookie usage alone does not describe the collection or processing policy.
Design decisions
track(),page(), andtransformEvent. Transforms receiveTrackPayload; audience delivery usesAudienceTrackPayload.configure()excludestrackingMode. Callinginit()changes modes and discards buffered events; callers can flush first.Custom event names, properties, and URL paths still require application review.
transformEventcan remove sensitive values before transmission.Remaining backend work
This PR implements the SDK portion. Backend support must:
processing_modebefore enrichment, logging, or queueing. Handle mixed batches per event, reject unknown modes, and reject identity fields on audience events.Checklist
CHANGELOG.mdupdatedconfigure()now explicitly excludes initialization-onlytrackingMode