Skip to content

feat(analytics): follow the app owner's choice and the visitor's consent - #351

Open
Amit-Shvil wants to merge 1 commit into
base44:mainfrom
Amit-Shvil:analytics-follows-consent
Open

Amit-Shvil wants to merge 1 commit into
base44:mainfrom
Amit-Shvil:analytics-follows-consent

Conversation

@Amit-Shvil

Copy link
Copy Markdown

What

App Analytics follows the app owner's choice and the visitor's consent. Today the SDK writes base44_analytics_session_id (localStorage, no expiry) and sends analytics on load even when the app's cookie banner declined.

The Base44 server marks published pages with <meta name="base44-analytics"> (base44-dev/apper, behind a flag):

Meta SDK
off no id stored, no /analytics/ event, no logUserInApp
consent nothing until Google Consent Mode analytics_storage is granted (via window.__b44Consent, which the server injects); a later denial stops it and removes the id
on as today; a banner's denial stops it and removes the id
absent unchanged
  • Before consent the id lives in memory only, so X-Base44-Anonymous-Id / the socket anonymous_id stay stable for the tab. It is stored once consent is granted (the same id).
  • Consent state lives in its own shared instance (analytics-consent), so an older SDK copy on the page that owns analytics can't break it.

Release

Please ship as a 0.8.x patch (templates pin ^0.8.54).

Tests

tests/unit/analytics-consent.test.ts: no storage write or request before a grant; grant starts, revoke stops and removes the key; off sends nothing; on and no-meta unchanged. 4 of 5 fail without the change. Full suite: 413 passed.

🤖 Generated with Claude Code

The server marks published pages with <meta name="base44-analytics">:
off never tracks or stores base44_analytics_session_id; consent waits for
Google Consent Mode analytics_storage via window.__b44Consent and removes the
id on a later denial; on tracks until a denial. No meta: unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant