@amplitude/analytics-browser 2.44.0 → 2.44.1
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 +1 -1
- package/lib/cjs/config/joined-config.d.ts.map +1 -1
- package/lib/cjs/config/joined-config.js +2 -2
- package/lib/cjs/config/joined-config.js.map +1 -1
- package/lib/cjs/config.d.ts +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/config/joined-config.d.ts.map +1 -1
- package/lib/esm/config/joined-config.js +3 -3
- package/lib/esm/config/joined-config.js.map +1 -1
- package/lib/esm/config.d.ts +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/scripts/amplitude-bookmarklet-snippet-min.js +1 -1
- package/lib/scripts/amplitude-bookmarklet.html +1 -1
- package/lib/scripts/amplitude-gtm-min.js +1 -1
- package/lib/scripts/amplitude-gtm-min.js.gz +0 -0
- package/lib/scripts/amplitude-gtm-min.js.map +1 -1
- package/lib/scripts/amplitude-gtm-snippet-min.js +1 -1
- package/lib/scripts/amplitude-min.js +1 -1
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.js.map +1 -1
- package/lib/scripts/amplitude-min.umd.js +1 -1
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/amplitude-snippet-instructions.html +1 -1
- package/lib/scripts/amplitude-snippet-min.js +1 -1
- package/lib/scripts/config/joined-config.d.ts.map +1 -1
- package/lib/scripts/config.d.ts +1 -1
- package/lib/scripts/version.d.ts +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ This SDK is also available through CDN. Copy the script loader below and paste b
|
|
|
53
53
|
<!-- README_SNIPPET_BLOCK -->
|
|
54
54
|
```html
|
|
55
55
|
<script type="text/javascript">
|
|
56
|
-
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},s=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))};!function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})}(e,t,Array.prototype.slice.call(arguments))}},i=function(e){for(var t=0;t<y.length;t++)o(e,y[t],!1);for(var r=0;r<g.length;r++)o(e,g[r],!0)};r.invoked=!0;var
|
|
56
|
+
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},s=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))};!function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})}(e,t,Array.prototype.slice.call(arguments))}},i=function(e){for(var t=0;t<y.length;t++)o(e,y[t],!1);for(var r=0;r<g.length;r++)o(e,g[r],!0)};r.invoked=!0;var a=t.createElement("script");a.type="text/javascript",a.integrity="sha384-0WVMHVbXPgywCOjxDkkzUj3HtTEavGCbBFhaCCxJZNHdd4G9fdqRWZESEKqkoOHx",a.crossOrigin="anonymous",a.async=!0,a.src="https://cdn.amplitude.com/libs/analytics-browser-2.44.1-min.js.gz",a.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var c=t.getElementsByTagName("script")[0];c.parentNode.insertBefore(a,c);for(var u=function(){return this._q=[],this},p=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],l=0;l<p.length;l++)n(u,p[l]);r.Identify=u;for(var d=function(){return this._q=[],this},f=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],v=0;v<f.length;v++)n(d,f[v]);r.Revenue=d;var y=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],g=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];i(r),r.createInstance=function(e){return r._iq[e]={_q:[]},i(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
|
|
57
57
|
|
|
58
58
|
amplitude.init("<YOUR_API_KEY>");
|
|
59
59
|
</script>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,aAAa,EAEb,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,aAAa,EAEb,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAGnB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE,mBAAmB,CAAC,EAAE,OAAO,GAAG,sCAAsC,CAAC;IACvE,eAAe,CAAC,EAAE,OAAO,GAAG,kCAAkC,CAAC;CAChE;AACD,MAAM,WAAW,sCAAuC,SAAQ,0BAA0B;IACxF;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,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;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QA+GxE;AAgBD;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,YAAY,GAAG,IAAI,EACjC,aAAa,EAAE,aAAa,GAC3B,IAAI,CA6GN"}
|
|
@@ -212,7 +212,7 @@ function updateBrowserConfigWithRemoteConfig(remoteConfig, browserConfig) {
|
|
|
212
212
|
// translate remote config to local compatible format
|
|
213
213
|
translateRemoteConfigToLocal(remoteConfig);
|
|
214
214
|
try {
|
|
215
|
-
browserConfig.loggerProvider.debug('Update browser config with remote configuration:',
|
|
215
|
+
browserConfig.loggerProvider.debug('Update browser config with remote configuration:', (0, analytics_core_1.safeJsonStringify)(remoteConfig));
|
|
216
216
|
// type cast error will be thrown if remoteConfig is not a valid RemoteConfigBrowserSDK
|
|
217
217
|
// and it will be caught by the try-catch block
|
|
218
218
|
var typedRemoteConfig = remoteConfig;
|
|
@@ -281,7 +281,7 @@ function updateBrowserConfigWithRemoteConfig(remoteConfig, browserConfig) {
|
|
|
281
281
|
browserConfig.customEnrichment = typedRemoteConfig.customEnrichment;
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
browserConfig.loggerProvider.debug('Browser config after remote config update:',
|
|
284
|
+
browserConfig.loggerProvider.debug('Browser config after remote config update:', (0, analytics_core_1.safeJsonStringify)(browserConfig));
|
|
285
285
|
}
|
|
286
286
|
catch (e) {
|
|
287
287
|
browserConfig.loggerProvider.error('Failed to apply remote configuration because of error: ', e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.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C,yDAAyD,EAAE,CAAC,CAAC,CAAC;KAClG;AACH,CAAC;AAhHD,kFAgHC","sourcesContent":["import {\n AutocaptureOptions,\n type ElementInteractionsOptions,\n BrowserConfig,\n CustomEnrichmentOptions,\n RemoteConfig,\n NetworkTrackingOptions,\n NetworkCaptureRule,\n SAFE_HEADERS,\n} from '@amplitude/analytics-core';\n\nexport interface AutocaptureOptionsRemoteConfig extends AutocaptureOptions {\n elementInteractions?: boolean | ElementInteractionsOptionsRemoteConfig;\n networkTracking?: boolean | NetworkTrackingOptionsRemoteConfig;\n}\nexport interface ElementInteractionsOptionsRemoteConfig extends ElementInteractionsOptions {\n /**\n * Related to pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n pageUrlAllowlistRegex?: string[];\n}\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 pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n captureRules?: NetworkCaptureRuleRemoteConfig[];\n}\n\n// Type alias for the remote config structure we expect (this is what comes from the filtered browserSDK config)\ntype RemoteConfigBrowserSDK = {\n autocapture?: AutocaptureOptionsRemoteConfig | boolean;\n customEnrichment?: CustomEnrichmentOptions | boolean;\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 // 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\nfunction mergeUrls(urlsExact: (string | RegExp)[], urlsRegex: string[] | undefined, browserConfig: BrowserConfig) {\n // Convert string patterns to RegExp objects, warn on invalid patterns and skip them\n const regexList = [];\n for (const pattern of urlsRegex ?? []) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n browserConfig.loggerProvider.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n return urlsExact.concat(regexList);\n}\n\n/**\n * Updates the browser config in place by applying remote configuration settings.\n * Primarily merges autocapture settings from the remote config into the browser config.\n *\n * @param remoteConfig - The remote configuration to apply, or null if none available\n * @param browserConfig - The browser config object to update (modified in place)\n */\nexport function updateBrowserConfigWithRemoteConfig(\n remoteConfig: RemoteConfig | null,\n browserConfig: BrowserConfig,\n): void {\n if (!remoteConfig) {\n return;\n }\n\n // translate remote config to local compatible format\n translateRemoteConfigToLocal(remoteConfig);\n\n try {\n browserConfig.loggerProvider.debug(\n 'Update browser config with remote configuration:',\n JSON.stringify(remoteConfig),\n );\n\n // type cast error will be thrown if remoteConfig is not a valid RemoteConfigBrowserSDK\n // and it will be caught by the try-catch block\n const typedRemoteConfig = remoteConfig as RemoteConfigBrowserSDK;\n\n // merge remoteConfig.autocapture and browserConfig.autocapture\n // if a field is in remoteConfig.autocapture, use that value\n // if a field is not in remoteConfig.autocapture, use the value from browserConfig.autocapture\n if (typedRemoteConfig && 'autocapture' in typedRemoteConfig) {\n if (typeof typedRemoteConfig.autocapture === 'boolean') {\n browserConfig.autocapture = typedRemoteConfig.autocapture;\n }\n\n if (typeof typedRemoteConfig.autocapture === 'object' && typedRemoteConfig.autocapture !== null) {\n const transformedAutocaptureRemoteConfig = { ...typedRemoteConfig.autocapture };\n\n if (browserConfig.autocapture === undefined) {\n browserConfig.autocapture = typedRemoteConfig.autocapture;\n }\n\n // Handle Element Interactions config initialization\n if (\n typeof typedRemoteConfig.autocapture.elementInteractions === 'object' &&\n typedRemoteConfig.autocapture.elementInteractions !== null &&\n typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex?.length\n ) {\n transformedAutocaptureRemoteConfig.elementInteractions = {\n ...typedRemoteConfig.autocapture.elementInteractions,\n };\n const transformedRcElementInteractions = transformedAutocaptureRemoteConfig.elementInteractions;\n\n // combine exact allow list and regex allow list into just 'pageUrlAllowlist'\n const exactAllowList = transformedRcElementInteractions.pageUrlAllowlist ?? [];\n const urlsRegex = typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex;\n transformedRcElementInteractions.pageUrlAllowlist = mergeUrls(exactAllowList, urlsRegex, browserConfig);\n\n // clean up the regex allow list\n delete transformedRcElementInteractions.pageUrlAllowlistRegex;\n }\n\n // Handle Network Tracking config initialization\n if (\n typeof typedRemoteConfig.autocapture.networkTracking === 'object' &&\n typedRemoteConfig.autocapture.networkTracking !== null &&\n typedRemoteConfig.autocapture.networkTracking.captureRules?.length\n ) {\n transformedAutocaptureRemoteConfig.networkTracking = {\n ...typedRemoteConfig.autocapture.networkTracking,\n };\n const transformedRcNetworkTracking = transformedAutocaptureRemoteConfig.networkTracking;\n /* istanbul ignore next */\n const captureRules = transformedRcNetworkTracking.captureRules ?? [];\n for (const rule of captureRules) {\n rule.urls = mergeUrls(rule.urls ?? [], rule.urlsRegex, browserConfig);\n delete rule.urlsRegex;\n }\n }\n\n if (typeof browserConfig.autocapture === 'boolean') {\n browserConfig.autocapture = {\n attribution: browserConfig.autocapture,\n fileDownloads: browserConfig.autocapture,\n formInteractions: browserConfig.autocapture,\n pageViews: browserConfig.autocapture,\n sessions: browserConfig.autocapture,\n elementInteractions: browserConfig.autocapture,\n webVitals: browserConfig.autocapture,\n frustrationInteractions: browserConfig.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n\n if (typeof browserConfig.autocapture === 'object') {\n browserConfig.autocapture = {\n ...browserConfig.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n }\n\n // Override default tracking options if autocapture is updated by remote config\n browserConfig.defaultTracking = browserConfig.autocapture;\n }\n\n if ('customEnrichment' in typedRemoteConfig && typedRemoteConfig.customEnrichment !== null) {\n // Respect a locally-explicit false: if the user disabled custom enrichment at init time,\n // remote config must not re-enable it.\n if (browserConfig.customEnrichment !== false) {\n browserConfig.customEnrichment = typedRemoteConfig.customEnrichment;\n }\n }\n\n browserConfig.loggerProvider.debug('Browser config after remote config update:', JSON.stringify(browserConfig));\n } catch (e) {\n browserConfig.loggerProvider.error('Failed to apply remote configuration because of error: ', e);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";;;;AAAA,4DAUmC;AAiCnC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,4BAA4B,CAAC,MAA4B;;;IACvE,iFAAiF;IACjF,0DAA0D;IAC1D;;;KAGC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE;QACjD,OAAO;KACR;IAED,mDAAmD;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,OAAO;KACR;IAED,IAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;QAC1C,KAA2B,IAAA,kBAAA,iBAAA,aAAa,CAAA,4CAAA,uEAAE;YAArC,IAAM,YAAY,0BAAA;YACrB,IAAI;gBACF,IAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;gBACnC,kEAAkE;gBAClE,IAAI,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAA,KAAK,SAAS,EAAE;oBACvC,IAAI,KAAK,CAAC,OAAO,EAAE;wBACjB,8DAA8D;wBAC9D,gDAAgD;wBAChD,OAAO,KAAK,CAAC,OAAO,CAAC;wBACrB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;4BAClC,MAAc,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;yBACtC;qBACF;yBAAM;wBACL,8CAA8C;wBAC7C,MAAc,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC;qBACvC;iBACF;gBAED,gDAAgD;gBAChD,4BAA4B,CAAC,KAA4B,CAAC,CAAC;aAC5D;YAAC,OAAO,CAAC,EAAE;gBACV,uDAAuD;gBACvD,wBAAwB;gBACxB,qDAAqD;aACtD;SACF;;;;;;;;;IAED,kGAAkG;IAClG,IAAI;QACF,I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AAC,EAAE;QACV,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,EAAE,CAAC,CAAC,CAAC;KAClG;AACH,CAAC;AAhHD,kFAgHC","sourcesContent":["import {\n AutocaptureOptions,\n type ElementInteractionsOptions,\n BrowserConfig,\n CustomEnrichmentOptions,\n RemoteConfig,\n NetworkTrackingOptions,\n NetworkCaptureRule,\n SAFE_HEADERS,\n safeJsonStringify,\n} from '@amplitude/analytics-core';\n\nexport interface AutocaptureOptionsRemoteConfig extends AutocaptureOptions {\n elementInteractions?: boolean | ElementInteractionsOptionsRemoteConfig;\n networkTracking?: boolean | NetworkTrackingOptionsRemoteConfig;\n}\nexport interface ElementInteractionsOptionsRemoteConfig extends ElementInteractionsOptions {\n /**\n * Related to pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n pageUrlAllowlistRegex?: string[];\n}\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 pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n captureRules?: NetworkCaptureRuleRemoteConfig[];\n}\n\n// Type alias for the remote config structure we expect (this is what comes from the filtered browserSDK config)\ntype RemoteConfigBrowserSDK = {\n autocapture?: AutocaptureOptionsRemoteConfig | boolean;\n customEnrichment?: CustomEnrichmentOptions | boolean;\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 // 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\nfunction mergeUrls(urlsExact: (string | RegExp)[], urlsRegex: string[] | undefined, browserConfig: BrowserConfig) {\n // Convert string patterns to RegExp objects, warn on invalid patterns and skip them\n const regexList = [];\n for (const pattern of urlsRegex ?? []) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n browserConfig.loggerProvider.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n return urlsExact.concat(regexList);\n}\n\n/**\n * Updates the browser config in place by applying remote configuration settings.\n * Primarily merges autocapture settings from the remote config into the browser config.\n *\n * @param remoteConfig - The remote configuration to apply, or null if none available\n * @param browserConfig - The browser config object to update (modified in place)\n */\nexport function updateBrowserConfigWithRemoteConfig(\n remoteConfig: RemoteConfig | null,\n browserConfig: BrowserConfig,\n): void {\n if (!remoteConfig) {\n return;\n }\n\n // translate remote config to local compatible format\n translateRemoteConfigToLocal(remoteConfig);\n\n try {\n browserConfig.loggerProvider.debug(\n 'Update browser config with remote configuration:',\n safeJsonStringify(remoteConfig),\n );\n\n // type cast error will be thrown if remoteConfig is not a valid RemoteConfigBrowserSDK\n // and it will be caught by the try-catch block\n const typedRemoteConfig = remoteConfig as RemoteConfigBrowserSDK;\n\n // merge remoteConfig.autocapture and browserConfig.autocapture\n // if a field is in remoteConfig.autocapture, use that value\n // if a field is not in remoteConfig.autocapture, use the value from browserConfig.autocapture\n if (typedRemoteConfig && 'autocapture' in typedRemoteConfig) {\n if (typeof typedRemoteConfig.autocapture === 'boolean') {\n browserConfig.autocapture = typedRemoteConfig.autocapture;\n }\n\n if (typeof typedRemoteConfig.autocapture === 'object' && typedRemoteConfig.autocapture !== null) {\n const transformedAutocaptureRemoteConfig = { ...typedRemoteConfig.autocapture };\n\n if (browserConfig.autocapture === undefined) {\n browserConfig.autocapture = typedRemoteConfig.autocapture;\n }\n\n // Handle Element Interactions config initialization\n if (\n typeof typedRemoteConfig.autocapture.elementInteractions === 'object' &&\n typedRemoteConfig.autocapture.elementInteractions !== null &&\n typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex?.length\n ) {\n transformedAutocaptureRemoteConfig.elementInteractions = {\n ...typedRemoteConfig.autocapture.elementInteractions,\n };\n const transformedRcElementInteractions = transformedAutocaptureRemoteConfig.elementInteractions;\n\n // combine exact allow list and regex allow list into just 'pageUrlAllowlist'\n const exactAllowList = transformedRcElementInteractions.pageUrlAllowlist ?? [];\n const urlsRegex = typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex;\n transformedRcElementInteractions.pageUrlAllowlist = mergeUrls(exactAllowList, urlsRegex, browserConfig);\n\n // clean up the regex allow list\n delete transformedRcElementInteractions.pageUrlAllowlistRegex;\n }\n\n // Handle Network Tracking config initialization\n if (\n typeof typedRemoteConfig.autocapture.networkTracking === 'object' &&\n typedRemoteConfig.autocapture.networkTracking !== null &&\n typedRemoteConfig.autocapture.networkTracking.captureRules?.length\n ) {\n transformedAutocaptureRemoteConfig.networkTracking = {\n ...typedRemoteConfig.autocapture.networkTracking,\n };\n const transformedRcNetworkTracking = transformedAutocaptureRemoteConfig.networkTracking;\n /* istanbul ignore next */\n const captureRules = transformedRcNetworkTracking.captureRules ?? [];\n for (const rule of captureRules) {\n rule.urls = mergeUrls(rule.urls ?? [], rule.urlsRegex, browserConfig);\n delete rule.urlsRegex;\n }\n }\n\n if (typeof browserConfig.autocapture === 'boolean') {\n browserConfig.autocapture = {\n attribution: browserConfig.autocapture,\n fileDownloads: browserConfig.autocapture,\n formInteractions: browserConfig.autocapture,\n pageViews: browserConfig.autocapture,\n sessions: browserConfig.autocapture,\n elementInteractions: browserConfig.autocapture,\n webVitals: browserConfig.autocapture,\n frustrationInteractions: browserConfig.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n\n if (typeof browserConfig.autocapture === 'object') {\n browserConfig.autocapture = {\n ...browserConfig.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n }\n\n // Override default tracking options if autocapture is updated by remote config\n browserConfig.defaultTracking = browserConfig.autocapture;\n }\n\n if ('customEnrichment' in typedRemoteConfig && typedRemoteConfig.customEnrichment !== null) {\n // Respect a locally-explicit false: if the user disabled custom enrichment at init time,\n // remote config must not re-enable it.\n if (browserConfig.customEnrichment !== false) {\n browserConfig.customEnrichment = typedRemoteConfig.customEnrichment;\n }\n }\n\n browserConfig.loggerProvider.debug('Browser config after remote config update:', safeJsonStringify(browserConfig));\n } catch (e) {\n browserConfig.loggerProvider.error('Failed to apply remote configuration because of error: ', e);\n }\n}\n"]}
|
package/lib/cjs/config.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare class BrowserConfig extends Config implements IBrowserConfig {
|
|
|
40
40
|
topLevelDomain?: string | undefined;
|
|
41
41
|
enableRequestBodyCompression: boolean;
|
|
42
42
|
customEnrichment?: boolean | CustomEnrichmentOptions | undefined;
|
|
43
|
-
readonly version = "2.44.
|
|
43
|
+
readonly version = "2.44.1";
|
|
44
44
|
protected _cookieStorage: Storage<UserSession>;
|
|
45
45
|
protected _deviceId?: string;
|
|
46
46
|
protected _lastEventId?: number;
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.44.
|
|
1
|
+
export declare const VERSION = "2.44.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/cjs/version.js
CHANGED
package/lib/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["export const VERSION = '2.44.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["export const VERSION = '2.44.1';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,aAAa,EAEb,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,aAAa,EAEb,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAGnB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE,mBAAmB,CAAC,EAAE,OAAO,GAAG,sCAAsC,CAAC;IACvE,eAAe,CAAC,EAAE,OAAO,GAAG,kCAAkC,CAAC;CAChE;AACD,MAAM,WAAW,sCAAuC,SAAQ,0BAA0B;IACxF;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,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;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QA+GxE;AAgBD;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,YAAY,GAAG,IAAI,EACjC,aAAa,EAAE,aAAa,GAC3B,IAAI,CA6GN"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __read, __spreadArray, __values } from "tslib";
|
|
2
|
-
import { SAFE_HEADERS, } from '@amplitude/analytics-core';
|
|
2
|
+
import { SAFE_HEADERS, safeJsonStringify, } from '@amplitude/analytics-core';
|
|
3
3
|
/**
|
|
4
4
|
* Performs a deep transformation of a remote config object so that
|
|
5
5
|
* it matches the expected schema of the local config.
|
|
@@ -208,7 +208,7 @@ export function updateBrowserConfigWithRemoteConfig(remoteConfig, browserConfig)
|
|
|
208
208
|
// translate remote config to local compatible format
|
|
209
209
|
translateRemoteConfigToLocal(remoteConfig);
|
|
210
210
|
try {
|
|
211
|
-
browserConfig.loggerProvider.debug('Update browser config with remote configuration:',
|
|
211
|
+
browserConfig.loggerProvider.debug('Update browser config with remote configuration:', safeJsonStringify(remoteConfig));
|
|
212
212
|
// type cast error will be thrown if remoteConfig is not a valid RemoteConfigBrowserSDK
|
|
213
213
|
// and it will be caught by the try-catch block
|
|
214
214
|
var typedRemoteConfig = remoteConfig;
|
|
@@ -277,7 +277,7 @@ export function updateBrowserConfigWithRemoteConfig(remoteConfig, browserConfig)
|
|
|
277
277
|
browserConfig.customEnrichment = typedRemoteConfig.customEnrichment;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
browserConfig.loggerProvider.debug('Browser config after remote config update:',
|
|
280
|
+
browserConfig.loggerProvider.debug('Browser config after remote config update:', safeJsonStringify(browserConfig));
|
|
281
281
|
}
|
|
282
282
|
catch (e) {
|
|
283
283
|
browserConfig.loggerProvider.error('Failed to apply remote configuration because of error: ', e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAQL,YAAY,GACb,MAAM,2BAA2B,CAAC;AAiCnC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAA4B;;;IACvE,iFAAiF;IACjF,0DAA0D;IAC1D;;;KAGC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE;QACjD,OAAO;KACR;IAED,mDAAmD;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,OAAO;KACR;IAED,IAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;QAC1C,KAA2B,IAAA,kBAAA,SAAA,aAAa,CAAA,4CAAA,uEAAE;YAArC,IAAM,YAAY,0BAAA;YACrB,IAAI;gBACF,IAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;gBAC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W,IAC/C,kCAAkC,CACtC,CAAC;iBACH;gBAED,IAAI,OAAO,aAAa,CAAC,WAAW,KAAK,QAAQ,EAAE;oBACjD,aAAa,CAAC,WAAW,yBACpB,aAAa,CAAC,WAAW,GACzB,kCAAkC,CACtC,CAAC;iBACH;aACF;YAED,+EAA+E;YAC/E,aAAa,CAAC,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;SAC3D;QAED,IAAI,kBAAkB,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,gBAAgB,KAAK,IAAI,EAAE;YAC1F,yFAAyF;YACzF,uCAAuC;YACvC,IAAI,aAAa,CAAC,gBAAgB,KAAK,KAAK,EAAE;gBAC5C,aAAa,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC;aACrE;SACF;QAED,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,4CAA4C,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;KACjH;IAAC,OAAO,CAAC,EAAE;QACV,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,EAAE,CAAC,CAAC,CAAC;KAClG;AACH,CAAC","sourcesContent":["import {\n AutocaptureOptions,\n type ElementInteractionsOptions,\n BrowserConfig,\n CustomEnrichmentOptions,\n RemoteConfig,\n NetworkTrackingOptions,\n NetworkCaptureRule,\n SAFE_HEADERS,\n} from '@amplitude/analytics-core';\n\nexport interface AutocaptureOptionsRemoteConfig extends AutocaptureOptions {\n elementInteractions?: boolean | ElementInteractionsOptionsRemoteConfig;\n networkTracking?: boolean | NetworkTrackingOptionsRemoteConfig;\n}\nexport interface ElementInteractionsOptionsRemoteConfig extends ElementInteractionsOptions {\n /**\n * Related to pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n pageUrlAllowlistRegex?: string[];\n}\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 pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n captureRules?: NetworkCaptureRuleRemoteConfig[];\n}\n\n// Type alias for the remote config structure we expect (this is what comes from the filtered browserSDK config)\ntype RemoteConfigBrowserSDK = {\n autocapture?: AutocaptureOptionsRemoteConfig | boolean;\n customEnrichment?: CustomEnrichmentOptions | boolean;\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 // 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\nfunction mergeUrls(urlsExact: (string | RegExp)[], urlsRegex: string[] | undefined, browserConfig: BrowserConfig) {\n // Convert string patterns to RegExp objects, warn on invalid patterns and skip them\n const regexList = [];\n for (const pattern of urlsRegex ?? []) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n browserConfig.loggerProvider.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n return urlsExact.concat(regexList);\n}\n\n/**\n * Updates the browser config in place by applying remote configuration settings.\n * Primarily merges autocapture settings from the remote config into the browser config.\n *\n * @param remoteConfig - The remote configuration to apply, or null if none available\n * @param browserConfig - The browser config object to update (modified in place)\n */\nexport function updateBrowserConfigWithRemoteConfig(\n remoteConfig: RemoteConfig | null,\n browserConfig: BrowserConfig,\n): void {\n if (!remoteConfig) {\n return;\n }\n\n // translate remote config to local compatible format\n translateRemoteConfigToLocal(remoteConfig);\n\n try {\n browserConfig.loggerProvider.debug(\n 'Update browser config with remote configuration:',\n JSON.stringify(remoteConfig),\n );\n\n // type cast error will be thrown if remoteConfig is not a valid RemoteConfigBrowserSDK\n // and it will be caught by the try-catch block\n const typedRemoteConfig = remoteConfig as RemoteConfigBrowserSDK;\n\n // merge remoteConfig.autocapture and browserConfig.autocapture\n // if a field is in remoteConfig.autocapture, use that value\n // if a field is not in remoteConfig.autocapture, use the value from browserConfig.autocapture\n if (typedRemoteConfig && 'autocapture' in typedRemoteConfig) {\n if (typeof typedRemoteConfig.autocapture === 'boolean') {\n browserConfig.autocapture = typedRemoteConfig.autocapture;\n }\n\n if (typeof typedRemoteConfig.autocapture === 'object' && typedRemoteConfig.autocapture !== null) {\n const transformedAutocaptureRemoteConfig = { ...typedRemoteConfig.autocapture };\n\n if (browserConfig.autocapture === undefined) {\n browserConfig.autocapture = typedRemoteConfig.autocapture;\n }\n\n // Handle Element Interactions config initialization\n if (\n typeof typedRemoteConfig.autocapture.elementInteractions === 'object' &&\n typedRemoteConfig.autocapture.elementInteractions !== null &&\n typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex?.length\n ) {\n transformedAutocaptureRemoteConfig.elementInteractions = {\n ...typedRemoteConfig.autocapture.elementInteractions,\n };\n const transformedRcElementInteractions = transformedAutocaptureRemoteConfig.elementInteractions;\n\n // combine exact allow list and regex allow list into just 'pageUrlAllowlist'\n const exactAllowList = transformedRcElementInteractions.pageUrlAllowlist ?? [];\n const urlsRegex = typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex;\n transformedRcElementInteractions.pageUrlAllowlist = mergeUrls(exactAllowList, urlsRegex, browserConfig);\n\n // clean up the regex allow list\n delete transformedRcElementInteractions.pageUrlAllowlistRegex;\n }\n\n // Handle Network Tracking config initialization\n if (\n typeof typedRemoteConfig.autocapture.networkTracking === 'object' &&\n typedRemoteConfig.autocapture.networkTracking !== null &&\n typedRemoteConfig.autocapture.networkTracking.captureRules?.length\n ) {\n transformedAutocaptureRemoteConfig.networkTracking = {\n ...typedRemoteConfig.autocapture.networkTracking,\n };\n const transformedRcNetworkTracking = transformedAutocaptureRemoteConfig.networkTracking;\n /* istanbul ignore next */\n const captureRules = transformedRcNetworkTracking.captureRules ?? [];\n for (const rule of captureRules) {\n rule.urls = mergeUrls(rule.urls ?? [], rule.urlsRegex, browserConfig);\n delete rule.urlsRegex;\n }\n }\n\n if (typeof browserConfig.autocapture === 'boolean') {\n browserConfig.autocapture = {\n attribution: browserConfig.autocapture,\n fileDownloads: browserConfig.autocapture,\n formInteractions: browserConfig.autocapture,\n pageViews: browserConfig.autocapture,\n sessions: browserConfig.autocapture,\n elementInteractions: browserConfig.autocapture,\n webVitals: browserConfig.autocapture,\n frustrationInteractions: browserConfig.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n\n if (typeof browserConfig.autocapture === 'object') {\n browserConfig.autocapture = {\n ...browserConfig.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n }\n\n // Override default tracking options if autocapture is updated by remote config\n browserConfig.defaultTracking = browserConfig.autocapture;\n }\n\n if ('customEnrichment' in typedRemoteConfig && typedRemoteConfig.customEnrichment !== null) {\n // Respect a locally-explicit false: if the user disabled custom enrichment at init time,\n // remote config must not re-enable it.\n if (browserConfig.customEnrichment !== false) {\n browserConfig.customEnrichment = typedRemoteConfig.customEnrichment;\n }\n }\n\n browserConfig.loggerProvider.debug('Browser config after remote config update:', JSON.stringify(browserConfig));\n } catch (e) {\n browserConfig.loggerProvider.error('Failed to apply remote configuration because of error: ', e);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAQL,YAAY,EACZ,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AAiCnC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAA4B;;;IACvE,iFAAiF;IACjF,0DAA0D;IAC1D;;;KAGC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE;QACjD,OAAO;KACR;IAED,mDAAmD;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,OAAO;KACR;IAED,IAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;QAC1C,KAA2B,IAAA,kBAAA,SAAA,aAAa,CAAA,4CAAA,uEAAE;YAArC,IAAM,YAAY,0B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AS,EAAE,aAAa,CAAC,WAAW,EACpC,uBAAuB,EAAE,aAAa,CAAC,WAAW,IAC/C,kCAAkC,CACtC,CAAC;iBACH;gBAED,IAAI,OAAO,aAAa,CAAC,WAAW,KAAK,QAAQ,EAAE;oBACjD,aAAa,CAAC,WAAW,yBACpB,aAAa,CAAC,WAAW,GACzB,kCAAkC,CACtC,CAAC;iBACH;aACF;YAED,+EAA+E;YAC/E,aAAa,CAAC,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;SAC3D;QAED,IAAI,kBAAkB,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,gBAAgB,KAAK,IAAI,EAAE;YAC1F,yFAAyF;YACzF,uCAAuC;YACvC,IAAI,aAAa,CAAC,gBAAgB,KAAK,KAAK,EAAE;gBAC5C,aAAa,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC;aACrE;SACF;QAED,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,4CAA4C,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC;KACpH;IAAC,OAAO,CAAC,EAAE;QACV,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,EAAE,CAAC,CAAC,CAAC;KAClG;AACH,CAAC","sourcesContent":["import {\n AutocaptureOptions,\n type ElementInteractionsOptions,\n BrowserConfig,\n CustomEnrichmentOptions,\n RemoteConfig,\n NetworkTrackingOptions,\n NetworkCaptureRule,\n SAFE_HEADERS,\n safeJsonStringify,\n} from '@amplitude/analytics-core';\n\nexport interface AutocaptureOptionsRemoteConfig extends AutocaptureOptions {\n elementInteractions?: boolean | ElementInteractionsOptionsRemoteConfig;\n networkTracking?: boolean | NetworkTrackingOptionsRemoteConfig;\n}\nexport interface ElementInteractionsOptionsRemoteConfig extends ElementInteractionsOptions {\n /**\n * Related to pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n pageUrlAllowlistRegex?: string[];\n}\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 pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n captureRules?: NetworkCaptureRuleRemoteConfig[];\n}\n\n// Type alias for the remote config structure we expect (this is what comes from the filtered browserSDK config)\ntype RemoteConfigBrowserSDK = {\n autocapture?: AutocaptureOptionsRemoteConfig | boolean;\n customEnrichment?: CustomEnrichmentOptions | boolean;\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 // 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\nfunction mergeUrls(urlsExact: (string | RegExp)[], urlsRegex: string[] | undefined, browserConfig: BrowserConfig) {\n // Convert string patterns to RegExp objects, warn on invalid patterns and skip them\n const regexList = [];\n for (const pattern of urlsRegex ?? []) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n browserConfig.loggerProvider.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n return urlsExact.concat(regexList);\n}\n\n/**\n * Updates the browser config in place by applying remote configuration settings.\n * Primarily merges autocapture settings from the remote config into the browser config.\n *\n * @param remoteConfig - The remote configuration to apply, or null if none available\n * @param browserConfig - The browser config object to update (modified in place)\n */\nexport function updateBrowserConfigWithRemoteConfig(\n remoteConfig: RemoteConfig | null,\n browserConfig: BrowserConfig,\n): void {\n if (!remoteConfig) {\n return;\n }\n\n // translate remote config to local compatible format\n translateRemoteConfigToLocal(remoteConfig);\n\n try {\n browserConfig.loggerProvider.debug(\n 'Update browser config with remote configuration:',\n safeJsonStringify(remoteConfig),\n );\n\n // type cast error will be thrown if remoteConfig is not a valid RemoteConfigBrowserSDK\n // and it will be caught by the try-catch block\n const typedRemoteConfig = remoteConfig as RemoteConfigBrowserSDK;\n\n // merge remoteConfig.autocapture and browserConfig.autocapture\n // if a field is in remoteConfig.autocapture, use that value\n // if a field is not in remoteConfig.autocapture, use the value from browserConfig.autocapture\n if (typedRemoteConfig && 'autocapture' in typedRemoteConfig) {\n if (typeof typedRemoteConfig.autocapture === 'boolean') {\n browserConfig.autocapture = typedRemoteConfig.autocapture;\n }\n\n if (typeof typedRemoteConfig.autocapture === 'object' && typedRemoteConfig.autocapture !== null) {\n const transformedAutocaptureRemoteConfig = { ...typedRemoteConfig.autocapture };\n\n if (browserConfig.autocapture === undefined) {\n browserConfig.autocapture = typedRemoteConfig.autocapture;\n }\n\n // Handle Element Interactions config initialization\n if (\n typeof typedRemoteConfig.autocapture.elementInteractions === 'object' &&\n typedRemoteConfig.autocapture.elementInteractions !== null &&\n typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex?.length\n ) {\n transformedAutocaptureRemoteConfig.elementInteractions = {\n ...typedRemoteConfig.autocapture.elementInteractions,\n };\n const transformedRcElementInteractions = transformedAutocaptureRemoteConfig.elementInteractions;\n\n // combine exact allow list and regex allow list into just 'pageUrlAllowlist'\n const exactAllowList = transformedRcElementInteractions.pageUrlAllowlist ?? [];\n const urlsRegex = typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex;\n transformedRcElementInteractions.pageUrlAllowlist = mergeUrls(exactAllowList, urlsRegex, browserConfig);\n\n // clean up the regex allow list\n delete transformedRcElementInteractions.pageUrlAllowlistRegex;\n }\n\n // Handle Network Tracking config initialization\n if (\n typeof typedRemoteConfig.autocapture.networkTracking === 'object' &&\n typedRemoteConfig.autocapture.networkTracking !== null &&\n typedRemoteConfig.autocapture.networkTracking.captureRules?.length\n ) {\n transformedAutocaptureRemoteConfig.networkTracking = {\n ...typedRemoteConfig.autocapture.networkTracking,\n };\n const transformedRcNetworkTracking = transformedAutocaptureRemoteConfig.networkTracking;\n /* istanbul ignore next */\n const captureRules = transformedRcNetworkTracking.captureRules ?? [];\n for (const rule of captureRules) {\n rule.urls = mergeUrls(rule.urls ?? [], rule.urlsRegex, browserConfig);\n delete rule.urlsRegex;\n }\n }\n\n if (typeof browserConfig.autocapture === 'boolean') {\n browserConfig.autocapture = {\n attribution: browserConfig.autocapture,\n fileDownloads: browserConfig.autocapture,\n formInteractions: browserConfig.autocapture,\n pageViews: browserConfig.autocapture,\n sessions: browserConfig.autocapture,\n elementInteractions: browserConfig.autocapture,\n webVitals: browserConfig.autocapture,\n frustrationInteractions: browserConfig.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n\n if (typeof browserConfig.autocapture === 'object') {\n browserConfig.autocapture = {\n ...browserConfig.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n }\n\n // Override default tracking options if autocapture is updated by remote config\n browserConfig.defaultTracking = browserConfig.autocapture;\n }\n\n if ('customEnrichment' in typedRemoteConfig && typedRemoteConfig.customEnrichment !== null) {\n // Respect a locally-explicit false: if the user disabled custom enrichment at init time,\n // remote config must not re-enable it.\n if (browserConfig.customEnrichment !== false) {\n browserConfig.customEnrichment = typedRemoteConfig.customEnrichment;\n }\n }\n\n browserConfig.loggerProvider.debug('Browser config after remote config update:', safeJsonStringify(browserConfig));\n } catch (e) {\n browserConfig.loggerProvider.error('Failed to apply remote configuration because of error: ', e);\n }\n}\n"]}
|
package/lib/esm/config.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare class BrowserConfig extends Config implements IBrowserConfig {
|
|
|
40
40
|
topLevelDomain?: string | undefined;
|
|
41
41
|
enableRequestBodyCompression: boolean;
|
|
42
42
|
customEnrichment?: boolean | CustomEnrichmentOptions | undefined;
|
|
43
|
-
readonly version = "2.44.
|
|
43
|
+
readonly version = "2.44.1";
|
|
44
44
|
protected _cookieStorage: Storage<UserSession>;
|
|
45
45
|
protected _deviceId?: string;
|
|
46
46
|
protected _lastEventId?: number;
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.44.
|
|
1
|
+
export declare const VERSION = "2.44.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export var VERSION = '2.44.
|
|
1
|
+
export var VERSION = '2.44.1';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/lib/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["export const VERSION = '2.44.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["export const VERSION = '2.44.1';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},i=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(i(e,t,Array.prototype.slice.call(arguments)))}}},s=function(e){for(var t=0;t<
|
|
1
|
+
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},i=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(i(e,t,Array.prototype.slice.call(arguments)))}}},s=function(e){for(var t=0;t<v.length;t++)o(e,v[t],!1);for(var r=0;r<y.length;r++)o(e,y[r],!0)};r.invoked=!0;var u=t.getElementsByTagName("script")[0],a=t.createElement("script");a.src="https://cdn.amplitude.com/libs/plugin-autocapture-browser-0.9.0-min.js.gz",a.async=!1,u.parentNode.insertBefore(a,u);var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-0WVMHVbXPgywCOjxDkkzUj3HtTEavGCbBFhaCCxJZNHdd4G9fdqRWZESEKqkoOHx",c.crossOrigin="anonymous",c.async=!1,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.44.1-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK"),e.amplitude.init("YOUR_API_KEY","YOUR_USER_ID",{instanceName:"amplitude-bookmarklet",serverZone:"YOUR_SERVER_ZONE",ingestionMetadata:{sourceName:"browser-typescript-bookmarklet",sourceVersion:"1.0.0"},optOut:!1}),amplitudeAutocapturePlugin&&litudeAutocapturePlugin.autocapturePlugin&&"function"==typeof amplitudeAutocapturePlugin.autocapturePlugin&&e.amplitude.add(amplitudeAutocapturePlugin.autocapturePlugin()),alert("Amplitude is now tracking events!")},u.parentNode.insertBefore(c,u);for(var p=function(){return this._q=[],this},l=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],d=0;d<l.length;d++)n(p,l[d]);r.Identify=p;for(var m=function(){return this._q=[],this},g=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],f=0;f<g.length;f++)n(m,g[f]);r.Revenue=m;var v=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],y=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];s(r),r.createInstance=function(e){return r._iq[e]={_q:[]},s(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
javascript:!function()%7B%22use%20strict%22%3B!function(e%2Ct)%7Bvar%20r%3De.amplitude%7C%7C%7B_q%3A%5B%5D%2C_iq%3A%7B%7D%7D%3Bif(r.invoked)e.console%26%26console.error%26%26console.error(%22Amplitude%20snippet%20has%20been%20loaded.%22)%3Belse%7Bvar%20n%3Dfunction(e%2Ct)%7Be.prototype%5Bt%5D%3Dfunction()%7Breturn%20this._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(arguments%2C0)%7D)%2Cthis%7D%7D%2Ci%3Dfunction(e%2Ct%2Cr)%7Breturn%20function(n)%7Be._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(r%2C0)%2Cresolve%3An%7D)%7D%7D%2Co%3Dfunction(e%2Ct%2Cr)%7Be%5Bt%5D%3Dfunction()%7Bif(r)return%7Bpromise%3Anew%20Promise(i(e%2Ct%2CArray.prototype.slice.call(arguments)))%7D%7D%7D%2Cs%3Dfunction(e)%7Bfor(var%20t%3D0%3Bt%
|
|
1
|
+
javascript:!function()%7B%22use%20strict%22%3B!function(e%2Ct)%7Bvar%20r%3De.amplitude%7C%7C%7B_q%3A%5B%5D%2C_iq%3A%7B%7D%7D%3Bif(r.invoked)e.console%26%26console.error%26%26console.error(%22Amplitude%20snippet%20has%20been%20loaded.%22)%3Belse%7Bvar%20n%3Dfunction(e%2Ct)%7Be.prototype%5Bt%5D%3Dfunction()%7Breturn%20this._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(arguments%2C0)%7D)%2Cthis%7D%7D%2Ci%3Dfunction(e%2Ct%2Cr)%7Breturn%20function(n)%7Be._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(r%2C0)%2Cresolve%3An%7D)%7D%7D%2Co%3Dfunction(e%2Ct%2Cr)%7Be%5Bt%5D%3Dfunction()%7Bif(r)return%7Bpromise%3Anew%20Promise(i(e%2Ct%2CArray.prototype.slice.call(arguments)))%7D%7D%7D%2Cs%3Dfunction(e)%7Bfor(var%20t%3D0%3Bt%3Cv.length%3Bt%2B%2B)o(e%2Cv%5Bt%5D%2C!1)%3Bfor(var%20r%3D0%3Br%3Cy.length%3Br%2B%2B)o(e%2Cy%5Br%5D%2C!0)%7D%3Br.invoked%3D!0%3Bvar%20u%3Dt.getElementsByTagName(%22script%22)%5B0%5D%2Ca%3Dt.createElement(%22script%22)%3Ba.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fplugin-autocapture-browser-0.9.0-min.js.gz%22%2Ca.async%3D!1%2Cu.parentNode.insertBefore(a%2Cu)%3Bvar%20c%3Dt.createElement(%22script%22)%3Bc.type%3D%22text%2Fjavascript%22%2Cc.integrity%3D%22sha384-0WVMHVbXPgywCOjxDkkzUj3HtTEavGCbBFhaCCxJZNHdd4G9fdqRWZESEKqkoOHx%22%2Cc.crossOrigin%3D%22anonymous%22%2Cc.async%3D!1%2Cc.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fanalytics-browser-2.44.1-min.js.gz%22%2Cc.onload%3Dfunction()%7Be.amplitude.runQueuedFunctions%7C%7Cconsole.log(%22%5BAmplitude%5D%20Error%3A%20could%20not%20load%20SDK%22)%2Ce.amplitude.init(%22YOUR_API_KEY%22%2C%22YOUR_USER_ID%22%2C%7BinstanceName%3A%22amplitude-bookmarklet%22%2CserverZone%3A%22YOUR_SERVER_ZONE%22%2CingestionMetadata%3A%7BsourceName%3A%22browser-typescript-bookmarklet%22%2CsourceVersion%3A%221.0.0%22%7D%2CoptOut%3A!1%7D)%2CamplitudeAutocapturePlugin%26%26amplitudeAutocapturePlugin.autocapturePlugin%26%26%22function%22%3D%3Dtypeof%20amplitudeAutocapturePlugin.autocapturePlugin%26%26e.amplitude.add(amplitudeAutocapturePlugin.autocapturePlugin())%2Calert(%22Amplitude%20is%20now%20tracking%20events!%22)%7D%2Cu.parentNode.insertBefore(c%2Cu)%3Bfor(var%20p%3Dfunction()%7Breturn%20this._q%3D%5B%5D%2Cthis%7D%2Cl%3D%5B%22add%22%2C%22append%22%2C%22clearAll%22%2C%22prepend%22%2C%22set%22%2C%22setOnce%22%2C%22unset%22%2C%22preInsert%22%2C%22postInsert%22%2C%22remove%22%2C%22getUserProperties%22%5D%2Cd%3D0%3Bd%3Cl.length%3Bd%2B%2B)n(p%2Cl%5Bd%5D)%3Br.Identify%3Dp%3Bfor(var%20m%3Dfunction()%7Breturn%20this._q%3D%5B%5D%2Cthis%7D%2Cg%3D%5B%22getEventProperties%22%2C%22setProductId%22%2C%22setQuantity%22%2C%22setPrice%22%2C%22setRevenue%22%2C%22setRevenueType%22%2C%22setReceipt%22%2C%22setReceiptSig%22%2C%22setCurrency%22%2C%22setEventProperties%22%5D%2Cf%3D0%3Bf%3Cg.length%3Bf%2B%2B)n(m%2Cg%5Bf%5D)%3Br.Revenue%3Dm%3Bvar%20v%3D%5B%22getDeviceId%22%2C%22setDeviceId%22%2C%22getSessionId%22%2C%22setSessionId%22%2C%22getUserId%22%2C%22setUserId%22%2C%22setOptOut%22%2C%22setTransport%22%2C%22reset%22%2C%22extendSession%22%5D%2Cy%3D%5B%22init%22%2C%22add%22%2C%22remove%22%2C%22track%22%2C%22logEvent%22%2C%22identify%22%2C%22groupIdentify%22%2C%22setGroup%22%2C%22revenue%22%2C%22flush%22%5D%3Bs(r)%2Cr.createInstance%3Dfunction(e)%7Breturn%20r._iq%5Be%5D%3D%7B_q%3A%5B%5D%7D%2Cs(r._iq%5Be%5D)%2Cr._iq%5Be%5D%7D%2Ce.amplitude%3Dr%7D%7D(window%2Cdocument)%7D()%3B%0A
|