Skip to content

feat(analytics): expose active A/B flags on window.DECO.flags - #90

Merged
guitavano merged 1 commit into
mainfrom
feat/expose-deco-flags
Jul 8, 2026
Merged

feat(analytics): expose active A/B flags on window.DECO.flags#90
guitavano merged 1 commit into
mainfrom
feat/expose-deco-flags

Conversation

@guitavano

@guitavano guitavano commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

OneDollarStats already reads the deco_segment cookie to enrich pageviews/events, but kept the flags in a module-local variable. This mirrors them on window.DECO.flags (read-only) so app code and GTM can read the visitor's cohort directly.

window.DECO.flags // => { TestHero: true }
  • Set in initOneDollarStats right after readFlagsFromCookie().
  • Kept off window.DECO.events — that's the event bus, not state.
  • Preserves any existing window.DECO (e.g. .events) — only assigns .flags.
  • Cast-based assignment to avoid coupling to the bus's Window typing (owned by the site runtime).

Tests: adds coverage that window.DECO.flags is populated from the cookie and that window.DECO.events is preserved.

🤖 Generated with Claude Code


Summary by cubic

Expose active A/B flags from the deco_segment cookie on window.DECO.flags so app code and GTM can read the visitor’s cohort. Keeps window.DECO.events unchanged and treats flags as a read-only mirror.

  • New Features
    • Populate window.DECO.flags in initOneDollarStats using readFlagsFromCookie().
    • Preserve any existing window.DECO (including .events) and avoid coupling to site runtime types.

Written for commit 805cb02. Summary will update on new commits.

Review in cubic

OneDollarStats already reads the deco_segment cookie to enrich pageviews and
events, but kept the flags module-local. Mirror them on window.DECO.flags
(read-only) so app code and GTM can read the visitor's cohort. Kept off
window.DECO.events (that's the event bus, not state).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@guitavano
guitavano requested a review from a team July 8, 2026 03:12
@guitavano
guitavano merged commit aeeb2fb into main Jul 8, 2026
2 checks passed
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 5.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant