@contentful/optimization-node 0.1.0-alpha10 → 0.1.0-alpha12

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center">
2
2
  <a href="https://www.contentful.com/developers/docs/personalization/">
3
- <img alt="Contentful Logo" title="Contentful" src="../../../contentful-icon.png" width="150">
3
+ <img alt="Contentful Logo" title="Contentful" src="https://raw.githubusercontent.com/contentful/optimization/v0.1.0-alpha12/contentful-icon.png" width="150">
4
4
  </a>
5
5
  </p>
6
6
 
@@ -10,8 +10,8 @@
10
10
 
11
11
  <div align="center">
12
12
 
13
- [Readme](./README.md) · [Reference](https://contentful.github.io/optimization) ·
14
- [Contributing](../../../CONTRIBUTING.md)
13
+ [Guides](https://contentful.github.io/optimization/documents/Guides.html) ·
14
+ [Reference](https://contentful.github.io/optimization) · [Contributing](https://github.com/contentful/optimization/blob/v0.1.0-alpha12/CONTRIBUTING.md)
15
15
 
16
16
  </div>
17
17
 
@@ -20,8 +20,8 @@
20
20
  > The Optimization SDK Suite is pre-release (alpha). Breaking changes may be published at any time.
21
21
 
22
22
  The Optimization Node SDK implements functionality specific to Node environments, based on the
23
- [Optimization Core Library](../../universal/core-sdk/README.md). This SDK is part of the
24
- [Contentful Optimization SDK Suite](../../../README.md).
23
+ [Optimization Core Library](https://github.com/contentful/optimization/blob/v0.1.0-alpha12/packages/universal/core-sdk/README.md). This SDK is part of the
24
+ [Contentful Optimization SDK Suite](https://github.com/contentful/optimization/blob/v0.1.0-alpha12/README.md).
25
25
 
26
26
  <details>
27
27
  <summary>Table of Contents</summary>
@@ -31,22 +31,22 @@ The Optimization Node SDK implements functionality specific to Node environments
31
31
  - [Reference Implementations](#reference-implementations)
32
32
  - [Configuration](#configuration)
33
33
  - [Top-level Configuration Options](#top-level-configuration-options)
34
- - [Analytics Options](#analytics-options)
34
+ - [API Options](#api-options)
35
35
  - [Event Builder Options](#event-builder-options)
36
36
  - [Fetch Options](#fetch-options)
37
- - [Personalization Options](#personalization-options)
38
37
  - [Optimization Methods](#optimization-methods)
39
- - [Personalization Data Resolution Methods](#personalization-data-resolution-methods)
40
- - [`getCustomFlag`](#getcustomflag)
41
- - [`personalizeEntry`](#personalizeentry)
38
+ - [Optimization Data Resolution Methods](#optimization-data-resolution-methods)
39
+ - [`getFlag`](#getflag)
40
+ - [`resolveOptimizedEntry`](#resolveoptimizedentry)
42
41
  - [`getMergeTagValue`](#getmergetagvalue)
43
- - [Personalization and Analytics Event Methods](#personalization-and-analytics-event-methods)
42
+ - [Experience API and Insights API Event Methods](#experience-api-and-insights-api-event-methods)
44
43
  - [`identify`](#identify)
45
44
  - [`page`](#page)
46
45
  - [`screen`](#screen)
47
46
  - [`track`](#track)
48
- - [`trackComponentView`](#trackcomponentview)
49
- - [`trackComponentClick`](#trackcomponentclick)
47
+ - [`trackView`](#trackview)
48
+ - [`trackClick`](#trackclick)
49
+ - [`trackHover`](#trackhover)
50
50
  - [`trackFlagView`](#trackflagview)
51
51
  - [Interceptors](#interceptors)
52
52
  - [Life-cycle Interceptors](#life-cycle-interceptors)
@@ -65,61 +65,106 @@ pnpm install @contentful/optimization-node
65
65
  Import the Optimization class; both CJS and ESM module systems are supported, ESM preferred:
66
66
 
67
67
  ```ts
68
- import Optimization from '@contentful/optimization-node'
68
+ import ContentfulOptimization from '@contentful/optimization-node'
69
69
  ```
70
70
 
71
71
  Configure and initialize the Optimization Node SDK:
72
72
 
73
73
  ```ts
74
- const optimization = new Optimization({ clientId: 'abc123' })
74
+ const optimization = new ContentfulOptimization({ clientId: 'abc123' })
75
+ const requestOptions = { locale: 'en-US' }
76
+
77
+ await optimization.page({}, requestOptions)
75
78
  ```
76
79
 
80
+ Create `optimization` once per module or process, then pass request-scoped Experience options as the
81
+ final argument to stateless event methods inside each incoming request.
82
+
83
+ ## Caching Guidance
84
+
85
+ The Node SDK is stateless, but that does not mean all request work is cacheable.
86
+
87
+ - Cache raw Contentful delivery payloads in your application layer.
88
+ - Treat cached Contentful entries as immutable.
89
+ - Use `resolveOptimizedEntry()` and `getMergeTagValue()` as request-local helpers when rendering.
90
+ - Do not memoize `page()`, `identify()`, `screen()`, `track()`, `trackView()`, `trackClick()`,
91
+ `trackHover()`, or `trackFlagView()`. Those methods emit outbound events and/or return profile
92
+ state for the current request.
93
+
94
+ For a step-by-step Express-style walkthrough that covers request context, profile persistence,
95
+ Contentful entry resolution, and hybrid Node + browser setups, see
96
+ [Integrating the Optimization Node SDK in a Node App](https://github.com/contentful/optimization/blob/v0.1.0-alpha12/documentation/integrating-the-node-sdk-in-a-node-app.md).
97
+
98
+ ## Development Harness
99
+
100
+ The package-local dev harness runs from `packages/node/node-sdk/dev/` and reads `.env` from this
101
+ package directory.
102
+
103
+ 1. Start from `.env.example` and create or update `packages/node/node-sdk/.env`.
104
+ 2. Prefer the repo-standard `PUBLIC_...` variable names shown in `.env.example`.
105
+ 3. Start the harness from the repo root:
106
+
107
+ ```sh
108
+ pnpm --filter @contentful/optimization-node dev
109
+ ```
110
+
77
111
  ## Reference Implementations
78
112
 
79
113
  Reference implementations illustrate how the SDK may be used under common scenarios, as well as
80
114
  select less-common scenarios, with the most basic example solution possible.
81
115
 
82
- - [Node SSR Only](../../../implementations/node-sdk/README.md): Example application that uses the
83
- Node SDK to render a personalized Web page
84
- - [Node SSR + Web Vanilla](../../../implementations/node-sdk+web-sdk/README.md): Example application
116
+ - [Node SSR Only](https://github.com/contentful/optimization/blob/v0.1.0-alpha12/implementations/node-sdk/README.md): Example application that uses the
117
+ Node SDK to render an optimized Web page
118
+ - [Node SSR + Web Vanilla](https://github.com/contentful/optimization/blob/v0.1.0-alpha12/implementations/node-sdk+web-sdk/README.md): Example application
85
119
  demonstrating simple profile synchronization between the Node and
86
- [Web](../../web/web-sdk/README.md) SDKs via cookie
120
+ [Web](https://github.com/contentful/optimization/blob/v0.1.0-alpha12/packages/web/web-sdk/README.md) SDKs via cookie
87
121
 
88
122
  ## Configuration
89
123
 
90
124
  ### Top-level Configuration Options
91
125
 
92
- | Option | Required? | Default | Description |
93
- | ----------------- | --------- | ----------------------------- | ------------------------------------------------------------------------------ |
94
- | `analytics` | No | See "Analytics Options" | Configuration specific to the Analytics/Insights API |
95
- | `app` | No | `undefined` | The application definition used to attribute events to a specific consumer app |
96
- | `clientId` | Yes | N/A | The Optimization API key |
97
- | `environment` | No | `'main'` | The environment identifier |
98
- | `eventBuilder` | No | See "Event Builder Options" | Event builder configuration (channel/library metadata, etc.) |
99
- | `fetchOptions` | No | See "Fetch Options" | Configuration for Fetch timeout and retry functionality |
100
- | `logLevel` | No | `'error'` | Minimum log level for the default console sink |
101
- | `personalization` | No | See "Personalization Options" | Configuration specific to the Personalization/Experience API |
102
-
103
- ### Analytics Options
104
-
105
- | Option | Required? | Default | Description |
106
- | --------- | --------- | ------------------------------------------ | ----------------------------- |
107
- | `baseUrl` | No | `'https://ingest.insights.ninetailed.co/'` | Base URL for the Insights API |
126
+ | Option | Required? | Default | Description |
127
+ | -------------- | --------- | --------------------------- | ------------------------------------------------------------------------------ |
128
+ | `api` | No | See "API Options" | Unified configuration for the Experience API and Insights API endpoints |
129
+ | `app` | No | `undefined` | The application definition used to attribute events to a specific consumer app |
130
+ | `clientId` | Yes | N/A | Shared API key for Experience API and Insights API requests |
131
+ | `environment` | No | `'main'` | The environment identifier |
132
+ | `eventBuilder` | No | See "Event Builder Options" | Event builder configuration (channel/library metadata, etc.) |
133
+ | `fetchOptions` | No | See "Fetch Options" | Configuration for Fetch timeout and retry functionality |
134
+ | `logLevel` | No | `'error'` | Minimum log level for the default console sink |
135
+
136
+ ### API Options
137
+
138
+ | Option | Required? | Default | Description |
139
+ | ------------------- | --------- | ------------------------------------------ | ------------------------------------------------------------ |
140
+ | `experienceBaseUrl` | No | `'https://experience.ninetailed.co/'` | Base URL for the Experience API |
141
+ | `insightsBaseUrl` | No | `'https://ingest.insights.ninetailed.co/'` | Base URL for the Insights API |
142
+ | `enabledFeatures` | No | `['ip-enrichment', 'location']` | Enabled features the Experience API may use for each request |
143
+
144
+ Request-scoped Experience API options are passed to stateless event methods as their final argument
145
+ instead of the SDK constructor:
146
+
147
+ | Option | Required? | Default | Description |
148
+ | ----------- | --------- | ----------- | ------------------------------------------------------------------------------ |
149
+ | `ip` | No | `undefined` | IP address override used by the Experience API for location analysis |
150
+ | `locale` | No | `undefined` | Locale used to translate `location.city` and `location.country` |
151
+ | `plainText` | No | `undefined` | Sends performance-critical Experience API endpoints in plain text |
152
+ | `preflight` | No | `undefined` | Instructs the Experience API to aggregate a new profile state but not store it |
108
153
 
109
154
  ### Event Builder Options
110
155
 
111
156
  Event builder options should only be supplied when building an SDK on top of the Optimization Node
112
157
  SDK or any of its descendent SDKs.
113
158
 
114
- | Option | Required? | Default | Description |
115
- | --------- | --------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------- |
116
- | `channel` | No | `'server'` | The channel that identifies where events originate from (e.g. `'web'`, `'mobile'`) |
117
- | `library` | No | `{ name: 'Optimization Node API', version: '0.0.0' }` | The client library metadata that is attached to all events |
159
+ | Option | Required? | Default | Description |
160
+ | --------- | --------- | ------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
161
+ | `channel` | No | `'server'` | The channel that identifies where events originate from (e.g. `'web'`, `'mobile'`) |
162
+ | `library` | No | `{ name: '@contentful/optimization-node', version: '0.0.0' }` | The client library metadata that is attached to all events |
118
163
 
119
164
  ### Fetch Options
120
165
 
121
166
  Fetch options allow for configuration of a Fetch API-compatible fetch method and the retry/timeout
122
- logic integrated into the Optimization API Client. Specify the `fetchMethod` when the host
167
+ logic integrated into the SDK's bundled API clients. Specify the `fetchMethod` when the host
123
168
  application environment does not offer a `fetch` method that is compatible with the standard Fetch
124
169
  API in its global scope.
125
170
 
@@ -137,24 +182,13 @@ Configuration method signatures:
137
182
  - `fetchMethod`: `(url: string | URL, init: RequestInit) => Promise<Response>`
138
183
  - `onFailedAttempt` and `onRequestTimeout`: `(options: FetchMethodCallbackOptions) => void`
139
184
 
140
- ### Personalization Options
141
-
142
- | Option | Required? | Default | Description |
143
- | ----------------- | --------- | ------------------------------------- | ------------------------------------------------------------------- |
144
- | `baseUrl` | No | `'https://experience.ninetailed.co/'` | Base URL for the Experience API |
145
- | `enabledFeatures` | No | `['ip-enrichment', 'location']` | Enabled features which the API may use for each request |
146
- | `ip` | No | `undefined` | IP address to override the API behavior for IP analysis |
147
- | `locale` | No | `'en-US'` (in API) | Locale used to translate `location.city` and `location.country` |
148
- | `plainText` | No | `false` | Sends performance-critical endpoints in plain text |
149
- | `preflight` | No | `false` | Instructs the API to aggregate a new profile state but not store it |
150
-
151
185
  ## Optimization Methods
152
186
 
153
187
  Arguments marked with an asterisk (\*) are always required.
154
188
 
155
- ### Personalization Data Resolution Methods
189
+ ### Optimization Data Resolution Methods
156
190
 
157
- #### `getCustomFlag`
191
+ #### `getFlag`
158
192
 
159
193
  Get the specified Custom Flag's value from the provided changes array.
160
194
 
@@ -167,14 +201,20 @@ Returns:
167
201
 
168
202
  - The resolved value for the specified Custom Flag, or `undefined` if it cannot be found.
169
203
 
204
+ Behavior notes:
205
+
206
+ - Node SDK is stateless; `getFlag(...)` does not auto-emit `trackFlagView`.
207
+ - If full map resolution is needed for advanced use cases, use
208
+ `optimization.flagsResolver.resolve(changes)`.
209
+
170
210
  > [!NOTE]
171
211
  >
172
212
  > If the `changes` argument is omitted, the method will return `undefined`.
173
213
 
174
- #### `personalizeEntry`
214
+ #### `resolveOptimizedEntry`
175
215
 
176
- Resolve a baseline Contentful entry to a personalized variant using the provided selected
177
- personalizations.
216
+ Resolve a baseline Contentful entry to an optimized variant using the provided selected
217
+ optimizations.
178
218
 
179
219
  Type arguments:
180
220
 
@@ -184,17 +224,17 @@ Type arguments:
184
224
 
185
225
  Arguments:
186
226
 
187
- - `entry`\*: The entry to personalize
188
- - `personalizations`: Selected personalizations
227
+ - `entry`\*: The baseline entry to resolve
228
+ - `selectedOptimizations`: Selected optimizations
189
229
 
190
230
  Returns:
191
231
 
192
- - The resolved personalized entry variant, or the supplied baseline entry if baseline is the
193
- selected variant or a variant cannot be found.
232
+ - The resolved optimized entry variant, or the supplied baseline entry if baseline is the selected
233
+ variant or a variant cannot be found.
194
234
 
195
235
  > [!NOTE]
196
236
  >
197
- > If the `personalizations` argument is omitted, the method will return the baseline entry.
237
+ > If the `selectedOptimizations` argument is omitted, the method will return the baseline entry.
198
238
 
199
239
  #### `getMergeTagValue`
200
240
 
@@ -211,7 +251,21 @@ Arguments:
211
251
  >
212
252
  > If the `profile` argument is omitted, the method will return the merge tag's fallback value.
213
253
 
214
- ### Personalization and Analytics Event Methods
254
+ ### Experience API and Insights API Event Methods
255
+
256
+ Pass request-scoped Experience options as the final argument to stateless event methods:
257
+
258
+ ```ts
259
+ const requestOptions = {
260
+ locale: req.acceptsLanguages()[0] ?? 'en-US',
261
+ }
262
+
263
+ await optimization.page({ ...requestContext, profile }, requestOptions)
264
+ ```
265
+
266
+ Request-scoped Experience options stay separate from the event payload. Event context such as page
267
+ data, locale metadata on the event, and user agent belong in `payload`, while `ip`, `locale`,
268
+ `plainText`, and `preflight` belong in `requestOptions`.
215
269
 
216
270
  Only the following methods may return an `OptimizationData` object:
217
271
 
@@ -219,15 +273,20 @@ Only the following methods may return an `OptimizationData` object:
219
273
  - `page`
220
274
  - `screen`
221
275
  - `track`
222
- - `trackComponentView` (when `payload.sticky` is `true`)
276
+ - `trackView` (when `payload.sticky` is `true`)
223
277
 
224
- `trackComponentClick` and `trackFlagView` return no data. When returned, `OptimizationData`
278
+ `trackClick`, `trackHover`, and `trackFlagView` return no data. When returned, `OptimizationData`
225
279
  contains:
226
280
 
227
281
  - `changes`: Currently used for Custom Flags
228
- - `personalizations`: Selected personalizations for the profile
282
+ - `selectedOptimizations`: Selected optimizations for the profile
229
283
  - `profile`: Profile associated with the evaluated events
230
284
 
285
+ In stateless runtimes, Insights-backed methods require a profile for delivery. Non-sticky
286
+ `trackView`, `trackClick`, `trackHover`, and `trackFlagView` require `payload.profile.id`. Sticky
287
+ `trackView` may omit `profile`, because the returned Experience profile is reused for the paired
288
+ Insights event.
289
+
231
290
  #### `identify`
232
291
 
233
292
  Identify the current profile/visitor to associate traits with a profile.
@@ -236,48 +295,55 @@ Arguments:
236
295
 
237
296
  - `payload`\*: Identify event builder arguments object, including an optional `profile` property
238
297
  with a `PartialProfile` value that requires only an `id`
298
+ - `requestOptions`: Optional request-scoped Experience API options passed as the final argument
239
299
 
240
300
  #### `page`
241
301
 
242
- Record a personalization page view.
302
+ Record an Experience API page view.
243
303
 
244
304
  Arguments:
245
305
 
246
306
  - `payload`\*: Page view event builder arguments object, including an optional `profile` property
247
307
  with a `PartialProfile` value that requires only an `id`
308
+ - `requestOptions`: Optional request-scoped Experience API options passed as the final argument
248
309
 
249
310
  #### `screen`
250
311
 
251
- Record a personalization screen view.
312
+ Record an Experience API screen view.
252
313
 
253
314
  Arguments:
254
315
 
255
316
  - `payload`\*: Screen view event builder arguments object, including an optional `profile` property
256
317
  with a `PartialProfile` value that requires only an `id`
318
+ - `requestOptions`: Optional request-scoped Experience API options passed as the final argument
257
319
 
258
320
  #### `track`
259
321
 
260
- Record a personalization custom track event.
322
+ Record an Experience API custom track event.
261
323
 
262
324
  Arguments:
263
325
 
264
326
  - `payload`\*: Track event builder arguments object, including an optional `profile` property with a
265
327
  `PartialProfile` value that requires only an `id`
328
+ - `requestOptions`: Optional request-scoped Experience API options passed as the final argument
266
329
 
267
- #### `trackComponentView`
330
+ #### `trackView`
268
331
 
269
- Record an analytics component view event. When the payload marks the component as "sticky", an
270
- additional personalization component view is recorded. This method only returns `OptimizationData`
271
- when the component is marked as "sticky".
332
+ Record an Insights API entry view event. When the payload marks the entry as "sticky", an additional
333
+ Experience API entry view is recorded. This method only returns `OptimizationData` when the entry is
334
+ marked as "sticky".
272
335
 
273
336
  Arguments:
274
337
 
275
- - `payload`\*: Component view event builder arguments object, including an optional `profile`
276
- property with a `PartialProfile` value that requires only an `id`
338
+ - `payload`\*: Entry view event builder arguments object. When `payload.sticky` is `true`, `profile`
339
+ is optional and the returned Experience profile is reused for Insights delivery. Otherwise,
340
+ `profile` is required and must contain at least an `id`
341
+ - `requestOptions`: Optional request-scoped Experience API options passed as the final argument.
342
+ Only used when `payload.sticky` is `true`
277
343
 
278
- #### `trackComponentClick`
344
+ #### `trackClick`
279
345
 
280
- Record an analytics component click event.
346
+ Record an Insights API entry click event.
281
347
 
282
348
  Returns:
283
349
 
@@ -285,11 +351,29 @@ Returns:
285
351
 
286
352
  Arguments:
287
353
 
288
- - `payload`\*: Component click event builder arguments object
354
+ - `payload`\*: Entry click event builder arguments object, including a required `profile` property
355
+ with a `PartialProfile` value that requires only an `id`
356
+ - `requestOptions`: Optional request-scoped Experience API options accepted for signature
357
+ consistency; currently unused
358
+
359
+ #### `trackHover`
360
+
361
+ Record an Insights API entry hover event.
362
+
363
+ Returns:
364
+
365
+ - `void`
366
+
367
+ Arguments:
368
+
369
+ - `payload`\*: Entry hover event builder arguments object, including a required `profile` property
370
+ with a `PartialProfile` value that requires only an `id`
371
+ - `requestOptions`: Optional request-scoped Experience API options accepted for signature
372
+ consistency; currently unused
289
373
 
290
374
  #### `trackFlagView`
291
375
 
292
- Track a feature flag view via analytics. This is functionally the same as a non-sticky component
376
+ Track a feature flag view via the Insights API. This is functionally the same as a non-sticky flag
293
377
  view event.
294
378
 
295
379
  Returns:
@@ -298,7 +382,10 @@ Returns:
298
382
 
299
383
  Arguments:
300
384
 
301
- - `payload`\*: Component view event builder arguments object
385
+ - `payload`\*: Flag view event builder arguments object, including a required `profile` property
386
+ with a `PartialProfile` value that requires only an `id`
387
+ - `requestOptions`: Optional request-scoped Experience API options accepted for signature
388
+ consistency; currently unused
302
389
 
303
390
  ## Interceptors
304
391
 
package/dist/260.mjs CHANGED
@@ -1,4 +1,4 @@
1
- const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha10";
1
+ const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha12";
2
2
  const OPTIMIZATION_NODE_SDK_NAME = "@contentful/optimization-node";
3
3
  export { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from "@contentful/optimization-core/constants";
4
4
  export { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION };
package/dist/260.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"260.mjs","sources":["../src/constants.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_VERSION__: string | undefined\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_PACKAGE_NAME__: string | undefined\n\n/**\n * The current version of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'0.0.0'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\n\n/**\n * The package name of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_NAME =\n typeof __OPTIMIZATION_PACKAGE_NAME__ === 'string'\n ? __OPTIMIZATION_PACKAGE_NAME__\n : '@contentful/optimization-node'\n\n/**\n * Re-exports of anonymous identifier constants used by the Optimization Core.\n *\n * @remarks\n * This constant is surfaced here to provide a stable import path for Node SDK\n * consumers. It represents the cookie key used by the Optimization Framework\n * to persist an anonymous identifier for tracking personalization and analytics\n * events when no explicit profile is known.\n *\n * @example\n * ```ts\n * import { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-node/constants'\n * const cookieId = request.cookies[ANONYMOUS_ID_COOKIE]\n * const storageId = localStorage.getItem(ANONYMOUS_ID_KEY)\n * ```\n *\n * @see {@link ANONYMOUS_ID_COOKIE} and {@link ANONYMOUS_ID_KEY} in\n * `@contentful/optimization-core` for the\n * authoritative definition and documentation.\n *\n * @public\n */\nexport { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-core/constants'\n"],"names":["OPTIMIZATION_NODE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_NODE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__"],"mappings":"AAYO,MAAMA,gCACoCC;AAS1C,MAAMC,6BAEPC"}
1
+ {"version":3,"file":"260.mjs","sources":["../src/constants.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_VERSION__: string | undefined\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_PACKAGE_NAME__: string | undefined\n\n/**\n * The current version of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'0.0.0'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\n\n/**\n * The package name of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_NAME =\n typeof __OPTIMIZATION_PACKAGE_NAME__ === 'string'\n ? __OPTIMIZATION_PACKAGE_NAME__\n : '@contentful/optimization-node'\n\n/**\n * Re-exports of anonymous identifier constants used by the Optimization Core.\n *\n * @remarks\n * This constant is surfaced here to provide a stable import path for Node SDK\n * consumers. It represents the cookie key used by the Optimization Framework\n * to persist an anonymous identifier for tracking optimization and insights\n * events when no explicit profile is known.\n *\n * @example\n * ```ts\n * import { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-node/constants'\n * const cookieId = request.cookies[ANONYMOUS_ID_COOKIE]\n * const storageId = localStorage.getItem(ANONYMOUS_ID_KEY)\n * ```\n *\n * @see {@link ANONYMOUS_ID_COOKIE} and {@link ANONYMOUS_ID_KEY} in\n * `@contentful/optimization-core` for the\n * authoritative definition and documentation.\n *\n * @public\n */\nexport { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-core/constants'\n"],"names":["OPTIMIZATION_NODE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_NODE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__"],"mappings":"AAYO,MAAMA,gCACoCC;AAS1C,MAAMC,6BAEPC"}
@@ -30,7 +30,7 @@ __webpack_require__.d(__webpack_exports__, {
30
30
  OPTIMIZATION_NODE_SDK_VERSION: ()=>OPTIMIZATION_NODE_SDK_VERSION
31
31
  });
32
32
  const constants_namespaceObject = require("@contentful/optimization-core/constants");
33
- const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha10";
33
+ const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha12";
34
34
  const OPTIMIZATION_NODE_SDK_NAME = "@contentful/optimization-node";
35
35
  exports.ANONYMOUS_ID_COOKIE = __webpack_exports__.ANONYMOUS_ID_COOKIE;
36
36
  exports.ANONYMOUS_ID_KEY = __webpack_exports__.ANONYMOUS_ID_KEY;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../src/constants.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_VERSION__: string | undefined\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_PACKAGE_NAME__: string | undefined\n\n/**\n * The current version of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'0.0.0'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\n\n/**\n * The package name of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_NAME =\n typeof __OPTIMIZATION_PACKAGE_NAME__ === 'string'\n ? __OPTIMIZATION_PACKAGE_NAME__\n : '@contentful/optimization-node'\n\n/**\n * Re-exports of anonymous identifier constants used by the Optimization Core.\n *\n * @remarks\n * This constant is surfaced here to provide a stable import path for Node SDK\n * consumers. It represents the cookie key used by the Optimization Framework\n * to persist an anonymous identifier for tracking personalization and analytics\n * events when no explicit profile is known.\n *\n * @example\n * ```ts\n * import { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-node/constants'\n * const cookieId = request.cookies[ANONYMOUS_ID_COOKIE]\n * const storageId = localStorage.getItem(ANONYMOUS_ID_KEY)\n * ```\n *\n * @see {@link ANONYMOUS_ID_COOKIE} and {@link ANONYMOUS_ID_KEY} in\n * `@contentful/optimization-core` for the\n * authoritative definition and documentation.\n *\n * @public\n */\nexport { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-core/constants'\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","OPTIMIZATION_NODE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_NODE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;ACMO,MAAMI,gCACoCC;AAS1C,MAAMC,6BAEPC"}
1
+ {"version":3,"file":"constants.cjs","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../src/constants.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_VERSION__: string | undefined\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_PACKAGE_NAME__: string | undefined\n\n/**\n * The current version of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'0.0.0'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\n\n/**\n * The package name of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_NAME =\n typeof __OPTIMIZATION_PACKAGE_NAME__ === 'string'\n ? __OPTIMIZATION_PACKAGE_NAME__\n : '@contentful/optimization-node'\n\n/**\n * Re-exports of anonymous identifier constants used by the Optimization Core.\n *\n * @remarks\n * This constant is surfaced here to provide a stable import path for Node SDK\n * consumers. It represents the cookie key used by the Optimization Framework\n * to persist an anonymous identifier for tracking optimization and insights\n * events when no explicit profile is known.\n *\n * @example\n * ```ts\n * import { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-node/constants'\n * const cookieId = request.cookies[ANONYMOUS_ID_COOKIE]\n * const storageId = localStorage.getItem(ANONYMOUS_ID_KEY)\n * ```\n *\n * @see {@link ANONYMOUS_ID_COOKIE} and {@link ANONYMOUS_ID_KEY} in\n * `@contentful/optimization-core` for the\n * authoritative definition and documentation.\n *\n * @public\n */\nexport { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-core/constants'\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","OPTIMIZATION_NODE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_NODE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;ACMO,MAAMI,gCACoCC;AAS1C,MAAMC,6BAEPC"}
package/dist/index.cjs CHANGED
@@ -6,7 +6,7 @@ var __webpack_modules__ = {
6
6
  OPTIMIZATION_NODE_SDK_VERSION: ()=>OPTIMIZATION_NODE_SDK_VERSION
7
7
  });
8
8
  require("@contentful/optimization-core/constants");
9
- const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha10";
9
+ const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha12";
10
10
  const OPTIMIZATION_NODE_SDK_NAME = "@contentful/optimization-node";
11
11
  }
12
12
  };
@@ -66,14 +66,14 @@ var __webpack_exports__ = {};
66
66
  };
67
67
  return (0, external_es_toolkit_namespaceObject.merge)(defaultConfig, restConfig);
68
68
  }
69
- class Optimization extends optimization_core_namespaceObject.CoreStateless {
69
+ class ContentfulOptimization extends optimization_core_namespaceObject.CoreStateless {
70
70
  constructor(config){
71
71
  const mergedConfig = mergeConfig(config);
72
72
  super(mergedConfig);
73
73
  }
74
74
  }
75
- const src_Optimization = Optimization;
76
- const src = src_Optimization;
75
+ const src_ContentfulOptimization = ContentfulOptimization;
76
+ const src = src_ContentfulOptimization;
77
77
  })();
78
78
  exports.OPTIMIZATION_NODE_SDK_NAME = __webpack_exports__.OPTIMIZATION_NODE_SDK_NAME;
79
79
  exports.OPTIMIZATION_NODE_SDK_VERSION = __webpack_exports__.OPTIMIZATION_NODE_SDK_VERSION;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/constants.ts","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../src/Optimization.ts","../src/index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_VERSION__: string | undefined\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_PACKAGE_NAME__: string | undefined\n\n/**\n * The current version of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'0.0.0'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\n\n/**\n * The package name of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_NAME =\n typeof __OPTIMIZATION_PACKAGE_NAME__ === 'string'\n ? __OPTIMIZATION_PACKAGE_NAME__\n : '@contentful/optimization-node'\n\n/**\n * Re-exports of anonymous identifier constants used by the Optimization Core.\n *\n * @remarks\n * This constant is surfaced here to provide a stable import path for Node SDK\n * consumers. It represents the cookie key used by the Optimization Framework\n * to persist an anonymous identifier for tracking personalization and analytics\n * events when no explicit profile is known.\n *\n * @example\n * ```ts\n * import { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-node/constants'\n * const cookieId = request.cookies[ANONYMOUS_ID_COOKIE]\n * const storageId = localStorage.getItem(ANONYMOUS_ID_KEY)\n * ```\n *\n * @see {@link ANONYMOUS_ID_COOKIE} and {@link ANONYMOUS_ID_KEY} in\n * `@contentful/optimization-core` for the\n * authoritative definition and documentation.\n *\n * @public\n */\nexport { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-core/constants'\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type CoreStatelessConfig, CoreStateless } from '@contentful/optimization-core'\nimport type { App } from '@contentful/optimization-core/api-schemas'\nimport { merge } from 'es-toolkit'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\n\n/**\n * Configuration for the Node-specific Optimization SDK.\n *\n * @remarks\n * This configuration extends {@link CoreStatelessConfig} but allows partial\n * overrides of the event-builder configuration. SDKs commonly inject their own\n * library metadata or channel definitions.\n *\n * @see {@link CoreStatelessConfig}\n *\n * @public\n */\nexport interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {\n /**\n * The application definition used to attribute events to a specific consumer app.\n *\n * @remarks\n * When not provided, events will not contain app metadata in their context.\n */\n app?: App\n\n /**\n * Partial overrides for the event builder configuration.\n *\n * @remarks\n * Any provided fields are merged with the default Node SDK metadata.\n * This differs from {@link CoreStatelessConfig} eventBuilder, which expects\n * a full configuration object.\n */\n eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>\n}\n\n/**\n * Merge user-supplied configuration with defaults for the Node SDK.\n *\n * @param config - The input configuration supplied by the caller.\n * @returns A fully composed {@link CoreStatelessConfig} object suitable for\n * constructing the core runtime.\n *\n * @remarks\n * Ensures that the Node SDK always identifies itself via a `server` channel\n * and a `library` metadata block unless explicitly overridden.\n *\n * @internal\n */\nfunction mergeConfig(config: OptimizationNodeConfig): CoreStatelessConfig {\n const { app, ...restConfig } = config\n\n const defaultConfig: Partial<CoreStatelessConfig> = {\n eventBuilder: {\n app,\n channel: 'server',\n library: { name: OPTIMIZATION_NODE_SDK_NAME, version: OPTIMIZATION_NODE_SDK_VERSION },\n },\n }\n return merge(defaultConfig, restConfig)\n}\n\n/**\n * Node-specific Optimization SDK built on {@link CoreStateless}.\n *\n * @remarks\n * This class adapts the stateless Optimization Core for Node runtimes by\n * applying environment-appropriate defaults (e.g., server channel, Node SDK\n * library metadata). No analytics or personalization behavior is modified—\n * only configuration defaults differ.\n *\n * @example\n * ```ts\n * import Optimization from '@contentful/optimization-node'\n *\n * const sdk = new Optimization({\n * clientId: 'abc-123',\n * environment: 'main',\n * logLevel: 'info',\n * })\n *\n * await sdk.track({ event: 'server_event', properties: { id: 1 } })\n * ```\n *\n * @see {@link CoreStateless}\n *\n * @public\n */\nclass Optimization extends CoreStateless {\n /**\n * Create an instance of the Node SDK with merged defaults.\n *\n * @param config - Partial Node-specific configuration. Any eventBuilder\n * fields provided are merged with Node's defaults.\n *\n * @example\n * ```ts\n * import Optimization from '@contentful/optimization-node'\n *\n * const optimization = new Optimization({ clientId: 'my-client-id' })\n * ```\n */\n constructor(config: OptimizationNodeConfig) {\n const mergedConfig: CoreStatelessConfig = mergeConfig(config)\n\n super(mergedConfig)\n }\n}\n\nexport default Optimization\n","/**\n * Contentful Optimization Node SDK.\n *\n * @remarks\n * Adds Node-specific defaults via the {@link Optimization} class.\n * Core and transitive API exports are available from dedicated entrypoints:\n * `@contentful/optimization-node/core-sdk`,\n * `@contentful/optimization-node/api-client`,\n * and `@contentful/optimization-node/api-schemas`.\n *\n * @packageDocumentation\n */\n\nimport Optimization from './Optimization'\n\nexport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\nexport * from './Optimization'\n\nexport default Optimization\n"],"names":["OPTIMIZATION_NODE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_NODE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__","__webpack_require__","definition","key","Object","obj","prop","Symbol","mergeConfig","config","app","restConfig","defaultConfig","merge","Optimization","CoreStateless","mergedConfig"],"mappings":";;;;;;;;QAYO,MAAMA,gCACoCC;QAS1C,MAAMC,6BAEPC;;;;;;;;;;;;;;ICxBNC,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;IC4CA,SAASI,YAAYC,MAA8B;QACjD,MAAM,EAAEC,GAAG,EAAE,GAAGC,YAAY,GAAGF;QAE/B,MAAMG,gBAA8C;YAClD,cAAc;gBACZF;gBACA,SAAS;gBACT,SAAS;oBAAE,MAAMX,UAAAA,0BAA0BA;oBAAE,SAASF,UAAAA,6BAA6BA;gBAAC;YACtF;QACF;QACA,OAAOgB,AAAAA,IAAAA,oCAAAA,KAAAA,AAAAA,EAAMD,eAAeD;IAC9B;IA4BA,MAAMG,qBAAqBC,kCAAAA,aAAaA;QActC,YAAYN,MAA8B,CAAE;YAC1C,MAAMO,eAAoCR,YAAYC;YAEtD,KAAK,CAACO;QACR;IACF;IAEA,yBAAeF;IC5Ff,YAAeA"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/constants.ts","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../src/ContentfulOptimization.ts","../src/index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_VERSION__: string | undefined\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_PACKAGE_NAME__: string | undefined\n\n/**\n * The current version of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'0.0.0'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\n\n/**\n * The package name of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_NAME =\n typeof __OPTIMIZATION_PACKAGE_NAME__ === 'string'\n ? __OPTIMIZATION_PACKAGE_NAME__\n : '@contentful/optimization-node'\n\n/**\n * Re-exports of anonymous identifier constants used by the Optimization Core.\n *\n * @remarks\n * This constant is surfaced here to provide a stable import path for Node SDK\n * consumers. It represents the cookie key used by the Optimization Framework\n * to persist an anonymous identifier for tracking optimization and insights\n * events when no explicit profile is known.\n *\n * @example\n * ```ts\n * import { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-node/constants'\n * const cookieId = request.cookies[ANONYMOUS_ID_COOKIE]\n * const storageId = localStorage.getItem(ANONYMOUS_ID_KEY)\n * ```\n *\n * @see {@link ANONYMOUS_ID_COOKIE} and {@link ANONYMOUS_ID_KEY} in\n * `@contentful/optimization-core` for the\n * authoritative definition and documentation.\n *\n * @public\n */\nexport { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-core/constants'\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { CoreStateless } from '@contentful/optimization-core'\nimport type { App } from '@contentful/optimization-core/api-schemas'\nimport { merge } from 'es-toolkit'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\n\ntype CoreStatelessConfig = ConstructorParameters<typeof CoreStateless>[0]\n\n/**\n * Configuration for the Node-specific ContentfulOptimization SDK.\n *\n * @remarks\n * This configuration extends {@link CoreStatelessConfig} but allows partial\n * overrides of the event-builder configuration. SDKs commonly inject their own\n * library metadata or channel definitions.\n *\n * @see {@link CoreStatelessConfig}\n *\n * @public\n */\nexport interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {\n /**\n * The application definition used to attribute events to a specific consumer app.\n *\n * @remarks\n * When not provided, events will not contain app metadata in their context.\n */\n app?: App\n\n /**\n * Partial overrides for the event builder configuration.\n *\n * @remarks\n * Any provided fields are merged with the default Node SDK metadata.\n * This differs from {@link CoreStatelessConfig} eventBuilder, which expects\n * a full configuration object.\n */\n eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>\n}\n\n/**\n * Merge user-supplied configuration with defaults for the Node SDK.\n *\n * @param config - The input configuration supplied by the caller.\n * @returns A fully composed {@link CoreStatelessConfig} object suitable for\n * constructing the core runtime.\n *\n * @remarks\n * Ensures that the Node SDK always identifies itself via a `server` channel\n * and a `library` metadata block unless explicitly overridden.\n *\n * @internal\n */\nfunction mergeConfig(config: OptimizationNodeConfig): CoreStatelessConfig {\n const { app, ...restConfig } = config\n\n const defaultConfig: Partial<CoreStatelessConfig> = {\n eventBuilder: {\n app,\n channel: 'server',\n library: { name: OPTIMIZATION_NODE_SDK_NAME, version: OPTIMIZATION_NODE_SDK_VERSION },\n },\n }\n return merge(defaultConfig, restConfig)\n}\n\n/**\n * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.\n *\n * @remarks\n * This class adapts the stateless ContentfulOptimization Core for Node runtimes by\n * applying environment-appropriate defaults (e.g., server channel, Node SDK\n * library metadata). No core runtime behavior is modified; only configuration\n * defaults differ.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const sdk = new ContentfulOptimization({\n * clientId: 'abc-123',\n * environment: 'main',\n * logLevel: 'info',\n * })\n *\n * const requestOptions = { locale: 'en-US' }\n *\n * await sdk.track({ event: 'server_event', properties: { id: 1 } }, requestOptions)\n * ```\n *\n * @see {@link CoreStateless}\n *\n * @public\n */\nclass ContentfulOptimization extends CoreStateless {\n /**\n * Create an instance of the Node SDK with merged defaults.\n *\n * @param config - Partial Node-specific configuration. Any eventBuilder\n * fields provided are merged with Node's defaults.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })\n * ```\n */\n constructor(config: OptimizationNodeConfig) {\n const mergedConfig: CoreStatelessConfig = mergeConfig(config)\n\n super(mergedConfig)\n }\n}\n\nexport default ContentfulOptimization\n","/**\n * Contentful ContentfulOptimization Node SDK.\n *\n * @remarks\n * Adds Node-specific defaults via the {@link ContentfulOptimization} class.\n * Core and transitive API exports are available from dedicated entrypoints:\n * `@contentful/optimization-node/core-sdk`,\n * `@contentful/optimization-node/api-client`,\n * and `@contentful/optimization-node/api-schemas`.\n *\n * @packageDocumentation\n */\n\nimport ContentfulOptimization from './ContentfulOptimization'\n\nexport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\nexport * from './ContentfulOptimization'\n\nexport default ContentfulOptimization\n"],"names":["OPTIMIZATION_NODE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_NODE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__","__webpack_require__","definition","key","Object","obj","prop","Symbol","mergeConfig","config","app","restConfig","defaultConfig","merge","ContentfulOptimization","CoreStateless","mergedConfig"],"mappings":";;;;;;;;QAYO,MAAMA,gCACoCC;QAS1C,MAAMC,6BAEPC;;;;;;;;;;;;;;ICxBNC,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;IC8CA,SAASI,YAAYC,MAA8B;QACjD,MAAM,EAAEC,GAAG,EAAE,GAAGC,YAAY,GAAGF;QAE/B,MAAMG,gBAA8C;YAClD,cAAc;gBACZF;gBACA,SAAS;gBACT,SAAS;oBAAE,MAAMX,UAAAA,0BAA0BA;oBAAE,SAASF,UAAAA,6BAA6BA;gBAAC;YACtF;QACF;QACA,OAAOgB,AAAAA,IAAAA,oCAAAA,KAAAA,AAAAA,EAAMD,eAAeD;IAC9B;IA8BA,MAAMG,+BAA+BC,kCAAAA,aAAaA;QAchD,YAAYN,MAA8B,CAAE;YAC1C,MAAMO,eAAoCR,YAAYC;YAEtD,KAAK,CAACO;QACR;IACF;IAEA,mCAAeF;IChGf,YAAeA"}
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Contentful Optimization Node SDK.
2
+ * Contentful ContentfulOptimization Node SDK.
3
3
  *
4
4
  * @remarks
5
- * Adds Node-specific defaults via the {@link Optimization} class.
5
+ * Adds Node-specific defaults via the {@link ContentfulOptimization} class.
6
6
  * Core and transitive API exports are available from dedicated entrypoints:
7
7
  * `@contentful/optimization-node/core-sdk`,
8
8
  * `@contentful/optimization-node/api-client`,
@@ -13,35 +13,36 @@
13
13
 
14
14
  import type { App } from '@contentful/optimization-core/api-schemas';
15
15
  import { CoreStateless } from '@contentful/optimization-core';
16
- import { CoreStatelessConfig } from '@contentful/optimization-core';
17
16
 
18
17
  /**
19
- * Node-specific Optimization SDK built on {@link CoreStateless}.
18
+ * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
20
19
  *
21
20
  * @remarks
22
- * This class adapts the stateless Optimization Core for Node runtimes by
21
+ * This class adapts the stateless ContentfulOptimization Core for Node runtimes by
23
22
  * applying environment-appropriate defaults (e.g., server channel, Node SDK
24
- * library metadata). No analytics or personalization behavior is modified—
25
- * only configuration defaults differ.
23
+ * library metadata). No core runtime behavior is modified; only configuration
24
+ * defaults differ.
26
25
  *
27
26
  * @example
28
27
  * ```ts
29
- * import Optimization from '@contentful/optimization-node'
28
+ * import ContentfulOptimization from '@contentful/optimization-node'
30
29
  *
31
- * const sdk = new Optimization({
30
+ * const sdk = new ContentfulOptimization({
32
31
  * clientId: 'abc-123',
33
32
  * environment: 'main',
34
33
  * logLevel: 'info',
35
34
  * })
36
35
  *
37
- * await sdk.track({ event: 'server_event', properties: { id: 1 } })
36
+ * const requestOptions = { locale: 'en-US' }
37
+ *
38
+ * await sdk.track({ event: 'server_event', properties: { id: 1 } }, requestOptions)
38
39
  * ```
39
40
  *
40
41
  * @see {@link CoreStateless}
41
42
  *
42
43
  * @public
43
44
  */
44
- declare class Optimization extends CoreStateless {
45
+ declare class ContentfulOptimization extends CoreStateless {
45
46
  /**
46
47
  * Create an instance of the Node SDK with merged defaults.
47
48
  *
@@ -50,14 +51,16 @@ declare class Optimization extends CoreStateless {
50
51
  *
51
52
  * @example
52
53
  * ```ts
53
- * import Optimization from '@contentful/optimization-node'
54
+ * import ContentfulOptimization from '@contentful/optimization-node'
54
55
  *
55
- * const optimization = new Optimization({ clientId: 'my-client-id' })
56
+ * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
56
57
  * ```
57
58
  */
58
59
  constructor(config: OptimizationNodeConfig);
59
60
  }
60
- export default Optimization;
61
+ export default ContentfulOptimization;
62
+
63
+ declare type CoreStatelessConfig = ConstructorParameters<typeof CoreStateless>[0];
61
64
 
62
65
  /**
63
66
  * The package name of the Optimization Node SDK, injected at build-time.
@@ -78,7 +81,7 @@ export declare const OPTIMIZATION_NODE_SDK_NAME: string;
78
81
  export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
79
82
 
80
83
  /**
81
- * Configuration for the Node-specific Optimization SDK.
84
+ * Configuration for the Node-specific ContentfulOptimization SDK.
82
85
  *
83
86
  * @remarks
84
87
  * This configuration extends {@link CoreStatelessConfig} but allows partial
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Contentful Optimization Node SDK.
2
+ * Contentful ContentfulOptimization Node SDK.
3
3
  *
4
4
  * @remarks
5
- * Adds Node-specific defaults via the {@link Optimization} class.
5
+ * Adds Node-specific defaults via the {@link ContentfulOptimization} class.
6
6
  * Core and transitive API exports are available from dedicated entrypoints:
7
7
  * `@contentful/optimization-node/core-sdk`,
8
8
  * `@contentful/optimization-node/api-client`,
@@ -13,35 +13,36 @@
13
13
 
14
14
  import type { App } from '@contentful/optimization-core/api-schemas';
15
15
  import { CoreStateless } from '@contentful/optimization-core';
16
- import { CoreStatelessConfig } from '@contentful/optimization-core';
17
16
 
18
17
  /**
19
- * Node-specific Optimization SDK built on {@link CoreStateless}.
18
+ * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
20
19
  *
21
20
  * @remarks
22
- * This class adapts the stateless Optimization Core for Node runtimes by
21
+ * This class adapts the stateless ContentfulOptimization Core for Node runtimes by
23
22
  * applying environment-appropriate defaults (e.g., server channel, Node SDK
24
- * library metadata). No analytics or personalization behavior is modified—
25
- * only configuration defaults differ.
23
+ * library metadata). No core runtime behavior is modified; only configuration
24
+ * defaults differ.
26
25
  *
27
26
  * @example
28
27
  * ```ts
29
- * import Optimization from '@contentful/optimization-node'
28
+ * import ContentfulOptimization from '@contentful/optimization-node'
30
29
  *
31
- * const sdk = new Optimization({
30
+ * const sdk = new ContentfulOptimization({
32
31
  * clientId: 'abc-123',
33
32
  * environment: 'main',
34
33
  * logLevel: 'info',
35
34
  * })
36
35
  *
37
- * await sdk.track({ event: 'server_event', properties: { id: 1 } })
36
+ * const requestOptions = { locale: 'en-US' }
37
+ *
38
+ * await sdk.track({ event: 'server_event', properties: { id: 1 } }, requestOptions)
38
39
  * ```
39
40
  *
40
41
  * @see {@link CoreStateless}
41
42
  *
42
43
  * @public
43
44
  */
44
- declare class Optimization extends CoreStateless {
45
+ declare class ContentfulOptimization extends CoreStateless {
45
46
  /**
46
47
  * Create an instance of the Node SDK with merged defaults.
47
48
  *
@@ -50,14 +51,16 @@ declare class Optimization extends CoreStateless {
50
51
  *
51
52
  * @example
52
53
  * ```ts
53
- * import Optimization from '@contentful/optimization-node'
54
+ * import ContentfulOptimization from '@contentful/optimization-node'
54
55
  *
55
- * const optimization = new Optimization({ clientId: 'my-client-id' })
56
+ * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
56
57
  * ```
57
58
  */
58
59
  constructor(config: OptimizationNodeConfig);
59
60
  }
60
- export default Optimization;
61
+ export default ContentfulOptimization;
62
+
63
+ declare type CoreStatelessConfig = ConstructorParameters<typeof CoreStateless>[0];
61
64
 
62
65
  /**
63
66
  * The package name of the Optimization Node SDK, injected at build-time.
@@ -78,7 +81,7 @@ export declare const OPTIMIZATION_NODE_SDK_NAME: string;
78
81
  export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
79
82
 
80
83
  /**
81
- * Configuration for the Node-specific Optimization SDK.
84
+ * Configuration for the Node-specific ContentfulOptimization SDK.
82
85
  *
83
86
  * @remarks
84
87
  * This configuration extends {@link CoreStatelessConfig} but allows partial
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Contentful Optimization Node SDK.
2
+ * Contentful ContentfulOptimization Node SDK.
3
3
  *
4
4
  * @remarks
5
- * Adds Node-specific defaults via the {@link Optimization} class.
5
+ * Adds Node-specific defaults via the {@link ContentfulOptimization} class.
6
6
  * Core and transitive API exports are available from dedicated entrypoints:
7
7
  * `@contentful/optimization-node/core-sdk`,
8
8
  * `@contentful/optimization-node/api-client`,
@@ -13,35 +13,36 @@
13
13
 
14
14
  import type { App } from '@contentful/optimization-core/api-schemas';
15
15
  import { CoreStateless } from '@contentful/optimization-core';
16
- import { CoreStatelessConfig } from '@contentful/optimization-core';
17
16
 
18
17
  /**
19
- * Node-specific Optimization SDK built on {@link CoreStateless}.
18
+ * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
20
19
  *
21
20
  * @remarks
22
- * This class adapts the stateless Optimization Core for Node runtimes by
21
+ * This class adapts the stateless ContentfulOptimization Core for Node runtimes by
23
22
  * applying environment-appropriate defaults (e.g., server channel, Node SDK
24
- * library metadata). No analytics or personalization behavior is modified—
25
- * only configuration defaults differ.
23
+ * library metadata). No core runtime behavior is modified; only configuration
24
+ * defaults differ.
26
25
  *
27
26
  * @example
28
27
  * ```ts
29
- * import Optimization from '@contentful/optimization-node'
28
+ * import ContentfulOptimization from '@contentful/optimization-node'
30
29
  *
31
- * const sdk = new Optimization({
30
+ * const sdk = new ContentfulOptimization({
32
31
  * clientId: 'abc-123',
33
32
  * environment: 'main',
34
33
  * logLevel: 'info',
35
34
  * })
36
35
  *
37
- * await sdk.track({ event: 'server_event', properties: { id: 1 } })
36
+ * const requestOptions = { locale: 'en-US' }
37
+ *
38
+ * await sdk.track({ event: 'server_event', properties: { id: 1 } }, requestOptions)
38
39
  * ```
39
40
  *
40
41
  * @see {@link CoreStateless}
41
42
  *
42
43
  * @public
43
44
  */
44
- declare class Optimization extends CoreStateless {
45
+ declare class ContentfulOptimization extends CoreStateless {
45
46
  /**
46
47
  * Create an instance of the Node SDK with merged defaults.
47
48
  *
@@ -50,14 +51,16 @@ declare class Optimization extends CoreStateless {
50
51
  *
51
52
  * @example
52
53
  * ```ts
53
- * import Optimization from '@contentful/optimization-node'
54
+ * import ContentfulOptimization from '@contentful/optimization-node'
54
55
  *
55
- * const optimization = new Optimization({ clientId: 'my-client-id' })
56
+ * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
56
57
  * ```
57
58
  */
58
59
  constructor(config: OptimizationNodeConfig);
59
60
  }
60
- export default Optimization;
61
+ export default ContentfulOptimization;
62
+
63
+ declare type CoreStatelessConfig = ConstructorParameters<typeof CoreStateless>[0];
61
64
 
62
65
  /**
63
66
  * The package name of the Optimization Node SDK, injected at build-time.
@@ -78,7 +81,7 @@ export declare const OPTIMIZATION_NODE_SDK_NAME: string;
78
81
  export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
79
82
 
80
83
  /**
81
- * Configuration for the Node-specific Optimization SDK.
84
+ * Configuration for the Node-specific ContentfulOptimization SDK.
82
85
  *
83
86
  * @remarks
84
87
  * This configuration extends {@link CoreStatelessConfig} but allows partial
package/dist/index.mjs CHANGED
@@ -15,14 +15,14 @@ function mergeConfig(config) {
15
15
  };
16
16
  return merge(defaultConfig, restConfig);
17
17
  }
18
- class Optimization extends __rspack_external__contentful_optimization_core_7d4758c6.CoreStateless {
18
+ class ContentfulOptimization extends __rspack_external__contentful_optimization_core_7d4758c6.CoreStateless {
19
19
  constructor(config){
20
20
  const mergedConfig = mergeConfig(config);
21
21
  super(mergedConfig);
22
22
  }
23
23
  }
24
- const src_Optimization = Optimization;
25
- const src = src_Optimization;
24
+ const src_ContentfulOptimization = ContentfulOptimization;
25
+ const src = src_ContentfulOptimization;
26
26
  export { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from "./260.mjs";
27
27
  export default src;
28
28
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/Optimization.ts","../src/index.ts"],"sourcesContent":["import { type CoreStatelessConfig, CoreStateless } from '@contentful/optimization-core'\nimport type { App } from '@contentful/optimization-core/api-schemas'\nimport { merge } from 'es-toolkit'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\n\n/**\n * Configuration for the Node-specific Optimization SDK.\n *\n * @remarks\n * This configuration extends {@link CoreStatelessConfig} but allows partial\n * overrides of the event-builder configuration. SDKs commonly inject their own\n * library metadata or channel definitions.\n *\n * @see {@link CoreStatelessConfig}\n *\n * @public\n */\nexport interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {\n /**\n * The application definition used to attribute events to a specific consumer app.\n *\n * @remarks\n * When not provided, events will not contain app metadata in their context.\n */\n app?: App\n\n /**\n * Partial overrides for the event builder configuration.\n *\n * @remarks\n * Any provided fields are merged with the default Node SDK metadata.\n * This differs from {@link CoreStatelessConfig} eventBuilder, which expects\n * a full configuration object.\n */\n eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>\n}\n\n/**\n * Merge user-supplied configuration with defaults for the Node SDK.\n *\n * @param config - The input configuration supplied by the caller.\n * @returns A fully composed {@link CoreStatelessConfig} object suitable for\n * constructing the core runtime.\n *\n * @remarks\n * Ensures that the Node SDK always identifies itself via a `server` channel\n * and a `library` metadata block unless explicitly overridden.\n *\n * @internal\n */\nfunction mergeConfig(config: OptimizationNodeConfig): CoreStatelessConfig {\n const { app, ...restConfig } = config\n\n const defaultConfig: Partial<CoreStatelessConfig> = {\n eventBuilder: {\n app,\n channel: 'server',\n library: { name: OPTIMIZATION_NODE_SDK_NAME, version: OPTIMIZATION_NODE_SDK_VERSION },\n },\n }\n return merge(defaultConfig, restConfig)\n}\n\n/**\n * Node-specific Optimization SDK built on {@link CoreStateless}.\n *\n * @remarks\n * This class adapts the stateless Optimization Core for Node runtimes by\n * applying environment-appropriate defaults (e.g., server channel, Node SDK\n * library metadata). No analytics or personalization behavior is modified—\n * only configuration defaults differ.\n *\n * @example\n * ```ts\n * import Optimization from '@contentful/optimization-node'\n *\n * const sdk = new Optimization({\n * clientId: 'abc-123',\n * environment: 'main',\n * logLevel: 'info',\n * })\n *\n * await sdk.track({ event: 'server_event', properties: { id: 1 } })\n * ```\n *\n * @see {@link CoreStateless}\n *\n * @public\n */\nclass Optimization extends CoreStateless {\n /**\n * Create an instance of the Node SDK with merged defaults.\n *\n * @param config - Partial Node-specific configuration. Any eventBuilder\n * fields provided are merged with Node's defaults.\n *\n * @example\n * ```ts\n * import Optimization from '@contentful/optimization-node'\n *\n * const optimization = new Optimization({ clientId: 'my-client-id' })\n * ```\n */\n constructor(config: OptimizationNodeConfig) {\n const mergedConfig: CoreStatelessConfig = mergeConfig(config)\n\n super(mergedConfig)\n }\n}\n\nexport default Optimization\n","/**\n * Contentful Optimization Node SDK.\n *\n * @remarks\n * Adds Node-specific defaults via the {@link Optimization} class.\n * Core and transitive API exports are available from dedicated entrypoints:\n * `@contentful/optimization-node/core-sdk`,\n * `@contentful/optimization-node/api-client`,\n * and `@contentful/optimization-node/api-schemas`.\n *\n * @packageDocumentation\n */\n\nimport Optimization from './Optimization'\n\nexport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\nexport * from './Optimization'\n\nexport default Optimization\n"],"names":["mergeConfig","config","app","restConfig","defaultConfig","OPTIMIZATION_NODE_SDK_NAME","OPTIMIZATION_NODE_SDK_VERSION","merge","Optimization","CoreStateless","mergedConfig"],"mappings":";;;AAkDA,SAASA,YAAYC,MAA8B;IACjD,MAAM,EAAEC,GAAG,EAAE,GAAGC,YAAY,GAAGF;IAE/B,MAAMG,gBAA8C;QAClD,cAAc;YACZF;YACA,SAAS;YACT,SAAS;gBAAE,MAAMG;gBAA4B,SAASC;YAA8B;QACtF;IACF;IACA,OAAOC,MAAMH,eAAeD;AAC9B;AA4BA,MAAMK,qBAAqBC,yDAAAA,aAAaA;IActC,YAAYR,MAA8B,CAAE;QAC1C,MAAMS,eAAoCV,YAAYC;QAEtD,KAAK,CAACS;IACR;AACF;AAEA,yBAAeF;AC5Ff,YAAeA"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/ContentfulOptimization.ts","../src/index.ts"],"sourcesContent":["import { CoreStateless } from '@contentful/optimization-core'\nimport type { App } from '@contentful/optimization-core/api-schemas'\nimport { merge } from 'es-toolkit'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\n\ntype CoreStatelessConfig = ConstructorParameters<typeof CoreStateless>[0]\n\n/**\n * Configuration for the Node-specific ContentfulOptimization SDK.\n *\n * @remarks\n * This configuration extends {@link CoreStatelessConfig} but allows partial\n * overrides of the event-builder configuration. SDKs commonly inject their own\n * library metadata or channel definitions.\n *\n * @see {@link CoreStatelessConfig}\n *\n * @public\n */\nexport interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {\n /**\n * The application definition used to attribute events to a specific consumer app.\n *\n * @remarks\n * When not provided, events will not contain app metadata in their context.\n */\n app?: App\n\n /**\n * Partial overrides for the event builder configuration.\n *\n * @remarks\n * Any provided fields are merged with the default Node SDK metadata.\n * This differs from {@link CoreStatelessConfig} eventBuilder, which expects\n * a full configuration object.\n */\n eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>\n}\n\n/**\n * Merge user-supplied configuration with defaults for the Node SDK.\n *\n * @param config - The input configuration supplied by the caller.\n * @returns A fully composed {@link CoreStatelessConfig} object suitable for\n * constructing the core runtime.\n *\n * @remarks\n * Ensures that the Node SDK always identifies itself via a `server` channel\n * and a `library` metadata block unless explicitly overridden.\n *\n * @internal\n */\nfunction mergeConfig(config: OptimizationNodeConfig): CoreStatelessConfig {\n const { app, ...restConfig } = config\n\n const defaultConfig: Partial<CoreStatelessConfig> = {\n eventBuilder: {\n app,\n channel: 'server',\n library: { name: OPTIMIZATION_NODE_SDK_NAME, version: OPTIMIZATION_NODE_SDK_VERSION },\n },\n }\n return merge(defaultConfig, restConfig)\n}\n\n/**\n * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.\n *\n * @remarks\n * This class adapts the stateless ContentfulOptimization Core for Node runtimes by\n * applying environment-appropriate defaults (e.g., server channel, Node SDK\n * library metadata). No core runtime behavior is modified; only configuration\n * defaults differ.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const sdk = new ContentfulOptimization({\n * clientId: 'abc-123',\n * environment: 'main',\n * logLevel: 'info',\n * })\n *\n * const requestOptions = { locale: 'en-US' }\n *\n * await sdk.track({ event: 'server_event', properties: { id: 1 } }, requestOptions)\n * ```\n *\n * @see {@link CoreStateless}\n *\n * @public\n */\nclass ContentfulOptimization extends CoreStateless {\n /**\n * Create an instance of the Node SDK with merged defaults.\n *\n * @param config - Partial Node-specific configuration. Any eventBuilder\n * fields provided are merged with Node's defaults.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })\n * ```\n */\n constructor(config: OptimizationNodeConfig) {\n const mergedConfig: CoreStatelessConfig = mergeConfig(config)\n\n super(mergedConfig)\n }\n}\n\nexport default ContentfulOptimization\n","/**\n * Contentful ContentfulOptimization Node SDK.\n *\n * @remarks\n * Adds Node-specific defaults via the {@link ContentfulOptimization} class.\n * Core and transitive API exports are available from dedicated entrypoints:\n * `@contentful/optimization-node/core-sdk`,\n * `@contentful/optimization-node/api-client`,\n * and `@contentful/optimization-node/api-schemas`.\n *\n * @packageDocumentation\n */\n\nimport ContentfulOptimization from './ContentfulOptimization'\n\nexport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\nexport * from './ContentfulOptimization'\n\nexport default ContentfulOptimization\n"],"names":["mergeConfig","config","app","restConfig","defaultConfig","OPTIMIZATION_NODE_SDK_NAME","OPTIMIZATION_NODE_SDK_VERSION","merge","ContentfulOptimization","CoreStateless","mergedConfig"],"mappings":";;;AAoDA,SAASA,YAAYC,MAA8B;IACjD,MAAM,EAAEC,GAAG,EAAE,GAAGC,YAAY,GAAGF;IAE/B,MAAMG,gBAA8C;QAClD,cAAc;YACZF;YACA,SAAS;YACT,SAAS;gBAAE,MAAMG;gBAA4B,SAASC;YAA8B;QACtF;IACF;IACA,OAAOC,MAAMH,eAAeD;AAC9B;AA8BA,MAAMK,+BAA+BC,yDAAAA,aAAaA;IAchD,YAAYR,MAA8B,CAAE;QAC1C,MAAMS,eAAoCV,YAAYC;QAEtD,KAAK,CAACS;IACR;AACF;AAEA,mCAAeF;AChGf,YAAeA"}
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@contentful/optimization-node",
3
- "version": "0.1.0-alpha10",
3
+ "version": "0.1.0-alpha12",
4
4
  "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/contentful/optimization.git",
8
+ "directory": "packages/node/node-sdk"
9
+ },
5
10
  "type": "module",
6
11
  "main": "./dist/index.cjs",
7
12
  "module": "./dist/index.mjs",
@@ -72,8 +77,16 @@
72
77
  "files": [
73
78
  "dist/**/*"
74
79
  ],
80
+ "buildTools": {
81
+ "bundleSize": {
82
+ "gzipBudgets": {
83
+ "index.cjs": 1200,
84
+ "index.mjs": 500
85
+ }
86
+ }
87
+ },
75
88
  "dependencies": {
76
89
  "es-toolkit": "^1.44.0",
77
- "@contentful/optimization-core": "0.1.0-alpha10"
90
+ "@contentful/optimization-core": "0.1.0-alpha12"
78
91
  }
79
92
  }