diff --git a/.github/workflows/main-pipeline.yaml b/.github/workflows/main-pipeline.yaml
index 82ccc90a..311fbdae 100644
--- a/.github/workflows/main-pipeline.yaml
+++ b/.github/workflows/main-pipeline.yaml
@@ -6,7 +6,80 @@ permissions:
on:
pull_request:
+concurrency:
+ group: main-pipeline-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
+ changes:
+ name: Detect Changes ๐
+ runs-on: namespace-profile-linux-8-vcpu-16-gb-ram-optimal
+ outputs:
+ build: ${{ steps.filter.outputs.build }}
+ unit: ${{ steps.filter.outputs.unit }}
+ e2e_node_ssr_only: ${{ steps.filter.outputs.e2e_node_ssr_only }}
+ e2e_node_ssr_web_vanilla: ${{ steps.filter.outputs.e2e_node_ssr_web_vanilla }}
+ e2e_web: ${{ steps.filter.outputs.e2e_web }}
+ e2e_react_native_android: ${{ steps.filter.outputs.e2e_react_native_android }}
+ steps:
+ - uses: namespacelabs/nscloud-checkout-action@v8
+
+ - uses: dorny/paths-filter@v3
+ id: filter
+ with:
+ filters: |
+ build:
+ - 'lib/**'
+ - 'platforms/**'
+ - 'universal/**'
+ - 'package.json'
+ - 'pnpm-lock.yaml'
+ - 'pnpm-workspace.yaml'
+ - 'tsconfig*.json'
+ - '.github/workflows/main-pipeline.yaml'
+ unit:
+ - 'lib/**'
+ - 'platforms/**'
+ - 'universal/**'
+ - '**/rstest.config.ts'
+ - 'package.json'
+ - 'pnpm-lock.yaml'
+ - 'pnpm-workspace.yaml'
+ - '.github/workflows/main-pipeline.yaml'
+ e2e_node_ssr_only:
+ - 'implementations/node-ssr-only/**'
+ - 'lib/**'
+ - 'platforms/**'
+ - 'universal/**'
+ - 'package.json'
+ - 'pnpm-lock.yaml'
+ - '.github/workflows/main-pipeline.yaml'
+ e2e_node_ssr_web_vanilla:
+ - 'implementations/node-ssr-web-vanilla/**'
+ - 'lib/**'
+ - 'platforms/**'
+ - 'universal/**'
+ - 'package.json'
+ - 'pnpm-lock.yaml'
+ - '.github/workflows/main-pipeline.yaml'
+ e2e_web:
+ - 'implementations/web-vanilla/**'
+ - 'lib/**'
+ - 'platforms/**'
+ - 'universal/**'
+ - 'package.json'
+ - 'pnpm-lock.yaml'
+ - '.github/workflows/main-pipeline.yaml'
+ e2e_react_native_android:
+ - 'implementations/react-native/**'
+ - 'platforms/javascript/react-native/**'
+ - 'lib/**'
+ - 'platforms/**'
+ - 'universal/**'
+ - 'package.json'
+ - 'pnpm-lock.yaml'
+ - '.github/workflows/main-pipeline.yaml'
+
setup:
name: pnpm install ๐ ๏ธ
runs-on: namespace-profile-linux-8-vcpu-16-gb-ram-optimal
@@ -92,7 +165,8 @@ jobs:
name: Build ๐ฆ
runs-on: namespace-profile-linux-8-vcpu-16-gb-ram-optimal
timeout-minutes: 15
- needs: setup
+ needs: [setup, changes]
+ if: needs.changes.outputs.build == 'true'
steps:
- uses: namespacelabs/nscloud-checkout-action@v8
@@ -108,7 +182,7 @@ jobs:
cache: pnpm
- run: pnpm install --prefer-offline --frozen-lockfile
- - run: pnpm build
+ - run: pnpm build:ci
type-check:
name: Type Check ๐ท
@@ -154,11 +228,23 @@ jobs:
- run: pnpm install --prefer-offline --frozen-lockfile
- run: pnpm lint:check
- test:
- name: Test ๐งช
+ test-unit:
+ name: Test ๐งช (${{ matrix.package }})
runs-on: namespace-profile-linux-8-vcpu-16-gb-ram-optimal
timeout-minutes: 15
- needs: setup
+ needs: [setup, changes]
+ if: needs.changes.outputs.unit == 'true'
+ strategy:
+ fail-fast: true
+ matrix:
+ include:
+ - package: '@contentful/optimization-api-schemas'
+ - package: '@contentful/optimization-api-client'
+ - package: '@contentful/optimization-core'
+ - package: '@contentful/optimization-node'
+ - package: '@contentful/optimization-web'
+ - package: '@contentful/optimization-web-preview-panel'
+ - package: '@contentful/optimization-react-native'
steps:
- uses: namespacelabs/nscloud-checkout-action@v8
@@ -174,28 +260,29 @@ jobs:
cache: pnpm
- run: pnpm install --prefer-offline --frozen-lockfile
- - run: pnpm test:unit
+ - run: pnpm --filter ${{ matrix.package }} test:unit
e2e-node-ssr-only:
name: E2E Node SSR Only ๐ฅ๏ธ
runs-on: namespace-profile-linux-8-vcpu-16-gb-ram-optimal
timeout-minutes: 15
- needs: setup
+ needs: [setup, changes]
+ if: needs.changes.outputs.e2e_node_ssr_only == 'true'
steps:
- uses: namespacelabs/nscloud-checkout-action@v8
- run: |
echo "DOTENV_CONFIG_QUIET=true" >>implementations/node-ssr-only/.env
- echo "VITE_NINETAILED_CLIENT_ID=${{secrets.NINETAILED_CLIENT_ID}}" >>implementations/node-ssr-only/.env
- echo "VITE_NINETAILED_ENVIRONMENT=${{secrets.NINETAILED_ENVIRONMENT}}" >>implementations/node-ssr-only/.env
- echo "VITE_EXPERIENCE_API_BASE_URL=http://localhost:8000/experience/" >>implementations/node-ssr-only/.env
- echo "VITE_INSIGHTS_API_BASE_URL=http://localhost:8000/insights/" >>implementations/node-ssr-only/.env
- echo "VITE_CONTENTFUL_TOKEN=${{secrets.CONTENTFUL_TOKEN}}" >>implementations/node-ssr-only/.env
- echo "VITE_CONTENTFUL_PREVIEW_TOKEN=${{secrets.CONTENTFUL_PREVIEW_TOKEN}}" >>implementations/node-ssr-only/.env
- echo "VITE_CONTENTFUL_ENVIRONMENT=${{secrets.CONTENTFUL_ENVIRONMENT}}" >>implementations/node-ssr-only/.env
- echo "VITE_CONTENTFUL_SPACE_ID=${{secrets.CONTENTFUL_SPACE_ID}}" >>implementations/node-ssr-only/.env
- echo "VITE_CONTENTFUL_CDA_HOST=localhost:8000" >>implementations/node-ssr-only/.env
- echo "VITE_CONTENTFUL_BASE_PATH=contentful" >>implementations/node-ssr-only/.env
+ echo "PUBLIC_NINETAILED_CLIENT_ID=${{secrets.NINETAILED_CLIENT_ID}}" >>implementations/node-ssr-only/.env
+ echo "PUBLIC_NINETAILED_ENVIRONMENT=${{secrets.NINETAILED_ENVIRONMENT}}" >>implementations/node-ssr-only/.env
+ echo "PUBLIC_EXPERIENCE_API_BASE_URL=http://localhost:8000/experience/" >>implementations/node-ssr-only/.env
+ echo "PUBLIC_INSIGHTS_API_BASE_URL=http://localhost:8000/insights/" >>implementations/node-ssr-only/.env
+ echo "PUBLIC_CONTENTFUL_TOKEN=${{secrets.CONTENTFUL_TOKEN}}" >>implementations/node-ssr-only/.env
+ echo "PUBLIC_CONTENTFUL_PREVIEW_TOKEN=${{secrets.CONTENTFUL_PREVIEW_TOKEN}}" >>implementations/node-ssr-only/.env
+ echo "PUBLIC_CONTENTFUL_ENVIRONMENT=${{secrets.CONTENTFUL_ENVIRONMENT}}" >>implementations/node-ssr-only/.env
+ echo "PUBLIC_CONTENTFUL_SPACE_ID=${{secrets.CONTENTFUL_SPACE_ID}}" >>implementations/node-ssr-only/.env
+ echo "PUBLIC_CONTENTFUL_CDA_HOST=localhost:8000" >>implementations/node-ssr-only/.env
+ echo "PUBLIC_CONTENTFUL_BASE_PATH=contentful" >>implementations/node-ssr-only/.env
- uses: actions/setup-node@v6
with:
@@ -229,22 +316,23 @@ jobs:
name: E2E Node SSR + Web Vanilla ๐ฅ๏ธ
runs-on: namespace-profile-linux-8-vcpu-16-gb-ram-optimal
timeout-minutes: 15
- needs: setup
+ needs: [setup, changes]
+ if: needs.changes.outputs.e2e_node_ssr_web_vanilla == 'true'
steps:
- uses: namespacelabs/nscloud-checkout-action@v8
- run: |
echo "DOTENV_CONFIG_QUIET=true" >>implementations/node-ssr-web-vanilla/.env
- echo "VITE_NINETAILED_CLIENT_ID=${{secrets.NINETAILED_CLIENT_ID}}" >>implementations/node-ssr-web-vanilla/.env
- echo "VITE_NINETAILED_ENVIRONMENT=${{secrets.NINETAILED_ENVIRONMENT}}" >>implementations/node-ssr-web-vanilla/.env
- echo "VITE_EXPERIENCE_API_BASE_URL=http://localhost:8000/experience/" >>implementations/node-ssr-web-vanilla/.env
- echo "VITE_INSIGHTS_API_BASE_URL=http://localhost:8000/insights/" >>implementations/node-ssr-web-vanilla/.env
- echo "VITE_CONTENTFUL_TOKEN=${{secrets.CONTENTFUL_TOKEN}}" >>implementations/node-ssr-web-vanilla/.env
- echo "VITE_CONTENTFUL_PREVIEW_TOKEN=${{secrets.CONTENTFUL_PREVIEW_TOKEN}}" >>implementations/node-ssr-web-vanilla/.env
- echo "VITE_CONTENTFUL_ENVIRONMENT=${{secrets.CONTENTFUL_ENVIRONMENT}}" >>implementations/node-ssr-web-vanilla/.env
- echo "VITE_CONTENTFUL_SPACE_ID=${{secrets.CONTENTFUL_SPACE_ID}}" >>implementations/node-ssr-web-vanilla/.env
- echo "VITE_CONTENTFUL_CDA_HOST=localhost:8000" >>implementations/node-ssr-web-vanilla/.env
- echo "VITE_CONTENTFUL_BASE_PATH=contentful" >>implementations/node-ssr-web-vanilla/.env
+ echo "PUBLIC_NINETAILED_CLIENT_ID=${{secrets.NINETAILED_CLIENT_ID}}" >>implementations/node-ssr-web-vanilla/.env
+ echo "PUBLIC_NINETAILED_ENVIRONMENT=${{secrets.NINETAILED_ENVIRONMENT}}" >>implementations/node-ssr-web-vanilla/.env
+ echo "PUBLIC_EXPERIENCE_API_BASE_URL=http://localhost:8000/experience/" >>implementations/node-ssr-web-vanilla/.env
+ echo "PUBLIC_INSIGHTS_API_BASE_URL=http://localhost:8000/insights/" >>implementations/node-ssr-web-vanilla/.env
+ echo "PUBLIC_CONTENTFUL_TOKEN=${{secrets.CONTENTFUL_TOKEN}}" >>implementations/node-ssr-web-vanilla/.env
+ echo "PUBLIC_CONTENTFUL_PREVIEW_TOKEN=${{secrets.CONTENTFUL_PREVIEW_TOKEN}}" >>implementations/node-ssr-web-vanilla/.env
+ echo "PUBLIC_CONTENTFUL_ENVIRONMENT=${{secrets.CONTENTFUL_ENVIRONMENT}}" >>implementations/node-ssr-web-vanilla/.env
+ echo "PUBLIC_CONTENTFUL_SPACE_ID=${{secrets.CONTENTFUL_SPACE_ID}}" >>implementations/node-ssr-web-vanilla/.env
+ echo "PUBLIC_CONTENTFUL_CDA_HOST=localhost:8000" >>implementations/node-ssr-web-vanilla/.env
+ echo "PUBLIC_CONTENTFUL_BASE_PATH=contentful" >>implementations/node-ssr-web-vanilla/.env
- uses: actions/setup-node@v6
with:
@@ -278,7 +366,8 @@ jobs:
name: E2E Web Vanilla ๐ฅ๏ธ
runs-on: namespace-profile-linux-8-vcpu-16-gb-ram-optimal
timeout-minutes: 15
- needs: setup
+ needs: [setup, changes]
+ if: needs.changes.outputs.e2e_web == 'true'
steps:
- uses: docker/setup-compose-action@v1
@@ -288,16 +377,16 @@ jobs:
run: |
cat > .env << 'EOF'
DOTENV_CONFIG_QUIET=true
- VITE_NINETAILED_CLIENT_ID=${{secrets.NINETAILED_CLIENT_ID}}
- VITE_NINETAILED_ENVIRONMENT=${{secrets.NINETAILED_ENVIRONMENT}}
- VITE_EXPERIENCE_API_BASE_URL=http://localhost:8000/experience/
- VITE_INSIGHTS_API_BASE_URL=http://localhost:8000/insights/
- VITE_CONTENTFUL_TOKEN=${{secrets.CONTENTFUL_TOKEN}}
- VITE_CONTENTFUL_PREVIEW_TOKEN=${{secrets.CONTENTFUL_PREVIEW_TOKEN}}
- VITE_CONTENTFUL_ENVIRONMENT=${{secrets.CONTENTFUL_ENVIRONMENT}}
- VITE_CONTENTFUL_SPACE_ID=${{secrets.CONTENTFUL_SPACE_ID}}
- VITE_CONTENTFUL_CDA_HOST=localhost:8000
- VITE_CONTENTFUL_BASE_PATH=contentful
+ PUBLIC_NINETAILED_CLIENT_ID=${{secrets.NINETAILED_CLIENT_ID}}
+ PUBLIC_NINETAILED_ENVIRONMENT=${{secrets.NINETAILED_ENVIRONMENT}}
+ PUBLIC_EXPERIENCE_API_BASE_URL=http://localhost:8000/experience/
+ PUBLIC_INSIGHTS_API_BASE_URL=http://localhost:8000/insights/
+ PUBLIC_CONTENTFUL_TOKEN=${{secrets.CONTENTFUL_TOKEN}}
+ PUBLIC_CONTENTFUL_PREVIEW_TOKEN=${{secrets.CONTENTFUL_PREVIEW_TOKEN}}
+ PUBLIC_CONTENTFUL_ENVIRONMENT=${{secrets.CONTENTFUL_ENVIRONMENT}}
+ PUBLIC_CONTENTFUL_SPACE_ID=${{secrets.CONTENTFUL_SPACE_ID}}
+ PUBLIC_CONTENTFUL_CDA_HOST=localhost:8000
+ PUBLIC_CONTENTFUL_BASE_PATH=contentful
EOF
cp .env implementations/node-ssr-only/
cp .env implementations/web-vanilla/
@@ -334,7 +423,8 @@ jobs:
name: E2E React Native Android ๐ฑ
runs-on: namespace-profile-linux-16-vcpu-32-gb-ram-optimal
timeout-minutes: 60
- needs: setup
+ needs: [setup, changes]
+ if: needs.changes.outputs.e2e_react_native_android == 'true'
env:
DETOX_AVD_NAME: test
CI: 'true'
@@ -410,15 +500,15 @@ jobs:
- name: Create .env file for React Native
run: |
cat > implementations/react-native/.env << 'EOF'
- VITE_NINETAILED_CLIENT_ID=${{ secrets.NINETAILED_CLIENT_ID }}
- VITE_NINETAILED_ENVIRONMENT=${{ secrets.NINETAILED_ENVIRONMENT }}
- VITE_EXPERIENCE_API_BASE_URL=http://localhost:8000/experience/
- VITE_INSIGHTS_API_BASE_URL=http://localhost:8000/insights/
- VITE_CONTENTFUL_TOKEN=${{ secrets.CONTENTFUL_TOKEN }}
- VITE_CONTENTFUL_ENVIRONMENT=${{ secrets.CONTENTFUL_ENVIRONMENT }}
- VITE_CONTENTFUL_SPACE_ID=${{ secrets.CONTENTFUL_SPACE_ID }}
- VITE_CONTENTFUL_CDA_HOST=localhost:8000
- VITE_CONTENTFUL_BASE_PATH=contentful
+ PUBLIC_NINETAILED_CLIENT_ID=${{ secrets.NINETAILED_CLIENT_ID }}
+ PUBLIC_NINETAILED_ENVIRONMENT=${{ secrets.NINETAILED_ENVIRONMENT }}
+ PUBLIC_EXPERIENCE_API_BASE_URL=http://localhost:8000/experience/
+ PUBLIC_INSIGHTS_API_BASE_URL=http://localhost:8000/insights/
+ PUBLIC_CONTENTFUL_TOKEN=${{ secrets.CONTENTFUL_TOKEN }}
+ PUBLIC_CONTENTFUL_ENVIRONMENT=${{ secrets.CONTENTFUL_ENVIRONMENT }}
+ PUBLIC_CONTENTFUL_SPACE_ID=${{ secrets.CONTENTFUL_SPACE_ID }}
+ PUBLIC_CONTENTFUL_CDA_HOST=localhost:8000
+ PUBLIC_CONTENTFUL_BASE_PATH=contentful
EOF
- name: Build Android app (Detox)
diff --git a/.gitignore b/.gitignore
index b8d46487..b869a393 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@
.contentfulrc.json
.env
.rslib
+.rsdoctor
.temp
.tmp
blob-report
diff --git a/implementations/node-ssr-only/package.json b/implementations/node-ssr-only/package.json
index 6f518745..0744d2ce 100644
--- a/implementations/node-ssr-only/package.json
+++ b/implementations/node-ssr-only/package.json
@@ -25,6 +25,7 @@
"@contentful/rich-text-html-renderer": "catalog:",
"@contentful/rich-text-types": "catalog:",
"contentful": "catalog:",
+ "ejs": "catalog:",
"express": "catalog:",
"express-rate-limit": "catalog:",
"qs": "catalog:",
diff --git a/implementations/node-ssr-only/src/app.ts b/implementations/node-ssr-only/src/app.ts
index d89b1344..41e88dfd 100644
--- a/implementations/node-ssr-only/src/app.ts
+++ b/implementations/node-ssr-only/src/app.ts
@@ -21,26 +21,26 @@ const limiter = rateLimit({
const app: Express = express()
app.use(limiter)
-app.set('view engine', 'pug') // configure Pug as the view engine
+app.set('view engine', 'ejs') // configure EJS as the view engine
app.set('views', path.join(__dirname, '.')) // define the directory for view templates
const optimizationConfig: OptimizationNodeConfig = {
- clientId: process.env.VITE_NINETAILED_CLIENT_ID ?? '',
- environment: process.env.VITE_NINETAILED_ENVIRONMENT ?? '',
+ clientId: process.env.PUBLIC_NINETAILED_CLIENT_ID ?? '',
+ environment: process.env.PUBLIC_NINETAILED_ENVIRONMENT ?? '',
logLevel: 'debug',
- analytics: { baseUrl: process.env.VITE_INSIGHTS_API_BASE_URL },
- personalization: { baseUrl: process.env.VITE_EXPERIENCE_API_BASE_URL },
+ analytics: { baseUrl: process.env.PUBLIC_INSIGHTS_API_BASE_URL },
+ personalization: { baseUrl: process.env.PUBLIC_EXPERIENCE_API_BASE_URL },
}
const sdk = new Optimization(optimizationConfig)
const ctflConfig: contentful.CreateClientParams = {
- accessToken: process.env.VITE_CONTENTFUL_TOKEN ?? '',
- environment: process.env.VITE_CONTENTFUL_ENVIRONMENT ?? '',
- space: process.env.VITE_CONTENTFUL_SPACE_ID ?? '',
- host: process.env.VITE_CONTENTFUL_CDA_HOST ?? '',
- basePath: process.env.VITE_CONTENTFUL_BASE_PATH ?? '',
- insecure: Boolean(process.env.VITE_CONTENTFUL_CDA_HOST),
+ accessToken: process.env.PUBLIC_CONTENTFUL_TOKEN ?? '',
+ environment: process.env.PUBLIC_CONTENTFUL_ENVIRONMENT ?? '',
+ space: process.env.PUBLIC_CONTENTFUL_SPACE_ID ?? '',
+ host: process.env.PUBLIC_CONTENTFUL_CDA_HOST ?? '',
+ basePath: process.env.PUBLIC_CONTENTFUL_BASE_PATH ?? '',
+ insecure: Boolean(process.env.PUBLIC_CONTENTFUL_CDA_HOST),
}
const ctfl = contentful.createClient(ctflConfig)
diff --git a/implementations/node-ssr-only/src/index.ejs b/implementations/node-ssr-only/src/index.ejs
new file mode 100644
index 00000000..255fad48
--- /dev/null
+++ b/implementations/node-ssr-only/src/index.ejs
@@ -0,0 +1,161 @@
+
+
+
+ Optimization Node SDK Implementation E2E Test
+
+
+
+
+ Optimization Node SDK Implementation E2E Test
+
+
+
+ States
+
+
+ <% if (profile.traits.identified === true) { %>
+ Identified
+ <% } else { %>
+ Identify
+ <% } %>
+
+
+
+
+ Entries
+
+
+ <% const entry1 = entries.get('1MwiFl4z7gkwqGYdvCmr8c') %>
+
+ <%- entry1.entry.fields.text %>
+
+
+ <% const entry2 = entries.get('4ib0hsHWoSOnCVdDkizE8d') %>
+
+
<%= entry2.entry.fields.text %>
+
+
+ <% const entry3 = entries.get('xFwgG3oNaOcjzWiGe4vXo') %>
+
+
<%= entry3.entry.fields.text %>
+
+
+ <% const entry4 = entries.get('2Z2WLOx07InSewC3LUB3eX') %>
+
+
<%= entry4.entry.fields.text %>
+
+
+ <% const entry5 = entries.get('5XHssysWUDECHzKLzoIsg1') %>
+
+
<%= entry5.entry.fields.text %>
+
+
+ <% const entry6 = entries.get('6zqoWXyiSrf0ja7I2WGtYj') %>
+
+
<%= entry6.entry.fields.text %>
+
+
+ <% const entry7 = entries.get('7pa5bOx8Z9NmNcr7mISvD') %>
+
+
<%= entry7.entry.fields.text %>
+
+
+
+
+
+
diff --git a/implementations/node-ssr-only/src/index.pug b/implementations/node-ssr-only/src/index.pug
deleted file mode 100644
index ec0daef7..00000000
--- a/implementations/node-ssr-only/src/index.pug
+++ /dev/null
@@ -1,145 +0,0 @@
-doctype html
-html(lang="en")
- head
- title Optimization Node SDK Implementation E2E Test
-
- style.
- html,
- textarea,
- input,
- button {
- font-family:
- -apple-system,
- BlinkMacSystemFont,
- avenir next,
- avenir,
- segoe ui,
- helvetica neue,
- Adwaita Sans,
- Cantarell,
- Ubuntu,
- roboto,
- noto,
- helvetica,
- arial,
- sans-serif;
- }
- h1,
- main {
- display: grid;
- grid-gap: 2rem;
- grid-template-rows: auto 1fr;
- max-width: 1040px;
- margin-inline: auto;
- }
- ol {
- margin: 0;
- }
- summary {
- cursor: pointer;
- }
- a {
- color: inherit;
-
- &:hover,
- &:active {
- color: blue;
- }
- }
- #entries > div {
- display: grid;
- grid-gap: 2rem;
- grid-auto-rows: 75dvh;
- justify-items: center;
- align-items: center;
- margin-block-end: 2rem;
-
- > div {
- display: grid;
- width: 100%;
- height: 100%;
- justify-items: center;
- align-items: center;
- background: #eee;
- }
- }
-
- body
- h1 Optimization Node SDK Implementation E2E Test
-
- main
- section
- h2 States
-
- p
- - if (profile.traits.identified === true)
- span Identified
- - else
- a(href=`/?userId=charles`) Identify
-
- section#entries
- h2 Entries
-
- div
- - const entry1 = entries.get('1MwiFl4z7gkwqGYdvCmr8c')
- div(
- data-ctfl-entry-id=entry1.entry.sys.id
- data-ctfl-personalization-id=(entry1.personalization || {}).experienceId
- data-ctfl-sticky=(entry1.personalization || {}).sticky
- data-ctfl-variant-index=(entry1.personalization || {}).variantIndex
- )
- != entry1.entry.fields.text
-
- - const entry2 = entries.get('4ib0hsHWoSOnCVdDkizE8d')
- div(
- data-ctfl-entry-id=entry2.entry.sys.id
- data-ctfl-personalization-id=(entry2.personalization || {}).experienceId
- data-ctfl-sticky=(entry2.personalization || {}).sticky
- data-ctfl-variant-index=(entry2.personalization || {}).variantIndex
- )
- p= entry2.entry.fields.text
-
- - const entry3 = entries.get('xFwgG3oNaOcjzWiGe4vXo')
- div(
- data-ctfl-entry-id=entry3.entry.sys.id
- data-ctfl-personalization-id=(entry3.personalization || {}).experienceId
- data-ctfl-sticky=(entry3.personalization || {}).sticky
- data-ctfl-variant-index=(entry3.personalization || {}).variantIndex
- )
- p= entry3.entry.fields.text
-
- - const entry4 = entries.get('2Z2WLOx07InSewC3LUB3eX')
- div(
- data-ctfl-entry-id=entry4.entry.sys.id
- data-ctfl-personalization-id=(entry4.personalization || {}).experienceId
- data-ctfl-sticky=(entry4.personalization || {}).sticky
- data-ctfl-variant-index=(entry4.personalization || {}).variantIndex
- )
- p= entry4.entry.fields.text
-
- - const entry5 = entries.get('5XHssysWUDECHzKLzoIsg1')
- div(
- data-ctfl-entry-id=entry5.entry.sys.id
- data-ctfl-personalization-id=(entry5.personalization || {}).experienceId
- data-ctfl-sticky=(entry5.personalization || {}).sticky
- data-ctfl-variant-index=(entry5.personalization || {}).variantIndex
- )
- p= entry5.entry.fields.text
-
- - const entry6 = entries.get('6zqoWXyiSrf0ja7I2WGtYj')
- div(
- data-ctfl-entry-id=entry6.entry.sys.id
- data-ctfl-personalization-id=(entry6.personalization || {}).experienceId
- data-ctfl-sticky=(entry6.personalization || {}).sticky
- data-ctfl-variant-index=(entry6.personalization || {}).variantIndex
- )
- p= entry6.entry.fields.text
-
- - const entry7 = entries.get('7pa5bOx8Z9NmNcr7mISvD')
- div(
- data-ctfl-entry-id=entry7.entry.sys.id
- data-ctfl-personalization-id=(entry7.personalization || {}).experienceId
- data-ctfl-sticky=(entry7.personalization || {}).sticky
- data-ctfl-variant-index=(entry7.personalization || {}).variantIndex
- )
- p= entry7.entry.fields.text
diff --git a/implementations/node-ssr-web-vanilla/package.json b/implementations/node-ssr-web-vanilla/package.json
index ac3809ea..4d3c77c7 100644
--- a/implementations/node-ssr-web-vanilla/package.json
+++ b/implementations/node-ssr-web-vanilla/package.json
@@ -19,7 +19,7 @@
"test:e2e:codegen": "playwright codegen",
"test:e2e:report": "playwright show-report",
"test:e2e:ui": "playwright test --ui",
- "test:unit": "vitest run --coverage",
+ "test:unit": "rstest run --coverage",
"typecheck": "tsc --noEmit"
},
"dependencies": {
@@ -36,14 +36,14 @@
"@types/node": "catalog:",
"@types/qs": "catalog:",
"@types/supertest": "catalog:",
- "@vitest/coverage-v8": "catalog:",
+ "@rstest/core": "catalog:",
+ "@rstest/coverage-istanbul": "catalog:",
"@types/cookie-parser": "1.4.7",
"dotenv": "catalog:",
"pm2": "catalog:",
"rimraf": "catalog:",
"supertest": "catalog:",
"tsx": "catalog:",
- "typescript": "catalog:",
- "vitest": "catalog:"
+ "typescript": "catalog:"
}
}
diff --git a/implementations/node-ssr-web-vanilla/vitest.config.ts b/implementations/node-ssr-web-vanilla/rstest.config.ts
similarity index 63%
rename from implementations/node-ssr-web-vanilla/vitest.config.ts
rename to implementations/node-ssr-web-vanilla/rstest.config.ts
index 45b3046b..d7dac7f6 100644
--- a/implementations/node-ssr-web-vanilla/vitest.config.ts
+++ b/implementations/node-ssr-web-vanilla/rstest.config.ts
@@ -1,5 +1,7 @@
+import { defineConfig } from '@rstest/core'
import { resolve } from 'node:path'
-import { defineConfig } from 'vitest/config'
+
+const coverageReporters = process.env.CI === 'true' ? ['text-summary', 'lcov'] : ['text', 'html']
export default defineConfig({
resolve: {
@@ -13,12 +15,11 @@ export default defineConfig({
'@contentful/optimization-node': resolve(__dirname, '../../platforms/javascript/node/src/'),
},
},
- test: {
- include: ['**/*.test.?(c|m)[jt]s?(x)'],
- globals: true,
- coverage: {
- include: ['src/**/*'],
- reporter: ['text', 'html'],
- },
+ include: ['**/*.test.?(c|m)[jt]s?(x)'],
+ globals: true,
+ testEnvironment: 'node',
+ coverage: {
+ include: ['src/**/*'],
+ reporters: coverageReporters,
},
})
diff --git a/implementations/node-ssr-web-vanilla/src/app.test.ts b/implementations/node-ssr-web-vanilla/src/app.test.ts
index c86b178c..7ae6d147 100644
--- a/implementations/node-ssr-web-vanilla/src/app.test.ts
+++ b/implementations/node-ssr-web-vanilla/src/app.test.ts
@@ -1,12 +1,12 @@
import request, { type Response } from 'supertest'
import app from './app'
-const CLIENT_ID = process.env.VITE_NINETAILED_CLIENT_ID ?? 'error'
+const CLIENT_ID = process.env.PUBLIC_NINETAILED_CLIENT_ID ?? ''
describe('GET /', () => {
it('returns the client ID', async () => {
const response: Response = await request(app).get('/smoke-test')
- expect(response.text).toContain(`"${CLIENT_ID}"`)
+ expect(response.text).toContain(`"clientId":"${CLIENT_ID}"`)
})
})
diff --git a/implementations/node-ssr-web-vanilla/src/app.ts b/implementations/node-ssr-web-vanilla/src/app.ts
index e2cf5465..1f2b92f2 100644
--- a/implementations/node-ssr-web-vanilla/src/app.ts
+++ b/implementations/node-ssr-web-vanilla/src/app.ts
@@ -19,19 +19,19 @@ app.use(limiter)
const config = {
contentful: {
- accessToken: process.env.VITE_CONTENTFUL_TOKEN,
- environment: process.env.VITE_NINETAILED_ENVIRONMENT,
- space: process.env.VITE_CONTENTFUL_SPACE_ID,
- host: process.env.VITE_CONTENTFUL_CDA_HOST,
- basePath: process.env.VITE_CONTENTFUL_BASE_PATH,
- insecure: Boolean(process.env.VITE_CONTENTFUL_CDA_HOST),
+ accessToken: process.env.PUBLIC_CONTENTFUL_TOKEN,
+ environment: process.env.PUBLIC_NINETAILED_ENVIRONMENT,
+ space: process.env.PUBLIC_CONTENTFUL_SPACE_ID,
+ host: process.env.PUBLIC_CONTENTFUL_CDA_HOST,
+ basePath: process.env.PUBLIC_CONTENTFUL_BASE_PATH,
+ insecure: Boolean(process.env.PUBLIC_CONTENTFUL_CDA_HOST),
},
optimization: {
- clientId: process.env.VITE_NINETAILED_CLIENT_ID ?? '',
- environment: process.env.VITE_NINETAILED_ENVIRONMENT,
+ clientId: process.env.PUBLIC_NINETAILED_CLIENT_ID ?? '',
+ environment: process.env.PUBLIC_NINETAILED_ENVIRONMENT,
logLevel: 'debug',
- analytics: { baseUrl: process.env.VITE_INSIGHTS_API_BASE_URL },
- personalization: { baseUrl: process.env.VITE_EXPERIENCE_API_BASE_URL },
+ analytics: { baseUrl: process.env.PUBLIC_INSIGHTS_API_BASE_URL },
+ personalization: { baseUrl: process.env.PUBLIC_EXPERIENCE_API_BASE_URL },
},
} as const
diff --git a/implementations/react-native/env.config.ts b/implementations/react-native/env.config.ts
index 8b47f86f..bc465ff2 100644
--- a/implementations/react-native/env.config.ts
+++ b/implementations/react-native/env.config.ts
@@ -1,13 +1,13 @@
import {
- VITE_CONTENTFUL_BASE_PATH,
- VITE_CONTENTFUL_CDA_HOST,
- VITE_CONTENTFUL_ENVIRONMENT,
- VITE_CONTENTFUL_SPACE_ID,
- VITE_CONTENTFUL_TOKEN,
- VITE_EXPERIENCE_API_BASE_URL,
- VITE_INSIGHTS_API_BASE_URL,
- VITE_NINETAILED_CLIENT_ID,
- VITE_NINETAILED_ENVIRONMENT,
+ PUBLIC_CONTENTFUL_BASE_PATH,
+ PUBLIC_CONTENTFUL_CDA_HOST,
+ PUBLIC_CONTENTFUL_ENVIRONMENT,
+ PUBLIC_CONTENTFUL_SPACE_ID,
+ PUBLIC_CONTENTFUL_TOKEN,
+ PUBLIC_EXPERIENCE_API_BASE_URL,
+ PUBLIC_INSIGHTS_API_BASE_URL,
+ PUBLIC_NINETAILED_CLIENT_ID,
+ PUBLIC_NINETAILED_ENVIRONMENT,
} from '@env'
import { Platform } from 'react-native'
@@ -46,21 +46,21 @@ function getAndroidCompatibleUrl(url: string): string {
export const ENV_CONFIG = {
contentful: {
- spaceId: VITE_CONTENTFUL_SPACE_ID,
- environment: VITE_CONTENTFUL_ENVIRONMENT,
- accessToken: VITE_CONTENTFUL_TOKEN,
- host: getAndroidCompatibleUrl(VITE_CONTENTFUL_CDA_HOST),
- basePath: VITE_CONTENTFUL_BASE_PATH,
+ spaceId: PUBLIC_CONTENTFUL_SPACE_ID,
+ environment: PUBLIC_CONTENTFUL_ENVIRONMENT,
+ accessToken: PUBLIC_CONTENTFUL_TOKEN,
+ host: getAndroidCompatibleUrl(PUBLIC_CONTENTFUL_CDA_HOST),
+ basePath: PUBLIC_CONTENTFUL_BASE_PATH,
},
optimization: {
- clientId: VITE_NINETAILED_CLIENT_ID,
- environment: VITE_NINETAILED_ENVIRONMENT,
+ clientId: PUBLIC_NINETAILED_CLIENT_ID,
+ environment: PUBLIC_NINETAILED_ENVIRONMENT,
},
api: {
- experienceBaseUrl: getAndroidCompatibleUrl(VITE_EXPERIENCE_API_BASE_URL),
- insightsBaseUrl: getAndroidCompatibleUrl(VITE_INSIGHTS_API_BASE_URL),
+ experienceBaseUrl: getAndroidCompatibleUrl(PUBLIC_EXPERIENCE_API_BASE_URL),
+ insightsBaseUrl: getAndroidCompatibleUrl(PUBLIC_INSIGHTS_API_BASE_URL),
},
entries: {
diff --git a/implementations/react-native/env.d.ts b/implementations/react-native/env.d.ts
index 36841588..8a85171a 100644
--- a/implementations/react-native/env.d.ts
+++ b/implementations/react-native/env.d.ts
@@ -1,11 +1,11 @@
declare module '@env' {
- export const VITE_NINETAILED_CLIENT_ID: string
- export const VITE_NINETAILED_ENVIRONMENT: string
- export const VITE_EXPERIENCE_API_BASE_URL: string
- export const VITE_INSIGHTS_API_BASE_URL: string
- export const VITE_CONTENTFUL_TOKEN: string
- export const VITE_CONTENTFUL_ENVIRONMENT: string
- export const VITE_CONTENTFUL_SPACE_ID: string
- export const VITE_CONTENTFUL_CDA_HOST: string
- export const VITE_CONTENTFUL_BASE_PATH: string
+ export const PUBLIC_NINETAILED_CLIENT_ID: string
+ export const PUBLIC_NINETAILED_ENVIRONMENT: string
+ export const PUBLIC_EXPERIENCE_API_BASE_URL: string
+ export const PUBLIC_INSIGHTS_API_BASE_URL: string
+ export const PUBLIC_CONTENTFUL_TOKEN: string
+ export const PUBLIC_CONTENTFUL_ENVIRONMENT: string
+ export const PUBLIC_CONTENTFUL_SPACE_ID: string
+ export const PUBLIC_CONTENTFUL_CDA_HOST: string
+ export const PUBLIC_CONTENTFUL_BASE_PATH: string
}
diff --git a/implementations/react-native/scripts/run-e2e-android.sh b/implementations/react-native/scripts/run-e2e-android.sh
index b4ce13c3..4d88c23f 100755
--- a/implementations/react-native/scripts/run-e2e-android.sh
+++ b/implementations/react-native/scripts/run-e2e-android.sh
@@ -16,8 +16,8 @@
# METRO_PORT - Port for Metro bundler (default: 8081)
# SKIP_BUILD - Set to "true" to skip the Android build step (default: false)
# CI - Set to "true" when running in CI environment (default: false)
-# VITE_NINETAILED_CLIENT_ID - Ninetailed client ID (default: test-client-id)
-# VITE_NINETAILED_ENVIRONMENT - Ninetailed environment (default: main)
+# PUBLIC_NINETAILED_CLIENT_ID - Ninetailed client ID (default: test-client-id)
+# PUBLIC_NINETAILED_ENVIRONMENT - Ninetailed environment (default: main)
#
# Usage:
# ./scripts/run-e2e-android.sh # Full run with build
@@ -249,15 +249,15 @@ create_env_file() {
log_info "Creating .env file..."
cat > "${RN_DIR}/.env" << EOF
-VITE_NINETAILED_CLIENT_ID=${VITE_NINETAILED_CLIENT_ID:-test-client-id}
-VITE_NINETAILED_ENVIRONMENT=${VITE_NINETAILED_ENVIRONMENT:-main}
-VITE_EXPERIENCE_API_BASE_URL=http://localhost:${MOCK_SERVER_PORT}/experience/
-VITE_INSIGHTS_API_BASE_URL=http://localhost:${MOCK_SERVER_PORT}/insights/
-VITE_CONTENTFUL_TOKEN=${VITE_CONTENTFUL_TOKEN:-test-token}
-VITE_CONTENTFUL_ENVIRONMENT=${VITE_CONTENTFUL_ENVIRONMENT:-master}
-VITE_CONTENTFUL_SPACE_ID=${VITE_CONTENTFUL_SPACE_ID:-test-space}
-VITE_CONTENTFUL_CDA_HOST=localhost:${MOCK_SERVER_PORT}
-VITE_CONTENTFUL_BASE_PATH=/contentful/
+PUBLIC_NINETAILED_CLIENT_ID=${PUBLIC_NINETAILED_CLIENT_ID:-test-client-id}
+PUBLIC_NINETAILED_ENVIRONMENT=${PUBLIC_NINETAILED_ENVIRONMENT:-main}
+PUBLIC_EXPERIENCE_API_BASE_URL=http://localhost:${MOCK_SERVER_PORT}/experience/
+PUBLIC_INSIGHTS_API_BASE_URL=http://localhost:${MOCK_SERVER_PORT}/insights/
+PUBLIC_CONTENTFUL_TOKEN=${PUBLIC_CONTENTFUL_TOKEN:-test-token}
+PUBLIC_CONTENTFUL_ENVIRONMENT=${PUBLIC_CONTENTFUL_ENVIRONMENT:-master}
+PUBLIC_CONTENTFUL_SPACE_ID=${PUBLIC_CONTENTFUL_SPACE_ID:-test-space}
+PUBLIC_CONTENTFUL_CDA_HOST=localhost:${MOCK_SERVER_PORT}
+PUBLIC_CONTENTFUL_BASE_PATH=/contentful/
EOF
log_info ".env file created at ${RN_DIR}/.env"
diff --git a/implementations/react-native/types/env.d.ts b/implementations/react-native/types/env.d.ts
index 9ff522e2..22a88a6a 100644
--- a/implementations/react-native/types/env.d.ts
+++ b/implementations/react-native/types/env.d.ts
@@ -1,11 +1,11 @@
declare module '@env' {
- export const VITE_CONTENTFUL_SPACE_ID: string
- export const VITE_CONTENTFUL_ENVIRONMENT: string
- export const VITE_CONTENTFUL_TOKEN: string
- export const VITE_CONTENTFUL_CDA_HOST: string
- export const VITE_CONTENTFUL_BASE_PATH: string
- export const VITE_NINETAILED_CLIENT_ID: string
- export const VITE_NINETAILED_ENVIRONMENT: string
- export const VITE_EXPERIENCE_API_BASE_URL: string
- export const VITE_INSIGHTS_API_BASE_URL: string
+ export const PUBLIC_CONTENTFUL_SPACE_ID: string
+ export const PUBLIC_CONTENTFUL_ENVIRONMENT: string
+ export const PUBLIC_CONTENTFUL_TOKEN: string
+ export const PUBLIC_CONTENTFUL_CDA_HOST: string
+ export const PUBLIC_CONTENTFUL_BASE_PATH: string
+ export const PUBLIC_NINETAILED_CLIENT_ID: string
+ export const PUBLIC_NINETAILED_ENVIRONMENT: string
+ export const PUBLIC_EXPERIENCE_API_BASE_URL: string
+ export const PUBLIC_INSIGHTS_API_BASE_URL: string
}
diff --git a/implementations/web-vanilla/.env.example b/implementations/web-vanilla/.env.example
index 39d0d995..ed05455f 100644
--- a/implementations/web-vanilla/.env.example
+++ b/implementations/web-vanilla/.env.example
@@ -1,15 +1,15 @@
DOTENV_CONFIG_QUIET=true
-VITE_NINETAILED_CLIENT_ID="mock-client-id"
-VITE_NINETAILED_ENVIRONMENT="main"
+PUBLIC_NINETAILED_CLIENT_ID="mock-client-id"
+PUBLIC_NINETAILED_ENVIRONMENT="main"
-VITE_EXPERIENCE_API_BASE_URL="http://localhost:8000/experience/"
-VITE_INSIGHTS_API_BASE_URL="http://localhost:8000/insights/"
+PUBLIC_EXPERIENCE_API_BASE_URL="http://localhost:8000/experience/"
+PUBLIC_INSIGHTS_API_BASE_URL="http://localhost:8000/insights/"
-VITE_CONTENTFUL_TOKEN="mock-token"
-VITE_CONTENTFUL_PREVIEW_TOKEN="mosk-preview-token"
-VITE_CONTENTFUL_ENVIRONMENT="master"
-VITE_CONTENTFUL_SPACE_ID="mock-space-id"
+PUBLIC_CONTENTFUL_TOKEN="mock-token"
+PUBLIC_CONTENTFUL_PREVIEW_TOKEN="mosk-preview-token"
+PUBLIC_CONTENTFUL_ENVIRONMENT="master"
+PUBLIC_CONTENTFUL_SPACE_ID="mock-space-id"
-VITE_CONTENTFUL_CDA_HOST="localhost:8000"
-VITE_CONTENTFUL_BASE_PATH="contentful"
+PUBLIC_CONTENTFUL_CDA_HOST="localhost:8000"
+PUBLIC_CONTENTFUL_BASE_PATH="contentful"
diff --git a/implementations/web-vanilla/nginx/templates/default.conf.template b/implementations/web-vanilla/nginx/templates/default.conf.template
index b054038d..b438e118 100644
--- a/implementations/web-vanilla/nginx/templates/default.conf.template
+++ b/implementations/web-vanilla/nginx/templates/default.conf.template
@@ -5,19 +5,19 @@ server {
ssi on;
ssi_types text/html;
- set $NGINX_NINETAILED_CLIENT_ID "${VITE_NINETAILED_CLIENT_ID}";
- set $NGINX_NINETAILED_ENVIRONMENT "${VITE_NINETAILED_ENVIRONMENT}";
+ set $NGINX_NINETAILED_CLIENT_ID "${PUBLIC_NINETAILED_CLIENT_ID}";
+ set $NGINX_NINETAILED_ENVIRONMENT "${PUBLIC_NINETAILED_ENVIRONMENT}";
- set $NGINX_EXPERIENCE_API_BASE_URL "${VITE_EXPERIENCE_API_BASE_URL}";
- set $NGINX_INSIGHTS_API_BASE_URL "${VITE_INSIGHTS_API_BASE_URL}";
+ set $NGINX_EXPERIENCE_API_BASE_URL "${PUBLIC_EXPERIENCE_API_BASE_URL}";
+ set $NGINX_INSIGHTS_API_BASE_URL "${PUBLIC_INSIGHTS_API_BASE_URL}";
- set $NGINX_CONTENTFUL_TOKEN "${VITE_CONTENTFUL_TOKEN}";
- set $NGINX_CONTENTFUL_PREVIEW_TOKEN "${VITE_CONTENTFUL_PREVIEW_TOKEN}";
- set $NGINX_CONTENTFUL_ENVIRONMENT "${VITE_CONTENTFUL_ENVIRONMENT}";
- set $NGINX_CONTENTFUL_SPACE_ID "${VITE_CONTENTFUL_SPACE_ID}";
+ set $NGINX_CONTENTFUL_TOKEN "${PUBLIC_CONTENTFUL_TOKEN}";
+ set $NGINX_CONTENTFUL_PREVIEW_TOKEN "${PUBLIC_CONTENTFUL_PREVIEW_TOKEN}";
+ set $NGINX_CONTENTFUL_ENVIRONMENT "${PUBLIC_CONTENTFUL_ENVIRONMENT}";
+ set $NGINX_CONTENTFUL_SPACE_ID "${PUBLIC_CONTENTFUL_SPACE_ID}";
- set $NGINX_CONTENTFUL_CDA_HOST "${VITE_CONTENTFUL_CDA_HOST}";
- set $NGINX_CONTENTFUL_BASE_PATH "${VITE_CONTENTFUL_BASE_PATH}";
+ set $NGINX_CONTENTFUL_CDA_HOST "${PUBLIC_CONTENTFUL_CDA_HOST}";
+ set $NGINX_CONTENTFUL_BASE_PATH "${PUBLIC_CONTENTFUL_BASE_PATH}";
listen 80;
diff --git a/implementations/web-vanilla/public/index.html b/implementations/web-vanilla/public/index.html
index 6a124b5d..3fc66088 100644
--- a/implementations/web-vanilla/public/index.html
+++ b/implementations/web-vanilla/public/index.html
@@ -68,11 +68,13 @@
}
}
}
+ #utility-panel,
#event-stream-panel {
position: sticky;
top: 0;
margin-block-start: -1px;
padding-block-start: 1px;
+ background: #fff;
}
#auto-observed,
#manually-observed {
@@ -315,6 +317,9 @@ Event Stream
// The `data-ctfl-entry-id` data attribute is required for auto-observing
element.dataset.ctflEntryId = entry.sys?.id
+ // Store the baseline ID so we can continue updating
+ if (entry.fields.nt_experiences) element.dataset.ctflBaselineId = entry.sys?.id
+
// Other standard auto-observing attributes are optional
if (personalization) {
element.dataset.ctflPersonalizationId = personalization?.experienceId
@@ -360,12 +365,25 @@ Event Stream
manuallyObservedEntryElements.set(element.dataset.entryId, [entry, personalization])
}
- // Subscribe to the event stream
- optimization.states.eventStream.subscribe((event) => {
- if (!event) return
+ // Render all the entries
+ function renderEntries() {
+ document.querySelectorAll('[data-ctfl-entry-id]').forEach(async (element) => {
+ await addPersonalizedEntry(
+ element.dataset.ctflBaselineId ?? element.dataset.ctflEntryId,
+ element,
+ )
+ })
- document.querySelector('#event-stream').appendChild(createEventDialog(event.type, event))
- })
+ document.querySelectorAll('[data-entry-id]').forEach(async (element) => {
+ const [entry, personalization] = await addPersonalizedEntry(
+ element.dataset.entryId,
+ element,
+ false,
+ )
+
+ manuallyObserveEntryElement(element, entry, personalization)
+ })
+ }
// Subscribe to consent state
optimization.states.consent.subscribe(async (consent) => {
@@ -383,25 +401,25 @@ Event Stream
})
})
+ // Subscribe to the event stream
+ optimization.states.eventStream.subscribe((event) => {
+ if (!event) return
+
+ document.querySelector('#event-stream').appendChild(createEventDialog(event.type, event))
+ })
+
+ // Subscribe to personalizations state
+ optimization.states.personalizations.subscribe(async (personalizations) => {
+ if (!personalizations) return
+
+ renderEntries()
+ })
+
// Subscribe to profile state, find entries in the markup, and render them
optimization.states.profile.subscribe((profile) => {
if (!profile) return
toggleIdentity(profile.traits && Object.keys(profile.traits).length)
-
- document.querySelectorAll('[data-ctfl-entry-id]').forEach(async (element) => {
- await addPersonalizedEntry(element.dataset.ctflEntryId, element)
- })
-
- document.querySelectorAll('[data-entry-id]').forEach(async (element) => {
- const [entry, personalization] = await addPersonalizedEntry(
- element.dataset.entryId,
- element,
- false,
- )
-
- manuallyObserveEntryElement(element, entry, personalization)
- })
})