fix(site): send analytics events in the WebSDK's XDM shape - #2815
Conversation
The custom analytics events dispatched from Analytics.astro never reached Adobe. The AWS WebSDK listens on a single event name, custom-awsm-acs-event-listener, and reads event content from the XDM _aws namespace (detail.xdm._aws.<ns>). Our code dispatched to two non-existent listener names (custom-awsm-acs-analytics-event-listener, custom-awsm-acs-search-event-listener) and wrapped content in detail.data, so the SDK's validators rejected and silently dropped every event. The page-view/scroll/link data that did appear came from the SDK's own auto-instrumentation, not from this code; internal search had no auto-equivalent, which is why it showed zero. Fix the dispatch layer to use the single correct listener and the detail.xdm._aws.<ns> envelope, verified against the upstream packages (AWSMarketingAdobeWebSDKClientSideLibs, AWSMarketingAdobeWebSDKHelpers) and the production wsdk.js bundle. Also remove the invalid pageView pageInteraction event (no such PageInteractionName exists; the SDK auto-fires the standard page view) and the dead site-section fields, which have no destination variable. Extend click tracking to cover existing interactive UI now that events land: language toggle, GitHub dropdown links, sidebar group expand, content tabs, landing CTAs, blog cards/nav, and landing/install code-copy buttons.
Documentation Preview ReadyYour documentation preview has been successfully deployed! Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-cms-2815/docs/user-guide/quickstart/overview/ Updated at: 2026-06-16T14:15:00.507Z |
|
Assessment: Comment Well-scoped, carefully researched bug fix — the two root causes (wrong listener name, wrong payload envelope) are correct, and I independently verified every new click-tracking selector against the live source markup ( Review themes
Solid investigation work tracing this against the upstream packages and production bundle — the selector labeling is clean and the dead page-view removal is the right call. |
pageHierarchy assumed the path began with /docs/, so on a deploy with a base path (e.g. the /pr-xxxx/ preview) the prefix leaked into the label (code-copy:pr-cms-2815|docs|...). Anchor on the 'docs' segment and take everything after it so any leading base path is ignored.
Address review feedback on the analytics tracking: - Navigating clicks (nav tabs, language toggle, GitHub menu, landing CTAs, blog cards/nav, outbound links) now dispatch with useBeacon=true so the request isn't cancelled when the page unloads - the same drop-on-navigation failure this PR otherwise fixes. Beacon is keyed off whether the click navigates, not the CTA type string, since nav-tab/lang-toggle navigate but are typed 'click'. - Drop the View Transition / astro:page-load comments that implied SPA navigation; ClientRouter isn't enabled, so each navigation is a full reload and the IIFE re-runs fresh. The page-load listener is kept as a guarded no-op in case view transitions are enabled later.
|
Thanks for the thorough review. Addressed in 0969bc1, with replies on both inline threads. Quick status on the other two themes:
|
|
Updated Assessment: Approve Re-reviewed after
Prettier passes on the file. The two open themes are reasonably dispositioned: Follow-up themes (non-blocking)
Nice work, and the beacon refinement is a genuine improvement over the original suggestion. |
|
Assessment: Approve Re-reviewed Verification of changes
On the two open themes: the test-coverage follow-up (extract the dispatch layer into an importable module + a single full-shape assertion) is a reasonable scope call to defer — please do track it, since this is the contract that already regressed once. The remaining manual check (an accepted beacon actually reaching the Adobe collect endpoint post-consent) is the one thing automation can't cover here, so a human pass through the cookie banner on the preview before merge is worthwhile. Nicely handled — the beacon refinement improved on the original suggestion. |
…turn Address review nits on the analytics click tracking: - Collapse whitespace on all CTA labels centrally in dispatchCTAClick, so labels from element textContent (icons/SVG/newlines) stay clean and consistent. Drops the now-redundant per-call normalization on home-cta. - Guard the install code-copy label: fall back to 'install' instead of emitting 'install:' with an empty tail if a [data-copy] ancestor is ever missing. - Add the missing return to the outbound-link handler so appending a handler below it can't accidentally shadow it, matching every sibling handler.
|
Addressed the actionable nits in 28f08be:
|
|
Assessment: Approve (unchanged) Re-reviewed
Prettier passes. The dispositions on the defensive No further blocking items from me — good to merge once a human completes the post-consent beacon check on the preview. |
Description
The custom analytics events dispatched from
site/src/components/Analytics.astrowere never reaching Adobe. Two independent bugs in the dispatch layer caused every custom event to be silently dropped:custom-awsm-acs-event-listener. Our code dispatched to two names that the SDK does not listen on:custom-awsm-acs-analytics-event-listenerandcustom-awsm-acs-search-event-listener.detail.xdm._aws.<namespace>and validates it before sending. Our code wrapped content indetail.data.<namespace>, so the validators rejected and dropped each event.Because of this, the page-view / scroll / link-click data visible in Adobe actually came from the SDK's own auto-instrumentation (auto page views, scroll detection,
clickCollectionEnabledlink tracking) — not from this code. Internal search has no SDK auto-equivalent, which is why search reporting showed zero and surfaced the bug.I verified the correct contract against the upstream packages
AWSMarketingAdobeWebSDKClientSideLibsandAWSMarketingAdobeWebSDKHelpers(thehelpers/*-event.tsbuilders and the listener constant), and confirmed it against the productionwsdk.jsbundle served fromd0.m.awsstatic.com(it listens only oncustom-awsm-acs-event-listenerand reads_aws/searchOperations/customCTAClick).What changed
custom-awsm-acs-event-listener, wrapping content asdetail.xdm._aws.<namespace>(search, custom CTA, and scroll all updated).pageInteractionwithname: 'pageView', but the only validPageInteractionNamevalues areimpressionandscroll; the SDK auto-fires the standardweb.webpagedetails.pageViewsitself. The deadsiteSection/hierarchyfields it carried had no destination variable on the report suite and are removed.docspath segment) so a deploy base path like/pr-xxxx/does not leak into the label.lang-toggle:<lang>github-menu:<label>sidebar-expand:<group>tab:<label>home-cta:<text-or-href>blog-card:<href>,blog-nav:<label>CodeBlockand install-command buttons →code-copy:<hierarchy|install:cmd>Related Issues
Type of Change
Bug fix
Testing
Verified end to end against the deployed PR preview build (
https://d3ehv1nix5p99z.cloudfront.net/pr-cms-2815/) using browser automation. Attached listeners for both the correct event name and the two old (buggy) names, then triggered real clicks and inspected each dispatched event.Result — every custom event now fires on
custom-awsm-acs-event-listenerwith thedetail.xdm._aws.*shape; zero events on the old listener names, and nodetail.datapayloads:eventTypexdm._awscontentweb.awsm.customCTAClickpageInteraction.click = { name: "lang-toggle:Python", type: "click" }web.awsm.customCTAClickpageInteraction.click = { name: "github-menu:Python SDK", type: "linkClick" }web.awsm.customCTAClickpageInteraction.click = { name: "code-copy:install:pip install strands-agents", type: "customClick" }web.awsm.customCTAClickweb.awsm.customCTAClickpageInteraction.click = { name: "sidebar-expand:Tools", type: "click" }Preview testing also surfaced the base-path bug: on the
/pr-cms-2815/preview the code-copy label was originallycode-copy:pr-cms-2815|docs|user-guide|.... After the base-path-aware fix it correctly resolves touser-guide|observability-evaluation|logson both preview and production-style paths (andhomefor/).Not yet confirmed: that the SDK forwards an accepted beacon to
edge.adobedc.net/ee/.../v1/interactafter consent. A reviewer can confirm by loading the preview, accepting performance cookies, and watching the Network tab while searching/clicking — the dispatched event shape is verified correct, so this is the only remaining link in the chain.hatch run prepareChecklist