@contentful/optimization-api-client 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1293,6 +1293,7 @@ export declare class ExperienceApiClient extends ApiClientBase {
1293
1293
  private readonly enabledFeatures?;
1294
1294
  private readonly ip?;
1295
1295
  private locale?;
1296
+ private readonly location?;
1296
1297
  private readonly plainText?;
1297
1298
  private readonly preflight?;
1298
1299
  /**
@@ -1313,7 +1314,8 @@ export declare class ExperienceApiClient extends ApiClientBase {
1313
1314
  * Retrieves a profile by ID.
1314
1315
  *
1315
1316
  * @param id - The profile ID to retrieve.
1316
- * @param options - Optional request options. `preflight` and `plainText` are not allowed here.
1317
+ * @param options - Optional request options. `location`, `preflight`, and `plainText`
1318
+ * are not allowed here.
1317
1319
  * @returns The current optimization data for the profile.
1318
1320
  *
1319
1321
  * @throws Error
@@ -1326,7 +1328,7 @@ export declare class ExperienceApiClient extends ApiClientBase {
1326
1328
  * })
1327
1329
  * ```
1328
1330
  */
1329
- getProfile(id: string, options?: Omit<ExperienceApiClientRequestOptions, 'preflight' | 'plainText'>): Promise<OptimizationData>;
1331
+ getProfile(id: string, options?: Omit<ExperienceApiClientRequestOptions, 'location' | 'preflight' | 'plainText'>): Promise<OptimizationData>;
1330
1332
  /**
1331
1333
  * Sends a POST request to mutate a profile or profiles.
1332
1334
  *
@@ -1492,6 +1494,19 @@ export declare interface ExperienceApiClientRequestOptions {
1492
1494
  * When omitted, the API can use a server-side default.
1493
1495
  */
1494
1496
  locale?: string;
1497
+ /**
1498
+ * Request location for `createProfile()`, `updateProfile()`, and `upsertProfile()`.
1499
+ *
1500
+ * @remarks
1501
+ * A per-request value replaces the constructor default as a whole object.
1502
+ * The API merges each event's `context.location` over this request location.
1503
+ * An explicit `{}` overrides the constructor default and supplies an empty
1504
+ * request-location default instead of Cloudflare geolocation. When omitted
1505
+ * from both sources, existing API fallback behavior applies.
1506
+ * This affects evaluation and profile updates; it is not a permanent location lock.
1507
+ * For `upsertManyProfiles()`, use each event's `context.location` instead.
1508
+ */
1509
+ location?: GeoLocation;
1495
1510
  /**
1496
1511
  * When `true`, sends performance-critical endpoints in plain text.
1497
1512
  *
@@ -2037,6 +2052,76 @@ export declare interface FetchMethodCallbackOptions {
2037
2052
  retriesLeft?: number;
2038
2053
  }
2039
2054
 
2055
+ /**
2056
+ * Zod schema describing geo-location properties for an event or singular profile request.
2057
+ *
2058
+ * @remarks
2059
+ * All properties are optional and can be derived from IP or device data.
2060
+ *
2061
+ * @public
2062
+ */
2063
+ declare const GeoLocation: z.ZodMiniObject<{
2064
+ /**
2065
+ * Geographical coordinates for the location.
2066
+ */
2067
+ coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
2068
+ /**
2069
+ * Latitude component of the coordinates.
2070
+ */
2071
+ latitude: z.ZodMiniNumber<number>;
2072
+ /**
2073
+ * Longitude component of the coordinates.
2074
+ */
2075
+ longitude: z.ZodMiniNumber<number>;
2076
+ }, z.core.$strip>>;
2077
+ /**
2078
+ * City name associated with the location.
2079
+ */
2080
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
2081
+ /**
2082
+ * Postal or ZIP code associated with the location.
2083
+ */
2084
+ postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2085
+ /**
2086
+ * Region or state name associated with the location.
2087
+ */
2088
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
2089
+ /**
2090
+ * Region or state code associated with the location.
2091
+ */
2092
+ regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2093
+ /**
2094
+ * Country name associated with the location.
2095
+ */
2096
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
2097
+ /**
2098
+ * Country code associated with the location.
2099
+ *
2100
+ * @remarks
2101
+ * Validated to exactly COUNTRY_CODE_LENGTH characters, typically
2102
+ * an ISO 3166-1 alpha-2 code.
2103
+ */
2104
+ countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2105
+ /**
2106
+ * Continent name associated with the location.
2107
+ */
2108
+ continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
2109
+ /**
2110
+ * Time zone identifier associated with the location.
2111
+ *
2112
+ * @remarks
2113
+ * Typically an IANA time zone string (e.g., `"Europe/Berlin"`).
2114
+ */
2115
+ timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
2116
+ }, z.core.$strip>;
2117
+
2118
+ /**
2119
+ * TypeScript type inferred from {@link GeoLocation}.
2120
+ *
2121
+ * @public
2122
+ */
2123
+ declare type GeoLocation = z.infer<typeof GeoLocation>;
2124
+
2040
2125
  /**
2041
2126
  * Properties that can be shared between global and per-client API configuration.
2042
2127
  *
package/dist/index.mjs CHANGED
@@ -159,15 +159,17 @@ class ExperienceApiClient extends src_ApiClientBase {
159
159
  enabledFeatures;
160
160
  ip;
161
161
  locale;
162
+ location;
162
163
  plainText;
163
164
  preflight;
164
165
  constructor(config){
165
166
  super('Experience', config);
166
- const { baseUrl, enabledFeatures, ip, locale, plainText, preflight } = config;
167
+ const { baseUrl, enabledFeatures, ip, locale, location, plainText, preflight } = config;
167
168
  this.baseUrl = baseUrl || EXPERIENCE_BASE_URL;
168
169
  this.enabledFeatures = enabledFeatures;
169
170
  this.ip = ip;
170
171
  this.locale = locale;
172
+ this.location = location;
171
173
  this.plainText = plainText;
172
174
  this.preflight = preflight;
173
175
  }
@@ -319,9 +321,12 @@ class ExperienceApiClient extends src_ApiClientBase {
319
321
  return bodyOptions;
320
322
  };
321
323
  constructExperienceRequestBody(events, options) {
324
+ const bodyOptions = this.constructBodyOptions(options);
325
+ const location = options.location ?? this.location;
326
+ if (void 0 !== location) bodyOptions.location = location;
322
327
  return ExperienceRequestData.parse({
323
328
  events: parseWithFriendlyError(ExperienceEventArray, events),
324
- options: this.constructBodyOptions(options)
329
+ options: bodyOptions
325
330
  });
326
331
  }
327
332
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/fetch/fetchInputToString.ts","../src/fetch/resolveFetchMethod.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/experience/ExperienceApiClient.ts","../src/insights/InsightsApiClient.ts","../src/ApiClient.ts"],"sourcesContent":["import type { FetchMethod } from './Fetch'\n\nexport const fetchInputToString = (input: Parameters<FetchMethod>[0]): string => {\n if (typeof input === 'string') return input\n\n return input.url\n}\n","import type { FetchMethod } from './Fetch'\n\nconst MISSING_FETCH_METHOD_MESSAGE = 'No fetch implementation available. Provide a fetchMethod.'\n\nexport function resolveFetchMethod(fetchMethod?: FetchMethod): FetchMethod {\n if (fetchMethod) return fetchMethod\n\n if (typeof globalThis.fetch === 'function') {\n return globalThis.fetch.bind(globalThis)\n }\n\n throw new Error(MISSING_FETCH_METHOD_MESSAGE)\n}\n","import { createScopedLogger } from '../logger'\nimport type { BaseFetchMethodOptions, FetchMethod, FetchMethodCallbackOptions } from './Fetch'\nimport { fetchInputToString } from './fetchInputToString'\nimport { resolveFetchMethod } from './resolveFetchMethod'\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 * @remarks\n * This value is fixed to `503 Service Unavailable`.\n *\n * @internal\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 *\n * @public\n */\nexport interface RetryFetchMethodOptions extends BaseFetchMethodOptions {\n /**\n * Delay (in milliseconds) between retry attempts.\n *\n * @defaultValue `0`\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 * @defaultValue `1`\n */\n retries?: number\n}\n\n/**\n * Internal configuration passed to the retry callback.\n *\n * @internal\n */\ninterface RetryFetchCallbackOptions extends RetryFetchMethodOptions {\n fetchMethod: FetchMethod\n\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: Parameters<FetchMethod>[1]\n\n /**\n * Request URL.\n */\n url: Parameters<FetchMethod>[0]\n}\n\n/**\n * Creates a callback function used by the retry loop to perform a protected fetch attempt.\n *\n * @param options - Internal options controlling request execution and retry classification.\n * @returns A function that performs one fetch attempt and either:\n * - returns a successful {@link Response},\n * - throws {@link HttpError} for retriable `503` responses, or\n * - aborts and returns `undefined` for non-retriable failures.\n *\n * @internal\n */\nfunction createRetryFetchCallback({\n apiName = 'Optimization',\n controller,\n fetchMethod,\n init,\n url,\n}: RetryFetchCallbackOptions) {\n return async () => {\n const urlLabel = fetchInputToString(url)\n\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 \"${urlLabel}\" 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 \"${urlLabel}\" 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 \"${urlLabel}\":`, 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 \"${urlLabel}\" failed:`, error)\n\n controller.abort()\n }\n }\n}\n\n/**\n * Waits for the configured retry delay between attempts.\n *\n * @param intervalTimeout - Delay in milliseconds before the next retry attempt.\n * @returns A promise that resolves immediately when delay is non-positive,\n * otherwise after the timeout elapses.\n *\n * @internal\n */\nasync function delayRetry(intervalTimeout: number): Promise<void> {\n if (intervalTimeout <= 0) {\n return\n }\n\n const { promise, resolve } = Promise.withResolvers<undefined>()\n setTimeout(() => {\n resolve(undefined)\n }, intervalTimeout)\n await promise\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 * @throws Error\n * Thrown when the request cannot be retried and no successful response is obtained.\n *\n * @remarks\n * This wrapper uses a lightweight internal retry loop and an {@link AbortController}\n * to cancel pending requests when a non-retriable error occurs.\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 *\n * @public\n */\nexport function createRetryFetchMethod({\n apiName = 'Optimization',\n fetchMethod,\n intervalTimeout = DEFAULT_INTERVAL_TIMEOUT,\n onFailedAttempt,\n retries = DEFAULT_RETRY_COUNT,\n}: RetryFetchMethodOptions = {}): FetchMethod {\n const resolvedFetchMethod = resolveFetchMethod(fetchMethod)\n\n return async (url, init) => {\n const controller = new AbortController()\n const maxAttempts = retries + 1\n const attemptFetch = createRetryFetchCallback({\n apiName,\n controller,\n fetchMethod: resolvedFetchMethod,\n init,\n url,\n })\n\n for (let attemptNumber = 1; attemptNumber <= maxAttempts; attemptNumber++) {\n try {\n const response = await attemptFetch()\n\n if (response) {\n return response\n }\n\n break\n } catch (error) {\n if (!(error instanceof HttpError) || error.status !== RETRY_RESPONSE_STATUS) {\n throw error\n }\n\n const retriesLeft = maxAttempts - attemptNumber\n\n onFailedAttempt?.({\n apiName,\n error,\n attemptNumber,\n retriesLeft,\n } satisfies FetchMethodCallbackOptions)\n\n if (retriesLeft === 0) {\n throw error\n }\n\n await delayRetry(intervalTimeout)\n }\n }\n\n throw new Error(`${apiName} API request to \"${fetchInputToString(url)}\" may not be retried.`)\n }\n}\n","import { createScopedLogger } from '../logger'\nimport type { BaseFetchMethodOptions, FetchMethod, FetchMethodCallbackOptions } from './Fetch'\nimport { fetchInputToString } from './fetchInputToString'\nimport { resolveFetchMethod } from './resolveFetchMethod'\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/** @internal */\nfunction isFetchAbortSignal(signal: unknown): signal is NonNullable<RequestInit['signal']> {\n return typeof signal === 'object' && signal !== null\n}\n\n/**\n * Configuration options for {@link createTimeoutFetchMethod}.\n *\n * @public\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 * @defaultValue `3000`\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 package 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 *\n * @public\n */\nexport function createTimeoutFetchMethod({\n apiName = 'Optimization',\n fetchMethod,\n onRequestTimeout,\n requestTimeout = DEFAULT_REQUEST_TIMEOUT,\n}: TimeoutFetchMethodOptions = {}): FetchMethod {\n const resolvedFetchMethod = resolveFetchMethod(fetchMethod)\n\n return async (url, init) => {\n const controller = new AbortController()\n\n const id = setTimeout(() => {\n if (typeof onRequestTimeout === 'function') {\n onRequestTimeout({ apiName })\n } else {\n logger.error(\n `Request to \"${fetchInputToString(url)}\" timed out`,\n new Error('Request timeout'),\n )\n }\n\n controller.abort()\n }, requestTimeout)\n\n const { signal } = controller\n\n if (!isFetchAbortSignal(signal)) {\n throw new Error('AbortController signal is not compatible with fetch.')\n }\n\n const requestInit = { ...init, signal }\n\n const response = await resolvedFetchMethod(url, requestInit)\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 *\n * @see {@link RetryFetchMethodOptions}\n * @see {@link TimeoutFetchMethodOptions}\n *\n * @public\n */\nexport interface ProtectedFetchMethodOptions\n extends RetryFetchMethodOptions, 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 * @throws Error\n * Rethrows the original error after logging, including abort errors.\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 *\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 *\n * @public\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 * @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 (input, init) => {\n * return fetch(input, init)\n * }\n * ```\n *\n * @public\n */\nexport type FetchInput = string | Request\nexport type FetchMethod = (input: FetchInput, 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. It is required in runtimes that do not provide\n * `globalThis.fetch`.\n */\n fetchMethod?: FetchMethod\n}\n\n/**\n * Options passed to callback functions invoked by fetch wrappers.\n *\n * @remarks\n * Not all fields are guaranteed to be present in all callback scenarios.\n *\n * @public\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 {@link 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 Fetch, { type FetchMethod, type ProtectedFetchMethodOptions } from './fetch'\nimport { createScopedLogger } from './logger'\n\nconst logger = createScopedLogger('ApiClient')\n\n/**\n * Default Contentful space environment used when none is explicitly provided.\n *\n * @internal\n */\nconst DEFAULT_ENVIRONMENT = 'master'\n\n/**\n * Configuration options for API clients extending `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 space environment identifier.\n *\n * @remarks\n * Used by the Experience API v3 and Insights API v2\n * `/environments/{environment}/` path segment.\n *\n * @defaultValue `'master'`\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 * Contentful Space identifier used for authentication or tracking.\n */\n spaceId: string\n}\n\n/**\n * Properties that can be shared between global and per-client API configuration.\n *\n * @public\n */\nexport type GlobalApiConfigProperties = 'environment' | 'fetchOptions' | 'spaceId'\n\n/**\n * Base class for API clients that provides shared configuration and error logging.\n *\n * @remarks\n * This abstract class is intended for internal use within the package and\n * must not be treated as part of the public API surface.\n *\n * Concrete API clients must 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 *\n * @internal\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 * Contentful Space identifier used for authentication or tracking.\n */\n protected readonly spaceId: string\n\n /**\n * Contentful space 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, spaceId, environment }: ApiConfig) {\n this.spaceId = spaceId\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 * @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 BatchExperienceRequestData,\n BatchExperienceResponse,\n ExperienceEventArray,\n ExperienceRequestData,\n ExperienceResponse,\n parseWithFriendlyError,\n type BatchExperienceEventArray,\n type BatchExperienceResponseData,\n type ExperienceRequestOptions as ExperienceRequestBodyOptions,\n type OptimizationData,\n} from '../api-schemas'\nimport ApiClientBase, { type ApiConfig } from '../ApiClientBase'\nimport { createScopedLogger } from '../logger'\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 *\n * @internal\n */\nexport type Feature = 'ip-enrichment' | 'location'\n\n/**\n * Options that control how requests to the Experience API are handled.\n *\n * @public\n */\nexport interface ExperienceApiClientRequestOptions {\n /**\n * Enabled features (for example, `\"ip-enrichment\"`) for the API to use for this request.\n *\n * @remarks\n * When omitted, the API can apply a default set of features.\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 otherwise uses\n * the server IP.\n */\n ip?: string\n\n /**\n * Experience API `locale` query parameter used to translate profile location fields such as\n * `location.city` and `location.country`.\n *\n * @remarks\n * When omitted, the API can use a server-side default.\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: ExperienceApiClientRequestOptions\n}\n\n/**\n * Parameters used when creating a profile.\n *\n * @public\n */\nexport interface 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 *\n * @public\n */\nexport interface 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 *\n * @public\n */\nexport interface 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 *\n * @public\n */\nexport interface BatchUpdateProfileParams {\n /**\n * Batch of events to process.\n */\n events: BatchExperienceEventArray\n}\n\n/**\n * Configuration for {@link ExperienceApiClient}.\n *\n * @public\n */\nexport interface ExperienceApiClientConfig extends ApiConfig, ExperienceApiClientRequestOptions {}\n\n/**\n * Client for interacting with the Experience API.\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 * spaceId: 'space-id',\n * environment: 'master',\n * })\n *\n * const profile = await client.getProfile('profile-id')\n * ```\n *\n * Extends `ApiClientBase`.\n *\n * @public\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?: ExperienceApiClientRequestOptions['enabledFeatures']\n private readonly ip?: ExperienceApiClientRequestOptions['ip']\n private locale?: ExperienceApiClientRequestOptions['locale']\n private readonly plainText?: ExperienceApiClientRequestOptions['plainText']\n private readonly preflight?: ExperienceApiClientRequestOptions['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 * Update the default Experience API locale used when request options omit `locale`.\n *\n * @param locale - Next default Experience API locale.\n *\n * @public\n */\n public setLocale(locale: ExperienceApiClientRequestOptions['locale']): void {\n this.locale = locale\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 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<ExperienceApiClientRequestOptions, '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 `v3/spaces/${this.spaceId}/environments/${this.environment}/profiles/${id}`,\n options,\n ),\n {\n method: 'GET',\n },\n )\n\n const {\n data: { changes, experiences, profile },\n } = parseWithFriendlyError(ExperienceResponse, await response.json())\n\n const data = { changes, selectedOptimizations: 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: ExperienceApiClientRequestOptions = {},\n ): Promise<OptimizationData> {\n const requestName = 'Create Profile'\n\n logger.info(`Sending \"${requestName}\" request`)\n\n const body = this.constructExperienceRequestBody(events, options)\n\n logger.debug(`\"${requestName}\" request body:`, body)\n\n try {\n const response = await this.makeProfileMutationRequest({\n url: `v3/spaces/${this.spaceId}/environments/${this.environment}/profiles`,\n body,\n options,\n })\n\n const {\n data: { changes, experiences, profile },\n } = parseWithFriendlyError(ExperienceResponse, await response.json())\n\n const data = { changes, selectedOptimizations: 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 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: ExperienceApiClientRequestOptions = {},\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 = this.constructExperienceRequestBody(events, options)\n\n logger.debug(`\"${requestName}\" request body:`, body)\n\n try {\n const response = await this.makeProfileMutationRequest({\n url: `v3/spaces/${this.spaceId}/environments/${this.environment}/profiles/${profileId}`,\n body,\n options,\n })\n\n const {\n data: { changes, experiences, profile },\n } = parseWithFriendlyError(ExperienceResponse, await response.json())\n\n const data = { changes, selectedOptimizations: 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?: ExperienceApiClientRequestOptions,\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 * Batch requests must contain at least one event. Every event must contain\n * an anonymous ID. Profiles will be created or updated according to the\n * 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 * { anonymousId: 'anon-1', type: 'identify', ... },\n * { anonymousId: 'anon-2', type: 'identify', ... },\n * ],\n * })\n * ```\n */\n public async upsertManyProfiles(\n { events }: BatchUpdateProfileParams,\n options: ExperienceApiClientRequestOptions = {},\n ): Promise<BatchExperienceResponseData['profiles']> {\n const requestName = 'Upsert Many Profiles'\n\n logger.info(`Sending \"${requestName}\" request`)\n\n const body = parseWithFriendlyError(BatchExperienceRequestData, {\n 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: `v3/spaces/${this.spaceId}/environments/${this.environment}/events`,\n body,\n options: { plainText: false, ...options },\n })\n\n const {\n data: { profiles },\n } = parseWithFriendlyError(BatchExperienceResponse, 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 can influence query parameters.\n * @returns The fully constructed URL as a string.\n *\n * @internal\n */\n private constructUrl(path: string, options: ExperienceApiClientRequestOptions): 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 can 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 }: ExperienceApiClientRequestOptions): 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 can 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 }: ExperienceApiClientRequestOptions): ExperienceRequestBodyOptions => {\n const bodyOptions: ExperienceRequestBodyOptions = {}\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 /**\n * Construct and validate the singular Experience mutation request payload.\n *\n * @param events - Events for the Experience API to evaluate.\n * @param options - Request options that can contribute body options.\n * @returns Validated singular Experience request body.\n *\n * @internal\n */\n private constructExperienceRequestBody(\n events: ExperienceEventArray,\n options: ExperienceApiClientRequestOptions,\n ): ExperienceRequestData {\n return ExperienceRequestData.parse({\n events: parseWithFriendlyError(ExperienceEventArray, events),\n options: this.constructBodyOptions(options),\n })\n }\n}\n","import { BatchInsightsEventArray, parseWithFriendlyError } from '../api-schemas'\nimport ApiClientBase, { type ApiConfig } from '../ApiClientBase'\nimport { createScopedLogger } from '../logger'\n\nconst logger = createScopedLogger('ApiClient:Insights')\nconst BEACON_FALLBACK_MESSAGE = 'beacon failed; falling back to fetch'\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 */\nexport interface InsightsApiClientRequestOptions {\n /**\n * Sender used to enqueue serialized events via the Beacon API or a similar mechanism.\n *\n * @param url - Target URL for the batched events.\n * @param body - Serialized batched insights events to be sent.\n * @returns `true` if the events were successfully queued, `false` otherwise.\n *\n * @remarks\n * This option is intended for last-chance lifecycle delivery. If it returns\n * `false` or throws, the client falls back to emitting events immediately via\n * `fetch` with `keepalive`.\n */\n beacon?: (url: string, body: string) => boolean\n}\n\n/**\n * Configuration for {@link InsightsApiClient}.\n *\n * @public\n */\nexport interface InsightsApiClientConfig extends ApiConfig {}\n\n/**\n * Client for sending analytics and insights events to the Ninetailed Insights API.\n *\n * @remarks\n * This client is optimized for sending batched events, optionally using a\n * custom beacon-like sender for last-chance lifecycle delivery.\n *\n * @example\n * ```ts\n * const insightsClient = new InsightsApiClient({\n * spaceId: 'space-id',\n * environment: 'master',\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 *\n * Extends `ApiClientBase`.\n *\n * @public\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 * 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 * spaceId: 'space-id',\n * environment: 'master',\n * })\n * ```\n */\n constructor(config: InsightsApiClientConfig) {\n super('Insights', config)\n\n const { baseUrl } = config\n\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- Set default for anything falsey\n this.baseUrl = baseUrl || INSIGHTS_BASE_URL\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 `beacon` sender.\n * @returns `true` when the event batch is successfully queued by the beacon\n * sender or a direct request is successfully sent, `false` otherwise.\n *\n * @remarks\n * If a `beacon` sender is provided, it will be invoked first with the\n * serialized request body. When the sender returns `true`, the events are\n * considered successfully queued and no network request is made by this\n * method.\n *\n * If the sender is missing, returns `false`, or throws, the events are\n * emitted immediately via `fetch`.\n *\n * @example\n * ```ts\n * const success = await insightsClient.sendBatchEvents(batches)\n * ```\n *\n * @example\n * ```ts\n * // Use Beacon for a last-chance lifecycle flush\n * const success = await insightsClient.sendBatchEvents(batches, {\n * beacon: (url, body) => navigator.sendBeacon(url, body),\n * })\n * ```\n */\n public async sendBatchEvents(\n batches: BatchInsightsEventArray,\n options: InsightsApiClientRequestOptions = {},\n ): Promise<boolean> {\n const { beacon } = options\n\n const url = new URL(\n `v2/spaces/${this.spaceId}/environments/${this.environment}/events`,\n this.baseUrl,\n )\n const urlString = url.toString()\n\n const body = parseWithFriendlyError(BatchInsightsEventArray, batches)\n const serializedBody = JSON.stringify(body)\n\n if (beacon) {\n logger.debug('Queueing events via beacon')\n\n try {\n const beaconSuccessfullyQueued = beacon(urlString, serializedBody)\n\n if (beaconSuccessfullyQueued) {\n return true\n }\n\n logger.warn(BEACON_FALLBACK_MESSAGE)\n } catch (error) {\n logger.warn(BEACON_FALLBACK_MESSAGE, error)\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(urlString, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: serializedBody,\n keepalive: !!beacon,\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 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 Experience API client.\n *\n * @remarks\n * Shared fields (`spaceId`, `environment`, and `fetchOptions`) are inherited\n * from top-level config; this object is for Experience-specific options.\n */\n experience?: Omit<ExperienceApiClientConfig, GlobalApiConfigProperties>\n\n /**\n * Configuration for the Insights API client.\n *\n * @remarks\n * Shared fields (`spaceId`, `environment`, and `fetchOptions`) are inherited\n * from top-level config; this object is for Insights-specific options.\n */\n insights?: Omit<InsightsApiClientConfig, GlobalApiConfigProperties>\n}\n\n/**\n * Aggregated API client providing access to Experience and Insights APIs.\n *\n * @remarks\n * This client encapsulates shared configuration and exposes dedicated\n * sub-clients for experience and insights use cases.\n *\n * @example\n * ```ts\n * const client = new ApiClient({\n * spaceId: 'space-id',\n * environment: 'master',\n * experience: {\n * // experience-specific overrides\n * },\n * insights: {\n * // insights-specific overrides\n * },\n * })\n *\n * const profile = await client.experience.getProfile('profile-id')\n * await client.insights.sendBatchEvents(batches)\n * ```\n *\n * @see {@link ExperienceApiClient}\n * @see {@link InsightsApiClient}\n *\n * @public\n */\nexport default class ApiClient {\n /**\n * Shared configuration applied to both Experience and Insights clients.\n *\n * @see {@link ApiConfig}\n */\n readonly config: ApiConfig\n\n /**\n * Client for experience-related operations.\n *\n * @see {@link ExperienceApiClient}\n */\n readonly experience: ExperienceApiClient\n\n /**\n * Client for insights-related operations.\n *\n * @see {@link InsightsApiClient}\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 { experience, insights, spaceId, environment, fetchOptions } = config\n const apiConfig: ApiConfig = {\n spaceId,\n environment,\n fetchOptions,\n }\n\n this.config = apiConfig\n\n this.experience = new ExperienceApiClient({\n ...apiConfig,\n ...experience,\n })\n\n this.insights = new InsightsApiClient({\n ...apiConfig,\n ...insights,\n })\n }\n}\n"],"names":["fetchInputToString","input","MISSING_FETCH_METHOD_MESSAGE","resolveFetchMethod","fetchMethod","globalThis","Error","logger","createScopedLogger","DEFAULT_INTERVAL_TIMEOUT","DEFAULT_RETRY_COUNT","RETRY_RESPONSE_STATUS","HTTP_ERROR_RESPONSE_STATUS","HttpError","message","status","Object","createRetryFetchCallback","apiName","controller","init","url","urlLabel","response","httpError","error","delayRetry","intervalTimeout","promise","resolve","Promise","setTimeout","undefined","createRetryFetchMethod","onFailedAttempt","retries","resolvedFetchMethod","AbortController","maxAttempts","attemptFetch","attemptNumber","retriesLeft","DEFAULT_REQUEST_TIMEOUT","isFetchAbortSignal","signal","createTimeoutFetchMethod","onRequestTimeout","requestTimeout","id","requestInit","clearTimeout","createProtectedFetchMethod","options","timeoutFetchMethod","retryFetchMethod","Fetch","DEFAULT_ENVIRONMENT","ApiClientBase","name","fetchOptions","spaceId","environment","requestName","EXPERIENCE_BASE_URL","ExperienceApiClient","config","baseUrl","enabledFeatures","ip","locale","plainText","preflight","changes","experiences","profile","parseWithFriendlyError","ExperienceResponse","data","body","JSON","events","profileId","BatchExperienceRequestData","profiles","BatchExperienceResponse","path","URL","headers","Map","bodyOptions","Array","ExperienceRequestData","ExperienceEventArray","BEACON_FALLBACK_MESSAGE","INSIGHTS_BASE_URL","InsightsApiClient","batches","beacon","urlString","BatchInsightsEventArray","serializedBody","beaconSuccessfullyQueued","ApiClient","experience","insights","apiConfig"],"mappings":";;AAEO,MAAMA,qBAAqB,CAACC;IACjC,IAAI,AAAiB,YAAjB,OAAOA,OAAoB,OAAOA;IAEtC,OAAOA,MAAM,GAAG;AAClB;ACJA,MAAMC,+BAA+B;AAE9B,SAASC,mBAAmBC,WAAyB;IAC1D,IAAIA,aAAa,OAAOA;IAExB,IAAI,AAA4B,cAA5B,OAAOC,WAAW,KAAK,EACzB,OAAOA,WAAW,KAAK,CAAC,IAAI,CAACA;IAG/B,MAAM,IAAIC,MAAMJ;AAClB;ACPA,MAAMK,SAASC,mBAAmB;AAOlC,MAAMC,2BAA2B;AAOjC,MAAMC,sBAAsB;AAU5B,MAAMC,wBAAwB;AAO9B,MAAMC,6BAA6B;AAOnC,MAAMC,kBAAkBP;IAIf,OAAc;IAQrB,YAAYQ,OAAe,EAAEC,SAAiBH,0BAA0B,CAAE;QACxE,KAAK,CAACE;QACNE,OAAO,cAAc,CAAC,IAAI,EAAEH,UAAU,SAAS;QAC/C,IAAI,CAAC,MAAM,GAAGE;IAChB;AACF;AAqEA,SAASE,yBAAyB,EAChCC,UAAU,cAAc,EACxBC,UAAU,EACVf,WAAW,EACXgB,IAAI,EACJC,GAAG,EACuB;IAC1B,OAAO;QACL,MAAMC,WAAWtB,mBAAmBqB;QAEpC,IAAI;YACF,MAAME,WAAW,MAAMnB,YAAYiB,KAAKD;YAExC,IAAIG,SAAS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;YACxC,GAAGyC,SAAS;YACZ,GAAGF,UAAU;QACf;QAEA,IAAI,CAAC,QAAQ,GAAG,IAAIR,kBAAkB;YACpC,GAAGU,SAAS;YACZ,GAAGD,QAAQ;QACb;IACF;AACF"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/fetch/fetchInputToString.ts","../src/fetch/resolveFetchMethod.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/experience/ExperienceApiClient.ts","../src/insights/InsightsApiClient.ts","../src/ApiClient.ts"],"sourcesContent":["import type { FetchMethod } from './Fetch'\n\nexport const fetchInputToString = (input: Parameters<FetchMethod>[0]): string => {\n if (typeof input === 'string') return input\n\n return input.url\n}\n","import type { FetchMethod } from './Fetch'\n\nconst MISSING_FETCH_METHOD_MESSAGE = 'No fetch implementation available. Provide a fetchMethod.'\n\nexport function resolveFetchMethod(fetchMethod?: FetchMethod): FetchMethod {\n if (fetchMethod) return fetchMethod\n\n if (typeof globalThis.fetch === 'function') {\n return globalThis.fetch.bind(globalThis)\n }\n\n throw new Error(MISSING_FETCH_METHOD_MESSAGE)\n}\n","import { createScopedLogger } from '../logger'\nimport type { BaseFetchMethodOptions, FetchMethod, FetchMethodCallbackOptions } from './Fetch'\nimport { fetchInputToString } from './fetchInputToString'\nimport { resolveFetchMethod } from './resolveFetchMethod'\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 * @remarks\n * This value is fixed to `503 Service Unavailable`.\n *\n * @internal\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 *\n * @public\n */\nexport interface RetryFetchMethodOptions extends BaseFetchMethodOptions {\n /**\n * Delay (in milliseconds) between retry attempts.\n *\n * @defaultValue `0`\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 * @defaultValue `1`\n */\n retries?: number\n}\n\n/**\n * Internal configuration passed to the retry callback.\n *\n * @internal\n */\ninterface RetryFetchCallbackOptions extends RetryFetchMethodOptions {\n fetchMethod: FetchMethod\n\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: Parameters<FetchMethod>[1]\n\n /**\n * Request URL.\n */\n url: Parameters<FetchMethod>[0]\n}\n\n/**\n * Creates a callback function used by the retry loop to perform a protected fetch attempt.\n *\n * @param options - Internal options controlling request execution and retry classification.\n * @returns A function that performs one fetch attempt and either:\n * - returns a successful {@link Response},\n * - throws {@link HttpError} for retriable `503` responses, or\n * - aborts and returns `undefined` for non-retriable failures.\n *\n * @internal\n */\nfunction createRetryFetchCallback({\n apiName = 'Optimization',\n controller,\n fetchMethod,\n init,\n url,\n}: RetryFetchCallbackOptions) {\n return async () => {\n const urlLabel = fetchInputToString(url)\n\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 \"${urlLabel}\" 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 \"${urlLabel}\" 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 \"${urlLabel}\":`, 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 \"${urlLabel}\" failed:`, error)\n\n controller.abort()\n }\n }\n}\n\n/**\n * Waits for the configured retry delay between attempts.\n *\n * @param intervalTimeout - Delay in milliseconds before the next retry attempt.\n * @returns A promise that resolves immediately when delay is non-positive,\n * otherwise after the timeout elapses.\n *\n * @internal\n */\nasync function delayRetry(intervalTimeout: number): Promise<void> {\n if (intervalTimeout <= 0) {\n return\n }\n\n const { promise, resolve } = Promise.withResolvers<undefined>()\n setTimeout(() => {\n resolve(undefined)\n }, intervalTimeout)\n await promise\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 * @throws Error\n * Thrown when the request cannot be retried and no successful response is obtained.\n *\n * @remarks\n * This wrapper uses a lightweight internal retry loop and an {@link AbortController}\n * to cancel pending requests when a non-retriable error occurs.\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 *\n * @public\n */\nexport function createRetryFetchMethod({\n apiName = 'Optimization',\n fetchMethod,\n intervalTimeout = DEFAULT_INTERVAL_TIMEOUT,\n onFailedAttempt,\n retries = DEFAULT_RETRY_COUNT,\n}: RetryFetchMethodOptions = {}): FetchMethod {\n const resolvedFetchMethod = resolveFetchMethod(fetchMethod)\n\n return async (url, init) => {\n const controller = new AbortController()\n const maxAttempts = retries + 1\n const attemptFetch = createRetryFetchCallback({\n apiName,\n controller,\n fetchMethod: resolvedFetchMethod,\n init,\n url,\n })\n\n for (let attemptNumber = 1; attemptNumber <= maxAttempts; attemptNumber++) {\n try {\n const response = await attemptFetch()\n\n if (response) {\n return response\n }\n\n break\n } catch (error) {\n if (!(error instanceof HttpError) || error.status !== RETRY_RESPONSE_STATUS) {\n throw error\n }\n\n const retriesLeft = maxAttempts - attemptNumber\n\n onFailedAttempt?.({\n apiName,\n error,\n attemptNumber,\n retriesLeft,\n } satisfies FetchMethodCallbackOptions)\n\n if (retriesLeft === 0) {\n throw error\n }\n\n await delayRetry(intervalTimeout)\n }\n }\n\n throw new Error(`${apiName} API request to \"${fetchInputToString(url)}\" may not be retried.`)\n }\n}\n","import { createScopedLogger } from '../logger'\nimport type { BaseFetchMethodOptions, FetchMethod, FetchMethodCallbackOptions } from './Fetch'\nimport { fetchInputToString } from './fetchInputToString'\nimport { resolveFetchMethod } from './resolveFetchMethod'\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/** @internal */\nfunction isFetchAbortSignal(signal: unknown): signal is NonNullable<RequestInit['signal']> {\n return typeof signal === 'object' && signal !== null\n}\n\n/**\n * Configuration options for {@link createTimeoutFetchMethod}.\n *\n * @public\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 * @defaultValue `3000`\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 package 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 *\n * @public\n */\nexport function createTimeoutFetchMethod({\n apiName = 'Optimization',\n fetchMethod,\n onRequestTimeout,\n requestTimeout = DEFAULT_REQUEST_TIMEOUT,\n}: TimeoutFetchMethodOptions = {}): FetchMethod {\n const resolvedFetchMethod = resolveFetchMethod(fetchMethod)\n\n return async (url, init) => {\n const controller = new AbortController()\n\n const id = setTimeout(() => {\n if (typeof onRequestTimeout === 'function') {\n onRequestTimeout({ apiName })\n } else {\n logger.error(\n `Request to \"${fetchInputToString(url)}\" timed out`,\n new Error('Request timeout'),\n )\n }\n\n controller.abort()\n }, requestTimeout)\n\n const { signal } = controller\n\n if (!isFetchAbortSignal(signal)) {\n throw new Error('AbortController signal is not compatible with fetch.')\n }\n\n const requestInit = { ...init, signal }\n\n const response = await resolvedFetchMethod(url, requestInit)\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 *\n * @see {@link RetryFetchMethodOptions}\n * @see {@link TimeoutFetchMethodOptions}\n *\n * @public\n */\nexport interface ProtectedFetchMethodOptions\n extends RetryFetchMethodOptions, 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 * @throws Error\n * Rethrows the original error after logging, including abort errors.\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 *\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 *\n * @public\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 * @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 (input, init) => {\n * return fetch(input, init)\n * }\n * ```\n *\n * @public\n */\nexport type FetchInput = string | Request\nexport type FetchMethod = (input: FetchInput, 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. It is required in runtimes that do not provide\n * `globalThis.fetch`.\n */\n fetchMethod?: FetchMethod\n}\n\n/**\n * Options passed to callback functions invoked by fetch wrappers.\n *\n * @remarks\n * Not all fields are guaranteed to be present in all callback scenarios.\n *\n * @public\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 {@link 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 Fetch, { type FetchMethod, type ProtectedFetchMethodOptions } from './fetch'\nimport { createScopedLogger } from './logger'\n\nconst logger = createScopedLogger('ApiClient')\n\n/**\n * Default Contentful space environment used when none is explicitly provided.\n *\n * @internal\n */\nconst DEFAULT_ENVIRONMENT = 'master'\n\n/**\n * Configuration options for API clients extending `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 space environment identifier.\n *\n * @remarks\n * Used by the Experience API v3 and Insights API v2\n * `/environments/{environment}/` path segment.\n *\n * @defaultValue `'master'`\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 * Contentful Space identifier used for authentication or tracking.\n */\n spaceId: string\n}\n\n/**\n * Properties that can be shared between global and per-client API configuration.\n *\n * @public\n */\nexport type GlobalApiConfigProperties = 'environment' | 'fetchOptions' | 'spaceId'\n\n/**\n * Base class for API clients that provides shared configuration and error logging.\n *\n * @remarks\n * This abstract class is intended for internal use within the package and\n * must not be treated as part of the public API surface.\n *\n * Concrete API clients must 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 *\n * @internal\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 * Contentful Space identifier used for authentication or tracking.\n */\n protected readonly spaceId: string\n\n /**\n * Contentful space 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, spaceId, environment }: ApiConfig) {\n this.spaceId = spaceId\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 * @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 BatchExperienceRequestData,\n BatchExperienceResponse,\n ExperienceEventArray,\n ExperienceRequestData,\n ExperienceResponse,\n parseWithFriendlyError,\n type BatchExperienceEventArray,\n type BatchExperienceResponseData,\n type ExperienceRequestOptions as ExperienceRequestBodyOptions,\n type GeoLocation,\n type OptimizationData,\n} from '../api-schemas'\nimport ApiClientBase, { type ApiConfig } from '../ApiClientBase'\nimport { createScopedLogger } from '../logger'\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 *\n * @internal\n */\nexport type Feature = 'ip-enrichment' | 'location'\n\n/**\n * Options that control how requests to the Experience API are handled.\n *\n * @public\n */\nexport interface ExperienceApiClientRequestOptions {\n /**\n * Enabled features (for example, `\"ip-enrichment\"`) for the API to use for this request.\n *\n * @remarks\n * When omitted, the API can apply a default set of features.\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 otherwise uses\n * the server IP.\n */\n ip?: string\n\n /**\n * Experience API `locale` query parameter used to translate profile location fields such as\n * `location.city` and `location.country`.\n *\n * @remarks\n * When omitted, the API can use a server-side default.\n */\n locale?: string\n\n /**\n * Request location for `createProfile()`, `updateProfile()`, and `upsertProfile()`.\n *\n * @remarks\n * A per-request value replaces the constructor default as a whole object.\n * The API merges each event's `context.location` over this request location.\n * An explicit `{}` overrides the constructor default and supplies an empty\n * request-location default instead of Cloudflare geolocation. When omitted\n * from both sources, existing API fallback behavior applies.\n * This affects evaluation and profile updates; it is not a permanent location lock.\n * For `upsertManyProfiles()`, use each event's `context.location` instead.\n */\n location?: GeoLocation\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: ExperienceApiClientRequestOptions\n}\n\n/**\n * Parameters used when creating a profile.\n *\n * @public\n */\nexport interface 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 *\n * @public\n */\nexport interface 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 *\n * @public\n */\nexport interface 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 *\n * @public\n */\nexport interface BatchUpdateProfileParams {\n /**\n * Batch of events to process.\n */\n events: BatchExperienceEventArray\n}\n\n/**\n * Configuration for {@link ExperienceApiClient}.\n *\n * @public\n */\nexport interface ExperienceApiClientConfig extends ApiConfig, ExperienceApiClientRequestOptions {}\n\n/**\n * Client for interacting with the Experience API.\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 * spaceId: 'space-id',\n * environment: 'master',\n * })\n *\n * const profile = await client.getProfile('profile-id')\n * ```\n *\n * Extends `ApiClientBase`.\n *\n * @public\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?: ExperienceApiClientRequestOptions['enabledFeatures']\n private readonly ip?: ExperienceApiClientRequestOptions['ip']\n private locale?: ExperienceApiClientRequestOptions['locale']\n private readonly location?: ExperienceApiClientRequestOptions['location']\n private readonly plainText?: ExperienceApiClientRequestOptions['plainText']\n private readonly preflight?: ExperienceApiClientRequestOptions['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, location, 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.location = location\n this.plainText = plainText\n this.preflight = preflight\n }\n\n /**\n * Update the default Experience API locale used when request options omit `locale`.\n *\n * @param locale - Next default Experience API locale.\n *\n * @public\n */\n public setLocale(locale: ExperienceApiClientRequestOptions['locale']): void {\n this.locale = locale\n }\n\n /**\n * Retrieves a profile by ID.\n *\n * @param id - The profile ID to retrieve.\n * @param options - Optional request options. `location`, `preflight`, and `plainText`\n * are not allowed here.\n * @returns The current optimization data for the profile.\n *\n * @throws 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<ExperienceApiClientRequestOptions, 'location' | '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 `v3/spaces/${this.spaceId}/environments/${this.environment}/profiles/${id}`,\n options,\n ),\n {\n method: 'GET',\n },\n )\n\n const {\n data: { changes, experiences, profile },\n } = parseWithFriendlyError(ExperienceResponse, await response.json())\n\n const data = { changes, selectedOptimizations: 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: ExperienceApiClientRequestOptions = {},\n ): Promise<OptimizationData> {\n const requestName = 'Create Profile'\n\n logger.info(`Sending \"${requestName}\" request`)\n\n const body = this.constructExperienceRequestBody(events, options)\n\n logger.debug(`\"${requestName}\" request body:`, body)\n\n try {\n const response = await this.makeProfileMutationRequest({\n url: `v3/spaces/${this.spaceId}/environments/${this.environment}/profiles`,\n body,\n options,\n })\n\n const {\n data: { changes, experiences, profile },\n } = parseWithFriendlyError(ExperienceResponse, await response.json())\n\n const data = { changes, selectedOptimizations: 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 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: ExperienceApiClientRequestOptions = {},\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 = this.constructExperienceRequestBody(events, options)\n\n logger.debug(`\"${requestName}\" request body:`, body)\n\n try {\n const response = await this.makeProfileMutationRequest({\n url: `v3/spaces/${this.spaceId}/environments/${this.environment}/profiles/${profileId}`,\n body,\n options,\n })\n\n const {\n data: { changes, experiences, profile },\n } = parseWithFriendlyError(ExperienceResponse, await response.json())\n\n const data = { changes, selectedOptimizations: 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?: ExperienceApiClientRequestOptions,\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 * Batch requests must contain at least one event. Every event must contain\n * an anonymous ID. Profiles will be created or updated according to the\n * 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 * { anonymousId: 'anon-1', type: 'identify', ... },\n * { anonymousId: 'anon-2', type: 'identify', ... },\n * ],\n * })\n * ```\n */\n public async upsertManyProfiles(\n { events }: BatchUpdateProfileParams,\n options: ExperienceApiClientRequestOptions = {},\n ): Promise<BatchExperienceResponseData['profiles']> {\n const requestName = 'Upsert Many Profiles'\n\n logger.info(`Sending \"${requestName}\" request`)\n\n const body = parseWithFriendlyError(BatchExperienceRequestData, {\n 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: `v3/spaces/${this.spaceId}/environments/${this.environment}/events`,\n body,\n options: { plainText: false, ...options },\n })\n\n const {\n data: { profiles },\n } = parseWithFriendlyError(BatchExperienceResponse, 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 can influence query parameters.\n * @returns The fully constructed URL as a string.\n *\n * @internal\n */\n private constructUrl(path: string, options: ExperienceApiClientRequestOptions): 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 can 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 }: ExperienceApiClientRequestOptions): 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 can 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 }: ExperienceApiClientRequestOptions): ExperienceRequestBodyOptions => {\n const bodyOptions: ExperienceRequestBodyOptions = {}\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 /**\n * Construct and validate the singular Experience mutation request payload.\n *\n * @param events - Events for the Experience API to evaluate.\n * @param options - Request options that can contribute body options.\n * @returns Validated singular Experience request body.\n *\n * @internal\n */\n private constructExperienceRequestBody(\n events: ExperienceEventArray,\n options: ExperienceApiClientRequestOptions,\n ): ExperienceRequestData {\n const bodyOptions = this.constructBodyOptions(options)\n const location = options.location ?? this.location\n\n if (location !== undefined) {\n bodyOptions.location = location\n }\n\n return ExperienceRequestData.parse({\n events: parseWithFriendlyError(ExperienceEventArray, events),\n options: bodyOptions,\n })\n }\n}\n","import { BatchInsightsEventArray, parseWithFriendlyError } from '../api-schemas'\nimport ApiClientBase, { type ApiConfig } from '../ApiClientBase'\nimport { createScopedLogger } from '../logger'\n\nconst logger = createScopedLogger('ApiClient:Insights')\nconst BEACON_FALLBACK_MESSAGE = 'beacon failed; falling back to fetch'\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 */\nexport interface InsightsApiClientRequestOptions {\n /**\n * Sender used to enqueue serialized events via the Beacon API or a similar mechanism.\n *\n * @param url - Target URL for the batched events.\n * @param body - Serialized batched insights events to be sent.\n * @returns `true` if the events were successfully queued, `false` otherwise.\n *\n * @remarks\n * This option is intended for last-chance lifecycle delivery. If it returns\n * `false` or throws, the client falls back to emitting events immediately via\n * `fetch` with `keepalive`.\n */\n beacon?: (url: string, body: string) => boolean\n}\n\n/**\n * Configuration for {@link InsightsApiClient}.\n *\n * @public\n */\nexport interface InsightsApiClientConfig extends ApiConfig {}\n\n/**\n * Client for sending analytics and insights events to the Ninetailed Insights API.\n *\n * @remarks\n * This client is optimized for sending batched events, optionally using a\n * custom beacon-like sender for last-chance lifecycle delivery.\n *\n * @example\n * ```ts\n * const insightsClient = new InsightsApiClient({\n * spaceId: 'space-id',\n * environment: 'master',\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 *\n * Extends `ApiClientBase`.\n *\n * @public\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 * 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 * spaceId: 'space-id',\n * environment: 'master',\n * })\n * ```\n */\n constructor(config: InsightsApiClientConfig) {\n super('Insights', config)\n\n const { baseUrl } = config\n\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- Set default for anything falsey\n this.baseUrl = baseUrl || INSIGHTS_BASE_URL\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 `beacon` sender.\n * @returns `true` when the event batch is successfully queued by the beacon\n * sender or a direct request is successfully sent, `false` otherwise.\n *\n * @remarks\n * If a `beacon` sender is provided, it will be invoked first with the\n * serialized request body. When the sender returns `true`, the events are\n * considered successfully queued and no network request is made by this\n * method.\n *\n * If the sender is missing, returns `false`, or throws, the events are\n * emitted immediately via `fetch`.\n *\n * @example\n * ```ts\n * const success = await insightsClient.sendBatchEvents(batches)\n * ```\n *\n * @example\n * ```ts\n * // Use Beacon for a last-chance lifecycle flush\n * const success = await insightsClient.sendBatchEvents(batches, {\n * beacon: (url, body) => navigator.sendBeacon(url, body),\n * })\n * ```\n */\n public async sendBatchEvents(\n batches: BatchInsightsEventArray,\n options: InsightsApiClientRequestOptions = {},\n ): Promise<boolean> {\n const { beacon } = options\n\n const url = new URL(\n `v2/spaces/${this.spaceId}/environments/${this.environment}/events`,\n this.baseUrl,\n )\n const urlString = url.toString()\n\n const body = parseWithFriendlyError(BatchInsightsEventArray, batches)\n const serializedBody = JSON.stringify(body)\n\n if (beacon) {\n logger.debug('Queueing events via beacon')\n\n try {\n const beaconSuccessfullyQueued = beacon(urlString, serializedBody)\n\n if (beaconSuccessfullyQueued) {\n return true\n }\n\n logger.warn(BEACON_FALLBACK_MESSAGE)\n } catch (error) {\n logger.warn(BEACON_FALLBACK_MESSAGE, error)\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(urlString, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: serializedBody,\n keepalive: !!beacon,\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 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 Experience API client.\n *\n * @remarks\n * Shared fields (`spaceId`, `environment`, and `fetchOptions`) are inherited\n * from top-level config; this object is for Experience-specific options.\n */\n experience?: Omit<ExperienceApiClientConfig, GlobalApiConfigProperties>\n\n /**\n * Configuration for the Insights API client.\n *\n * @remarks\n * Shared fields (`spaceId`, `environment`, and `fetchOptions`) are inherited\n * from top-level config; this object is for Insights-specific options.\n */\n insights?: Omit<InsightsApiClientConfig, GlobalApiConfigProperties>\n}\n\n/**\n * Aggregated API client providing access to Experience and Insights APIs.\n *\n * @remarks\n * This client encapsulates shared configuration and exposes dedicated\n * sub-clients for experience and insights use cases.\n *\n * @example\n * ```ts\n * const client = new ApiClient({\n * spaceId: 'space-id',\n * environment: 'master',\n * experience: {\n * // experience-specific overrides\n * },\n * insights: {\n * // insights-specific overrides\n * },\n * })\n *\n * const profile = await client.experience.getProfile('profile-id')\n * await client.insights.sendBatchEvents(batches)\n * ```\n *\n * @see {@link ExperienceApiClient}\n * @see {@link InsightsApiClient}\n *\n * @public\n */\nexport default class ApiClient {\n /**\n * Shared configuration applied to both Experience and Insights clients.\n *\n * @see {@link ApiConfig}\n */\n readonly config: ApiConfig\n\n /**\n * Client for experience-related operations.\n *\n * @see {@link ExperienceApiClient}\n */\n readonly experience: ExperienceApiClient\n\n /**\n * Client for insights-related operations.\n *\n * @see {@link InsightsApiClient}\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 { experience, insights, spaceId, environment, fetchOptions } = config\n const apiConfig: ApiConfig = {\n spaceId,\n environment,\n fetchOptions,\n }\n\n this.config = apiConfig\n\n this.experience = new ExperienceApiClient({\n ...apiConfig,\n ...experience,\n })\n\n this.insights = new InsightsApiClient({\n ...apiConfig,\n ...insights,\n })\n }\n}\n"],"names":["fetchInputToString","input","MISSING_FETCH_METHOD_MESSAGE","resolveFetchMethod","fetchMethod","globalThis","Error","logger","createScopedLogger","DEFAULT_INTERVAL_TIMEOUT","DEFAULT_RETRY_COUNT","RETRY_RESPONSE_STATUS","HTTP_ERROR_RESPONSE_STATUS","HttpError","message","status","Object","createRetryFetchCallback","apiName","controller","init","url","urlLabel","response","httpError","error","delayRetry","intervalTimeout","promise","resolve","Promise","setTimeout","undefined","createRetryFetchMethod","onFailedAttempt","retries","resolvedFetchMethod","AbortController","maxAttempts","attemptFetch","attemptNumber","retriesLeft","DEFAULT_REQUEST_TIMEOUT","isFetchAbortSignal","signal","createTimeoutFetchMethod","onRequestTimeout","requestTimeout","id","requestInit","clearTimeout","createProtectedFetchMethod","options","timeoutFetchMethod","retryFetchMethod","Fetch","DEFAULT_ENVIRONMENT","ApiClientBase","name","fetchOptions","spaceId","environment","requestName","EXPERIENCE_BASE_URL","ExperienceApiClient","config","baseUrl","enabledFeatures","ip","locale","location","plainText","preflight","changes","experiences","profile","parseWithFriendlyError","ExperienceResponse","data","body","JSON","events","profileId","BatchExperienceRequestData","profiles","BatchExperienceResponse","path","URL","headers","Map","bodyOptions","Array","ExperienceRequestData","ExperienceEventArray","BEACON_FALLBACK_MESSAGE","INSIGHTS_BASE_URL","InsightsApiClient","batches","beacon","urlString","BatchInsightsEventArray","serializedBody","beaconSuccessfullyQueued","ApiClient","experience","insights","apiConfig"],"mappings":";;AAEO,MAAMA,qBAAqB,CAACC;IACjC,IAAI,AAAiB,YAAjB,OAAOA,OAAoB,OAAOA;IAEtC,OAAOA,MAAM,GAAG;AAClB;ACJA,MAAMC,+BAA+B;AAE9B,SAASC,mBAAmBC,WAAyB;IAC1D,IAAIA,aAAa,OAAOA;IAExB,IAAI,AAA4B,cAA5B,OAAOC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AACuF,yBAAyBrE;YACvC;QACF;QAEA,MAAMqC,cAAc;QAEpBvD,yBAAO,IAAI,CAAC,CAAC,SAAS,EAAEuD,YAAY,SAAS,CAAC;QAE9CvD,yBAAO,KAAK,CAAC,CAAC,CAAC,EAAEuD,YAAY,eAAe,CAAC,EAAEiB;QAE/C,IAAI;YACF,MAAM,IAAI,CAAC,KAAK,CAACoB,WAAW;gBAC1B,QAAQ;gBACR,SAAS;oBACP,gBAAgB;gBAClB;gBACA,MAAME;gBACN,WAAW,CAAC,CAACH;YACf;YAEA3F,yBAAO,KAAK,CAAC,CAAC,CAAC,EAAEuD,YAAY,gCAAgC,CAAC;YAE9D,OAAO;QACT,EAAE,OAAOrC,OAAO;YACd,IAAI,CAAC,eAAe,CAACA,OAAO;gBAAEqC;YAAY;YAE1C,OAAO;QACT;IACF;AACF;AClIe,MAAMyC;IAMV,OAAiB;IAOjB,WAA+B;IAO/B,SAA2B;IAOpC,YAAYtC,MAAuB,CAAE;QACnC,MAAM,EAAEuC,UAAU,EAAEC,QAAQ,EAAE7C,OAAO,EAAEC,WAAW,EAAEF,YAAY,EAAE,GAAGM;QACrE,MAAMyC,YAAuB;YAC3B9C;YACAC;YACAF;QACF;QAEA,IAAI,CAAC,MAAM,GAAG+C;QAEd,IAAI,CAAC,UAAU,GAAG,IAAI1C,oBAAoB;YACxC,GAAG0C,SAAS;YACZ,GAAGF,UAAU;QACf;QAEA,IAAI,CAAC,QAAQ,GAAG,IAAIR,kBAAkB;YACpC,GAAGU,SAAS;YACZ,GAAGD,QAAQ;QACb;IACF;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentful/optimization-api-client",
3
3
  "description": "API client for Contentful Optimization services",
4
- "version": "2.1.0",
4
+ "version": "2.2.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -64,7 +64,7 @@
64
64
  "gzipBudgets": {
65
65
  "guards.cjs": 550,
66
66
  "guards.mjs": 200,
67
- "index.cjs": 5000,
67
+ "index.cjs": 5200,
68
68
  "index.mjs": 4700
69
69
  }
70
70
  }