Skip to content

feat: PoC - V3 space-scoped Experience API paths for CF-Entities#383

Draft
khaalid subaan (Khaalidsub) wants to merge 1 commit into
mainfrom
feat/cf-entities-v3-poc
Draft

feat: PoC - V3 space-scoped Experience API paths for CF-Entities#383
khaalid subaan (Khaalidsub) wants to merge 1 commit into
mainfrom
feat/cf-entities-v3-poc

Conversation

@Khaalidsub

Copy link
Copy Markdown

Summary

Proof of concept demonstrating the Optimization SDK calling the Experience API via V3 space-scoped paths instead of V2 organization-scoped paths. This enables the SDK to consume audiences and experiences stored as CF-Entities rather than legacy content type entries.

Changes

SDK Patch (packages/universal/api-client/)

Replaces V2 URL construction with V3:

- v2/organizations/${clientId}/environments/${environment}/profiles
+ v3/spaces/${clientId}/environments/${environment}/profiles

For the PoC, clientId is repurposed as spaceId for V3 routing.

New Implementation (implementations/cf-entities-poc/)

Minimal React app that:

  • Initializes the Optimization SDK with clientId = spaceId (iyqlttzomqet)
  • Points to the dev Experience API (https://experience.ninetailed.engineering/)
  • Provides buttons to send identify and page events
  • Displays the raw API response showing audience evaluation and experience resolution
  • Shows which experiences/variants were selected

How to test

cd implementations/cf-entities-poc
pnpm install
pnpm dev
# Open http://localhost:3002

Click "Identify (Segment User traits)" to send an identify event with traits that match the "Segment User" audience. The Experience API will:

  1. Read config from KV (iyqlttzomqet:main) - populated by the config pusher in ninetailed-new PR #7111
  2. Evaluate the "Segment User" audience rules against the profile
  3. Return the "[Segment] Most Frequent Product Upsell" experience assignment

Companion PRs

  • Entity definitions: contentful/cf-entities#feat/p13n-audiences-experiences
  • Integration API + Config Pusher: ninetailed-new#7111

Architecture

React App (this PR)
    |
    v  POST /v3/spaces/iyqlttzomqet/environments/main/profiles
Experience API Gateway (dev)
    |
    v  Reads config from KV
SPACE_ENV_CONFIGS_KV["iyqlttzomqet:main"]
    |   (populated by config pusher from ninetailed-new)
    v
Profiles Durable Object
    |  Evaluates audience rules against profile
    |  Resolves experience assignments
    v
Response: { profile, experiences, changes }

Patches the ExperienceApiClient to use V3 space-scoped paths:
  v3/spaces/{spaceId}/environments/{environment}/profiles

Adds a minimal React PoC app (implementations/cf-entities-poc/) that:
- Initializes the Optimization SDK with spaceId as clientId
- Points to the dev Experience API (experience.ninetailed.engineering)
- Sends identify/page events to trigger audience evaluation
- Displays the raw API response showing experience resolution

The V3 path reads config from SPACE_ENV_CONFIGS_KV[spaceId:envId]
which is populated by the config pusher in ninetailed-new.
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