create-content-sdk-app 2.4.0-canary.20260907075319 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,8 +12,8 @@
12
12
  # CSDK_PUBLIC_SITECORE_API_HOST=
13
13
 
14
14
  # Site / language
15
- # CSDK_PUBLIC_SITECORE_DEFAULT_SITE=
16
- # CSDK_PUBLIC_SITECORE_DEFAULT_LANGUAGE=en
15
+ # CSDK_PUBLIC_DEFAULT_SITE_NAME=
16
+ # CSDK_PUBLIC_DEFAULT_LANGUAGE=en
17
17
 
18
18
  # Global switch for Content SDK experimental features. Set to `true`
19
19
  # together with individual `CSDK_EXPERIMENTAL_*` flags during development.
@@ -24,3 +24,6 @@
24
24
 
25
25
  # Timeout (ms) for Sitecore Experience Edge requests to respond within. Default is 400.
26
26
  # PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT=
27
+
28
+ # Optional secret for /api/revalidate endpoint used to revalidate loaders cache
29
+ # SITECORE_REVALIDATE_SECRET=
@@ -1,2 +1,3 @@
1
1
  <sc-editing-scripts />
2
+ <app-cdp-page-view />
2
3
  <router-outlet />
@@ -1,11 +1,12 @@
1
1
  import { Component, effect, inject, signal } from '@angular/core';
2
2
  import { RouterOutlet } from '@angular/router';
3
3
  import { ScEditingScriptsComponent, SitecoreContextService } from '@sitecore-content-sdk/angular';
4
+ import { CdpPageViewComponent } from './components/content-sdk/cdp-page-view.component';
4
5
  import { TranslateService } from '@ngx-translate/core';
5
6
 
6
7
  @Component({
7
8
  selector: 'app-root',
8
- imports: [RouterOutlet, ScEditingScriptsComponent],
9
+ imports: [RouterOutlet, ScEditingScriptsComponent, CdpPageViewComponent],
9
10
  templateUrl: './app.html',
10
11
  styleUrl: './app.css',
11
12
  })
@@ -0,0 +1,58 @@
1
+ import { Component, effect, inject } from '@angular/core';
2
+ import {
3
+ CdpHelper,
4
+ SITECORE_ANALYTICS,
5
+ SitecoreContextService,
6
+ } from '@sitecore-content-sdk/angular';
7
+ import config from 'sitecore.config';
8
+
9
+ /**
10
+ * CDP page view component. Dispatches a Sitecore CDP page view event on initial load and on
11
+ * every client-side navigation. Template-less — it only performs the side effect.
12
+ *
13
+ * page data comes from {@link SitecoreContextService}, dispatch goes through the {@link SITECORE_ANALYTICS} facade
14
+ * Runs in browser only.
15
+ *
16
+ * See Sitecore Content SDK documentation for details:
17
+ * https://www.npmjs.com/package/@sitecore-content-sdk/events
18
+ */
19
+ @Component({
20
+ selector: 'app-cdp-page-view',
21
+ template: '',
22
+ })
23
+ export class CdpPageViewComponent {
24
+ private readonly analytics = inject(SITECORE_ANALYTICS);
25
+ private readonly context = inject(SitecoreContextService);
26
+
27
+ constructor() {
28
+ effect(() => {
29
+ const page = this.context.page();
30
+ // Do not create events in editing or preview mode, or if missing route data.
31
+ if (!page || !page.mode.isNormal) {
32
+ return;
33
+ }
34
+ const route = page.layout.sitecore.route;
35
+ if (!route?.itemId) {
36
+ return;
37
+ }
38
+
39
+ const language = page.locale || config.defaultLanguage;
40
+ const pageVariantId = CdpHelper.getPageVariantId(
41
+ route.itemId,
42
+ language,
43
+ page.layout.sitecore.context.variantId as string,
44
+ config.personalize.scope
45
+ );
46
+
47
+ // Events may not be initialized (the façade is a no-op in dev / when Edge config is
48
+ // missing, and swallows runtime failures at debug level).
49
+ void this.analytics.pageView({
50
+ channel: 'WEB',
51
+ currency: 'USD',
52
+ page: route.name,
53
+ pageVariantId,
54
+ language,
55
+ });
56
+ });
57
+ }
58
+ }
@@ -52,6 +52,9 @@ const loaderCache = createLoaderCache({
52
52
 
53
53
  app.use(express.json());
54
54
 
55
+ /** Health check endpoint. */
56
+ app.get('/healthz', (_req, res) => res.sendStatus(200));
57
+
55
58
  /** Production webhook: POST /api/revalidate (Sitecore Edge OSR). */
56
59
  app.use(
57
60
  createSitecoreRevalidateMiddleware({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-content-sdk-app",
3
- "version": "2.4.0-canary.20260907075319",
3
+ "version": "2.4.0",
4
4
  "description": "Sitecore Content SDK initializer",
5
5
  "bin": "./dist/index.js",
6
6
  "scripts": {
@@ -38,12 +38,12 @@
38
38
  "minimist": "^1.2.8"
39
39
  },
40
40
  "devDependencies": {
41
- "@sitecore-content-sdk/analytics-core": "2.1.3-canary.20260907075319",
42
- "@sitecore-content-sdk/angular": "0.3.0-canary.20260907075319",
43
- "@sitecore-content-sdk/cli": "2.3.0-canary.20260907075319",
44
- "@sitecore-content-sdk/events": "2.1.3-canary.20260907075319",
45
- "@sitecore-content-sdk/nextjs": "2.4.0-canary.20260907075319",
46
- "@sitecore-content-sdk/personalize": "2.1.1-canary.20260907075319",
41
+ "@sitecore-content-sdk/analytics-core": "^2.1.2",
42
+ "@sitecore-content-sdk/angular": "~1.0.0",
43
+ "@sitecore-content-sdk/cli": "^2.3.0",
44
+ "@sitecore-content-sdk/events": "^2.1.2",
45
+ "@sitecore-content-sdk/nextjs": "^2.4.0",
46
+ "@sitecore-content-sdk/personalize": "^2.1.0",
47
47
  "@stylistic/eslint-plugin": "^5.2.2",
48
48
  "@types/chai": "^5.2.2",
49
49
  "@types/cross-spawn": "^6.0.6",