@amplitude/analytics-core 2.60.0 → 2.60.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  <p align="center">
2
2
  <a href="https://amplitude.com" target="_blank" align="center">
3
- <img src="https://static.amplitude.com/lightning/46c85bfd91905de8047f1ee65c7c93d6fa9ee6ea/static/media/amplitude-logo-with-text.4fb9e463.svg" width="280">
3
+ <img src="https://static.amplitude.com/brand/amplitude-logo-with-text.svg" width="280">
4
4
  </a>
5
5
  <br />
6
6
  </p>
7
7
 
8
8
  # @amplitude/analytics-core
9
9
 
10
- Internal Node package for Amplitude
10
+ Internal package shared by Amplitude SDKs.
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEvF,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kCAAmC,SAAQ,sBAAsB;IAChF;;OAEG;IACH,YAAY,CAAC,EAAE,8BAA8B,EAAE,CAAC;CACjD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC9B,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAC/B,MAAM,EAAE,OAAO,GACd,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAWrB;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAClD,eAAe,EAAE,OAAO,GAAG,kCAAkC,GAAG,SAAS,EACzE,MAAM,EAAE,OAAO,GACd,kCAAkC,GAAG,SAAS,CAahD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAsHxE"}
1
+ {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEvF,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kCAAmC,SAAQ,sBAAsB;IAChF;;OAEG;IACH,YAAY,CAAC,EAAE,8BAA8B,EAAE,CAAC;CACjD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC9B,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAC/B,MAAM,EAAE,OAAO,GACd,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAWrB;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAClD,eAAe,EAAE,OAAO,GAAG,kCAAkC,GAAG,SAAS,EACzE,MAAM,EAAE,OAAO,GACd,kCAAkC,GAAG,SAAS,CAahD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QA0HxE"}
@@ -202,6 +202,10 @@ function translateRemoteConfigToLocal(config) {
202
202
  frustrationInteractions.deadClicks = frustrationInteractions.deadClick;
203
203
  delete frustrationInteractions.deadClick;
204
204
  }
205
+ if (frustrationInteractions.errorClick) {
206
+ frustrationInteractions.errorClicks = frustrationInteractions.errorClick;
207
+ delete frustrationInteractions.errorClick;
208
+ }
205
209
  }
206
210
  // normalize viewportContentUpdated inside elementInteractions
