Skip to content

fix: resolve multi-word audience/campaign names at page level - #65

Merged
ramboz merged 1 commit into
v2from
fix/multiword-audience-campaign-names
Aug 12, 2026
Merged

fix: resolve multi-word audience/campaign names at page level#65
ramboz merged 1 commit into
v2from
fix/multiword-audience-campaign-names

Conversation

@ramboz

@ramboz ramboz commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Problem

A page-level audience or campaign with a multi-word name (e.g. returning-visitor, black-friday) resolves its membership but never serves the variant — the experience is silently dropped.

Root cause: page-level metadata is read with getAllMetadata, which camelCases keys (audience-returning-visitorreturningVisitor). Names are then matched + looked up in class-name form, and toClassName('returningVisitor')returningvisitor (the word boundary is lost), so it matches neither the project config key (returning-visitor) nor the camelCase one. Section- and fragment-level already key names by class-name, so they work — only page-level is affected.

Fix

  • getAllMetadata(scope, keyFn = toCamelCase) — an optional key transform. The default is unchanged, so experiments keep their camelCased config props (startDate, requiresConsent, …).
  • applyAllModifications passes toClassName for audience/campaign page metadata (experiments keep toCamelCase), matching how section- and fragment-level already read names.
  • Config readers (getAudienceConfig / getCampaignConfig) are unchanged — they already handle class-name keys.

Tests

Adds page-level fixtures + tests for a multi-word audience and a multi-word campaign name. They fail red before this change (the variant isn't served) and pass after. Full suite green — 101 tests, including experiments — no regression.


Found while building a bring-your-own-engine integration (see #64) — this is bug #2 from that RFC. It removes the need for hyphen-free tokens at page level.

🤖 Generated with Claude Code

Page-level audience/campaign metadata is read via getAllMetadata, which
camelCases keys (audience-returning-visitor -> returningVisitor). Names are then
matched + looked up in class-name form, and toClassName('returningVisitor') ->
'returningvisitor' (the word boundary is lost), so a multi-word name resolves
membership but never finds its variant URL -- the experience is silently not
served. Section- and fragment-level already key names by class-name and work.

getAllMetadata now takes an optional key transform (default toCamelCase, so
experiments keep their camelCased config props like startDate/requiresConsent).
applyAllModifications passes toClassName for audience/campaign page metadata,
matching section/fragment level. Config readers are unchanged.

Adds page-level fixtures + tests for a multi-word audience and campaign name
(red before this change). Full suite green (101), incl. experiments -- no regression.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

ramboz added a commit that referenced this pull request Aug 12, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ramboz
ramboz merged commit 3fa2579 into v2 Aug 12, 2026
4 checks passed
@ramboz
ramboz deleted the fix/multiword-audience-campaign-names branch August 12, 2026 18:45
github-actions Bot pushed a commit that referenced this pull request Aug 12, 2026
## [1.2.2](v1.2.1...v1.2.2) (2026-08-12)

### Bug Fixes

* resolve multi-word audience/campaign names at page level ([#65](#65)) ([3fa2579](3fa2579))
ramboz added a commit that referenced this pull request Aug 12, 2026
- rename tracking hook to rumTracking; note the existing aem:experimentation DOM events for custom tracking
- resolve two open questions into Decisions: one decision provider; reference worker in examples/
- reframe bug #2 as a clean cross-cutting fix (audiences/campaigns class-name at every level; experiments keep camelCase, with the why) and credit #65

Co-Authored-By: Claude Opus 4.8 <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