Skip to content

🐞 fix(sticky): Updating "sticky" view event emission behavior#174

Merged
Charles Hudson (phobetron) merged 1 commit intomainfrom
NT-2733_sticky-view-behavior-update
Mar 12, 2026
Merged

🐞 fix(sticky): Updating "sticky" view event emission behavior#174
Charles Hudson (phobetron) merged 1 commit intomainfrom
NT-2733_sticky-view-behavior-update

Conversation

@phobetron
Copy link
Collaborator

@phobetron Charles Hudson (phobetron) commented Mar 12, 2026

Improve sticky view tracking so sticky payloads are sent only until the first successful personalization response, then suppressed for later updates on the same rendered instance/element.

Also update core view tracking to always emit analytics for sticky views while still returning personalization data when available.

  • React Native: propagate sticky metadata through viewport tracking, guard in-flight sticky sends, reset dedupe state when identity changes, and add tests for success dedupe, retry behavior, and per-instance scope
  • Web: pass tracked elements through timed detectors and dedupe sticky sends per element with a WeakSet, with matching tests for success/retry/instance

[NT-2733]

Improve sticky view tracking so sticky payloads are sent only until the
first successful personalization response, then suppressed for later
updates on the same rendered instance/element.

Also update core view tracking to always emit analytics for sticky views
while still returning personalization data when available.

- React Native: propagate `sticky` metadata through viewport tracking, guard
  in-flight sticky sends, reset dedupe state when identity changes, and add
  tests for success dedupe, retry behavior, and per-instance scope
- Web: pass tracked elements through timed detectors and dedupe sticky sends
  per element with a `WeakSet`, with matching tests for success/retry/instance

[[NT-2733](https://contentful.atlassian.net/browse/NT-2733)]
@phobetron Charles Hudson (phobetron) force-pushed the NT-2733_sticky-view-behavior-update branch from cacb469 to 3079ef9 Compare March 12, 2026 15:04
const stickyInFlightRef = useRef(false)
const stickyIdentityRef = useRef<string | null>(null)

const stickyIdentity = `${componentId}::${experienceId ?? ''}::${variantIndex}::${sticky === true ? '1' : '0'}`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should probably be extracted to a function or made cleaner somehow

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What standard should we follow to ensure such a line would be "clean"? To me it appears to be a specially-formatted disambiguation ID, assembled using string interpolation, that would only add more boilerplate to move to a function.

@phobetron Charles Hudson (phobetron) merged commit da1b949 into main Mar 12, 2026
30 checks passed
@phobetron Charles Hudson (phobetron) deleted the NT-2733_sticky-view-behavior-update branch March 12, 2026 16:01
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