207
211
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";;;;AAAA,gDAAkD;AAkBlD;;;GAGG;AACH,SAAgB,SAAS,CACvB,SAA8B,EAC9B,SAA+B,EAC/B,MAAe;;IAEf,IAAM,SAAS,GAAa,EAAE,CAAC;;QAC/B,KAAsB,IAAA,KAAA,iBAAA,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAA,gBAAA,4BAAE;YAAlC,IAAM,OAAO,WAAA;YAChB,IAAI;gBACF,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;aACrC;YAAC,OAAO,UAAU,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC,iCAA0B,OAAO,CAAE,EAAE,UAAU,CAAC,CAAC;aAC9D;SACF;;;;;;;;;IAED,OAAO,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAfD,8BAeC;AAED;;;GAGG;AACH,SAAgB,oCAAoC,CAClD,eAAyE,EACzE,MAAe;;;IAEf,IAAI,OAAO,eAAe,KAAK,QAAQ,IAAI,eAAe,KAAK,IAAI,IAAI,CAAC,CAAA,MAAA,eAAe,CAAC,YAAY,0CAAE,MAAM,CAAA,EAAE;QAC5G,OAAO,SAAS,CAAC;KAClB;IAED,IAAM,WAAW,wBAA4C,eAAe,CAAE,CAAC;IAC/E,0BAA0B;IAC1B,IAAM,YAAY,GAAG,MAAA,WAAW,CAAC,YAAY,mCAAI,EAAE,CAAC;;QACpD,KAAmB,IAAA,iBAAA,iBAAA,YAAY,CAAA,0CAAA,oEAAE;YAA5B,IAAM,IAAI,yBAAA;YACb,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC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ACD,OAAO,mBAAmB,CAAC,gBAAgB,CAAC;aAC7C;SACF;KACF;IAAC,OAAO,CAAC,EAAE;QACV,0BAA0B;QAC1B,4CAA4C;KAC7C;AACH,CAAC;AAtHD,oEAsHC","sourcesContent":["import { SAFE_HEADERS } from '../types/constants';\nimport { ILogger } from '../logger';\nimport { NetworkCaptureRule, NetworkTrackingOptions } from '../types/network-tracking';\n\nexport interface NetworkCaptureRuleRemoteConfig extends NetworkCaptureRule {\n /**\n * Related to urls but holds regex strings which will be initialized and appended to urls\n */\n urlsRegex?: string[];\n}\n\nexport interface NetworkTrackingOptionsRemoteConfig extends NetworkTrackingOptions {\n /**\n * Related to urls but holds regex strings which will be initialized and appended to urls\n */\n captureRules?: NetworkCaptureRuleRemoteConfig[];\n}\n\n/**\n * Converts regex string patterns to RegExp objects and appends them to an exact URL list.\n * Invalid patterns are skipped and a warning is logged.\n */\nexport function mergeUrls(\n urlsExact: (string | RegExp)[],\n urlsRegex: string[] | undefined,\n logger: ILogger,\n): (string | RegExp)[] {\n const regexList: RegExp[] = [];\n for (const pattern of urlsRegex ?? []) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n logger.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n return urlsExact.concat(regexList);\n}\n\n/**\n * Transforms networkTracking remote config by merging urlsRegex into urls on each capture rule.\n * Returns a shallow-cloned networkTracking object when transform is needed, otherwise undefined.\n */\nexport function transformNetworkTrackingRemoteConfig(\n networkTracking: boolean | NetworkTrackingOptionsRemoteConfig | undefined,\n logger: ILogger,\n): NetworkTrackingOptionsRemoteConfig | undefined {\n if (typeof networkTracking !== 'object' || networkTracking === null || !networkTracking.captureRules?.length) {\n return undefined;\n }\n\n const transformed: NetworkTrackingOptionsRemoteConfig = { ...networkTracking };\n /* istanbul ignore next */\n const captureRules = transformed.captureRules ?? [];\n for (const rule of captureRules) {\n rule.urls = mergeUrls(rule.urls ?? [], rule.urlsRegex, logger);\n delete rule.urlsRegex;\n }\n return transformed;\n}\n\n/**\n * Performs a deep transformation of a remote config object so that\n * it matches the expected schema of the local config.\n *\n * Specifically, it normalizes nested `enabled` flags into concise union types.\n *\n * ### Transformation Rules:\n * - If an object has `enabled: true`, it is replaced by the same object without the `enabled` field.\n * - If it has only `enabled: true`, it is replaced with `true`.\n * - If it has `enabled: false`, it is replaced with `false` regardless of other fields.\n *\n * ### Examples:\n * Input: { prop: { enabled: true, hello: 'world' }}\n * Output: { prop: { hello: 'world' } }\n *\n * Input: { prop: { enabled: true }}\n * Output: { prop: true }\n *\n * Input: { prop: { enabled: false, hello: 'world' }}\n * Output: { prop: false }\n *\n * Input: { prop: { hello: 'world' }}\n * Output: { prop: { hello: 'world' } } // No change\n *\n * @param config Remote config object to be transformed\n * @returns Transformed config object compatible with local schema\n */\nexport function translateRemoteConfigToLocal(config?: Record<string, any>) {\n // Disabling type checking rules because remote config comes from a remote source\n // and this function needs to handle any unexpected values\n /* eslint-disable @typescript-eslint/no-unsafe-member-access,\n @typescript-eslint/no-unsafe-assignment,\n @typescript-eslint/no-unsafe-argument\n */\n if (typeof config !== 'object' || config === null) {\n return;\n }\n\n // translations are not applied on array properties\n if (Array.isArray(config)) {\n return;\n }\n\n const propertyNames = Object.keys(config);\n for (const propertyName of propertyNames) {\n try {\n const value = config[propertyName];\n // transform objects with { enabled } property to boolean | object\n if (typeof value?.enabled === 'boolean') {\n if (value.enabled) {\n // if enabled is true, set the value to the rest of the object\n // or true if the object has no other properties\n delete value.enabled;\n if (Object.keys(value).length === 0) {\n (config as any)[propertyName] = true;\n }\n } else {\n // If enabled is false, set the value to false\n (config as any)[propertyName] = false;\n }\n }\n\n // recursively translate properties of the value\n translateRemoteConfigToLocal(value as Record<string, any>);\n } catch (e) {\n // a failure here means that an accessor threw an error\n // so don't translate it\n // TODO(diagnostics): add a diagnostic event for this\n }\n }\n\n // translate remote responseHeaders and requestHeaders to local responseHeaders and requestHeaders\n try {\n if (config.autocapture?.networkTracking?.captureRules?.length) {\n for (const rule of config.autocapture.networkTracking.captureRules) {\n for (const header of ['responseHeaders', 'requestHeaders']) {\n const { captureSafeHeaders, allowlist } = rule[header] ?? {};\n if (!captureSafeHeaders && !allowlist) {\n continue;\n }\n // if allowlist is not an array, remote config contract is violated, remove it\n if (allowlist !== undefined && !Array.isArray(allowlist)) {\n delete rule[header];\n continue;\n }\n rule[header] = [...(captureSafeHeaders ? SAFE_HEADERS : []), ...(allowlist ?? [])];\n }\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n // surprise exception, so don't translate it\n }\n\n // alias browser `pageViews` onto React Native `screenViews`. Remote config\n // currently delivers browserSDK-shaped payloads; keep `pageViews` so the\n // browser SDK still receives it.\n if (config.autocapture?.pageViews !== undefined) {\n config.autocapture.screenViews = config.autocapture.pageViews;\n }\n\n // translate frustrationInteractions pluralization\n const frustrationInteractions = config.autocapture?.frustrationInteractions;\n if (frustrationInteractions) {\n if (frustrationInteractions.rageClick) {\n frustrationInteractions.rageClicks = frustrationInteractions.rageClick;\n delete frustrationInteractions.rageClick;\n }\n if (frustrationInteractions.deadClick) {\n frustrationInteractions.deadClicks = frustrationInteractions.deadClick;\n delete frustrationInteractions.deadClick;\n }\n }\n\n // normalize viewportContentUpdated inside elementInteractions\n try {\n const elementInteractions = config.autocapture?.elementInteractions;\n if (elementInteractions && typeof elementInteractions === 'object') {\n // { enabled: true } (no other fields) collapses to `true`; convert back to {} for the SDK.\n if (elementInteractions.viewportContentUpdated === true) {\n elementInteractions.viewportContentUpdated = {};\n }\n // { enabled: false, ... } collapses to `false`; convert back to { enabled: false } for the SDK.\n if (elementInteractions.viewportContentUpdated === false) {\n elementInteractions.viewportContentUpdated = { enabled: false };\n }\n // Migrate deprecated top-level exposureDuration to viewportContentUpdated.exposureDuration\n if (elementInteractions.exposureDuration !== undefined) {\n const viewportContentUpdated = elementInteractions.viewportContentUpdated;\n if (viewportContentUpdated === undefined) {\n elementInteractions.viewportContentUpdated = { exposureDuration: elementInteractions.exposureDuration };\n } else if (\n typeof viewportContentUpdated === 'object' &&\n viewportContentUpdated.exposureDuration === undefined &&\n viewportContentUpdated.enabled !== false\n ) {\n viewportContentUpdated.exposureDuration = elementInteractions.exposureDuration;\n }\n delete elementInteractions.exposureDuration;\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n // surprise exception, so don't translate it\n }\n}\n"]}
1
+ {"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";;;;AAAA,gDAAkD;AAkBlD;;;GAGG;AACH,SAAgB,SAAS,CACvB,SAA8B,EAC9B,SAA+B,EAC/B,MAAe;;IAEf,IAAM,SAAS,GAAa,EAAE,CAAC;;QAC/B,KAAsB,IAAA,KAAA,iBAAA,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAA,gBAAA,4BAAE;YAAlC,IAAM,OAAO,WAAA;YAChB,IAAI;gBACF,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;aACrC;YAAC,OAAO,UAAU,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC,iCAA0B,OAAO,CAAE,EAAE,UAAU,CAAC,CAAC;aAC9D;SACF;;;;;;;;;IAED,OAAO,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAfD,8BAeC;AAED;;;GAGG;AACH,SAAgB,oCAAoC,CAClD,eAAyE,EACzE,MAAe;;;IAEf,IAAI,OAAO,eAAe,KAAK,QAAQ,IAAI,eAAe,KAAK,IAAI,IAAI,CAAC,CAAA,MAAA,eAAe,CAAC,YAAY,0CAAE,MAAM,CAAA,EAAE;QAC5G,OAAO,SAAS,CAAC;KAClB;IAED,IAAM,WAAW,wBAA4C,eAAe,CAAE,CAAC;IAC/E,0BAA0B;IAC1B,IAAM,YAAY,GAAG,MAAA,WAAW,CAAC,YAAY,mCAAI,EAAE,CAAC;;QACpD,KAAmB,IAAA,iBAAA,iBAAA,YAAY,CAAA,0CA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S,EAAE;oBACxC,mBAAmB,CAAC,sBAAsB,GAAG,EAAE,gBAAgB,EAAE,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;iBACzG;qBAAM,IACL,OAAO,sBAAsB,KAAK,QAAQ;oBAC1C,sBAAsB,CAAC,gBAAgB,KAAK,SAAS;oBACrD,sBAAsB,CAAC,OAAO,KAAK,KAAK,EACxC;oBACA,sBAAsB,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;iBAChF;gBACD,OAAO,mBAAmB,CAAC,gBAAgB,CAAC;aAC7C;SACF;KACF;IAAC,OAAO,CAAC,EAAE;QACV,0BAA0B;QAC1B,4CAA4C;KAC7C;AACH,CAAC;AA1HD,oEA0HC","sourcesContent":["import { SAFE_HEADERS } from '../types/constants';\nimport { ILogger } from '../logger';\nimport { NetworkCaptureRule, NetworkTrackingOptions } from '../types/network-tracking';\n\nexport interface NetworkCaptureRuleRemoteConfig extends NetworkCaptureRule {\n /**\n * Related to urls but holds regex strings which will be initialized and appended to urls\n */\n urlsRegex?: string[];\n}\n\nexport interface NetworkTrackingOptionsRemoteConfig extends NetworkTrackingOptions {\n /**\n * Related to urls but holds regex strings which will be initialized and appended to urls\n */\n captureRules?: NetworkCaptureRuleRemoteConfig[];\n}\n\n/**\n * Converts regex string patterns to RegExp objects and appends them to an exact URL list.\n * Invalid patterns are skipped and a warning is logged.\n */\nexport function mergeUrls(\n urlsExact: (string | RegExp)[],\n urlsRegex: string[] | undefined,\n logger: ILogger,\n): (string | RegExp)[] {\n const regexList: RegExp[] = [];\n for (const pattern of urlsRegex ?? []) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n logger.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n return urlsExact.concat(regexList);\n}\n\n/**\n * Transforms networkTracking remote config by merging urlsRegex into urls on each capture rule.\n * Returns a shallow-cloned networkTracking object when transform is needed, otherwise undefined.\n */\nexport function transformNetworkTrackingRemoteConfig(\n networkTracking: boolean | NetworkTrackingOptionsRemoteConfig | undefined,\n logger: ILogger,\n): NetworkTrackingOptionsRemoteConfig | undefined {\n if (typeof networkTracking !== 'object' || networkTracking === null || !networkTracking.captureRules?.length) {\n return undefined;\n }\n\n const transformed: NetworkTrackingOptionsRemoteConfig = { ...networkTracking };\n /* istanbul ignore next */\n const captureRules = transformed.captureRules ?? [];\n for (const rule of captureRules) {\n rule.urls = mergeUrls(rule.urls ?? [], rule.urlsRegex, logger);\n delete rule.urlsRegex;\n }\n return transformed;\n}\n\n/**\n * Performs a deep transformation of a remote config object so that\n * it matches the expected schema of the local config.\n *\n * Specifically, it normalizes nested `enabled` flags into concise union types.\n *\n * ### Transformation Rules:\n * - If an object has `enabled: true`, it is replaced by the same object without the `enabled` field.\n * - If it has only `enabled: true`, it is replaced with `true`.\n * - If it has `enabled: false`, it is replaced with `false` regardless of other fields.\n *\n * ### Examples:\n * Input: { prop: { enabled: true, hello: 'world' }}\n * Output: { prop: { hello: 'world' } }\n *\n * Input: { prop: { enabled: true }}\n * Output: { prop: true }\n *\n * Input: { prop: { enabled: false, hello: 'world' }}\n * Output: { prop: false }\n *\n * Input: { prop: { hello: 'world' }}\n * Output: { prop: { hello: 'world' } } // No change\n *\n * @param config Remote config object to be transformed\n * @returns Transformed config object compatible with local schema\n */\nexport function translateRemoteConfigToLocal(config?: Record<string, any>) {\n // Disabling type checking rules because remote config comes from a remote source\n // and this function needs to handle any unexpected values\n /* eslint-disable @typescript-eslint/no-unsafe-member-access,\n @typescript-eslint/no-unsafe-assignment,\n @typescript-eslint/no-unsafe-argument\n */\n if (typeof config !== 'object' || config === null) {\n return;\n }\n\n // translations are not applied on array properties\n if (Array.isArray(config)) {\n return;\n }\n\n const propertyNames = Object.keys(config);\n for (const propertyName of propertyNames) {\n try {\n const value = config[propertyName];\n // transform objects with { enabled } property to boolean | object\n if (typeof value?.enabled === 'boolean') {\n if (value.enabled) {\n // if enabled is true, set the value to the rest of the object\n // or true if the object has no other properties\n delete value.enabled;\n if (Object.keys(value).length === 0) {\n (config as any)[propertyName] = true;\n }\n } else {\n // If enabled is false, set the value to false\n (config as any)[propertyName] = false;\n }\n }\n\n // recursively translate properties of the value\n translateRemoteConfigToLocal(value as Record<string, any>);\n } catch (e) {\n // a failure here means that an accessor threw an error\n // so don't translate it\n // TODO(diagnostics): add a diagnostic event for this\n }\n }\n\n // translate remote responseHeaders and requestHeaders to local responseHeaders and requestHeaders\n try {\n if (config.autocapture?.networkTracking?.captureRules?.length) {\n for (const rule of config.autocapture.networkTracking.captureRules) {\n for (const header of ['responseHeaders', 'requestHeaders']) {\n const { captureSafeHeaders, allowlist } = rule[header] ?? {};\n if (!captureSafeHeaders && !allowlist) {\n continue;\n }\n // if allowlist is not an array, remote config contract is violated, remove it\n if (allowlist !== undefined && !Array.isArray(allowlist)) {\n delete rule[header];\n continue;\n }\n rule[header] = [...(captureSafeHeaders ? SAFE_HEADERS : []), ...(allowlist ?? [])];\n }\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n // surprise exception, so don't translate it\n }\n\n // alias browser `pageViews` onto React Native `screenViews`. Remote config\n // currently delivers browserSDK-shaped payloads; keep `pageViews` so the\n // browser SDK still receives it.\n if (config.autocapture?.pageViews !== undefined) {\n config.autocapture.screenViews = config.autocapture.pageViews;\n }\n\n // translate frustrationInteractions pluralization\n const frustrationInteractions = config.autocapture?.frustrationInteractions;\n if (frustrationInteractions) {\n if (frustrationInteractions.rageClick) {\n frustrationInteractions.rageClicks = frustrationInteractions.rageClick;\n delete frustrationInteractions.rageClick;\n }\n if (frustrationInteractions.deadClick) {\n frustrationInteractions.deadClicks = frustrationInteractions.deadClick;\n delete frustrationInteractions.deadClick;\n }\n if (frustrationInteractions.errorClick) {\n frustrationInteractions.errorClicks = frustrationInteractions.errorClick;\n delete frustrationInteractions.errorClick;\n }\n }\n\n // normalize viewportContentUpdated inside elementInteractions\n try {\n const elementInteractions = config.autocapture?.elementInteractions;\n if (elementInteractions && typeof elementInteractions === 'object') {\n // { enabled: true } (no other fields) collapses to `true`; convert back to {} for the SDK.\n if (elementInteractions.viewportContentUpdated === true) {\n elementInteractions.viewportContentUpdated = {};\n }\n // { enabled: false, ... } collapses to `false`; convert back to { enabled: false } for the SDK.\n if (elementInteractions.viewportContentUpdated === false) {\n elementInteractions.viewportContentUpdated = { enabled: false };\n }\n // Migrate deprecated top-level exposureDuration to viewportContentUpdated.exposureDuration\n if (elementInteractions.exposureDuration !== undefined) {\n const viewportContentUpdated = elementInteractions.viewportContentUpdated;\n if (viewportContentUpdated === undefined) {\n elementInteractions.viewportContentUpdated = { exposureDuration: elementInteractions.exposureDuration };\n } else if (\n typeof viewportContentUpdated === 'object' &&\n viewportContentUpdated.exposureDuration === undefined &&\n viewportContentUpdated.enabled !== false\n ) {\n viewportContentUpdated.exposureDuration = elementInteractions.exposureDuration;\n }\n delete elementInteractions.exposureDuration;\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n // surprise exception, so don't translate it\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEvF,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kCAAmC,SAAQ,sBAAsB;IAChF;;OAEG;IACH,YAAY,CAAC,EAAE,8BAA8B,EAAE,CAAC;CACjD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC9B,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAC/B,MAAM,EAAE,OAAO,GACd,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAWrB;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAClD,eAAe,EAAE,OAAO,GAAG,kCAAkC,GAAG,SAAS,EACzE,MAAM,EAAE,OAAO,GACd,kCAAkC,GAAG,SAAS,CAahD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAsHxE"}
1
+ {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEvF,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kCAAmC,SAAQ,sBAAsB;IAChF;;OAEG;IACH,YAAY,CAAC,EAAE,8BAA8B,EAAE,CAAC;CACjD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC9B,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAC/B,MAAM,EAAE,OAAO,GACd,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAWrB;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAClD,eAAe,EAAE,OAAO,GAAG,kCAAkC,GAAG,SAAS,EACzE,MAAM,EAAE,OAAO,GACd,kCAAkC,GAAG,SAAS,CAahD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QA0HxE"}
@@ -197,6 +197,10 @@ export function translateRemoteConfigToLocal(config) {
197
197
  frustrationInteractions.deadClicks = frustrationInteractions.deadClick;
198
198
  delete frustrationInteractions.deadClick;
199
199
  }
200
+ if (frustrationInteractions.errorClick) {
201
+ frustrationInteractions.errorClicks = frustrationInteractions.errorClick;
202
+ delete frustrationInteractions.errorClick;
203
+ }
200
204
  }
201
205
  // normalize viewportContentUpdated inside elementInteractions
202
206
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAkBlD;;;GAGG;AACH,MAAM,UAAU,SAAS,CACvB,SAA8B,EAC9B,SAA+B,EAC/B,MAAe;;IAEf,IAAM,SAAS,GAAa,EAAE,CAAC;;QAC/B,KAAsB,IAAA,KAAA,SAAA,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAA,gBAAA,4BAAE;YAAlC,IAAM,OAAO,WAAA;YAChB,IAAI;gBACF,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;aACrC;YAAC,OAAO,UAAU,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC,iCAA0B,OAAO,CAAE,EAAE,UAAU,CAAC,CAAC;aAC9D;SACF;;;;;;;;;IAED,OAAO,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oCAAoC,CAClD,eAAyE,EACzE,MAAe;;;IAEf,IAAI,OAAO,eAAe,KAAK,QAAQ,IAAI,eAAe,KAAK,IAAI,IAAI,CAAC,CAAA,MAAA,eAAe,CAAC,YAAY,0CAAE,MAAM,CAAA,EAAE;QAC5G,OAAO,SAAS,CAAC;KAClB;IAED,IAAM,WAAW,gBAA4C,eAAe,CAAE,CAAC;IAC/E,0BAA0B;IAC1B,IAAM,YAAY,GAAG,MAAA,WAAW,CAAC,YAAY,mCAAI,EAAE,CAAC;;QACpD,KAAmB,IAAA,iBAAA,SAAA,YAAY,C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AC1C,sBAAsB,CAAC,gBAAgB,KAAK,SAAS;oBACrD,sBAAsB,CAAC,OAAO,KAAK,KAAK,EACxC;oBACA,sBAAsB,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;iBAChF;gBACD,OAAO,mBAAmB,CAAC,gBAAgB,CAAC;aAC7C;SACF;KACF;IAAC,OAAO,CAAC,EAAE;QACV,0BAA0B;QAC1B,4CAA4C;KAC7C;AACH,CAAC","sourcesContent":["import { SAFE_HEADERS } from '../types/constants';\nimport { ILogger } from '../logger';\nimport { NetworkCaptureRule, NetworkTrackingOptions } from '../types/network-tracking';\n\nexport interface NetworkCaptureRuleRemoteConfig extends NetworkCaptureRule {\n /**\n * Related to urls but holds regex strings which will be initialized and appended to urls\n */\n urlsRegex?: string[];\n}\n\nexport interface NetworkTrackingOptionsRemoteConfig extends NetworkTrackingOptions {\n /**\n * Related to urls but holds regex strings which will be initialized and appended to urls\n */\n captureRules?: NetworkCaptureRuleRemoteConfig[];\n}\n\n/**\n * Converts regex string patterns to RegExp objects and appends them to an exact URL list.\n * Invalid patterns are skipped and a warning is logged.\n */\nexport function mergeUrls(\n urlsExact: (string | RegExp)[],\n urlsRegex: string[] | undefined,\n logger: ILogger,\n): (string | RegExp)[] {\n const regexList: RegExp[] = [];\n for (const pattern of urlsRegex ?? []) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n logger.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n return urlsExact.concat(regexList);\n}\n\n/**\n * Transforms networkTracking remote config by merging urlsRegex into urls on each capture rule.\n * Returns a shallow-cloned networkTracking object when transform is needed, otherwise undefined.\n */\nexport function transformNetworkTrackingRemoteConfig(\n networkTracking: boolean | NetworkTrackingOptionsRemoteConfig | undefined,\n logger: ILogger,\n): NetworkTrackingOptionsRemoteConfig | undefined {\n if (typeof networkTracking !== 'object' || networkTracking === null || !networkTracking.captureRules?.length) {\n return undefined;\n }\n\n const transformed: NetworkTrackingOptionsRemoteConfig = { ...networkTracking };\n /* istanbul ignore next */\n const captureRules = transformed.captureRules ?? [];\n for (const rule of captureRules) {\n rule.urls = mergeUrls(rule.urls ?? [], rule.urlsRegex, logger);\n delete rule.urlsRegex;\n }\n return transformed;\n}\n\n/**\n * Performs a deep transformation of a remote config object so that\n * it matches the expected schema of the local config.\n *\n * Specifically, it normalizes nested `enabled` flags into concise union types.\n *\n * ### Transformation Rules:\n * - If an object has `enabled: true`, it is replaced by the same object without the `enabled` field.\n * - If it has only `enabled: true`, it is replaced with `true`.\n * - If it has `enabled: false`, it is replaced with `false` regardless of other fields.\n *\n * ### Examples:\n * Input: { prop: { enabled: true, hello: 'world' }}\n * Output: { prop: { hello: 'world' } }\n *\n * Input: { prop: { enabled: true }}\n * Output: { prop: true }\n *\n * Input: { prop: { enabled: false, hello: 'world' }}\n * Output: { prop: false }\n *\n * Input: { prop: { hello: 'world' }}\n * Output: { prop: { hello: 'world' } } // No change\n *\n * @param config Remote config object to be transformed\n * @returns Transformed config object compatible with local schema\n */\nexport function translateRemoteConfigToLocal(config?: Record<string, any>) {\n // Disabling type checking rules because remote config comes from a remote source\n // and this function needs to handle any unexpected values\n /* eslint-disable @typescript-eslint/no-unsafe-member-access,\n @typescript-eslint/no-unsafe-assignment,\n @typescript-eslint/no-unsafe-argument\n */\n if (typeof config !== 'object' || config === null) {\n return;\n }\n\n // translations are not applied on array properties\n if (Array.isArray(config)) {\n return;\n }\n\n const propertyNames = Object.keys(config);\n for (const propertyName of propertyNames) {\n try {\n const value = config[propertyName];\n // transform objects with { enabled } property to boolean | object\n if (typeof value?.enabled === 'boolean') {\n if (value.enabled) {\n // if enabled is true, set the value to the rest of the object\n // or true if the object has no other properties\n delete value.enabled;\n if (Object.keys(value).length === 0) {\n (config as any)[propertyName] = true;\n }\n } else {\n // If enabled is false, set the value to false\n (config as any)[propertyName] = false;\n }\n }\n\n // recursively translate properties of the value\n translateRemoteConfigToLocal(value as Record<string, any>);\n } catch (e) {\n // a failure here means that an accessor threw an error\n // so don't translate it\n // TODO(diagnostics): add a diagnostic event for this\n }\n }\n\n // translate remote responseHeaders and requestHeaders to local responseHeaders and requestHeaders\n try {\n if (config.autocapture?.networkTracking?.captureRules?.length) {\n for (const rule of config.autocapture.networkTracking.captureRules) {\n for (const header of ['responseHeaders', 'requestHeaders']) {\n const { captureSafeHeaders, allowlist } = rule[header] ?? {};\n if (!captureSafeHeaders && !allowlist) {\n continue;\n }\n // if allowlist is not an array, remote config contract is violated, remove it\n if (allowlist !== undefined && !Array.isArray(allowlist)) {\n delete rule[header];\n continue;\n }\n rule[header] = [...(captureSafeHeaders ? SAFE_HEADERS : []), ...(allowlist ?? [])];\n }\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n // surprise exception, so don't translate it\n }\n\n // alias browser `pageViews` onto React Native `screenViews`. Remote config\n // currently delivers browserSDK-shaped payloads; keep `pageViews` so the\n // browser SDK still receives it.\n if (config.autocapture?.pageViews !== undefined) {\n config.autocapture.screenViews = config.autocapture.pageViews;\n }\n\n // translate frustrationInteractions pluralization\n const frustrationInteractions = config.autocapture?.frustrationInteractions;\n if (frustrationInteractions) {\n if (frustrationInteractions.rageClick) {\n frustrationInteractions.rageClicks = frustrationInteractions.rageClick;\n delete frustrationInteractions.rageClick;\n }\n if (frustrationInteractions.deadClick) {\n frustrationInteractions.deadClicks = frustrationInteractions.deadClick;\n delete frustrationInteractions.deadClick;\n }\n }\n\n // normalize viewportContentUpdated inside elementInteractions\n try {\n const elementInteractions = config.autocapture?.elementInteractions;\n if (elementInteractions && typeof elementInteractions === 'object') {\n // { enabled: true } (no other fields) collapses to `true`; convert back to {} for the SDK.\n if (elementInteractions.viewportContentUpdated === true) {\n elementInteractions.viewportContentUpdated = {};\n }\n // { enabled: false, ... } collapses to `false`; convert back to { enabled: false } for the SDK.\n if (elementInteractions.viewportContentUpdated === false) {\n elementInteractions.viewportContentUpdated = { enabled: false };\n }\n // Migrate deprecated top-level exposureDuration to viewportContentUpdated.exposureDuration\n if (elementInteractions.exposureDuration !== undefined) {\n const viewportContentUpdated = elementInteractions.viewportContentUpdated;\n if (viewportContentUpdated === undefined) {\n elementInteractions.viewportContentUpdated = { exposureDuration: elementInteractions.exposureDuration };\n } else if (\n typeof viewportContentUpdated === 'object' &&\n viewportContentUpdated.exposureDuration === undefined &&\n viewportContentUpdated.enabled !== false\n ) {\n viewportContentUpdated.exposureDuration = elementInteractions.exposureDuration;\n }\n delete elementInteractions.exposureDuration;\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n // surprise exception, so don't translate it\n }\n}\n"]}
1
+ {"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAkBlD;;;GAGG;AACH,MAAM,UAAU,SAAS,CACvB,SAA8B,EAC9B,SAA+B,EAC/B,MAAe;;IAEf,IAAM,SAAS,GAAa,EAAE,CAAC;;QAC/B,KAAsB,IAAA,KAAA,SAAA,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAA,gBAAA,4BAAE;YAAlC,IAAM,OAAO,WAAA;YAChB,IAAI;gBACF,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;aACrC;YAAC,OAAO,UAAU,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC,iCAA0B,OAAO,CAAE,EAAE,UAAU,CAAC,CAAC;aAC9D;SACF;;;;;;;;;IAED,OAAO,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oCAAoC,CAClD,eAAyE,EACzE,MAAe;;;IAEf,IAAI,OAAO,eAAe,KAAK,QAAQ,IAAI,eAAe,KAAK,IAAI,IAAI,CAAC,CAAA,MAAA,eAAe,CAAC,YAAY,0CAAE,MAAM,CAAA,EAAE;QAC5G,OAAO,SAAS,CAAC;KAClB;IAED,I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ACD,2FAA2F;YAC3F,IAAI,mBAAmB,CAAC,gBAAgB,KAAK,SAAS,EAAE;gBACtD,IAAM,sBAAsB,GAAG,mBAAmB,CAAC,sBAAsB,CAAC;gBAC1E,IAAI,sBAAsB,KAAK,SAAS,EAAE;oBACxC,mBAAmB,CAAC,sBAAsB,GAAG,EAAE,gBAAgB,EAAE,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;iBACzG;qBAAM,IACL,OAAO,sBAAsB,KAAK,QAAQ;oBAC1C,sBAAsB,CAAC,gBAAgB,KAAK,SAAS;oBACrD,sBAAsB,CAAC,OAAO,KAAK,KAAK,EACxC;oBACA,sBAAsB,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;iBAChF;gBACD,OAAO,mBAAmB,CAAC,gBAAgB,CAAC;aAC7C;SACF;KACF;IAAC,OAAO,CAAC,EAAE;QACV,0BAA0B;QAC1B,4CAA4C;KAC7C;AACH,CAAC","sourcesContent":["import { SAFE_HEADERS } from '../types/constants';\nimport { ILogger } from '../logger';\nimport { NetworkCaptureRule, NetworkTrackingOptions } from '../types/network-tracking';\n\nexport interface NetworkCaptureRuleRemoteConfig extends NetworkCaptureRule {\n /**\n * Related to urls but holds regex strings which will be initialized and appended to urls\n */\n urlsRegex?: string[];\n}\n\nexport interface NetworkTrackingOptionsRemoteConfig extends NetworkTrackingOptions {\n /**\n * Related to urls but holds regex strings which will be initialized and appended to urls\n */\n captureRules?: NetworkCaptureRuleRemoteConfig[];\n}\n\n/**\n * Converts regex string patterns to RegExp objects and appends them to an exact URL list.\n * Invalid patterns are skipped and a warning is logged.\n */\nexport function mergeUrls(\n urlsExact: (string | RegExp)[],\n urlsRegex: string[] | undefined,\n logger: ILogger,\n): (string | RegExp)[] {\n const regexList: RegExp[] = [];\n for (const pattern of urlsRegex ?? []) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n logger.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n return urlsExact.concat(regexList);\n}\n\n/**\n * Transforms networkTracking remote config by merging urlsRegex into urls on each capture rule.\n * Returns a shallow-cloned networkTracking object when transform is needed, otherwise undefined.\n */\nexport function transformNetworkTrackingRemoteConfig(\n networkTracking: boolean | NetworkTrackingOptionsRemoteConfig | undefined,\n logger: ILogger,\n): NetworkTrackingOptionsRemoteConfig | undefined {\n if (typeof networkTracking !== 'object' || networkTracking === null || !networkTracking.captureRules?.length) {\n return undefined;\n }\n\n const transformed: NetworkTrackingOptionsRemoteConfig = { ...networkTracking };\n /* istanbul ignore next */\n const captureRules = transformed.captureRules ?? [];\n for (const rule of captureRules) {\n rule.urls = mergeUrls(rule.urls ?? [], rule.urlsRegex, logger);\n delete rule.urlsRegex;\n }\n return transformed;\n}\n\n/**\n * Performs a deep transformation of a remote config object so that\n * it matches the expected schema of the local config.\n *\n * Specifically, it normalizes nested `enabled` flags into concise union types.\n *\n * ### Transformation Rules:\n * - If an object has `enabled: true`, it is replaced by the same object without the `enabled` field.\n * - If it has only `enabled: true`, it is replaced with `true`.\n * - If it has `enabled: false`, it is replaced with `false` regardless of other fields.\n *\n * ### Examples:\n * Input: { prop: { enabled: true, hello: 'world' }}\n * Output: { prop: { hello: 'world' } }\n *\n * Input: { prop: { enabled: true }}\n * Output: { prop: true }\n *\n * Input: { prop: { enabled: false, hello: 'world' }}\n * Output: { prop: false }\n *\n * Input: { prop: { hello: 'world' }}\n * Output: { prop: { hello: 'world' } } // No change\n *\n * @param config Remote config object to be transformed\n * @returns Transformed config object compatible with local schema\n */\nexport function translateRemoteConfigToLocal(config?: Record<string, any>) {\n // Disabling type checking rules because remote config comes from a remote source\n // and this function needs to handle any unexpected values\n /* eslint-disable @typescript-eslint/no-unsafe-member-access,\n @typescript-eslint/no-unsafe-assignment,\n @typescript-eslint/no-unsafe-argument\n */\n if (typeof config !== 'object' || config === null) {\n return;\n }\n\n // translations are not applied on array properties\n if (Array.isArray(config)) {\n return;\n }\n\n const propertyNames = Object.keys(config);\n for (const propertyName of propertyNames) {\n try {\n const value = config[propertyName];\n // transform objects with { enabled } property to boolean | object\n if (typeof value?.enabled === 'boolean') {\n if (value.enabled) {\n // if enabled is true, set the value to the rest of the object\n // or true if the object has no other properties\n delete value.enabled;\n if (Object.keys(value).length === 0) {\n (config as any)[propertyName] = true;\n }\n } else {\n // If enabled is false, set the value to false\n (config as any)[propertyName] = false;\n }\n }\n\n // recursively translate properties of the value\n translateRemoteConfigToLocal(value as Record<string, any>);\n } catch (e) {\n // a failure here means that an accessor threw an error\n // so don't translate it\n // TODO(diagnostics): add a diagnostic event for this\n }\n }\n\n // translate remote responseHeaders and requestHeaders to local responseHeaders and requestHeaders\n try {\n if (config.autocapture?.networkTracking?.captureRules?.length) {\n for (const rule of config.autocapture.networkTracking.captureRules) {\n for (const header of ['responseHeaders', 'requestHeaders']) {\n const { captureSafeHeaders, allowlist } = rule[header] ?? {};\n if (!captureSafeHeaders && !allowlist) {\n continue;\n }\n // if allowlist is not an array, remote config contract is violated, remove it\n if (allowlist !== undefined && !Array.isArray(allowlist)) {\n delete rule[header];\n continue;\n }\n rule[header] = [...(captureSafeHeaders ? SAFE_HEADERS : []), ...(allowlist ?? [])];\n }\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n // surprise exception, so don't translate it\n }\n\n // alias browser `pageViews` onto React Native `screenViews`. Remote config\n // currently delivers browserSDK-shaped payloads; keep `pageViews` so the\n // browser SDK still receives it.\n if (config.autocapture?.pageViews !== undefined) {\n config.autocapture.screenViews = config.autocapture.pageViews;\n }\n\n // translate frustrationInteractions pluralization\n const frustrationInteractions = config.autocapture?.frustrationInteractions;\n if (frustrationInteractions) {\n if (frustrationInteractions.rageClick) {\n frustrationInteractions.rageClicks = frustrationInteractions.rageClick;\n delete frustrationInteractions.rageClick;\n }\n if (frustrationInteractions.deadClick) {\n frustrationInteractions.deadClicks = frustrationInteractions.deadClick;\n delete frustrationInteractions.deadClick;\n }\n if (frustrationInteractions.errorClick) {\n frustrationInteractions.errorClicks = frustrationInteractions.errorClick;\n delete frustrationInteractions.errorClick;\n }\n }\n\n // normalize viewportContentUpdated inside elementInteractions\n try {\n const elementInteractions = config.autocapture?.elementInteractions;\n if (elementInteractions && typeof elementInteractions === 'object') {\n // { enabled: true } (no other fields) collapses to `true`; convert back to {} for the SDK.\n if (elementInteractions.viewportContentUpdated === true) {\n elementInteractions.viewportContentUpdated = {};\n }\n // { enabled: false, ... } collapses to `false`; convert back to { enabled: false } for the SDK.\n if (elementInteractions.viewportContentUpdated === false) {\n elementInteractions.viewportContentUpdated = { enabled: false };\n }\n // Migrate deprecated top-level exposureDuration to viewportContentUpdated.exposureDuration\n if (elementInteractions.exposureDuration !== undefined) {\n const viewportContentUpdated = elementInteractions.viewportContentUpdated;\n if (viewportContentUpdated === undefined) {\n elementInteractions.viewportContentUpdated = { exposureDuration: elementInteractions.exposureDuration };\n } else if (\n typeof viewportContentUpdated === 'object' &&\n viewportContentUpdated.exposureDuration === undefined &&\n viewportContentUpdated.enabled !== false\n ) {\n viewportContentUpdated.exposureDuration = elementInteractions.exposureDuration;\n }\n delete elementInteractions.exposureDuration;\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n // surprise exception, so don't translate it\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/analytics-core",
3
- "version": "2.60.0",
3
+ "version": "2.60.2",
4
4
  "description": "",
5
5
  "author": "Amplitude Inc",
6
6
  "homepage": "https://github.com/amplitude/Amplitude-TypeScript",