@contentful/optimization-api-client 0.1.0-alpha

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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +282 -0
  3. package/dist/ApiClient.d.ts +74 -0
  4. package/dist/ApiClient.d.ts.map +1 -0
  5. package/dist/ApiClient.js +61 -0
  6. package/dist/ApiClient.js.map +1 -0
  7. package/dist/ApiClientBase.d.ts +113 -0
  8. package/dist/ApiClientBase.d.ts.map +1 -0
  9. package/dist/ApiClientBase.js +94 -0
  10. package/dist/ApiClientBase.js.map +1 -0
  11. package/dist/builders/EventBuilder.d.ts +589 -0
  12. package/dist/builders/EventBuilder.d.ts.map +1 -0
  13. package/dist/builders/EventBuilder.js +349 -0
  14. package/dist/builders/EventBuilder.js.map +1 -0
  15. package/dist/builders/index.d.ts +3 -0
  16. package/dist/builders/index.d.ts.map +1 -0
  17. package/dist/builders/index.js +3 -0
  18. package/dist/builders/index.js.map +1 -0
  19. package/dist/experience/ExperienceApiClient.d.ts +267 -0
  20. package/dist/experience/ExperienceApiClient.d.ts.map +1 -0
  21. package/dist/experience/ExperienceApiClient.js +324 -0
  22. package/dist/experience/ExperienceApiClient.js.map +1 -0
  23. package/dist/experience/index.d.ts +4 -0
  24. package/dist/experience/index.d.ts.map +1 -0
  25. package/dist/experience/index.js +4 -0
  26. package/dist/experience/index.js.map +1 -0
  27. package/dist/fetch/Fetch.d.ts +96 -0
  28. package/dist/fetch/Fetch.d.ts.map +1 -0
  29. package/dist/fetch/Fetch.js +27 -0
  30. package/dist/fetch/Fetch.js.map +1 -0
  31. package/dist/fetch/createProtectedFetchMethod.d.ts +40 -0
  32. package/dist/fetch/createProtectedFetchMethod.d.ts.map +1 -0
  33. package/dist/fetch/createProtectedFetchMethod.js +53 -0
  34. package/dist/fetch/createProtectedFetchMethod.js.map +1 -0
  35. package/dist/fetch/createRetryFetchMethod.d.ts +60 -0
  36. package/dist/fetch/createRetryFetchMethod.d.ts.map +1 -0
  37. package/dist/fetch/createRetryFetchMethod.js +138 -0
  38. package/dist/fetch/createRetryFetchMethod.js.map +1 -0
  39. package/dist/fetch/createTimeoutFetchMethod.d.ts +51 -0
  40. package/dist/fetch/createTimeoutFetchMethod.d.ts.map +1 -0
  41. package/dist/fetch/createTimeoutFetchMethod.js +51 -0
  42. package/dist/fetch/createTimeoutFetchMethod.js.map +1 -0
  43. package/dist/fetch/index.d.ts +7 -0
  44. package/dist/fetch/index.d.ts.map +1 -0
  45. package/dist/fetch/index.js +7 -0
  46. package/dist/fetch/index.js.map +1 -0
  47. package/dist/index.cjs +708 -0
  48. package/dist/index.cjs.map +1 -0
  49. package/dist/index.d.ts +8 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +8 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/index.mjs +583 -0
  54. package/dist/index.mjs.map +1 -0
  55. package/dist/insights/InsightsApiClient.d.ts +130 -0
  56. package/dist/insights/InsightsApiClient.d.ts.map +1 -0
  57. package/dist/insights/InsightsApiClient.js +142 -0
  58. package/dist/insights/InsightsApiClient.js.map +1 -0
  59. package/dist/insights/index.d.ts +4 -0
  60. package/dist/insights/index.d.ts.map +1 -0
  61. package/dist/insights/index.js +4 -0
  62. package/dist/insights/index.js.map +1 -0
  63. package/package.json +27 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/ApiClient.ts","../src/fetch/createRetryFetchMethod.ts","../src/fetch/createTimeoutFetchMethod.ts","../src/fetch/createProtectedFetchMethod.ts","../src/fetch/Fetch.ts","../src/fetch/index.ts","../src/ApiClientBase.ts","../src/builders/EventBuilder.ts","../src/experience/ExperienceApiClient.ts","../src/experience/index.ts","../src/insights/InsightsApiClient.ts","../src/insights/index.ts","../../../lib/logger/src/Logger.ts","webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object"],"sourcesContent":["import type { ApiConfig, GlobalApiConfigProperties } from './ApiClientBase'\nimport ExperienceApiClient, { type ExperienceApiClientConfig } from './experience'\nimport InsightsApiClient, { type InsightsApiClientConfig } from './insights'\n\n/**\n * Configuration for the high-level {@link ApiClient}.\n *\n * @public\n */\nexport interface ApiClientConfig extends Pick<ApiConfig, GlobalApiConfigProperties> {\n /**\n * Configuration for the personalization (Experience) API client.\n *\n * @remarks\n * Any properties shared with {@link ApiConfig} are taken from the top-level\n * config and overridden by this object when specified.\n */\n personalization?: Omit<ExperienceApiClientConfig, GlobalApiConfigProperties>\n\n /**\n * Configuration for the analytics (Insights) API client.\n *\n * @remarks\n * Any properties shared with {@link ApiConfig} are taken from the top-level\n * config and overridden by this object when specified.\n */\n analytics?: Omit<InsightsApiClientConfig, GlobalApiConfigProperties>\n}\n\n/**\n * Aggregated API client providing access to Experience and Insights APIs.\n *\n * @public\n *\n * @remarks\n * This client encapsulates shared configuration and exposes dedicated\n * sub-clients for personalization and analytics use cases.\n *\n * @example\n * ```ts\n * const client = new ApiClient({\n * clientId: 'org-id',\n * environment: 'main',\n * preview: false,\n * personalization: {\n * // experience-specific overrides\n * },\n * analytics: {\n * // insights-specific overrides\n * },\n * })\n *\n * const profile = await client.experience.getProfile('profile-id')\n * const batch = await client.insights.upsertManyProfiles({ events: batchEvents })\n * ```\n */\nexport default class ApiClient {\n /**\n * Shared configuration applied to both Experience and Insights clients.\n */\n readonly config: ApiConfig\n\n /**\n * Client for personalization and experience-related operations.\n */\n readonly experience: ExperienceApiClient\n\n /**\n * Client for analytics and insights-related operations.\n */\n readonly insights: InsightsApiClient\n\n /**\n * Creates a new aggregated {@link ApiClient} instance.\n *\n * @param config - Global API client configuration with optional per-client overrides.\n */\n constructor(config: ApiClientConfig) {\n const { personalization, analytics, ...apiConfig } = config\n\n this.config = apiConfig\n\n this.experience = new ExperienceApiClient({\n ...apiConfig,\n ...personalization,\n })\n\n this.insights = new InsightsApiClient({\n ...apiConfig,\n ...analytics,\n })\n }\n}\n","import { createScopedLogger } from 'logger'\nimport retry from 'p-retry'\nimport type { BaseFetchMethodOptions, FetchMethod, FetchMethodCallbackOptions } from './Fetch'\n\nconst logger = createScopedLogger('ApiClient:Retry')\n\n/**\n * Default interval (in milliseconds) between retry attempts.\n *\n * @internal\n */\nconst DEFAULT_INTERVAL_TIMEOUT = 0\n\n/**\n * Default number of retry attempts.\n *\n * @internal\n */\nconst DEFAULT_RETRY_COUNT = 1\n\n/**\n * HTTP status code that triggers a retry.\n *\n * @internal\n *\n * @remarks\n * This value is currently fixed to `503 Service Unavailable`.\n */\nconst RETRY_RESPONSE_STATUS = 503\n\n/**\n * Default HTTP status code used for {@link HttpError}.\n *\n * @internal\n */\nconst HTTP_ERROR_RESPONSE_STATUS = 500\n\n/**\n * Error type representing HTTP failures with an associated status code.\n *\n * @internal\n */\nclass HttpError extends Error {\n /**\n * The HTTP status code associated with the error.\n */\n public status: number\n\n /**\n * Creates a new {@link HttpError}.\n *\n * @param message - Description of the error.\n * @param status - HTTP status code associated with the error.\n */\n constructor(message: string, status: number = HTTP_ERROR_RESPONSE_STATUS) {\n super(message)\n Object.setPrototypeOf(this, HttpError.prototype)\n this.status = status\n }\n}\n\n/**\n * Configuration options for {@link createRetryFetchMethod}.\n */\nexport interface RetryFetchMethodOptions extends BaseFetchMethodOptions {\n /**\n * Delay (in milliseconds) between retry attempts.\n *\n * @remarks\n * Defaults to {@link DEFAULT_INTERVAL_TIMEOUT}.\n */\n intervalTimeout?: number\n\n /**\n * Callback invoked whenever a retry attempt fails.\n *\n * @param options - Information about the failed attempt.\n *\n * @remarks\n * This callback is invoked with additional metadata such as the attempt\n * number and the number of retries left.\n */\n onFailedAttempt?: (options: FetchMethodCallbackOptions) => void\n\n /**\n * Maximum number of retry attempts.\n *\n * @remarks\n * Defaults to {@link DEFAULT_RETRY_COUNT}.\n */\n retries?: number\n}\n\n/**\n * Internal configuration passed to the retry callback.\n *\n * @internal\n */\ninterface RetryFetchCallbackOptions extends RetryFetchMethodOptions {\n /**\n * Abort controller used to cancel the underlying fetch requests.\n */\n controller: AbortController\n\n /**\n * Initialization options passed to the `fetch` implementation.\n */\n init: RequestInit\n\n /**\n * Request URL.\n */\n url: string | URL\n}\n\n/**\n * Creates a callback function used by `p-retry` to perform a fetch with retry logic.\n *\n * @param options - Internal options controlling the retry behavior.\n * @returns A function that, when invoked, performs the fetch and applies retry rules.\n *\n * @internal\n */\nfunction createRetryFetchCallback({\n apiName = 'Optimization',\n controller,\n fetchMethod = fetch,\n init,\n url,\n}: RetryFetchCallbackOptions) {\n return async () => {\n try {\n const response = await fetchMethod(url, init)\n\n if (response.status === RETRY_RESPONSE_STATUS) {\n throw new HttpError(\n `${apiName} API request to \"${url.toString()}\" failed with status: \"[${response.status}] ${response.statusText}\".`,\n RETRY_RESPONSE_STATUS,\n )\n }\n\n if (!response.ok) {\n const httpError = new Error(\n `Request to \"${url.toString()}\" failed with status: [${response.status}] ${response.statusText} - traceparent: ${response.headers.get('traceparent')}`,\n )\n logger.error('Request failed with non-OK status:', httpError)\n\n controller.abort()\n\n return\n }\n\n logger.debug(`Response from \"${url.toString()}\":`, response)\n\n return response\n } catch (error) {\n if (error instanceof HttpError && error.status === RETRY_RESPONSE_STATUS) {\n throw error\n }\n\n logger.error(`Request to \"${url.toString()}\" failed:`, error)\n\n controller.abort()\n }\n }\n}\n\n/**\n * Creates a {@link FetchMethod} that retries failed requests according to the\n * provided configuration.\n *\n * @param options - Configuration options that control retry behavior.\n * @returns A {@link FetchMethod} that automatically retries qualifying failures.\n *\n * @remarks\n * This wrapper integrates with `p-retry` and uses an {@link AbortController}\n * to cancel pending requests when a non-retriable error occurs.\n *\n * @throws {@link Error}\n * Thrown when the request cannot be retried and no successful response is obtained.\n *\n * @example\n * ```ts\n * const fetchWithRetry = createRetryFetchMethod({\n * apiName: 'Optimization',\n * retries: 3,\n * intervalTimeout: 200,\n * onFailedAttempt: ({ attemptNumber, retriesLeft }) => {\n * console.warn(`Attempt ${attemptNumber} failed. Retries left: ${retriesLeft}`)\n * },\n * })\n *\n * const response = await fetchWithRetry('https://example.com', { method: 'GET' })\n * ```\n */\nexport function createRetryFetchMethod({\n apiName = 'Optimization',\n fetchMethod = fetch,\n intervalTimeout = DEFAULT_INTERVAL_TIMEOUT,\n onFailedAttempt,\n retries = DEFAULT_RETRY_COUNT,\n}: RetryFetchMethodOptions = {}): FetchMethod {\n return async (url: string | URL, init: RequestInit) => {\n const controller = new AbortController()\n\n let retryResponse: Response | undefined = undefined\n\n try {\n retryResponse = await retry<Response | undefined>(\n createRetryFetchCallback({ apiName, controller, fetchMethod, init, url }),\n {\n minTimeout: intervalTimeout,\n onFailedAttempt: (options: FetchMethodCallbackOptions) =>\n onFailedAttempt?.({ ...options, apiName }),\n retries,\n signal: controller.signal,\n },\n )\n } catch (error) {\n // Abort errors caused by timeouts should not bubble up and be reported by third-party tools (e.g. Sentry)\n if (!(error instanceof Error) || error.name !== 'AbortError') {\n throw error\n }\n }\n\n if (!retryResponse) {\n throw new Error(`${apiName} API request to \"${url.toString()}\" may not be retried.`)\n }\n\n return retryResponse\n }\n}\n","import { createScopedLogger } from 'logger'\nimport type { BaseFetchMethodOptions, FetchMethod, FetchMethodCallbackOptions } from './Fetch'\n\nconst logger = createScopedLogger('ApiClient:Timeout')\n\n/**\n * Default timeout (in milliseconds) for outgoing requests.\n *\n * @internal\n */\nconst DEFAULT_REQUEST_TIMEOUT = 3000\n\n/**\n * Configuration options for {@link createTimeoutFetchMethod}.\n */\nexport interface TimeoutFetchMethodOptions extends BaseFetchMethodOptions {\n /**\n * Callback invoked when a request exceeds the configured timeout.\n *\n * @param options - Information about the timed-out request.\n *\n * @remarks\n * If this callback is not provided, a default error is logged.\n *\n * @see {@link FetchMethodCallbackOptions}\n */\n onRequestTimeout?: (options: FetchMethodCallbackOptions) => void\n\n /**\n * Maximum time (in milliseconds) to wait for a response before aborting the request.\n *\n * @remarks\n * Defaults to {@link DEFAULT_REQUEST_TIMEOUT}.\n */\n requestTimeout?: number\n}\n\n/**\n * Creates a {@link FetchMethod} that aborts requests after a configurable timeout.\n *\n * @param options - Configuration options controlling timeout behavior.\n * @returns A {@link FetchMethod} that enforces a timeout for each request.\n *\n * @remarks\n * When a timeout occurs, the request is aborted using an {@link AbortController}.\n * If `onRequestTimeout` is not provided, an error is logged by the {@link logger}.\n *\n * @example\n * ```ts\n * const fetchWithTimeout = createTimeoutFetchMethod({\n * apiName: 'Optimization',\n * requestTimeout: 5000,\n * onRequestTimeout: ({ apiName }) => {\n * console.warn(`${apiName} request timed out`)\n * },\n * })\n *\n * const response = await fetchWithTimeout('https://example.com', { method: 'GET' })\n * ```\n *\n * @see {@link TimeoutFetchMethodOptions}\n */\nexport function createTimeoutFetchMethod({\n apiName = 'Optimization',\n fetchMethod = fetch,\n onRequestTimeout,\n requestTimeout = DEFAULT_REQUEST_TIMEOUT,\n}: TimeoutFetchMethodOptions = {}): FetchMethod {\n return async (url: string | URL, init: RequestInit) => {\n const controller = new AbortController()\n\n const id = setTimeout(() => {\n if (typeof onRequestTimeout === 'function') {\n onRequestTimeout({ apiName })\n } else {\n logger.error(`Request to \"${url.toString()}\" timed out`, new Error('Request timeout'))\n }\n\n controller.abort()\n }, requestTimeout)\n\n const response = await fetchMethod(url, { ...init, signal: controller.signal })\n\n clearTimeout(id)\n\n return response\n }\n}\n","import { createScopedLogger } from 'logger'\nimport { createRetryFetchMethod, type RetryFetchMethodOptions } from './createRetryFetchMethod'\nimport {\n createTimeoutFetchMethod,\n type TimeoutFetchMethodOptions,\n} from './createTimeoutFetchMethod'\nimport type { FetchMethod } from './Fetch'\n\nconst logger = createScopedLogger('ApiClient:Fetch')\n\n/**\n * Options for {@link createProtectedFetchMethod}, combining timeout and retry behavior.\n */\nexport interface ProtectedFetchMethodOptions\n extends RetryFetchMethodOptions,\n TimeoutFetchMethodOptions {}\n\n/**\n * Creates a {@link FetchMethod} that combines timeout and retry protection.\n *\n * @param options - Configuration options for both timeout and retry behavior.\n * @returns A {@link FetchMethod} that applies timeout and retry logic to requests.\n *\n * @remarks\n * The resulting method first wraps the base fetch with a timeout (via\n * {@link createTimeoutFetchMethod}), then applies retry behavior (via\n * {@link createRetryFetchMethod}).\n *\n * If an error is thrown during configuration or request execution, it is logged\n * using {@link logger}.\n *\n * @throws {@link Error}\n * Rethrows the original error after logging, including abort errors.\n *\n * @example\n * ```ts\n * const fetchProtected = createProtectedFetchMethod({\n * apiName: 'Optimization',\n * requestTimeout: 4000,\n * retries: 2,\n * })\n *\n * const response = await fetchProtected('https://example.com/experiences', {\n * method: 'GET',\n * })\n * ```\n */\nexport function createProtectedFetchMethod(options: ProtectedFetchMethodOptions): FetchMethod {\n try {\n const timeoutFetchMethod = createTimeoutFetchMethod(options)\n const retryFetchMethod = createRetryFetchMethod({ ...options, fetchMethod: timeoutFetchMethod })\n\n return retryFetchMethod\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n logger.warn('Request aborted due to network issues. This request may not be retried.')\n } else {\n logger.error('Request failed:', error)\n }\n }\n throw error\n }\n}\n","import { createProtectedFetchMethod } from './createProtectedFetchMethod'\n\n/**\n * Signature of a fetch method used by the API clients.\n *\n * @param url - The request URL.\n * @param init - Initialization options passed to `fetch`.\n * @returns A promise that resolves with the {@link Response}.\n *\n * @public\n *\n * @remarks\n * This abstraction allows the underlying implementation to be replaced,\n * for example in tests or different runtime environments.\n *\n * @example\n * ```ts\n * const method: FetchMethod = async (url, init) => {\n * return fetch(url, init)\n * }\n * ```\n */\nexport type FetchMethod = (url: string | URL, init: RequestInit) => Promise<Response>\n\n/**\n * Base options shared across fetch method factories.\n *\n * @public\n */\nexport interface BaseFetchMethodOptions {\n /**\n * Human-readable name of the API being called.\n *\n * @remarks\n * Used primarily for logging and error messages.\n */\n apiName?: string\n\n /**\n * Custom fetch implementation to use instead of the global `fetch`.\n *\n * @remarks\n * This is useful for providing polyfills, mocks, or instrumented fetch\n * implementations.\n */\n fetchMethod?: FetchMethod\n}\n\n/**\n * Options passed to callback functions invoked by fetch wrappers.\n *\n * @public\n *\n * @remarks\n * Not all fields are guaranteed to be present in all callback scenarios.\n */\nexport interface FetchMethodCallbackOptions {\n /**\n * Name of the API associated with the request.\n */\n apiName?: string\n\n /**\n * Error that caused the callback to be invoked, if available.\n */\n error?: Error\n\n /**\n * The current attempt number (for retry callbacks).\n */\n attemptNumber?: number\n\n /**\n * Number of retry attempts remaining (for retry callbacks).\n */\n retriesLeft?: number\n}\n\n/**\n * Namespace-like object providing factory methods for protected fetch functions.\n *\n * @public\n */\nconst Fetch = {\n /**\n * Creates a fully protected fetch method with timeout and retry behavior.\n *\n * @example\n * ```ts\n * const fetchMethod = Fetch.create({\n * apiName: 'Optimization',\n * requestTimeout: 3000,\n * retries: 2,\n * })\n *\n * const response = await fetchMethod('https://example.com', { method: 'GET' })\n * ```\n *\n * @see createProtectedFetchMethod\n */\n create: createProtectedFetchMethod,\n}\n\nexport default Fetch\n","import Fetch from './Fetch'\n\nexport * from './createProtectedFetchMethod'\nexport * from './createRetryFetchMethod'\nexport * from './createTimeoutFetchMethod'\nexport * from './Fetch'\n\nexport default Fetch\n","import { createScopedLogger } from 'logger'\nimport Fetch, { type FetchMethod, type ProtectedFetchMethodOptions } from './fetch'\n\nconst logger = createScopedLogger('ApiClient')\n\n/**\n * Default Contentful environment used when none is explicitly provided.\n *\n * @internal\n */\nconst DEFAULT_ENVIRONMENT = 'main'\n\n/**\n * Configuration options for API clients extending {@link ApiClientBase}.\n *\n * @public\n */\nexport interface ApiConfig {\n /**\n * Base URL for the API.\n *\n * @remarks\n * When omitted, the concrete client is expected to construct full URLs\n * internally.\n */\n baseUrl?: string\n\n /**\n * Contentful environment identifier.\n *\n * @remarks\n * Defaults to `main` when not provided.\n */\n environment?: string\n\n /**\n * Options used to configure the underlying protected fetch method.\n *\n * @remarks\n * `apiName` is derived from the client name and must not be provided here.\n */\n fetchOptions?: Omit<ProtectedFetchMethodOptions, 'apiName'>\n\n /**\n * Client identifier used for authentication or tracking.\n */\n clientId: string\n}\n\n/**\n * Properties that may be shared between global and per-client API configuration.\n *\n * @public\n */\nexport type GlobalApiConfigProperties = 'environment' | 'fetchOptions' | 'clientId'\n\n/**\n * Base class for API clients that provides shared configuration and error logging.\n *\n * @internal\n *\n * @remarks\n * This abstract class is intended for internal use within the package and\n * should not be treated as part of the public API surface.\n *\n * Concrete API clients should extend this class to inherit consistent logging\n * behavior and fetch configuration.\n *\n * @example\n * ```ts\n * interface MyClientConfig extends ApiConfig {\n * // additional config\n * }\n *\n * class MyClient extends ApiClientBase {\n * constructor(config: MyClientConfig) {\n * super('MyClient', config)\n * }\n *\n * async getSomething() {\n * const response = await this.fetch('https://example.com', { method: 'GET' })\n * return response.json()\n * }\n * }\n * ```\n */\nabstract class ApiClientBase {\n /**\n * Name of the API client, used in log messages and as the `apiName` for fetch.\n */\n protected readonly name: string\n\n /**\n * Client identifier used for authentication or tracking.\n */\n protected readonly clientId: string\n\n /**\n * Contentful environment associated with this client.\n */\n protected readonly environment: string\n\n /**\n * Protected fetch method used by the client to perform HTTP requests.\n */\n protected readonly fetch: FetchMethod\n\n /**\n * Creates a new API client base instance.\n *\n * @param name - Human-readable name of the client (used for logging and `apiName`).\n * @param config - Configuration options for the client.\n */\n constructor(name: string, { fetchOptions, clientId, environment }: ApiConfig) {\n this.clientId = clientId\n this.environment = environment ?? DEFAULT_ENVIRONMENT\n this.name = name\n\n this.fetch = Fetch.create({ ...(fetchOptions ?? {}), apiName: name })\n }\n\n /**\n * Logs errors that occur during API requests with standardized messages.\n *\n * @param error - The error thrown by the underlying operation.\n * @param options - Additional metadata about the request.\n * @param options.requestName - Human-readable name of the request operation.\n *\n * @protected\n *\n * @remarks\n * Abort errors are logged at `warn` level and other errors at `error` level.\n * The log message includes the client name for better debugging context.\n */\n protected logRequestError(error: unknown, { requestName }: { requestName: string }): void {\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n logger.warn(\n `[${this.name}] \"${requestName}\" request aborted due to network issues. This request may not be retried.`,\n )\n } else {\n logger.error(`[${this.name}] \"${requestName}\" request failed:`, error)\n }\n }\n }\n}\n\nexport default ApiClientBase\n","import {\n type App,\n Campaign,\n type Channel,\n type ComponentViewEvent,\n GeoLocation,\n type IdentifyEvent,\n type Library,\n Page,\n PageEventContext,\n type PageViewEvent,\n Properties,\n Screen,\n ScreenEventContext,\n type ScreenViewEvent,\n type TrackEvent,\n Traits,\n type UniversalEventProperties,\n} from '@contentful/optimization-api-schemas'\nimport { merge } from 'es-toolkit'\nimport * as z from 'zod/mini'\n\n/**\n * Configuration options for creating an {@link EventBuilder} instance.\n *\n * @public\n * @remarks\n * The configuration is typically provided by the host application to adapt\n * event payloads to the runtime environment (browser, framework, etc.).\n *\n * @example\n * ```ts\n * const builder = new EventBuilder({\n * app: { name: 'my-app', version: '1.0.0' },\n * channel: 'web',\n * library: { name: '@contentful/optimization-sdk', version: '1.2.3' },\n * getLocale: () => navigator.language,\n * getPageProperties: () => ({\n * path: window.location.pathname,\n * url: window.location.href,\n * title: document.title,\n * query: {},\n * referrer: document.referrer,\n * search: window.location.search,\n * }),\n * })\n * ```\n */\nexport interface EventBuilderConfig {\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 * The channel that identifies where events originate from (e.g. web, mobile).\n *\n * @see {@link Channel}\n */\n channel: Channel\n\n /**\n * The client library metadata that is attached to all events.\n *\n * @remarks\n * This is typically used to record the library name and version.\n */\n library: Library\n\n /**\n * Function used to resolve the locale for outgoing events.\n *\n * @remarks\n * If not provided, the builder falls back to the default `'en-US'`. Locale\n * values supplied directly as arguments to event builder methods take\n * precedence.\n *\n * @returns The locale string (e.g. `'en-US'`), or `undefined` if unavailable.\n */\n getLocale?: () => string | undefined\n\n /**\n * Function that returns the current page properties.\n *\n * @remarks\n * Page properties are currently added to the context of all events, as well\n * as the `properties` of the page event. When specified, all properties of\n * the `Page` type are required, but may contain empty values.\n *\n * @returns A {@link Page} object containing information about the current page.\n * @see {@link Page}\n */\n getPageProperties?: () => Page\n\n /**\n * Function used to obtain the current user agent string when applicable.\n *\n * @returns A user agent string, or `undefined` if unavailable.\n */\n getUserAgent?: () => string | undefined\n}\n\nconst UniversalEventBuilderArgs = z.object({\n campaign: z.optional(Campaign),\n locale: z.optional(z.string()),\n location: z.optional(GeoLocation),\n page: z.optional(Page),\n screen: z.optional(Screen),\n userAgent: z.optional(z.string()),\n})\n\n/**\n * Arguments used to construct the universal (shared) portion of all events.\n *\n * @public\n */\nexport type UniversalEventBuilderArgs = z.infer<typeof UniversalEventBuilderArgs>\n\nconst ComponentViewBuilderArgs = z.extend(UniversalEventBuilderArgs, {\n componentId: z.string(),\n experienceId: z.optional(z.string()),\n variantIndex: z.optional(z.number()),\n sticky: z.optional(z.boolean()),\n})\n\n/**\n * Arguments for constructing component view events.\n *\n * @public\n */\nexport type ComponentViewBuilderArgs = z.infer<typeof ComponentViewBuilderArgs>\n\nconst IdentifyBuilderArgs = z.extend(UniversalEventBuilderArgs, {\n traits: z.optional(Traits),\n userId: z.string(),\n})\n\n/**\n * Arguments for constructing identify events.\n *\n * @public\n * @remarks\n * Traits are merged by the API; only specified properties may be overwritten.\n */\nexport type IdentifyBuilderArgs = z.infer<typeof IdentifyBuilderArgs>\n\nconst PageViewBuilderArgs = z.extend(UniversalEventBuilderArgs, {\n properties: z.optional(z.partial(Page)),\n})\n\n/**\n * Arguments for constructing page view events.\n *\n * @public\n * @remarks\n * Any properties passed here are merged with the base page properties from\n * {@link EventBuilderConfig.getPageProperties}.\n */\nexport type PageViewBuilderArgs = z.infer<typeof PageViewBuilderArgs>\n\nconst ScreenViewBuilderArgs = z.extend(UniversalEventBuilderArgs, {\n name: z.string(),\n properties: Properties,\n})\n\n/**\n * Arguments for constructing screen view events.\n *\n * @public\n * @remarks\n * Any properties passed here are merged with the base screen properties from\n * {@link EventBuilderConfig.getScreenProperties}.\n */\nexport type ScreenViewBuilderArgs = z.infer<typeof ScreenViewBuilderArgs>\n\nconst TrackBuilderArgs = z.extend(UniversalEventBuilderArgs, {\n event: z.string(),\n properties: z.optional(z.prefault(Properties, {})),\n})\n\n/**\n * Arguments for constructing track events.\n *\n * @public\n */\nexport type TrackBuilderArgs = z.infer<typeof TrackBuilderArgs>\n\n/**\n * Default page properties used when no explicit page information is available.\n *\n * @public\n *\n * @defaultValue\n * ```ts\n * {\n * path: '',\n * query: {},\n * referrer: '',\n * search: '',\n * title: '',\n * url: '',\n * }\n * ```\n *\n * @remarks\n * Values are required by the API; values may not be `undefined`. Empty values are valid.\n */\nexport const DEFAULT_PAGE_PROPERTIES = {\n path: '',\n query: {},\n referrer: '',\n search: '',\n title: '',\n url: '',\n}\n\n/**\n * Internal helper class for building analytics and personalization events.\n *\n * @remarks\n * This class coordinates configuration and argument validation to produce\n * strongly-typed event payloads compatible with\n * `@contentful/optimization-api-schemas`.\n *\n * @public\n */\nclass EventBuilder {\n /**\n * Application metadata attached to each event.\n *\n * @internal\n */\n app?: App\n\n /**\n * Channel value attached to each event.\n *\n * @internal\n */\n channel: Channel\n\n /**\n * Library metadata attached to each event.\n *\n * @internal\n */\n library: Library\n\n /**\n * Function that provides the locale when available.\n *\n * @internal\n */\n getLocale: () => string | undefined\n\n /**\n * Function that provides baseline page properties.\n *\n * @internal\n */\n getPageProperties: () => Page\n\n /**\n * Function that provides the user agent string when available.\n *\n * @internal\n */\n getUserAgent: () => string | undefined\n\n /**\n * Creates a new {@link EventBuilder} instance.\n *\n * @param config - Configuration used to customize event payloads.\n *\n * @internal\n * @remarks\n * Callers are expected to reuse a single instance when possible to avoid\n * repeatedly reconfiguring the builder.\n *\n * @example\n * ```ts\n * const builder = new EventBuilder({\n * channel: 'web',\n * library: { name: '@contentful/optimization-sdk', version: '1.0.0' },\n * })\n * ```\n */\n constructor(config: EventBuilderConfig) {\n const { app, channel, library, getLocale, getPageProperties, getUserAgent } = config\n this.app = app\n this.channel = channel\n this.library = library\n this.getLocale = getLocale ?? (() => 'en-US')\n this.getPageProperties = getPageProperties ?? (() => DEFAULT_PAGE_PROPERTIES)\n this.getUserAgent = getUserAgent ?? (() => undefined)\n }\n\n /**\n * Builds the universal event properties shared across all event types.\n *\n * @param args - Arguments overriding the default context values.\n * @returns A fully populated {@link UniversalEventProperties} object.\n *\n * @protected\n *\n * @remarks\n * This method is used internally by the specific event-builder methods\n * (e.g. {@link EventBuilder.buildPageView}).\n */\n protected buildUniversalEventProperties({\n campaign = {},\n locale,\n location,\n page,\n screen,\n userAgent,\n }: UniversalEventBuilderArgs): UniversalEventProperties {\n const timestamp = new Date().toISOString()\n\n return {\n channel: this.channel,\n context: {\n app: this.app,\n campaign,\n gdpr: { isConsentGiven: true },\n library: this.library,\n locale: locale ?? this.getLocale() ?? 'en-US',\n location,\n page: page ?? this.getPageProperties(),\n screen,\n userAgent: userAgent ?? this.getUserAgent(),\n },\n messageId: crypto.randomUUID(),\n originalTimestamp: timestamp,\n sentAt: timestamp,\n timestamp,\n }\n }\n\n /**\n * Builds a component view event payload for a Contentful entry-based component.\n *\n * @param args - {@link ComponentViewBuilderArgs} arguments describing the component view.\n * @returns A {@link ComponentViewEvent} describing the view.\n *\n * @public\n *\n * @example\n * ```ts\n * const event = builder.buildComponentView({\n * componentId: 'entry-123',\n * experienceId: 'personalization-123',\n * variantIndex: 1,\n * })\n * ```\n */\n buildComponentView(args: ComponentViewBuilderArgs): ComponentViewEvent {\n const { componentId, experienceId, variantIndex, ...universal } =\n ComponentViewBuilderArgs.parse(args)\n\n return {\n ...this.buildUniversalEventProperties(universal),\n type: 'component',\n componentType: 'Entry',\n componentId,\n experienceId,\n variantIndex: variantIndex ?? 0,\n }\n }\n\n /**\n * Builds a component view event payload for a Custom Flag component.\n *\n * @param args - {@link ComponentViewBuilderArgs} arguments describing the Custom Flag view.\n * @returns A {@link ComponentViewEvent} describing the view.\n *\n * @public\n *\n * @remarks\n * This is a specialized variant of {@link EventBuilder.buildComponentView}\n * that sets `componentType` to `'Variable'`.\n *\n * @example\n * ```ts\n * const event = builder.buildFlagView({\n * componentId: 'feature-flag-key',\n * experienceId: 'personalization-123',\n * })\n * ```\n */\n buildFlagView(args: ComponentViewBuilderArgs): ComponentViewEvent {\n return {\n ...this.buildComponentView(args),\n componentType: 'Variable',\n }\n }\n\n /**\n * Builds an identify event payload to associate a user ID with traits.\n *\n * @param args - {@link IdentifyBuilderArgs} arguments describing the identified user.\n * @returns An {@link IdentifyEvent} payload.\n *\n * @public\n *\n * @remarks\n * - Traits are merged by the API; only specified properties may be overwritten.\n * - The User ID is consumer-specified and should not contain the value of any\n * ID generated by the Experience API.\n *\n * @example\n * ```ts\n * const event = builder.buildIdentify({\n * userId: 'user-123',\n * traits: { plan: 'pro' },\n * })\n * ```\n */\n buildIdentify(args: IdentifyBuilderArgs): IdentifyEvent {\n const { traits = {}, userId, ...universal } = IdentifyBuilderArgs.parse(args)\n\n return {\n ...this.buildUniversalEventProperties(universal),\n type: 'identify',\n traits,\n userId,\n }\n }\n\n /**\n * Builds a page view event payload.\n *\n * @param args - Optional {@link PageViewBuilderArgs} overrides for the page view event.\n * @returns A {@link PageViewEvent} payload.\n *\n * @public\n *\n * @remarks\n * Page properties are created by merging:\n * 1. The base page properties from {@link EventBuilderConfig.getPageProperties}, and\n * 2. The partial `properties` argument passed in.\n *\n * The title always falls back to {@link DEFAULT_PAGE_PROPERTIES}.title when undefined.\n *\n * @example\n * ```ts\n * const event = builder.buildPageView({\n * properties: {\n * title: 'Homepage',\n * },\n * })\n * ```\n */\n buildPageView(args: PageViewBuilderArgs = {}): PageViewEvent {\n const { properties = {}, ...universal } = PageViewBuilderArgs.parse(args)\n\n const pageProperties = this.getPageProperties()\n\n const merged = merge(\n {\n ...pageProperties,\n title: pageProperties.title ?? DEFAULT_PAGE_PROPERTIES.title,\n },\n properties,\n )\n\n const {\n context: { screen: _, ...universalContext },\n ...universalProperties\n } = this.buildUniversalEventProperties(universal)\n\n const context = PageEventContext.parse(universalContext)\n\n return {\n ...universalProperties,\n context,\n type: 'page',\n properties: merged,\n }\n }\n\n /**\n * Builds a screen view event payload.\n *\n * @param args - {@link ScreenViewBuilderArgs} arguments for the screen view event.\n * @returns A {@link ScreenViewEvent} payload.\n *\n * @public\n *\n * @example\n * ```ts\n * const event = builder.buildScreenView({\n * name: 'home',\n * properties: {\n * title: 'Home Screen',\n * },\n * })\n * ```\n */\n buildScreenView(args: ScreenViewBuilderArgs): ScreenViewEvent {\n const { name, properties, ...universal } = ScreenViewBuilderArgs.parse(args)\n\n const {\n context: { page: _, ...universalContext },\n ...universalProperties\n } = this.buildUniversalEventProperties(universal)\n\n const context = ScreenEventContext.parse(universalContext)\n\n return {\n ...universalProperties,\n context,\n type: 'screen',\n name,\n properties,\n }\n }\n\n /**\n * Builds a track event payload for arbitrary user actions.\n *\n * @param args - {@link TrackBuilderArgs} arguments describing the tracked event.\n * @returns A {@link TrackEvent} payload.\n *\n * @public\n *\n * @example\n * ```ts\n * const event = builder.buildTrack({\n * event: 'button_clicked',\n * properties: { id: 'primary-cta', location: 'hero' },\n * })\n * ```\n */\n buildTrack(args: TrackBuilderArgs): TrackEvent {\n const { event, properties = {}, ...universal } = TrackBuilderArgs.parse(args)\n\n return {\n ...this.buildUniversalEventProperties(universal),\n type: 'track',\n event,\n properties,\n }\n }\n}\n\nexport default EventBuilder\n","import {\n BatchExperienceResponse,\n ExperienceEventArray,\n ExperienceResponse,\n type BatchExperienceData,\n type BatchExperienceEventArray,\n type ExperienceRequestData,\n type ExperienceRequestOptions,\n type OptimizationData,\n} from '@contentful/optimization-api-schemas'\nimport { createScopedLogger } from 'logger'\nimport ApiClientBase, { type ApiConfig } from '../ApiClientBase'\n\nconst logger = createScopedLogger('ApiClient:Experience')\n\n/**\n * Default base URL for the Experience API.\n *\n * @public\n */\nexport const EXPERIENCE_BASE_URL = 'https://experience.ninetailed.co/'\n\n/**\n * Feature flags supported by the Experience API.\n */\ntype Feature = 'ip-enrichment' | 'location'\n\n/**\n * Options that control how requests to the Experience API are handled.\n */\ninterface RequestOptions {\n /**\n * Enabled features (for example, `\"ip-enrichment\"`) which the API should use for this request.\n *\n * @remarks\n * When omitted, a default set of features may be applied.\n */\n enabledFeatures?: Feature[]\n\n /**\n * IP address to override the API behavior for IP analysis.\n *\n * @remarks\n * Commonly used in ESR or SSR environments, as the API would otherwise use\n * the server IP.\n */\n ip?: string\n\n /**\n * Locale used to translate `location.city` and `location.country`.\n *\n * @remarks\n * When omitted, a server-side default may be used.\n */\n locale?: string\n\n /**\n * When `true`, sends performance-critical endpoints in plain text.\n *\n * @remarks\n * The Ninetailed API accepts certain endpoints in plain text to avoid CORS\n * preflight requests, which can improve performance in browser environments.\n */\n plainText?: boolean\n\n /**\n * When `true`, instructs the API to aggregate a new profile state but not store it.\n *\n * @remarks\n * This is commonly used in ESR or SSR environments where you want to\n * preview the result without persisting changes.\n */\n preflight?: boolean\n}\n\n/**\n * Internal options for profile mutation requests.\n *\n * @internal\n */\ninterface ProfileMutationRequestOptions {\n url: string\n body: unknown\n options: RequestOptions\n}\n\n/**\n * Parameters used when creating a profile.\n */\ninterface CreateProfileParams {\n /**\n * Events used to aggregate the profile state.\n */\n events: ExperienceEventArray\n}\n\n/**\n * Parameters used when updating an existing profile.\n */\ninterface UpdateProfileParams extends CreateProfileParams {\n /**\n * ID of the profile to update.\n */\n profileId: string\n}\n\n/**\n * Parameters used when creating or updating a profile.\n */\ninterface UpsertProfileParams extends CreateProfileParams {\n /**\n * Optional ID of the profile; when omitted, a new profile is created.\n */\n profileId?: string\n}\n\n/**\n * Parameters used when performing a batch profile update.\n */\ninterface BatchUpdateProfileParams {\n /**\n * Batch of events to process.\n */\n events: BatchExperienceEventArray\n}\n\n/**\n * Configuration for {@link ExperienceApiClient}.\n */\nexport interface ExperienceApiClientConfig extends ApiConfig, RequestOptions {}\n\n/**\n * Client for interacting with the Experience API.\n *\n * @public\n *\n * @remarks\n * This client is responsible for reading and mutating Ninetailed profiles\n * using the Experience API.\n *\n * @example\n * ```ts\n * const client = new ExperienceApiClient({\n * clientId: 'org-id',\n * environment: 'main',\n * })\n *\n * const profile = await client.getProfile('profile-id')\n * ```\n */\nexport default class ExperienceApiClient extends ApiClientBase {\n /**\n * Base URL used for Experience API requests.\n */\n protected readonly baseUrl: string\n\n private readonly enabledFeatures?: RequestOptions['enabledFeatures']\n private readonly ip?: RequestOptions['ip']\n private readonly locale?: RequestOptions['locale']\n private readonly plainText?: RequestOptions['plainText']\n private readonly preflight?: RequestOptions['preflight']\n\n /**\n * Creates a new {@link ExperienceApiClient} instance.\n *\n * @param config - Configuration for the Experience API client.\n */\n constructor(config: ExperienceApiClientConfig) {\n super('Experience', config)\n\n const { baseUrl, enabledFeatures, ip, locale, plainText, preflight } = config\n\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- Set default for anything falsey\n this.baseUrl = baseUrl || EXPERIENCE_BASE_URL\n this.enabledFeatures = enabledFeatures\n this.ip = ip\n this.locale = locale\n this.plainText = plainText\n this.preflight = preflight\n }\n\n /**\n * Retrieves a profile by ID.\n *\n * @param id - The profile ID to retrieve.\n * @param options - Optional request options. `preflight` and `plainText` are not allowed here.\n * @returns The current optimization data for the profile.\n *\n * @throws {@link Error}\n * Thrown if `id` is missing or the underlying request fails.\n *\n * @example\n * ```ts\n * const profile = await client.getProfile('profile-id', {\n * locale: 'en-US',\n * })\n * ```\n */\n public async getProfile(\n id: string,\n options: Omit<RequestOptions, 'preflight' | 'plainText'> = {},\n ): Promise<OptimizationData> {\n if (!id) throw new Error('Valid profile ID required.')\n\n const requestName = 'Get Profile'\n\n logger.info(`Sending \"${requestName}\" request`)\n\n try {\n const response = await this.fetch(\n this.constructUrl(\n `v2/organizations/${this.clientId}/environments/${this.environment}/profiles/${id}`,\n options,\n ),\n {\n method: 'GET',\n },\n )\n\n const {\n data: { changes, experiences, profile },\n } = ExperienceResponse.parse(await response.json())\n\n const data = { changes, personalizations: experiences, profile }\n\n logger.debug(`\"${requestName}\" request successfully completed`)\n\n return data\n } catch (error) {\n this.logRequestError(error, { requestName })\n\n throw error\n }\n }\n\n /**\n * Sends a POST request to mutate a profile or profiles.\n *\n * @param request - Mutation request options including URL, body, and request options.\n * @returns The raw {@link Response} from the underlying fetch.\n *\n * @internal\n */\n private async makeProfileMutationRequest({\n url,\n body,\n options,\n }: ProfileMutationRequestOptions): Promise<Response> {\n return await this.fetch(this.constructUrl(url, options), {\n method: 'POST',\n headers: this.constructHeaders(options),\n body: JSON.stringify(body),\n keepalive: true,\n })\n }\n\n /**\n * Creates a profile and returns the resulting optimization data.\n *\n * @param params - Parameters containing the events to aggregate into the profile.\n * @param options - Optional request options.\n * @returns The optimization data for the newly created profile.\n *\n * @remarks\n * The returned profile ID can be used for subsequent update requests.\n *\n * @example\n * ```ts\n * const data = await client.createProfile({\n * events: [{ type: 'identify', userId: 'user-123' }],\n * })\n * ```\n */\n public async createProfile(\n { events }: CreateProfileParams,\n options: RequestOptions = {},\n ): Promise<OptimizationData> {\n const requestName = 'Create Profile'\n\n logger.info(`Sending \"${requestName}\" request`)\n\n const body: ExperienceRequestData = {\n events: ExperienceEventArray.parse(events),\n options: this.constructBodyOptions(options),\n }\n\n logger.debug(`\"${requestName}\" request body:`, body)\n\n try {\n const response = await this.makeProfileMutationRequest({\n url: `v2/organizations/${this.clientId}/environments/${this.environment}/profiles`,\n body,\n options,\n })\n\n const {\n data: { changes, experiences, profile },\n } = ExperienceResponse.parse(await response.json())\n\n const data = { changes, personalizations: experiences, profile }\n\n logger.debug(`\"${requestName}\" request successfully completed`)\n\n return data\n } catch (error) {\n this.logRequestError(error, { requestName })\n\n throw error\n }\n }\n\n /**\n * Updates an existing profile with the given profile ID.\n *\n * @param params - Parameters including the profile ID and events.\n * @param options - Optional request options.\n * @returns The updated optimization data for the profile.\n *\n * @throws {@link Error}\n * Thrown if `profileId` is missing or the underlying request fails.\n *\n * @example\n * ```ts\n * const data = await client.updateProfile({\n * profileId: 'profile-id',\n * events: [{ type: 'track', event: 'viewed_video' }],\n * })\n * ```\n */\n public async updateProfile(\n { profileId, events }: UpdateProfileParams,\n options: RequestOptions = {},\n ): Promise<OptimizationData> {\n if (!profileId) throw new Error('Valid profile ID required.')\n\n const requestName = 'Update Profile'\n\n logger.info(`Sending \"${requestName}\" request`)\n\n const body: ExperienceRequestData = {\n events: ExperienceEventArray.parse(events),\n options: this.constructBodyOptions(options),\n }\n\n logger.debug(`\"${requestName}\" request body:`, body)\n\n try {\n const response = await this.makeProfileMutationRequest({\n url: `v2/organizations/${this.clientId}/environments/${this.environment}/profiles/${profileId}`,\n body,\n options,\n })\n\n const {\n data: { changes, experiences, profile },\n } = ExperienceResponse.parse(await response.json())\n\n const data = { changes, personalizations: experiences, profile }\n\n logger.debug(`\"${requestName}\" request successfully completed`)\n\n return data\n } catch (error) {\n this.logRequestError(error, { requestName })\n\n throw error\n }\n }\n\n /**\n * Creates or updates a profile depending on whether a `profileId` is provided.\n *\n * @param params - Parameters including optional profile ID and events.\n * @param options - Optional request options.\n * @returns The resulting optimization data.\n *\n * @example\n * ```ts\n * // Create\n * await client.upsertProfile({ events })\n *\n * // Update\n * await client.upsertProfile({ profileId: 'profile-id', events })\n * ```\n */\n public async upsertProfile(\n { profileId, events }: UpsertProfileParams,\n options?: RequestOptions,\n ): Promise<OptimizationData> {\n if (!profileId) {\n return await this.createProfile({ events }, options)\n } else {\n return await this.updateProfile({ profileId, events }, options)\n }\n }\n\n /**\n * Sends multiple events to the Ninetailed Experience API to upsert many profiles.\n *\n * @param params - Parameters containing the batch of events.\n * @param options - Optional request options.\n * @returns The list of profiles affected by the batch operation.\n *\n * @remarks\n * Every event must contain an anonymous ID. Profiles will be created or\n * updated according to the anonymous ID.\n *\n * This method is intended to be used from server environments.\n *\n * @example\n * ```ts\n * const profiles = await client.upsertManyProfiles({\n * events: [\n * [{ type: 'identify', userId: 'user-1' }],\n * [{ type: 'identify', userId: 'user-2' }],\n * ],\n * })\n * ```\n */\n public async upsertManyProfiles(\n { events }: BatchUpdateProfileParams,\n options: RequestOptions = {},\n ): Promise<BatchExperienceData['profiles']> {\n const requestName = 'Upsert Many Profiles'\n\n logger.info(`Sending \"${requestName}\" request`)\n\n const body: ExperienceRequestData = {\n events: ExperienceEventArray.parse(events),\n options: this.constructBodyOptions(options),\n }\n\n logger.debug(`\"${requestName}\" request body:`, body)\n\n try {\n const response = await this.makeProfileMutationRequest({\n url: `v2/organizations/${this.clientId}/environments/${this.environment}/events`,\n body,\n options: { plainText: false, ...options },\n })\n\n const {\n data: { profiles },\n } = BatchExperienceResponse.parse(await response.json())\n\n logger.debug(`\"${requestName}\" request successfully completed`)\n\n return profiles\n } catch (error) {\n this.logRequestError(error, { requestName })\n\n throw error\n }\n }\n\n /**\n * Constructs a request URL with query parameters derived from request options.\n *\n * @param path - Path relative to the Experience API base URL.\n * @param options - Request options that may influence query parameters.\n * @returns The fully constructed URL as a string.\n *\n * @internal\n */\n private constructUrl(path: string, options: RequestOptions): string {\n const url = new URL(path, this.baseUrl)\n const locale = options.locale ?? this.locale\n const preflight = options.preflight ?? this.preflight\n\n if (locale) {\n url.searchParams.set('locale', locale)\n }\n\n if (preflight) {\n url.searchParams.set('type', 'preflight')\n }\n\n return url.toString()\n }\n\n /**\n * Constructs request headers based on request options and default configuration.\n *\n * @param options - Request options that may influence headers.\n * @returns A record of HTTP headers to send with the request.\n *\n * @internal\n */\n private constructHeaders({\n ip = this.ip,\n plainText = this.plainText,\n }: RequestOptions): Record<string, string> {\n const headers = new Map<string, string>()\n\n if (ip) {\n headers.set('X-Force-IP', ip)\n }\n\n if (plainText ?? this.plainText ?? true) {\n headers.set('Content-Type', 'text/plain')\n } else {\n headers.set('Content-Type', 'application/json')\n }\n\n return Object.fromEntries(headers)\n }\n\n /**\n * Constructs the `options` section of the request body for profile mutations.\n *\n * @param options - Request options that may specify enabled features.\n * @returns Experience API body options including feature flags.\n *\n * @internal\n */\n private readonly constructBodyOptions = ({\n enabledFeatures = this.enabledFeatures,\n }: RequestOptions): ExperienceRequestOptions => {\n const bodyOptions: ExperienceRequestOptions = {}\n\n if (enabledFeatures && Array.isArray(enabledFeatures) && enabledFeatures.length > 0) {\n bodyOptions.features = enabledFeatures\n } else {\n bodyOptions.features = ['ip-enrichment', 'location']\n }\n\n return bodyOptions\n }\n}\n","import ExperienceApiClient from './ExperienceApiClient'\n\nexport * from './ExperienceApiClient'\n\nexport default ExperienceApiClient\n","import { BatchInsightsEventArray } from '@contentful/optimization-api-schemas'\nimport { createScopedLogger } from 'logger'\nimport ApiClientBase, { type ApiConfig } from '../ApiClientBase'\n\nconst logger = createScopedLogger('ApiClient:Insights')\n\n/**\n * Default base URL for the Insights ingest API.\n *\n * @public\n */\nexport const INSIGHTS_BASE_URL = 'https://ingest.insights.ninetailed.co/'\n\n/**\n * Options that control how Insights events are sent.\n *\n * @public\n */\ninterface RequestOptions {\n /**\n * Handler used to enqueue events via the Beacon API or a similar mechanism.\n *\n * @param url - Target URL for the batched events.\n * @param data - Array of batched insights events to be sent.\n * @returns `true` if the events were successfully queued, `false` otherwise.\n *\n * @remarks\n * When provided, this handler is preferred over direct `fetch` calls. If it\n * returns `false`, the client falls back to emitting events immediately via\n * `fetch`.\n */\n beaconHandler?: (url: string | URL, data: BatchInsightsEventArray) => boolean\n}\n\n/**\n * Configuration for {@link InsightsApiClient}.\n *\n * @public\n */\nexport interface InsightsApiClientConfig extends ApiConfig, RequestOptions {}\n\n/**\n * Client for sending analytics and insights events to the Ninetailed Insights API.\n *\n * @public\n *\n * @remarks\n * This client is optimized for sending batched events, optionally using a\n * custom beacon-like handler when available.\n *\n * @example\n * ```ts\n * const insightsClient = new InsightsApiClient({\n * clientId: 'org-id',\n * environment: 'main',\n * preview: false,\n * })\n *\n * await insightsClient.sendBatchEvents([\n * {\n * profile: { id: 'profile-123', ... },\n * events: [\n * {\n * type: 'track',\n * event: 'button_clicked',\n * properties: { id: 'primary-cta' },\n * },\n * ],\n * }\n * ])\n * ```\n */\nexport default class InsightsApiClient extends ApiClientBase {\n /**\n * Base URL used for Insights API requests.\n */\n protected readonly baseUrl: string\n\n /**\n * Optional handler used to enqueue events via the Beacon API or a similar mechanism.\n */\n private readonly beaconHandler: RequestOptions['beaconHandler']\n\n /**\n * Creates a new {@link InsightsApiClient} instance.\n *\n * @param config - Configuration for the Insights API client.\n *\n * @example\n * ```ts\n * const client = new InsightsApiClient({\n * clientId: 'org-id',\n * environment: 'main',\n * beaconHandler: (url, data) => {\n * return navigator.sendBeacon(url.toString(), JSON.stringify(data))\n * },\n * })\n * ```\n */\n constructor(config: InsightsApiClientConfig) {\n super('Insights', config)\n\n const { baseUrl, beaconHandler } = config\n\n this.baseUrl = baseUrl ?? INSIGHTS_BASE_URL\n this.beaconHandler = beaconHandler\n }\n\n /**\n * Sends batches of insights events to the Ninetailed Insights API.\n *\n * @param batches - Array of event batches to send.\n * @param options - Optional request options, including a per-call `beaconHandler`.\n * @returns A promise that resolves when the events have been sent or queued.\n *\n * @remarks\n * If a `beaconHandler` is provided (either in the method call or in the\n * client configuration) it will be invoked first. When the handler returns\n * `true`, the events are considered successfully queued and no network\n * request is made by this method.\n *\n * If the handler is missing or returns `false`, the events are emitted\n * immediately via `fetch`.\n *\n * @returns A boolean value that is true when either the event batch is successfully\n * queued by the beacon handler or a direct request is successfully sent.\n *\n * @example\n * ```ts\n * const success = await insightsClient.sendBatchEvents(batches)\n * ```\n *\n * @example\n * ```ts\n * // Override beaconHandler for a single call\n * const success = await insightsClient.sendBatchEvents(batches, {\n * beaconHandler: (url, data) => {\n * return navigator.sendBeacon(url.toString(), JSON.stringify(data))\n * },\n * })\n * ```\n */\n public async sendBatchEvents(\n batches: BatchInsightsEventArray,\n options: RequestOptions = {},\n ): Promise<boolean> {\n const { beaconHandler = this.beaconHandler } = options\n\n const url = new URL(\n `v1/organizations/${this.clientId}/environments/${this.environment}/events`,\n this.baseUrl,\n )\n\n const body = BatchInsightsEventArray.parse(batches)\n\n if (typeof beaconHandler === 'function') {\n logger.debug('Queueing events via beaconHandler')\n\n const beaconSuccessfullyQueued = beaconHandler(url, body)\n\n if (beaconSuccessfullyQueued) {\n return true\n } else {\n logger.warn(\n 'beaconHandler failed to queue events; events will be emitted immediately via fetch',\n )\n }\n }\n\n const requestName = 'Event Batches'\n\n logger.info(`Sending \"${requestName}\" request`)\n\n logger.debug(`\"${requestName}\" request body:`, body)\n\n try {\n await this.fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n keepalive: true,\n })\n\n logger.debug(`\"${requestName}\" request successfully completed`)\n\n return true\n } catch (error) {\n this.logRequestError(error, { requestName })\n\n return false\n }\n }\n}\n","import InsightsApiClient from './InsightsApiClient'\n\nexport * from './InsightsApiClient'\n\nexport default InsightsApiClient\n","import { diary, enable, type Diary, type LogEvent } from 'diary'\n\nimport type LogSink from './LogSink'\n\nexport class Logger {\n readonly name = '@contentful/optimization'\n\n private readonly PREFIX_PARTS = ['Ctfl', 'O10n']\n private readonly DELIMITER = ':'\n private readonly diary: Diary\n private sinks: LogSink[] = []\n\n constructor() {\n this.diary = diary(this.name, this.onLogEvent.bind(this))\n enable(this.name)\n }\n\n private assembleLocationPrefix(logLocation: string): string {\n return `[${[...this.PREFIX_PARTS, logLocation].join(this.DELIMITER)}]`\n }\n\n public addSink(sink: LogSink): void {\n this.sinks = [...this.sinks.filter((existingSink) => existingSink.name !== sink.name), sink]\n }\n\n public removeSink(name: string): void {\n this.sinks = this.sinks.filter((sink) => sink.name !== name)\n }\n\n public removeSinks(): void {\n this.sinks = []\n }\n\n public debug(logLocation: string, message: string, ...args: unknown[]): void {\n this.diary.debug(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args)\n }\n\n public info(logLocation: string, message: string, ...args: unknown[]): void {\n this.diary.info(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args)\n }\n\n public log(logLocation: string, message: string, ...args: unknown[]): void {\n this.diary.log(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args)\n }\n\n public warn(logLocation: string, message: string, ...args: unknown[]): void {\n this.diary.warn(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args)\n }\n\n public error(logLocation: string, message: string | Error, ...args: unknown[]): void {\n this.diary.error(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args)\n }\n\n public fatal(logLocation: string, message: string | Error, ...args: unknown[]): void {\n this.diary.fatal(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args)\n }\n\n private onLogEvent(event: LogEvent): void {\n this.sinks.forEach((sink) => {\n sink.ingest(event)\n })\n }\n}\n\nexport const logger = new Logger()\n\nexport interface ScopedLogger {\n debug: (message: string, ...args: unknown[]) => void\n info: (message: string, ...args: unknown[]) => void\n log: (message: string, ...args: unknown[]) => void\n warn: (message: string, ...args: unknown[]) => void\n error: (message: string | Error, ...args: unknown[]) => void\n fatal: (message: string | Error, ...args: unknown[]) => void\n}\n\nexport function createScopedLogger(location: string): ScopedLogger {\n return {\n debug: (message: string, ...args: unknown[]) => {\n logger.debug(location, message, ...args)\n },\n info: (message: string, ...args: unknown[]) => {\n logger.info(location, message, ...args)\n },\n log: (message: string, ...args: unknown[]) => {\n logger.log(location, message, ...args)\n },\n warn: (message: string, ...args: unknown[]) => {\n logger.warn(location, message, ...args)\n },\n error: (message: string | Error, ...args: unknown[]) => {\n logger.error(location, message, ...args)\n },\n fatal: (message: string | Error, ...args: unknown[]) => {\n logger.fatal(location, message, ...args)\n },\n }\n}\n","// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\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};"],"names":["ApiClient","config","personalization","analytics","apiConfig","ExperienceApiClient","InsightsApiClient","logger","createScopedLogger","DEFAULT_INTERVAL_TIMEOUT","DEFAULT_RETRY_COUNT","RETRY_RESPONSE_STATUS","HTTP_ERROR_RESPONSE_STATUS","HttpError","Error","message","status","Object","createRetryFetchCallback","apiName","controller","fetchMethod","fetch","init","url","response","httpError","error","createRetryFetchMethod","intervalTimeout","onFailedAttempt","retries","AbortController","retryResponse","retry","options","DEFAULT_REQUEST_TIMEOUT","createTimeoutFetchMethod","onRequestTimeout","requestTimeout","id","setTimeout","clearTimeout","createProtectedFetchMethod","timeoutFetchMethod","retryFetchMethod","Fetch","DEFAULT_ENVIRONMENT","ApiClientBase","name","fetchOptions","clientId","environment","requestName","UniversalEventBuilderArgs","z","Campaign","GeoLocation","Page","Screen","ComponentViewBuilderArgs","IdentifyBuilderArgs","Traits","PageViewBuilderArgs","ScreenViewBuilderArgs","Properties","TrackBuilderArgs","DEFAULT_PAGE_PROPERTIES","EventBuilder","app","channel","library","getLocale","getPageProperties","getUserAgent","undefined","campaign","locale","location","page","screen","userAgent","timestamp","Date","crypto","args","componentId","experienceId","variantIndex","universal","traits","userId","properties","pageProperties","merged","merge","_","universalContext","universalProperties","context","PageEventContext","ScreenEventContext","event","EXPERIENCE_BASE_URL","baseUrl","enabledFeatures","ip","plainText","preflight","changes","experiences","profile","ExperienceResponse","data","body","JSON","events","ExperienceEventArray","profileId","profiles","BatchExperienceResponse","path","URL","headers","Map","bodyOptions","Array","INSIGHTS_BASE_URL","beaconHandler","batches","BatchInsightsEventArray","beaconSuccessfullyQueued","Logger","diary","enable","logLocation","sink","existingSink","__webpack_require__","module","getter","definition","key","obj","prop","Symbol"],"mappings":";;;;;;;;QAwDe,MAAMA;YAIV,OAAiB;YAKjB,WAA+B;Y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uE,UAAU/D,YAAYsE;gBACrC;YACF;QACF;;;;;;;;;;;;;;IC/FAqD,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzE7H,OAAO,cAAc,CAAC,UAAS6H,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACK,KAAKC,OAAU/H,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC8H,KAAKC;;;ICClFN,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOO,UAA0BA,OAAO,WAAW,EACrDhI,OAAO,cAAc,CAAC,UAASgI,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEhI,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D"}
@@ -0,0 +1,8 @@
1
+ export { default as ApiClient } from './ApiClient';
2
+ export * from '@contentful/optimization-api-schemas';
3
+ export * from './ApiClient';
4
+ export * from './ApiClientBase';
5
+ export * from './builders';
6
+ export * from './experience';
7
+ export * from './insights';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAElD,cAAc,sCAAsC,CAAA;AACpD,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { default as ApiClient } from './ApiClient';
2
+ export * from '@contentful/optimization-api-schemas';
3
+ export * from './ApiClient';
4
+ export * from './ApiClientBase';
5
+ export * from './builders';
6
+ export * from './experience';
7
+ export * from './insights';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAElD,cAAc,sCAAsC,CAAA;AACpD,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}