Skip to content

feat: auto-preload selectPlacements for configured accounts#85

Open
mattbodle wants to merge 1 commit intomainfrom
feature/no-jira-preload-selection-cache
Open

feat: auto-preload selectPlacements for configured accounts#85
mattbodle wants to merge 1 commit intomainfrom
feature/no-jira-preload-selection-cache

Conversation

@mattbodle
Copy link
Copy Markdown
Collaborator

Summary

Adds account-scoped preload configuration to the Rokt Kit. When a partner's account ID is listed in PRELOAD_CONFIGS and all required attributes for that account are present, the Kit automatically calls selectPlacements with preload: true. WSDK caches the experiences response so the confirmation page can render without a second API round-trip.

Ulta configuration (account 2550745407543340151):

  • Required attributes: email, firstname, cartitems
  • Preload identifier: RoktExperience
  • omitUrl: true — makes the cache key page-independent

Trigger points: The check runs after every setUserAttribute, onUserIdentified, processEvent, and when the launcher finishes initializing, so the preload fires as soon as the complete attribute set is available regardless of ordering.

Session gate: self.hasPreloaded ensures the preload fires at most once per tab/session, even if attributes are updated again afterward.

Testing Plan

  • 6 new unit tests in test/src/tests.js covering: unknown account no-op, partial attributes no-op, trigger via setUserAttribute, trigger via onUserIdentified, once-per-session guard, and uninitialized-kit guard.
  • All 133 tests pass in Chrome and Firefox.
  • End-to-end validation requires the WSDK PR (sdk-web#1184) to be deployed — the preload: true flag on selectPlacements is handled there.

Adds account-scoped preload config. When all required attributes are
present for a known account (currently Ulta: email, firstname,
cartitems), the kit automatically calls selectPlacements with
preload:true so WSDK can cache the experiences response before the
confirmation page renders. The preload fires at most once per session
and is gated by kit readiness.

Co-Authored-By: Claude Sonnet 4.6 <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