Repository navigation
feat(personalize): Contentstack Personalize variant delivery + seed - #36
vaishnavi-kedar-cstk wants to merge 2 commits into
Conversation
Add Contentstack Personalize support so a Spartacus storefront can serve audience/returning-visitor variants, and ship a ready-to-import Personalize config in the starter pack. Connector (library): - New ContentstackPersonalizeService seam — asked for the current shopper's variant aliases on every CMS fetch. Default no-op (reads optional static contentstack.personalize.variantAliases), so apps without personalization are unchanged; apps override it with an SDK-backed implementation. - Client service threads aliases into all four Delivery API calls via .variants(...) and folds them into the TransferState cache key (so one segment's composite entry is never replayed for another). Call arity is preserved when there are no aliases. - Page + component adapters resolve aliases from the seam and pass them through. - Product-carousel normalizer now maps the entry title (was dropped) so an authored/personalized heading renders. - Config gains contentstack.personalize.variantAliases (static demo/test aliases). - Type shims: .variants() on the delivery SDK, title on CmsProductCarouselComponent. - Export the seam from the public API. Tests updated/added (171 passing). Starter pack (seed): - personalize/ — project config: attribute has_visited, audience returning_user (has_visited IS TRUE), Segmented experience (short UID 0) linked to product_carousel_component. Source stack key / org / user ids stripped. - Carousel entry variant (seed_carousel) overriding the heading to "Welcome back..." (alias cs_personalize_0_0). - README: personalization section + operational notes (org project quota, unique project name, single-run import, edge-verify commands). A single `csdx cm:stacks:import` recreates content + a new Personalize project (auto-linked) + the carousel variant; the app resolves new-vs-returning per shopper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
|
Two things before this lands:
Smaller things:
|
|
Thanks Tim, this is really useful. This PR mainly covers the foundation — it makes the connector capable of delivering variants; the demo app shows one way to decide them (client-side). It was put together before the epic discussion we had, so it's a capability proof, not a full-fledged Contentstack Personalize PR. The complete approach — proper decisioning, SSR, tracking, previews — is what we'll define in the PRD and TRD for the epic (DX-20947), and we'll reframe the tickets off that. So treat this as the foundation; the real scope lands through the epic. I wanted eyes on the direction before we build the full thing on top of it. I'll incorporate your feedback and suggestions, and create the tickets off the PRD and TRD once we have them for the epic. |
What & why
Adds Contentstack Personalize support to the connector so a Spartacus storefront can serve audience-specific / returning-visitor variants, and ships a ready-to-import Personalize config in the starter pack.
Demo condition: new vs. returning visitor.
has_visited = true, stamped on product view) → variant heading "Welcome back — pick up where you left off." (aliascs_personalize_0_0).How it works
App resolves the Personalize user manifest → variant aliases → connector threads them into the Delivery API (
.variants(...)) → Contentstack returns the composite (personalized) entry. SAP OCC still supplies live price/stock.Changes — connector (library)
ContentstackPersonalizeServiceseam — the connector asks it for the current shopper's variant aliases on every CMS fetch. Default is a no-op (reads optional staticcontentstack.personalize.variantAliases), so apps without personalization are unchanged; apps override it with an SDK-backed implementation..variants(...)and folds them into the TransferState cache key (so one segment's composite entry is never replayed for another). Call arity preserved when there are no aliases.title(was dropped) — this is what makes an authored/personalized heading render.contentstack.personalize.variantAliases(static demo/test aliases)..variants()on the delivery SDK;titleonCmsProductCarouselComponent.Changes — starter pack (seed)
personalize/— project config: attributehas_visited, audiencereturning_user(has_visited IS TRUE), Segmented experience (short UID0) linked toproduct_carousel_component. Source stack key / org / user ids stripped.seed_carousel) overriding the heading to "Welcome back…".A single
csdx cm:stacks:importrecreates content + a new Personalize project (auto-linked) + the carousel variant.Validated
cm:stacks:importinto a fresh stack: 7/7 modules 100%, incl. variant entries; new Personalize project auto-created; edge decisioning live (new→base, returning→variant).ng add @spartacus/schematics→ connector → import) renders the base; returning variant verified via Delivery API + edge manifest.Notes
docs/connector-wiki(the personalization work sits on top of that branch's connector changes), so this diff is personalization-only. Retarget tomainafter the docs branch merges if preferred.PersonalizeService,provideAppInitializer) lives in the consuming apps, not this library.🤖 Generated with Claude Code