Skip to content

Fix analytics SDK shutdown and device-cookie cleanup - #1704

Closed
David Pine (IEvangelist) wants to merge 1 commit into
mainfrom
ievangelist-cookie-compliance
Closed

David Pine (IEvangelist) wants to merge 1 commit into
mainfrom
ievangelist-cookie-compliance

Conversation

@IEvangelist

Copy link
Copy Markdown
Member

Summary

Apply updated analytics settings before reloading the page, and prevent a delayed SDK bootstrap from initializing with stale settings.

  • Disable SDK cookie writes and pause the collection channel when Analytics becomes false, rather than unloading and flushing queued events.
  • Remove only MicrosoftApplicationsTelemetryDeviceId, covering root-path host-only and current-domain variants while preserving other cookies.
  • Recheck the current Analytics value immediately before SDK initialization. Existing regional defaults remain unchanged.
  • Add real-SDK coverage for cookie creation, reloads, setting changes, and client navigation across desktop, tablet, and mobile. Tests route local content through the production origin and intercept collection requests so test events never reach the production collector.
  • Document the runtime behavior and focused regression commands.

Third-party links and affiliations

None.

Validation

  • Focused Playwright suite covering cookie settings, analytics scripts, and dialog layout: 99 passed across the existing three Chromium viewport projects.
  • Related unit/component suites covering analytics contracts, redirects, custom components, and site tour: 99 passed.
  • Analytics contract suite rerun before publication: 9 passed.
  • Targeted JavaScript/TypeScript lint, changed-test type checking, browser-test formatting, and Git whitespace checks passed.
  • No local production build was run; production compilation remains on the existing CI path.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 21, 2026 16:26

Copilot AI 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.

Copilot review overview

🔵 Needs a closer look

Analytics shutdown and consent changes span runtime code, cookies, and browser behavior and warrant final human review.

Review effort: Lite
Findings: None

What changed in this PR

Updates analytics consent handling to prevent stale SDK initialization, stop telemetry on withdrawal, and clean up only the device identifier cookie.

Changes:

  • Rechecks consent before SDK initialization.
  • Disables cookies, pauses collection, and removes scoped device-cookie variants.
  • Adds unit and real-SDK E2E coverage.
  • Documents analytics behavior and validation commands.
File Description
src/​frontend/​tests/​unit/​analytics-script-contracts.vitest.test.ts Tests consent guards and failure handling.
src/​frontend/​tests/​e2e/​cookie-consent.spec.ts Adds cookie, SDK, reload, withdrawal, and navigation coverage.
src/​frontend/​src/​components/​starlight/​Head.astro Applies consent changes and performs scoped analytics cleanup.
src/​frontend/​public/​scripts/​analytics/​1ds.js Prevents initialization without current analytics consent.
.github/​astro.instructions.md Documents analytics behavior and regression commands.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Frontend HTML artifact ready

The latest frontend build uploaded the frontend-dist artifact for PR #1704. Use the VS Code button below to open this PR with GitHub Artifacts Explorer and browse the built HTML locally.

VS Code: Open PR #1704 artifacts

This comment updates automatically when a new frontend build artifact is uploaded.

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.

2 participants