Skip to content

feat(autocapture): attach selector algo config hash on zoning events - #1861

Draft
jxiwang wants to merge 1 commit into
mainfrom
cursor/attach-selector-config-hash-cacb
Draft

feat(autocapture): attach selector algo config hash on zoning events#1861
jxiwang wants to merge 1 commit into
mainfrom
cursor/attach-selector-config-hash-cacb

Conversation

@jxiwang

@jxiwang jxiwang commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Wires [Amplitude] Selector Algo Config Hash onto autocapture events that already flow through @amplitude/element-selector. This builds on the hashing primitives from #1841 and limits attachment to existing element-selector integration points only.

Where the hash is attached

@amplitude/element-selector is only consumed by plugin-autocapture-browser today, so the hash is attached there:

Event Integration point
[Amplitude] Element Clicked DataExtractor.getEventProperties()
[Amplitude] Element Changed DataExtractor.getEventProperties()
[Amplitude] Rage Click via targetElementProperties spread from getEventProperties()
[Amplitude] Dead Click / [Amplitude] Error Click via getEventProperties()
[Amplitude] Viewport Content Updated fireViewportContentUpdated() (element paths already come from DataExtractor.getElementPath())

Not included: [Amplitude] Page Viewedplugin-page-view-tracking-browser does not use @amplitude/element-selector, so no new dependency or subscription was added there.

What's added in @amplitude/element-selector

  • hashSelectorConfig() / canonicalizeSelectorConfig() — stable SHA-256 fingerprint of resolved config
  • AMPLITUDE_EVENT_PROP_SELECTOR_ALGO_CONFIG_HASH — shared event property key
  • ELEMENT_SELECTOR_REMOTE_CONFIG_KEY — re-exported from element-selector; autocapture's element-selector-config.ts now imports it from there

Verification

  • pnpm --filter @amplitude/element-selector test — 284 passed
  • pnpm --filter @amplitude/plugin-autocapture-browser test — 413 passed (100% coverage)
  • pnpm build — all 27 packages built successfully
  • pnpm lint — clean for changed packages
Open in Web Open in Cursor 

Add stable selector-config hashing primitives to @amplitude/element-selector
(from #1841) and wire the hash onto autocapture events that already flow
through the element-selector engine.

The hash is attached only where @amplitude/element-selector is already used:
- DataExtractor.getEventProperties (Element Clicked, Element Changed, Rage
  Click, Dead Click, Error Click, and other selector-bearing element events)
- Viewport Content Updated (element paths come from DataExtractor.getElementPath)

Page Viewed is intentionally excluded because page-view-tracking does not
consume the element-selector package.
@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size
packages/analytics-browser/lib/scripts/amplitude-min.js.gz 62.42 KB (+3.07% 🔺)
packages/session-replay-browser/lib/scripts/session-replay-browser-min.js.gz 133.19 KB (0%)
packages/unified/lib/scripts/amplitude-min.umd.js.gz 215.01 KB (+0.87% 🔺)
@amplitude/element-selector (gzipped esm) 3.24 KB (+21.62% 🔺)

@jxiwang
jxiwang changed the base branch from main to cursor/element-selector-config-hash-7d25 June 26, 2026 22:47
@jxiwang
jxiwang changed the base branch from cursor/element-selector-config-hash-7d25 to main June 26, 2026 22:47
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