Skip to content

fix(analytics): remember a visitor's Decline so "on" pages send nothing before the banner replays it - #363

Merged
Amit-Shvil merged 3 commits into
mainfrom
visitor-tracking/sdk-remember-decline
Nov 4, 2026
Merged

Amit-Shvil merged 3 commits into
mainfrom
visitor-tracking/sdk-remember-decline

Conversation

@Amit-Shvil

Copy link
Copy Markdown
Contributor

Bug

App mode On (<meta name="base44-analytics" content="on">). A visitor declines in the app's cookie banner. On every following page load (real-browser test of @base44/sdk@0.8.58-beta.0 on Cookie Lab Test, 2026-11-03):

317ms setItem base44_analytics_session_id=…
318ms xhr …/analytics/track/batch
372ms gtag consent update {"analytics_storage":"denied",…}   ← banner replays the saved Decline
372ms removeItem base44_analytics_session_id

The SDK stores the id and sends one batch before the denial arrives.

Fix

  • New localStorage marker base44_analytics_denied = "1". A denial writes it; a grant removes it.
  • initialConsentGranted(mode): consent → false; on → not denied; else true. Used for the initial analytics-consent state.
  • Storage throws → marker reads as "not denied" (same as today; the banner replay still stops tracking).
  • Mode consent → on after a Decline: the visitor stays untracked until they Accept. Intended: it honors their choice.

Tests

New unit test in analytics-consent.test.ts: after a Decline, the next "on" page stores and sends nothing; a later Accept clears the marker and starts tracking. Local npm ci failed (local npm proxy 502 on follow-redirects), so CI is the test run.

Release

Ship in 0.8.58 (beta.0 already published from main 150fabb).

🤖 Generated with Claude Code

…ng before the banner replays it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.8.58-beta.0-pr.363.6724db0

Prefer not to change any import paths? Install using npm alias so your code still imports @base44/sdk:

npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.58-beta.0-pr.363.6724db0"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.58-beta.0-pr.363.6724db0"
  }
}

Preview published to npm registry — try new features instantly!

…d-Decline test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the docs-draft PR has auto-drafted documentation suggestions label Nov 3, 2026
@Amit-Shvil
Amit-Shvil requested a review from guyofeck November 3, 2026 15:32

@Maozsm Maozsm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, ship it

@Amit-Shvil
Amit-Shvil merged commit 95091d2 into main Nov 4, 2026
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-draft PR has auto-drafted documentation suggestions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants