@amplitude/plugin-network-capture-browser 1.1.7-networktrackingprereleasemay.0 → 1.1.9
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 +3 -3
- package/lib/cjs/network-capture-plugin.d.ts +1 -2
- package/lib/cjs/network-capture-plugin.d.ts.map +1 -1
- package/lib/cjs/network-capture-plugin.js.map +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.d.ts.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/network-capture-plugin.d.ts +1 -2
- package/lib/esm/network-capture-plugin.d.ts.map +1 -1
- package/lib/esm/network-capture-plugin.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.d.ts.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +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/network-capture-plugin.d.ts +1 -2
- package/lib/scripts/network-capture-plugin.d.ts.map +1 -1
- package/lib/scripts/version.d.ts +1 -1
- package/lib/scripts/version.d.ts.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
## TODO: Re-write this README.md to match plugin-network-capture
|
|
12
12
|
|
|
13
|
-
Browser SDK plugin for
|
|
13
|
+
Browser SDK plugin for network capture.
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -26,9 +26,9 @@ yarn add @amplitude/plugin-network-capture-browser@beta
|
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
|
-
This plugin works on top of the Amplitude Browser SDK,
|
|
29
|
+
This plugin works on top of the Amplitude Browser SDK, and tracks network request events
|
|
30
30
|
|
|
31
|
-
To use this plugin, you need to install `@amplitude/
|
|
31
|
+
To use this plugin, you need to install `@amplitude/plugin-network-capture-browser`
|
|
32
32
|
|
|
33
33
|
### 1. Import Amplitude packages
|
|
34
34
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrowserClient, BrowserConfig, EnrichmentPlugin,
|
|
1
|
+
import { BrowserClient, BrowserConfig, EnrichmentPlugin, NetworkRequestEvent, NetworkTrackingOptions } from '@amplitude/analytics-core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { HasEventTargetAddRemove } from 'rxjs/internal/observable/fromEvent';
|
|
4
4
|
declare global {
|
|
@@ -7,7 +7,6 @@ declare global {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
export type BrowserEnrichmentPlugin = EnrichmentPlugin<BrowserClient, BrowserConfig>;
|
|
10
|
-
export type AutoCaptureOptionsWithDefaults = Required<Pick<ElementInteractionsOptions, 'debounceTime' | 'cssSelectorAllowlist' | 'actionClickAllowlist'>> & ElementInteractionsOptions;
|
|
11
10
|
export declare enum ObservablesEnum {
|
|
12
11
|
NetworkObservable = "networkObservable"
|
|
13
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-capture-plugin.d.ts","sourceRoot":"","sources":["../../src/network-capture-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"network-capture-plugin.d.ts","sourceRoot":"","sources":["../../src/network-capture-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EAGnB,sBAAsB,EAEvB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAgB,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAG7E,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE,uBAAuB,CAAC,KAAK,CAAC,CAAC;KAC5C;CACF;AAED,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAErF,oBAAY,eAAe;IACzB,iBAAiB,sBAAsB;CACxC;AAGD,KAAK,oBAAoB,CAAC,CAAC,IAAI;IAC7B,KAAK,EAAE,CAAC,CAAC;IACT,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;CACnF,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,KAAK,CAAC;AACnD,MAAM,MAAM,4BAA4B,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG;IACtE,KAAK,EAAE,UAAU,GAAG,KAAK,CAAC;IAC1B,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,sBAAsB,EAAE,OAAO,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9C,CAAC;AAGF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG,4BAA4B,CAAC,CAAC,CAAC,CAAC;AAE5F,MAAM,WAAW,oBAAoB;IACnC,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,CAAC;CACxF;AAED,eAAO,MAAM,oBAAoB,aAAa,sBAAsB,KAAQ,uBA8E3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-capture-plugin.js","sourceRoot":"","sources":["../../src/network-capture-plugin.ts"],"names":[],"mappings":";;;;AAAA,0CAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"network-capture-plugin.js","sourceRoot":"","sources":["../../src/network-capture-plugin.ts"],"names":[],"mappings":";;;;AAAA,0CAA0C;AAC1C,4DASmC;AACnC,6DAAyC;AACzC,6BAAgD;AAEhD,6DAA2D;AAU3D,IAAY,eAEX;AAFD,WAAY,eAAe;IACzB,0DAAuC,CAAA;AACzC,CAAC,EAFW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAE1B;AAyBM,IAAM,oBAAoB,GAAG,UAAC,OAAoC;IAApC,wBAAA,EAAA,YAAoC;IACvE,IAAM,IAAI,GAAG,SAAS,CAAC,WAAW,CAAC;IACnC,IAAM,IAAI,GAAG,YAAY,CAAC;IAC1B,IAAI,MAAe,CAAC;IAEpB,IAAM,aAAa,GAAmB,EAAE,CAAC;IAEzC,IAAM,4BAA4B,GAAG,UACnC,KAAQ,EACR,IAAiC;QAEjC,IAAM,SAAS,GAA8D;YAC3E,KAAK,OAAA;YACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,IAAI,MAAA;SACL,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,6CAA6C;IAC7C,IAAM,iBAAiB,GAAG;;QACxB,IAAM,iBAAiB,GAAG,IAAI,iBAAU,CAAwC,UAAC,QAAQ;YACvF,IAAM,QAAQ,GAAG,IAAI,qCAAoB,CAAC,UAAC,KAAK;gBAC9C,IAAM,mBAAmB,GAAG,4BAA4B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;gBAC3E,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;YACH,gCAAe,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC5C,OAAO;gBACL,gCAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACxC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH;YACE,GAAC,eAAe,CAAC,iBAAiB,IAAG,iBAAiB;eACtD;IACJ,CAAC,CAAC;IAEF,IAAM,KAAK,GAAqC,UAAO,MAAM,EAAE,SAAS;;;YACtE,wBAAwB;YACxB,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;gBACnC,sBAAO;aACR;YAGK,cAAc,GAAG,iBAAiB,EAAE,CAAC;YAErC,0BAA0B,GAAG,IAAA,wCAAkB,EAAC;gBACpD,cAAc,gBAAA;gBACd,sBAAsB,EAAE,OAAO;gBAC/B,SAAS,WAAA;aACV,CAAC,CAAC;YACH,aAAa,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YAE/C,0BAA0B;YAC1B,MAAM,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC;YAChC,0BAA0B;YAC1B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,CAAC,UAAG,IAAI,kCAA+B,CAAC,CAAC;;;SACrD,CAAC;IAEF,0BAA0B;IAC1B,IAAM,OAAO,GAAuC,UAAO,KAAK;;YAC9D,sBAAO,KAAK,EAAC;;SACd,CAAC;IAEF,IAAM,QAAQ,GAAG;;;;;gBACf,KAA2B,kBAAA,iBAAA,aAAa,CAAA,mHAAE;oBAA/B,YAAY;oBACrB,YAAY,CAAC,WAAW,EAAE,CAAC;iBAC5B;;;;;;;;;;;SACF,CAAC;IAEF,OAAO;QACL,IAAI,MAAA;QACJ,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,OAAO,SAAA;QACP,QAAQ,UAAA;KACT,CAAC;AACJ,CAAC,CAAC;AA9EW,QAAA,oBAAoB,wBA8E/B","sourcesContent":["/* eslint-disable no-restricted-globals */\nimport {\n BrowserClient,\n BrowserConfig,\n EnrichmentPlugin,\n NetworkRequestEvent,\n networkObserver,\n NetworkEventCallback,\n NetworkTrackingOptions,\n ILogger,\n} from '@amplitude/analytics-core';\nimport * as constants from './constants';\nimport { Observable, Subscription } from 'rxjs';\nimport { HasEventTargetAddRemove } from 'rxjs/internal/observable/fromEvent';\nimport { trackNetworkEvents } from './track-network-event';\n\ndeclare global {\n interface Window {\n navigation: HasEventTargetAddRemove<Event>;\n }\n}\n\nexport type BrowserEnrichmentPlugin = EnrichmentPlugin<BrowserClient, BrowserConfig>;\n\nexport enum ObservablesEnum {\n NetworkObservable = 'networkObservable',\n}\n\n// Base TimestampedEvent type\ntype BaseTimestampedEvent<T> = {\n event: T;\n timestamp: number;\n type: 'rage' | 'click' | 'change' | 'error' | 'navigate' | 'mutation' | 'network';\n};\n\n// Specific types for events with targetElementProperties\nexport type ElementBasedEvent = MouseEvent | Event;\nexport type ElementBasedTimestampedEvent<T> = BaseTimestampedEvent<T> & {\n event: MouseEvent | Event;\n type: 'click' | 'change';\n closestTrackedAncestor: Element;\n targetElementProperties: Record<string, any>;\n};\n\n// Union type for all possible TimestampedEvents\nexport type TimestampedEvent<T> = BaseTimestampedEvent<T> | ElementBasedTimestampedEvent<T>;\n\nexport interface AllWindowObservables {\n [ObservablesEnum.NetworkObservable]: Observable<TimestampedEvent<NetworkRequestEvent>>;\n}\n\nexport const networkCapturePlugin = (options: NetworkTrackingOptions = {}): BrowserEnrichmentPlugin => {\n const name = constants.PLUGIN_NAME;\n const type = 'enrichment';\n let logger: ILogger;\n\n const subscriptions: Subscription[] = [];\n\n const addAdditionalEventProperties = <T>(\n event: T,\n type: TimestampedEvent<T>['type'],\n ): TimestampedEvent<T> | ElementBasedTimestampedEvent<T> => {\n const baseEvent: BaseTimestampedEvent<T> | ElementBasedTimestampedEvent<T> = {\n event,\n timestamp: Date.now(),\n type,\n };\n\n return baseEvent;\n };\n\n // Create observables on events on the window\n const createObservables = (): AllWindowObservables => {\n const networkObservable = new Observable<TimestampedEvent<NetworkRequestEvent>>((observer) => {\n const callback = new NetworkEventCallback((event) => {\n const eventWithProperties = addAdditionalEventProperties(event, 'network');\n observer.next(eventWithProperties);\n });\n networkObserver.subscribe(callback, logger);\n return () => {\n networkObserver.unsubscribe(callback);\n };\n });\n\n return {\n [ObservablesEnum.NetworkObservable]: networkObservable,\n };\n };\n\n const setup: BrowserEnrichmentPlugin['setup'] = async (config, amplitude) => {\n /* istanbul ignore if */\n if (typeof document === 'undefined') {\n return;\n }\n\n // Create observables for events on the window\n const allObservables = createObservables();\n\n const networkRequestSubscription = trackNetworkEvents({\n allObservables,\n networkTrackingOptions: options,\n amplitude,\n });\n subscriptions.push(networkRequestSubscription);\n\n /* istanbul ignore next */\n logger = config?.loggerProvider;\n /* istanbul ignore next */\n logger?.log(`${name} has been successfully added.`);\n };\n\n /* istanbul ignore next */\n const execute: BrowserEnrichmentPlugin['execute'] = async (event) => {\n return event;\n };\n\n const teardown = async () => {\n for (const subscription of subscriptions) {\n subscription.unsubscribe();\n }\n };\n\n return {\n name,\n type,\n setup,\n execute,\n teardown,\n };\n};\n"]}
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.1.
|
|
1
|
+
export declare const VERSION = "1.1.9";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/cjs/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
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,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["export const VERSION = '1.1.9';\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrowserClient, BrowserConfig, EnrichmentPlugin,
|
|
1
|
+
import { BrowserClient, BrowserConfig, EnrichmentPlugin, NetworkRequestEvent, NetworkTrackingOptions } from '@amplitude/analytics-core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { HasEventTargetAddRemove } from 'rxjs/internal/observable/fromEvent';
|
|
4
4
|
declare global {
|
|
@@ -7,7 +7,6 @@ declare global {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
export type BrowserEnrichmentPlugin = EnrichmentPlugin<BrowserClient, BrowserConfig>;
|
|
10
|
-
export type AutoCaptureOptionsWithDefaults = Required<Pick<ElementInteractionsOptions, 'debounceTime' | 'cssSelectorAllowlist' | 'actionClickAllowlist'>> & ElementInteractionsOptions;
|
|
11
10
|
export declare enum ObservablesEnum {
|
|
12
11
|
NetworkObservable = "networkObservable"
|
|
13
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-capture-plugin.d.ts","sourceRoot":"","sources":["../../src/network-capture-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"network-capture-plugin.d.ts","sourceRoot":"","sources":["../../src/network-capture-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EAGnB,sBAAsB,EAEvB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAgB,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAG7E,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE,uBAAuB,CAAC,KAAK,CAAC,CAAC;KAC5C;CACF;AAED,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAErF,oBAAY,eAAe;IACzB,iBAAiB,sBAAsB;CACxC;AAGD,KAAK,oBAAoB,CAAC,CAAC,IAAI;IAC7B,KAAK,EAAE,CAAC,CAAC;IACT,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;CACnF,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,KAAK,CAAC;AACnD,MAAM,MAAM,4BAA4B,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG;IACtE,KAAK,EAAE,UAAU,GAAG,KAAK,CAAC;IAC1B,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,sBAAsB,EAAE,OAAO,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9C,CAAC;AAGF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG,4BAA4B,CAAC,CAAC,CAAC,CAAC;AAE5F,MAAM,WAAW,oBAAoB;IACnC,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,CAAC;CACxF;AAED,eAAO,MAAM,oBAAoB,aAAa,sBAAsB,KAAQ,uBA8E3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-capture-plugin.js","sourceRoot":"","sources":["../../src/network-capture-plugin.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"network-capture-plugin.js","sourceRoot":"","sources":["../../src/network-capture-plugin.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,OAAO,EAKL,eAAe,EACf,oBAAoB,GAGrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAgB,MAAM,MAAM,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAU3D,MAAM,CAAN,IAAY,eAEX;AAFD,WAAY,eAAe;IACzB,0DAAuC,CAAA;AACzC,CAAC,EAFW,eAAe,KAAf,eAAe,QAE1B;AAyBD,MAAM,CAAC,IAAM,oBAAoB,GAAG,UAAC,OAAoC;IAApC,wBAAA,EAAA,YAAoC;IACvE,IAAM,IAAI,GAAG,SAAS,CAAC,WAAW,CAAC;IACnC,IAAM,IAAI,GAAG,YAAY,CAAC;IAC1B,IAAI,MAAe,CAAC;IAEpB,IAAM,aAAa,GAAmB,EAAE,CAAC;IAEzC,IAAM,4BAA4B,GAAG,UACnC,KAAQ,EACR,IAAiC;QAEjC,IAAM,SAAS,GAA8D;YAC3E,KAAK,OAAA;YACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,IAAI,MAAA;SACL,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,6CAA6C;IAC7C,IAAM,iBAAiB,GAAG;;QACxB,IAAM,iBAAiB,GAAG,IAAI,UAAU,CAAwC,UAAC,QAAQ;YACvF,IAAM,QAAQ,GAAG,IAAI,oBAAoB,CAAC,UAAC,KAAK;gBAC9C,IAAM,mBAAmB,GAAG,4BAA4B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;gBAC3E,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;YACH,eAAe,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC5C,OAAO;gBACL,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACxC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH;YACE,GAAC,eAAe,CAAC,iBAAiB,IAAG,iBAAiB;eACtD;IACJ,CAAC,CAAC;IAEF,IAAM,KAAK,GAAqC,UAAO,MAAM,EAAE,SAAS;;;YACtE,wBAAwB;YACxB,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;gBACnC,sBAAO;aACR;YAGK,cAAc,GAAG,iBAAiB,EAAE,CAAC;YAErC,0BAA0B,GAAG,kBAAkB,CAAC;gBACpD,cAAc,gBAAA;gBACd,sBAAsB,EAAE,OAAO;gBAC/B,SAAS,WAAA;aACV,CAAC,CAAC;YACH,aAAa,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YAE/C,0BAA0B;YAC1B,MAAM,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC;YAChC,0BAA0B;YAC1B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,CAAC,UAAG,IAAI,kCAA+B,CAAC,CAAC;;;SACrD,CAAC;IAEF,0BAA0B;IAC1B,IAAM,OAAO,GAAuC,UAAO,KAAK;;YAC9D,sBAAO,KAAK,EAAC;;SACd,CAAC;IAEF,IAAM,QAAQ,GAAG;;;;;gBACf,KAA2B,kBAAA,SAAA,aAAa,CAAA,mHAAE;oBAA/B,YAAY;oBACrB,YAAY,CAAC,WAAW,EAAE,CAAC;iBAC5B;;;;;;;;;;;SACF,CAAC;IAEF,OAAO;QACL,IAAI,MAAA;QACJ,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,OAAO,SAAA;QACP,QAAQ,UAAA;KACT,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable no-restricted-globals */\nimport {\n BrowserClient,\n BrowserConfig,\n EnrichmentPlugin,\n NetworkRequestEvent,\n networkObserver,\n NetworkEventCallback,\n NetworkTrackingOptions,\n ILogger,\n} from '@amplitude/analytics-core';\nimport * as constants from './constants';\nimport { Observable, Subscription } from 'rxjs';\nimport { HasEventTargetAddRemove } from 'rxjs/internal/observable/fromEvent';\nimport { trackNetworkEvents } from './track-network-event';\n\ndeclare global {\n interface Window {\n navigation: HasEventTargetAddRemove<Event>;\n }\n}\n\nexport type BrowserEnrichmentPlugin = EnrichmentPlugin<BrowserClient, BrowserConfig>;\n\nexport enum ObservablesEnum {\n NetworkObservable = 'networkObservable',\n}\n\n// Base TimestampedEvent type\ntype BaseTimestampedEvent<T> = {\n event: T;\n timestamp: number;\n type: 'rage' | 'click' | 'change' | 'error' | 'navigate' | 'mutation' | 'network';\n};\n\n// Specific types for events with targetElementProperties\nexport type ElementBasedEvent = MouseEvent | Event;\nexport type ElementBasedTimestampedEvent<T> = BaseTimestampedEvent<T> & {\n event: MouseEvent | Event;\n type: 'click' | 'change';\n closestTrackedAncestor: Element;\n targetElementProperties: Record<string, any>;\n};\n\n// Union type for all possible TimestampedEvents\nexport type TimestampedEvent<T> = BaseTimestampedEvent<T> | ElementBasedTimestampedEvent<T>;\n\nexport interface AllWindowObservables {\n [ObservablesEnum.NetworkObservable]: Observable<TimestampedEvent<NetworkRequestEvent>>;\n}\n\nexport const networkCapturePlugin = (options: NetworkTrackingOptions = {}): BrowserEnrichmentPlugin => {\n const name = constants.PLUGIN_NAME;\n const type = 'enrichment';\n let logger: ILogger;\n\n const subscriptions: Subscription[] = [];\n\n const addAdditionalEventProperties = <T>(\n event: T,\n type: TimestampedEvent<T>['type'],\n ): TimestampedEvent<T> | ElementBasedTimestampedEvent<T> => {\n const baseEvent: BaseTimestampedEvent<T> | ElementBasedTimestampedEvent<T> = {\n event,\n timestamp: Date.now(),\n type,\n };\n\n return baseEvent;\n };\n\n // Create observables on events on the window\n const createObservables = (): AllWindowObservables => {\n const networkObservable = new Observable<TimestampedEvent<NetworkRequestEvent>>((observer) => {\n const callback = new NetworkEventCallback((event) => {\n const eventWithProperties = addAdditionalEventProperties(event, 'network');\n observer.next(eventWithProperties);\n });\n networkObserver.subscribe(callback, logger);\n return () => {\n networkObserver.unsubscribe(callback);\n };\n });\n\n return {\n [ObservablesEnum.NetworkObservable]: networkObservable,\n };\n };\n\n const setup: BrowserEnrichmentPlugin['setup'] = async (config, amplitude) => {\n /* istanbul ignore if */\n if (typeof document === 'undefined') {\n return;\n }\n\n // Create observables for events on the window\n const allObservables = createObservables();\n\n const networkRequestSubscription = trackNetworkEvents({\n allObservables,\n networkTrackingOptions: options,\n amplitude,\n });\n subscriptions.push(networkRequestSubscription);\n\n /* istanbul ignore next */\n logger = config?.loggerProvider;\n /* istanbul ignore next */\n logger?.log(`${name} has been successfully added.`);\n };\n\n /* istanbul ignore next */\n const execute: BrowserEnrichmentPlugin['execute'] = async (event) => {\n return event;\n };\n\n const teardown = async () => {\n for (const subscription of subscriptions) {\n subscription.unsubscribe();\n }\n };\n\n return {\n name,\n type,\n setup,\n execute,\n teardown,\n };\n};\n"]}
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.1.
|
|
1
|
+
export declare const VERSION = "1.1.9";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/esm/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/lib/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export var VERSION = '1.1.
|
|
1
|
+
export var VERSION = '1.1.9';
|
|
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,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["export const VERSION = '1.1.9';\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var amplitudeNetworkCapturePlugin=function(t){"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},e(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},n.apply(this,arguments)};function i(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function u(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,u)}c((n=n.apply(t,e||[])).next())}))}function o(t,e){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=u(0),s.throw=u(1),s.return=u(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function c(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var a=function(){var t="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[t]?globalThis[t]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},l=c([],u(Array(256).keys()),!1).map((function(t){return t.toString(16).padStart(2,"0")})),h=function(t){var e,r=a();if(!(null===(e=null==r?void 0:r.crypto)||void 0===e?void 0:e.getRandomValues))return function(t){return t?(t^16*Math.random()>>t/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,h)}(t);var n=r.crypto.getRandomValues(new Uint8Array(16));return n[6]=15&n[6]|64,n[8]=63&n[8]|128,c([],u(n.entries()),!1).map((function(t){var e=u(t,2),r=e[0],n=e[1];return[4,6,8,10].includes(r)?"-".concat(l[n]):l[n]})).join("")},f=function(){function t(t){this.request=t}return Object.defineProperty(t.prototype,"headers",{get:function(){if(this._headers)return this._headers;var t=this.request.headers;if(Array.isArray(t)){var e=t;this._headers=e.reduce((function(t,e){var r=u(e,2),n=r[0],i=r[1];return t[n]=i,t}),{})}else if(t instanceof Headers){var r={};t.forEach((function(t,e){r[e]=t})),this._headers=r}else"object"==typeof t&&(this._headers=t);return this._headers},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var t=a();if(null==t?void 0:t.TextEncoder){var e=this.request.body;return this._bodySize=p(e,100),this._bodySize}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),t}(),d=function(){function t(t){this.body=t}return Object.defineProperty(t.prototype,"bodySize",{get:function(){return p(this.body,100)},enumerable:!1,configurable:!0}),t}();function p(t,e){var r,n,i,o=a(),c=null==o?void 0:o.TextEncoder;if(c){var l;if("string"==typeof t)l=t,i=(new c).encode(l).length;else if(t instanceof Blob)i=(l=t).size;else if(t instanceof URLSearchParams)l=t,i=(new c).encode(l.toString()).length;else if(ArrayBuffer.isView(t))i=(l=t).byteLength;else if(t instanceof ArrayBuffer)i=(l=t).byteLength;else if(t instanceof FormData){var h=t,f=0,d=0;try{for(var p=s(h.entries()),v=p.next();!v.done;v=p.next()){var y=u(v.value,2),b=y[0],m=y[1];if(f+=b.length,"string"==typeof m)f+=(new c).encode(m).length;else{if(!(m instanceof Blob))return;f+=m.size}if(++d>=e)return}}catch(t){r={error:t}}finally{try{v&&!v.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}i=f}else if(t instanceof ReadableStream)return void(l=t);return i}}var v=function(){function t(t){this.response=t}return Object.defineProperty(t.prototype,"headers",{get:function(){var t;if(this._headers)return this._headers;if(this.response.headers instanceof Headers){var e=this.response.headers,r={};return null===(t=null==e?void 0:e.forEach)||void 0===t||t.call(e,(function(t,e){r[e]=t})),this._headers=r,r}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bodySize",{get:function(){var t,e;if(void 0!==this._bodySize)return this._bodySize;var r=null===(e=null===(t=this.response.headers)||void 0===t?void 0:t.get)||void 0===e?void 0:e.call(t,"content-length"),n=r?parseInt(r,10):void 0;return this._bodySize=n,n},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),t}(),y=function(){function t(t,e,r){this.statusCode=t,this.headersString=e,this.size=r}return Object.defineProperty(t.prototype,"bodySize",{get:function(){return this.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"headers",{get:function(){var t,e;if(this.headersString){var r={},n=this.headersString.split("\r\n");try{for(var i=s(n),o=i.next();!o.done;o=i.next()){var c=u(o.value.split(": "),2),a=c[0],l=c[1];a&&l&&(r[a]=l)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return r}},enumerable:!1,configurable:!0}),t}(),b=function(){function t(t,e,r,n,i,o,s,u,c,a,l){this.type=t,this.method=e,this.timestamp=r,this.startTime=n,this.url=i,this.requestWrapper=o,this.status=s,this.duration=u,this.responseWrapper=c,this.error=a,this.endTime=l}return t.prototype.toSerializable=function(){var t,e,r,n,i={type:this.type,method:this.method,url:this.url,timestamp:this.timestamp,status:this.status,duration:this.duration,error:this.error,startTime:this.startTime,endTime:this.endTime,requestHeaders:null===(t=this.requestWrapper)||void 0===t?void 0:t.headers,requestBodySize:null===(e=this.requestWrapper)||void 0===e?void 0:e.bodySize,responseHeaders:null===(r=this.responseWrapper)||void 0===r?void 0:r.headers,responseBodySize:null===(n=this.responseWrapper)||void 0===n?void 0:n.bodySize};return Object.fromEntries(Object.entries(i).filter((function(t){var e=u(t,2);return e[0],void 0!==e[1]})))},t}();var m=function(t,e){void 0===e&&(e=h()),this.callback=t,this.id=e},g=function(){function t(e){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=e;var r=a();t.isSupported()&&(this.globalScope=r)}return t.isSupported=function(){var t=a();return!!t&&!!t.fetch},t.prototype.subscribe=function(t,e){var r,n,i,o,s,u,c;if(this.logger||(this.logger=e),this.eventCallbacks.set(t.id,t),!this.isObserving){var a=null===(i=null===(n=null===(r=this.globalScope)||void 0===r?void 0:r.XMLHttpRequest)||void 0===n?void 0:n.prototype)||void 0===i?void 0:i.open,l=null===(u=null===(s=null===(o=this.globalScope)||void 0===o?void 0:o.XMLHttpRequest)||void 0===s?void 0:s.prototype)||void 0===u?void 0:u.send;a&&l&&this.observeXhr(a,l);var h=null===(c=this.globalScope)||void 0===c?void 0:c.fetch;h&&this.observeFetch(h),this.isObserving=!0}},t.prototype.unsubscribe=function(t){this.eventCallbacks.delete(t.id)},t.prototype.triggerEventCallbacks=function(t){var e=this;this.eventCallbacks.forEach((function(r){var n;try{r.callback(t)}catch(t){null===(n=e.logger)||void 0===n||n.debug("an unexpected error occurred while triggering event callbacks",t)}}))},t.prototype.handleNetworkRequestEvent=function(t,e,r,n,i,o,s){var u;if(void 0!==o&&void 0!==s){var c,a,l,h="GET";!function(t){return"object"==typeof t&&null!==t&&"url"in t&&"method"in t}(e)?c=null===(u=null==e?void 0:e.toString)||void 0===u?void 0:u.call(e):(c=e.url,h=e.method),h=(null==r?void 0:r.method)||h,n&&(a=n.status),i&&(l={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},a=0);var f=Math.floor(performance.now()-s),d=Math.floor(o+f),p=new b(t,h,o,o,c,r,a,f,n,l,d);this.triggerEventCallbacks(p)}},t.prototype.getTimestamps=function(){var t,e;return{startTime:null===(t=Date.now)||void 0===t?void 0:t.call(Date),durationStart:null===(e=null===performance||void 0===performance?void 0:performance.now)||void 0===e?void 0:e.call(performance)}},t.prototype.observeFetch=function(t){var e=this;this.globalScope&&t&&(this.globalScope.fetch=function(r,n){return i(e,void 0,void 0,(function(){var e,i,s,u,c,a;return o(this,(function(o){switch(o.label){case 0:try{e=this.getTimestamps()}catch(t){null===(c=this.logger)||void 0===c||c.debug("an unexpected error occurred while retrieving timestamps",t)}o.label=1;case 1:return o.trys.push([1,3,,4]),[4,t(r,n)];case 2:return i=o.sent(),[3,4];case 3:return u=o.sent(),s=u,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",r,n?new f(n):void 0,i?new v(i):void 0,s,null==e?void 0:e.startTime,null==e?void 0:e.durationStart)}catch(t){null===(a=this.logger)||void 0===a||a.debug("an unexpected error occurred while handling fetch",t)}if(i)return[2,i];throw s}}))}))})},t.prototype.observeXhr=function(t,e){if(this.globalScope&&t&&e){var r=this.globalScope.XMLHttpRequest.prototype,i=this;r.open=function(){for(var e,r,o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var c=u(o,2),a=c[0],l=c[1];try{this.$$AmplitudeAnalyticsEvent=n({method:a,url:null===(e=null==l?void 0:l.toString)||void 0===e?void 0:e.call(l)},i.getTimestamps())}catch(t){null===(r=i.logger)||void 0===r||r.debug("an unexpected error occurred while calling xhr open",t)}return t.apply(this,o)},r.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=this,o=t[0],s=n.$$AmplitudeAnalyticsEvent;return n.addEventListener("loadend",(function(){var t;try{var e=n.getAllResponseHeaders(),r=n.getResponseHeader("content-length"),u=new y(n.status,e,r?parseInt(r,10):void 0),c=new d(o);s.status=n.status,i.handleNetworkRequestEvent("xhr",{url:s.url,method:s.method},c,u,void 0,s.startTime,s.durationStart)}catch(e){null===(t=i.logger)||void 0===t||t.debug("an unexpected error occurred while handling xhr send",e)}})),e.apply(n,t)}}},t}(),w=new g;function _(t){return"function"==typeof t}function S(t){var e=t((function(t){Error.call(t),t.stack=(new Error).stack}));return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var x=S((function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}}));function A(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var O=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var e;return t.prototype.unsubscribe=function(){var t,e,r,n,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=s(o),l=a.next();!l.done;l=a.next()){l.value.remove(this)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else o.remove(this);var h=this.initialTeardown;if(_(h))try{h()}catch(t){i=t instanceof x?t.errors:[t]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var d=s(f),p=d.next();!p.done;p=d.next()){var v=p.value;try{T(v)}catch(t){i=null!=i?i:[],t instanceof x?i=c(c([],u(i)),u(t.errors)):i.push(t)}}}catch(t){r={error:t}}finally{try{p&&!p.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}}if(i)throw new x(i)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)T(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(e)}},t.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},t.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},t.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&A(e,t)},t.prototype.remove=function(e){var r=this._finalizers;r&&A(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=((e=new t).closed=!0,e),t}(),E=O.EMPTY;function k(t){return t instanceof O||t&&"closed"in t&&_(t.remove)&&_(t.add)&&_(t.unsubscribe)}function T(t){_(t)?t():t.unsubscribe()}var j={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},P=function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,c([t,e],u(r)))};function q(){}function z(t){t()}var C=function(t){function e(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,k(e)&&e.add(r)):r.destination=W,r}return r(e,t),e.create=function(t,e,r){return new M(t,e,r)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(O),I=Function.prototype.bind;function R(t,e){return I.call(t,e)}var F=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){N(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){N(t)}else N(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){N(t)}},t}(),M=function(t){function e(e,r,n){var i,o,s=t.call(this)||this;_(e)||!e?i={next:null!=e?e:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:s&&j.useDeprecatedNextContext?((o=Object.create(e)).unsubscribe=function(){return s.unsubscribe()},i={next:e.next&&R(e.next,o),error:e.error&&R(e.error,o),complete:e.complete&&R(e.complete,o)}):i=e;return s.destination=new F(i),s}return r(e,t),e}(C);function N(t){var e;e=t,P((function(){throw e}))}var W={closed:!0,next:q,error:function(t){throw t},complete:q},U="function"==typeof Symbol&&Symbol.observable||"@@observable";function H(t){return t}var L=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n,i=this,o=(n=t)&&n instanceof C||function(t){return t&&_(t.next)&&_(t.error)&&_(t.complete)}(n)&&k(n)?t:new M(t,e,r);return z((function(){var t=i,e=t.operator,r=t.source;o.add(e?e.call(o,r):r?i._subscribe(o):i._trySubscribe(o))})),o},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=B(e))((function(e,n){var i=new M({next:function(e){try{t(e)}catch(t){n(t),i.unsubscribe()}},error:n,complete:e});r.subscribe(i)}))},t.prototype._subscribe=function(t){var e;return null===(e=this.source)||void 0===e?void 0:e.subscribe(t)},t.prototype[U]=function(){return this},t.prototype.pipe=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return(0===(t=e).length?H:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)})(this)},t.prototype.toPromise=function(t){var e=this;return new(t=B(t))((function(t,r){var n;e.subscribe((function(t){return n=t}),(function(t){return r(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function B(t){var e;return null!==(e=null!=t?t:j.Promise)&&void 0!==e?e:Promise}function D(t){return _(null==t?void 0:t.lift)}function V(t){return function(e){if(D(e))return e.lift((function(e){try{return t(e,this)}catch(t){this.error(t)}}));throw new TypeError("Unable to lift unknown Observable type")}}function $(t,e,r,n,i){return new X(t,e,r,n,i)}var X=function(t){function e(e,r,n,i,o,s){var u=t.call(this,e)||this;return u.onFinalize=o,u.shouldUnsubscribe=s,u._next=r?function(t){try{r(t)}catch(t){e.error(t)}}:t.prototype._next,u._error=i?function(t){try{i(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,u._complete=n?function(){try{n()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,u}return r(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}},e}(C);!function(t){function e(e,r){var n=t.call(this)||this;return n.source=e,n.subjectFactory=r,n._subject=null,n._refCount=0,n._connection=null,D(e)&&(n.lift=e.lift),n}r(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype._teardown=function(){this._refCount=0;var t=this._connection;this._subject=this._connection=null,null==t||t.unsubscribe()},e.prototype.connect=function(){var t=this,e=this._connection;if(!e){e=this._connection=new O;var r=this.getSubject();e.add(this.source.subscribe($(r,void 0,(function(){t._teardown(),r.complete()}),(function(e){t._teardown(),r.error(e)}),(function(){return t._teardown()})))),e.closed&&(this._connection=null,e=O.EMPTY)}return e},e.prototype.refCount=function(){return V((function(t,e){var r=null;t._refCount++;var n=$(e,void 0,void 0,void 0,(function(){if(!t||t._refCount<=0||0<--t._refCount)r=null;else{var n=t._connection,i=r;r=null,!n||i&&n!==i||n.unsubscribe(),e.unsubscribe()}}));t.subscribe(n),n.closed||(r=t.connect())}))(this)}}(L);var Y,Q={now:function(){return(Q.delegate||performance).now()},delegate:void 0},G={schedule:function(t){var e=requestAnimationFrame,r=cancelAnimationFrame,n=e((function(e){r=void 0,t(e)}));return new O((function(){return null==r?void 0:r(n)}))},requestAnimationFrame:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=G.delegate;return((null==r?void 0:r.requestAnimationFrame)||requestAnimationFrame).apply(void 0,c([],u(t)))},cancelAnimationFrame:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return cancelAnimationFrame.apply(void 0,c([],u(t)))},delegate:void 0};new L((function(t){var e=Y||Q,r=e.now(),n=0,i=function(){t.closed||(n=G.requestAnimationFrame((function(o){n=0;var s=e.now();t.next({timestamp:Y?s:o,elapsed:s-r}),i()})))};return i(),function(){n&&G.cancelAnimationFrame(n)}}));var J=S((function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),K=function(t){function e(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r(e,t),e.prototype.lift=function(t){var e=new Z(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new J},e.prototype.next=function(t){var e=this;z((function(){var r,n;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var i=s(e.currentObservers),o=i.next();!o.done;o=i.next()){o.value.next(t)}}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}}))},e.prototype.error=function(t){var e=this;z((function(){if(e._throwIfClosed(),!e.isStopped){e.hasError=e.isStopped=!0,e.thrownError=t;for(var r=e.observers;r.length;)r.shift().error(t)}}))},e.prototype.complete=function(){var t=this;z((function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var e=t.observers;e.length;)e.shift().complete()}}))},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?E:(this.currentObservers=null,o.push(t),new O((function(){e.currentObservers=null,A(o,t)})))},e.prototype._checkFinalizedStatuses=function(t){var e=this,r=e.hasError,n=e.thrownError,i=e.isStopped;r?t.error(n):i&&t.complete()},e.prototype.asObservable=function(){var t=new L;return t.source=this,t},e.create=function(t,e){return new Z(t,e)},e}(L),Z=function(t){function e(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return r(e,t),e.prototype.next=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===r||r.call(e,t)},e.prototype.error=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===r||r.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,r;return null!==(r=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==r?r:E},e}(K);!function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}r(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){var t=this,e=t.hasError,r=t.thrownError,n=t._value;if(e)throw r;return this._throwIfClosed(),n},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)}}(K);var tt={now:function(){return(tt.delegate||Date).now()},delegate:void 0};!function(t){function e(e,r,n){void 0===e&&(e=1/0),void 0===r&&(r=1/0),void 0===n&&(n=tt);var i=t.call(this)||this;return i._bufferSize=e,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,r),i}r(e,t),e.prototype.next=function(e){var r=this,n=r.isStopped,i=r._buffer,o=r._infiniteTimeWindow,s=r._timestampProvider,u=r._windowTime;n||(i.push(e),!o&&i.push(s.now()+u)),this._trimBuffer(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var e=this._innerSubscribe(t),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!t.closed;i+=r?1:2)t.next(n[i]);return this._checkFinalizedStatuses(t),e},e.prototype._trimBuffer=function(){var t=this,e=t._bufferSize,r=t._timestampProvider,n=t._buffer,i=t._infiniteTimeWindow,o=(i?1:2)*e;if(e<1/0&&o<n.length&&n.splice(0,n.length-o),!i){for(var s=r.now(),u=0,c=1;c<n.length&&n[c]<=s;c+=2)u=c;u&&n.splice(0,u+1)}}}(K),function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._value=null,e._hasValue=!1,e._isComplete=!1,e}r(e,t),e.prototype._checkFinalizedStatuses=function(t){var e=this,r=e.hasError,n=e._hasValue,i=e._value,o=e.thrownError,s=e.isStopped,u=e._isComplete;r?t.error(o):(s||u)&&(n&&t.next(i),t.complete())},e.prototype.next=function(t){this.isStopped||(this._value=t,this._hasValue=!0)},e.prototype.complete=function(){var e=this,r=e._hasValue,n=e._value;e._isComplete||(this._isComplete=!0,r&&t.prototype.next.call(this,n),t.prototype.complete.call(this))}}(K);var et,rt=function(t){function e(e,r){return t.call(this)||this}return r(e,t),e.prototype.schedule=function(t,e){return this},e}(O),nt=function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,c([t,e],u(r)))},it=function(t){return clearInterval(t)},ot=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n.pending=!1,n}return r(e,t),e.prototype.schedule=function(t,e){var r;if(void 0===e&&(e=0),this.closed)return this;this.state=t;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,e)),this.pending=!0,this.delay=e,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,e),this},e.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),nt(t.flush.bind(t,this),r)},e.prototype.recycleAsyncId=function(t,e,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return e;null!=e&&it(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,e);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var r,n=!1;try{this.work(t)}catch(t){n=!0,r=t||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},e.prototype.unsubscribe=function(){if(!this.closed){var e=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,A(n,this),null!=e&&(this.id=this.recycleAsyncId(r,e,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(rt),st=1,ut={};function ct(t){return t in ut&&(delete ut[t],!0)}var at=function(t){var e=st++;return ut[e]=!0,et||(et=Promise.resolve()),et.then((function(){return ct(e)&&t()})),e},lt=function(t){ct(t)},ht={setImmediate:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=ht.delegate;return((null==r?void 0:r.setImmediate)||at).apply(void 0,c([],u(t)))},clearImmediate:function(t){return lt(t)},delegate:void 0},ft=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return r(e,t),e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e._scheduled||(e._scheduled=ht.setImmediate(e.flush.bind(e,void 0))))},e.prototype.recycleAsyncId=function(e,r,n){var i;if(void 0===n&&(n=0),null!=n?n>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);var o=e.actions;null!=r&&(null===(i=o[o.length-1])||void 0===i?void 0:i.id)!==r&&(ht.clearImmediate(r),e._scheduled===r&&(e._scheduled=void 0))},e}(ot),dt=function(){function t(e,r){void 0===r&&(r=t.now),this.schedulerActionCtor=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},t.now=tt.now,t}(),pt=function(t){function e(e,r){void 0===r&&(r=dt.now);var n=t.call(this,e,r)||this;return n.actions=[],n._active=!1,n}return r(e,t),e.prototype.flush=function(t){var e=this.actions;if(this._active)e.push(t);else{var r;this._active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=e.shift());if(this._active=!1,r){for(;t=e.shift();)t.unsubscribe();throw r}}},e}(dt),vt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.flush=function(t){this._active=!0;var e=this._scheduled;this._scheduled=void 0;var r,n=this.actions;t=t||n.shift();do{if(r=t.execute(t.state,t.delay))break}while((t=n[0])&&t.id===e&&n.shift());if(this._active=!1,r){for(;(t=n[0])&&t.id===e&&n.shift();)t.unsubscribe();throw r}},e}(pt);new vt(ft),new pt(ot);var yt=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return r(e,t),e.prototype.schedule=function(e,r){return void 0===r&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!=n&&n>0||null==n&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.flush(this),0)},e}(ot),bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(pt);new bt(yt);var mt=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return r(e,t),e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e._scheduled||(e._scheduled=G.requestAnimationFrame((function(){return e.flush(void 0)}))))},e.prototype.recycleAsyncId=function(e,r,n){var i;if(void 0===n&&(n=0),null!=n?n>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);var o=e.actions;null!=r&&r===e._scheduled&&(null===(i=o[o.length-1])||void 0===i?void 0:i.id)!==r&&(G.cancelAnimationFrame(r),e._scheduled=void 0)},e}(ot),gt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.flush=function(t){var e;this._active=!0,t?e=t.id:(e=this._scheduled,this._scheduled=void 0);var r,n=this.actions;t=t||n.shift();do{if(r=t.execute(t.state,t.delay))break}while((t=n[0])&&t.id===e&&n.shift());if(this._active=!1,r){for(;(t=n[0])&&t.id===e&&n.shift();)t.unsubscribe();throw r}},e}(pt);new gt(mt),function(t){function e(e,r){void 0===e&&(e=_t),void 0===r&&(r=1/0);var n=t.call(this,e,(function(){return n.frame}))||this;return n.maxFrames=r,n.frame=0,n.index=-1,n}r(e,t),e.prototype.flush=function(){for(var t,e,r=this.actions,n=this.maxFrames;(e=r[0])&&e.delay<=n&&(r.shift(),this.frame=e.delay,!(t=e.execute(e.state,e.delay))););if(t){for(;e=r.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10}(pt);var wt,_t=function(t){function e(e,r,n){void 0===n&&(n=e.index+=1);var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.index=n,i.active=!0,i.index=e.index=n,i}return r(e,t),e.prototype.schedule=function(r,n){if(void 0===n&&(n=0),Number.isFinite(n)){if(!this.id)return t.prototype.schedule.call(this,r,n);this.active=!1;var i=new e(this.scheduler,this.work);return this.add(i),i.schedule(r,n)}return O.EMPTY},e.prototype.requestAsyncId=function(t,r,n){void 0===n&&(n=0),this.delay=t.frame+n;var i=t.actions;return i.push(this),i.sort(e.sortActions),1},e.prototype.recycleAsyncId=function(t,e,r){},e.prototype._execute=function(e,r){if(!0===this.active)return t.prototype._execute.call(this,e,r)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(ot);new L((function(t){return t.complete()})),function(t){t.NEXT="N",t.ERROR="E",t.COMPLETE="C"}(wt||(wt={})),S((function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}})),S((function(t){return function(){t(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}})),S((function(t){return function(e){t(this),this.name="NotFoundError",this.message=e}})),S((function(t){return function(e){t(this),this.name="SequenceError",this.message=e}})),S((function(t){return function(e){void 0===e&&(e=null),t(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}})),new L(q);var St,xt="500-599";function At(t,e){var r="^"+e.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(r).test(t)}function Ot(t,e){var r,n,i=e.split(",");try{for(var o=s(i),c=o.next();!c.done;c=o.next()){var a=u(c.value.split("-").map(Number),2),l=a[0],h=a[1];if(t===l&&void 0===h)return!0;if(t>=l&&t<=h)return!0}}catch(t){r={error:t}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1}function Et(t){var e;if(t)try{var r=null===(e=a())||void 0===e?void 0:e.location.href,n=new URL(t,r),i=n.searchParams.toString(),o=n.hash.replace("#",""),s=n.href,u=n.host;return n.hash="",n.search="",{query:i,fragment:o,href:s,hrefWithoutQueryOrHash:n.href,host:u}}catch(t){return}}function kt(t,e){var r;void 0===e&&(e={});var n=Et(t.url);if(!n)return!1;var i,o=n.host;if(!1!==e.ignoreAmplitudeRequests&&(At(o,"*.amplitude.com")||At(o,"amplitude.com")))return!1;if(null===(r=e.ignoreHosts)||void 0===r?void 0:r.find((function(t){return At(o,t)})))return!1;if(!e.captureRules&&void 0!==t.status&&!Ot(t.status,xt))return!1;if(e.captureRules&&(c([],u(e.captureRules),!1).reverse().find((function(e){return i=function(t,e,r){if(!t.hosts||t.hosts.find((function(t){return At(e,t)})))return!((r||0===r)&&!Ot(r,t.statusCodeRange||xt))}(e,o,t.status),void 0!==i})),!i))return!1;return!0}function Tt(t){var e,r,n=t.allObservables,i=t.networkTrackingOptions,o=t.amplitude;return n.networkObservable.pipe((e=function(t){return kt(t.event,i)},V((function(t,n){var i=0;t.subscribe($(n,(function(t){return e.call(r,t,i++)&&n.next(t)})))})))).subscribe((function(t){var e,r,n,i=t.event,s=Et(i.url);if(s){var u=null===(r=i.responseWrapper)||void 0===r?void 0:r.bodySize,c=null===(n=i.requestWrapper)||void 0===n?void 0:n.bodySize,a=((e={})["[Amplitude] URL"]=s.hrefWithoutQueryOrHash,e["[Amplitude] URL Query"]=s.query,e["[Amplitude] URL Fragment"]=s.fragment,e["[Amplitude] Request Method"]=i.method,e["[Amplitude] Status Code"]=i.status,e["[Amplitude] Start Time"]=i.startTime,e["[Amplitude] Completion Time"]=i.endTime,e["[Amplitude] Duration"]=i.duration,e["[Amplitude] Request Body Size"]=c,e["[Amplitude] Response Body Size"]=u,e["[Amplitude] Request Type"]=i.type,e);null==o||o.track("[Amplitude] Network Request",a)}}))}!function(t){t.NetworkObservable="networkObservable"}(St||(St={}));var jt=function(t){void 0===t&&(t={});var e,r="@amplitude/plugin-network-capture-browser",n=[],u=function(){var t,r=new L((function(t){var r=new m((function(e){var r=function(t,e){return{event:t,timestamp:Date.now(),type:e}}(e,"network");t.next(r)}));return w.subscribe(r,e),function(){w.unsubscribe(r)}}));return(t={})[St.NetworkObservable]=r,t};return{name:r,type:"enrichment",setup:function(s,c){return i(void 0,void 0,void 0,(function(){var i,a;return o(this,(function(o){return"undefined"==typeof document||(i=u(),a=Tt({allObservables:i,networkTrackingOptions:t,amplitude:c}),n.push(a),null==(e=null==s?void 0:s.loggerProvider)||e.log("".concat(r," has been successfully added."))),[2]}))}))},execute:function(t){return i(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,t]}))}))},teardown:function(){return i(void 0,void 0,void 0,(function(){var t,e,r,i;return o(this,(function(o){try{for(t=s(n),e=t.next();!e.done;e=t.next())e.value.unsubscribe()}catch(t){r={error:t}}finally{try{e&&!e.done&&(i=t.return)&&i.call(t)}finally{if(r)throw r.error}}return[2]}))}))}}};return t.networkCapturePlugin=jt,t.plugin=jt,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
|
1
|
+
var amplitudeNetworkCapturePlugin=function(t){"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},e(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},n.apply(this,arguments)};function i(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function u(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,u)}c((n=n.apply(t,e||[])).next())}))}function o(t,e){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=u(0),s.throw=u(1),s.return=u(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function c(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var a=function(){var t="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[t]?globalThis[t]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},l=c([],u(Array(256).keys()),!1).map((function(t){return t.toString(16).padStart(2,"0")})),h=function(t){var e,r=a();if(!(null===(e=null==r?void 0:r.crypto)||void 0===e?void 0:e.getRandomValues))return function(t){return t?(t^16*Math.random()>>t/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,h)}(t);var n=r.crypto.getRandomValues(new Uint8Array(16));return n[6]=15&n[6]|64,n[8]=63&n[8]|128,c([],u(n.entries()),!1).map((function(t){var e=u(t,2),r=e[0],n=e[1];return[4,6,8,10].includes(r)?"-".concat(l[n]):l[n]})).join("")},f=function(){function t(t){this.request=t}return Object.defineProperty(t.prototype,"headers",{get:function(){if(this._headers)return this._headers;var t=this.request.headers;if(Array.isArray(t)){var e=t;this._headers=e.reduce((function(t,e){var r=u(e,2),n=r[0],i=r[1];return t[n]=i,t}),{})}else if(t instanceof Headers){var r={};t.forEach((function(t,e){r[e]=t})),this._headers=r}else"object"==typeof t&&(this._headers=t);return this._headers},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var t=a();if(null==t?void 0:t.TextEncoder){var e=this.request.body;return this._bodySize=p(e,100),this._bodySize}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),t}(),d=function(){function t(t){this.body=t}return Object.defineProperty(t.prototype,"bodySize",{get:function(){return p(this.body,100)},enumerable:!1,configurable:!0}),t}();function p(t,e){var r,n,i,o=a(),c=null==o?void 0:o.TextEncoder;if(c){var l;if("string"==typeof t)l=t,i=(new c).encode(l).length;else if(t instanceof Blob)i=(l=t).size;else if(t instanceof URLSearchParams)l=t,i=(new c).encode(l.toString()).length;else if(ArrayBuffer.isView(t))i=(l=t).byteLength;else if(t instanceof ArrayBuffer)i=(l=t).byteLength;else if(t instanceof FormData){var h=t,f=0,d=0;try{for(var p=s(h.entries()),v=p.next();!v.done;v=p.next()){var y=u(v.value,2),b=y[0],m=y[1];if(f+=b.length,"string"==typeof m)f+=(new c).encode(m).length;else{if(!(m instanceof Blob))return;f+=m.size}if(++d>=e)return}}catch(t){r={error:t}}finally{try{v&&!v.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}i=f}else if(t instanceof ReadableStream)return void(l=t);return i}}var v=function(){function t(t){this.response=t}return Object.defineProperty(t.prototype,"headers",{get:function(){var t;if(this._headers)return this._headers;if(this.response.headers instanceof Headers){var e=this.response.headers,r={};return null===(t=null==e?void 0:e.forEach)||void 0===t||t.call(e,(function(t,e){r[e]=t})),this._headers=r,r}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bodySize",{get:function(){var t,e;if(void 0!==this._bodySize)return this._bodySize;var r=null===(e=null===(t=this.response.headers)||void 0===t?void 0:t.get)||void 0===e?void 0:e.call(t,"content-length"),n=r?parseInt(r,10):void 0;return this._bodySize=n,n},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),t}(),y=function(){function t(t,e,r){this.statusCode=t,this.headersString=e,this.size=r}return Object.defineProperty(t.prototype,"bodySize",{get:function(){return this.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"headers",{get:function(){var t,e;if(this.headersString){var r={},n=this.headersString.split("\r\n");try{for(var i=s(n),o=i.next();!o.done;o=i.next()){var c=u(o.value.split(": "),2),a=c[0],l=c[1];a&&l&&(r[a]=l)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return r}},enumerable:!1,configurable:!0}),t}(),b=function(){function t(t,e,r,n,i,o,s,u,c,a,l){void 0===s&&(s=0),this.type=t,this.method=e,this.timestamp=r,this.startTime=n,this.url=i,this.requestWrapper=o,this.status=s,this.duration=u,this.responseWrapper=c,this.error=a,this.endTime=l}return t.prototype.toSerializable=function(){var t,e,r,n,i={type:this.type,method:this.method,url:this.url,timestamp:this.timestamp,status:this.status,duration:this.duration,error:this.error,startTime:this.startTime,endTime:this.endTime,requestHeaders:null===(t=this.requestWrapper)||void 0===t?void 0:t.headers,requestBodySize:null===(e=this.requestWrapper)||void 0===e?void 0:e.bodySize,responseHeaders:null===(r=this.responseWrapper)||void 0===r?void 0:r.headers,responseBodySize:null===(n=this.responseWrapper)||void 0===n?void 0:n.bodySize};return Object.fromEntries(Object.entries(i).filter((function(t){var e=u(t,2);return e[0],void 0!==e[1]})))},t}();var m=function(t,e){void 0===e&&(e=h()),this.callback=t,this.id=e},g=function(){function t(e){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=e;var r=a();t.isSupported()&&(this.globalScope=r)}return t.isSupported=function(){var t=a();return!!t&&!!t.fetch},t.prototype.subscribe=function(t,e){var r,n,i,o,s,u,c;if(this.logger||(this.logger=e),this.eventCallbacks.set(t.id,t),!this.isObserving){var a=null===(i=null===(n=null===(r=this.globalScope)||void 0===r?void 0:r.XMLHttpRequest)||void 0===n?void 0:n.prototype)||void 0===i?void 0:i.open,l=null===(u=null===(s=null===(o=this.globalScope)||void 0===o?void 0:o.XMLHttpRequest)||void 0===s?void 0:s.prototype)||void 0===u?void 0:u.send;a&&l&&this.observeXhr(a,l);var h=null===(c=this.globalScope)||void 0===c?void 0:c.fetch;h&&this.observeFetch(h),this.isObserving=!0}},t.prototype.unsubscribe=function(t){this.eventCallbacks.delete(t.id)},t.prototype.triggerEventCallbacks=function(t){var e=this;this.eventCallbacks.forEach((function(r){var n;try{r.callback(t)}catch(t){null===(n=e.logger)||void 0===n||n.debug("an unexpected error occurred while triggering event callbacks",t)}}))},t.prototype.handleNetworkRequestEvent=function(t,e,r,n,i,o,s){var u;if(void 0!==o&&void 0!==s){var c,a,l,h="GET";!function(t){return"object"==typeof t&&null!==t&&"url"in t&&"method"in t}(e)?c=null===(u=null==e?void 0:e.toString)||void 0===u?void 0:u.call(e):(c=e.url,h=e.method),h=(null==r?void 0:r.method)||h,n&&(a=n.status),i&&(l={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},a=0);var f=Math.floor(performance.now()-s),d=Math.floor(o+f),p=new b(t,h,o,o,c,r,a,f,n,l,d);this.triggerEventCallbacks(p)}},t.prototype.getTimestamps=function(){var t,e;return{startTime:null===(t=Date.now)||void 0===t?void 0:t.call(Date),durationStart:null===(e=null===performance||void 0===performance?void 0:performance.now)||void 0===e?void 0:e.call(performance)}},t.prototype.observeFetch=function(t){var e=this;this.globalScope&&t&&(this.globalScope.fetch=function(r,n){return i(e,void 0,void 0,(function(){var e,i,s,u,c,a;return o(this,(function(o){switch(o.label){case 0:try{e=this.getTimestamps()}catch(t){null===(c=this.logger)||void 0===c||c.debug("an unexpected error occurred while retrieving timestamps",t)}o.label=1;case 1:return o.trys.push([1,3,,4]),[4,t(r,n)];case 2:return i=o.sent(),[3,4];case 3:return u=o.sent(),s=u,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",r,n?new f(n):void 0,i?new v(i):void 0,s,null==e?void 0:e.startTime,null==e?void 0:e.durationStart)}catch(t){null===(a=this.logger)||void 0===a||a.debug("an unexpected error occurred while handling fetch",t)}if(i)return[2,i];throw s}}))}))})},t.prototype.observeXhr=function(t,e){if(this.globalScope&&t&&e){var r=this.globalScope.XMLHttpRequest.prototype,i=this;r.open=function(){for(var e,r,o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var c=u(o,2),a=c[0],l=c[1];try{this.$$AmplitudeAnalyticsEvent=n({method:a,url:null===(e=null==l?void 0:l.toString)||void 0===e?void 0:e.call(l)},i.getTimestamps())}catch(t){null===(r=i.logger)||void 0===r||r.debug("an unexpected error occurred while calling xhr open",t)}return t.apply(this,o)},r.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=this,o=t[0],s=n.$$AmplitudeAnalyticsEvent;return n.addEventListener("loadend",(function(){var t;try{var e=n.getAllResponseHeaders(),r=n.getResponseHeader("content-length"),u=new y(n.status,e,r?parseInt(r,10):void 0),c=new d(o);s.status=n.status,i.handleNetworkRequestEvent("xhr",{url:s.url,method:s.method},c,u,void 0,s.startTime,s.durationStart)}catch(e){null===(t=i.logger)||void 0===t||t.debug("an unexpected error occurred while handling xhr send",e)}})),e.apply(n,t)}}},t}(),w=new g;function _(t){return"function"==typeof t}function S(t){var e=t((function(t){Error.call(t),t.stack=(new Error).stack}));return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var x=S((function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}}));function A(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var O=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var e;return t.prototype.unsubscribe=function(){var t,e,r,n,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=s(o),l=a.next();!l.done;l=a.next()){l.value.remove(this)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else o.remove(this);var h=this.initialTeardown;if(_(h))try{h()}catch(t){i=t instanceof x?t.errors:[t]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var d=s(f),p=d.next();!p.done;p=d.next()){var v=p.value;try{T(v)}catch(t){i=null!=i?i:[],t instanceof x?i=c(c([],u(i)),u(t.errors)):i.push(t)}}}catch(t){r={error:t}}finally{try{p&&!p.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}}if(i)throw new x(i)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)T(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(e)}},t.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},t.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},t.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&A(e,t)},t.prototype.remove=function(e){var r=this._finalizers;r&&A(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=((e=new t).closed=!0,e),t}(),E=O.EMPTY;function k(t){return t instanceof O||t&&"closed"in t&&_(t.remove)&&_(t.add)&&_(t.unsubscribe)}function T(t){_(t)?t():t.unsubscribe()}var j={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},P=function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,c([t,e],u(r)))};function q(){}function z(t){t()}var C=function(t){function e(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,k(e)&&e.add(r)):r.destination=W,r}return r(e,t),e.create=function(t,e,r){return new M(t,e,r)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(O),I=Function.prototype.bind;function R(t,e){return I.call(t,e)}var F=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){N(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){N(t)}else N(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){N(t)}},t}(),M=function(t){function e(e,r,n){var i,o,s=t.call(this)||this;_(e)||!e?i={next:null!=e?e:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:s&&j.useDeprecatedNextContext?((o=Object.create(e)).unsubscribe=function(){return s.unsubscribe()},i={next:e.next&&R(e.next,o),error:e.error&&R(e.error,o),complete:e.complete&&R(e.complete,o)}):i=e;return s.destination=new F(i),s}return r(e,t),e}(C);function N(t){var e;e=t,P((function(){throw e}))}var W={closed:!0,next:q,error:function(t){throw t},complete:q},U="function"==typeof Symbol&&Symbol.observable||"@@observable";function H(t){return t}var L=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n,i=this,o=(n=t)&&n instanceof C||function(t){return t&&_(t.next)&&_(t.error)&&_(t.complete)}(n)&&k(n)?t:new M(t,e,r);return z((function(){var t=i,e=t.operator,r=t.source;o.add(e?e.call(o,r):r?i._subscribe(o):i._trySubscribe(o))})),o},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=B(e))((function(e,n){var i=new M({next:function(e){try{t(e)}catch(t){n(t),i.unsubscribe()}},error:n,complete:e});r.subscribe(i)}))},t.prototype._subscribe=function(t){var e;return null===(e=this.source)||void 0===e?void 0:e.subscribe(t)},t.prototype[U]=function(){return this},t.prototype.pipe=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return(0===(t=e).length?H:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)})(this)},t.prototype.toPromise=function(t){var e=this;return new(t=B(t))((function(t,r){var n;e.subscribe((function(t){return n=t}),(function(t){return r(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function B(t){var e;return null!==(e=null!=t?t:j.Promise)&&void 0!==e?e:Promise}function D(t){return _(null==t?void 0:t.lift)}function V(t){return function(e){if(D(e))return e.lift((function(e){try{return t(e,this)}catch(t){this.error(t)}}));throw new TypeError("Unable to lift unknown Observable type")}}function $(t,e,r,n,i){return new X(t,e,r,n,i)}var X=function(t){function e(e,r,n,i,o,s){var u=t.call(this,e)||this;return u.onFinalize=o,u.shouldUnsubscribe=s,u._next=r?function(t){try{r(t)}catch(t){e.error(t)}}:t.prototype._next,u._error=i?function(t){try{i(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,u._complete=n?function(){try{n()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,u}return r(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}},e}(C);!function(t){function e(e,r){var n=t.call(this)||this;return n.source=e,n.subjectFactory=r,n._subject=null,n._refCount=0,n._connection=null,D(e)&&(n.lift=e.lift),n}r(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype._teardown=function(){this._refCount=0;var t=this._connection;this._subject=this._connection=null,null==t||t.unsubscribe()},e.prototype.connect=function(){var t=this,e=this._connection;if(!e){e=this._connection=new O;var r=this.getSubject();e.add(this.source.subscribe($(r,void 0,(function(){t._teardown(),r.complete()}),(function(e){t._teardown(),r.error(e)}),(function(){return t._teardown()})))),e.closed&&(this._connection=null,e=O.EMPTY)}return e},e.prototype.refCount=function(){return V((function(t,e){var r=null;t._refCount++;var n=$(e,void 0,void 0,void 0,(function(){if(!t||t._refCount<=0||0<--t._refCount)r=null;else{var n=t._connection,i=r;r=null,!n||i&&n!==i||n.unsubscribe(),e.unsubscribe()}}));t.subscribe(n),n.closed||(r=t.connect())}))(this)}}(L);var Y,Q={now:function(){return(Q.delegate||performance).now()},delegate:void 0},G={schedule:function(t){var e=requestAnimationFrame,r=cancelAnimationFrame,n=e((function(e){r=void 0,t(e)}));return new O((function(){return null==r?void 0:r(n)}))},requestAnimationFrame:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=G.delegate;return((null==r?void 0:r.requestAnimationFrame)||requestAnimationFrame).apply(void 0,c([],u(t)))},cancelAnimationFrame:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return cancelAnimationFrame.apply(void 0,c([],u(t)))},delegate:void 0};new L((function(t){var e=Y||Q,r=e.now(),n=0,i=function(){t.closed||(n=G.requestAnimationFrame((function(o){n=0;var s=e.now();t.next({timestamp:Y?s:o,elapsed:s-r}),i()})))};return i(),function(){n&&G.cancelAnimationFrame(n)}}));var J=S((function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),K=function(t){function e(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r(e,t),e.prototype.lift=function(t){var e=new Z(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new J},e.prototype.next=function(t){var e=this;z((function(){var r,n;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var i=s(e.currentObservers),o=i.next();!o.done;o=i.next()){o.value.next(t)}}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}}))},e.prototype.error=function(t){var e=this;z((function(){if(e._throwIfClosed(),!e.isStopped){e.hasError=e.isStopped=!0,e.thrownError=t;for(var r=e.observers;r.length;)r.shift().error(t)}}))},e.prototype.complete=function(){var t=this;z((function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var e=t.observers;e.length;)e.shift().complete()}}))},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?E:(this.currentObservers=null,o.push(t),new O((function(){e.currentObservers=null,A(o,t)})))},e.prototype._checkFinalizedStatuses=function(t){var e=this,r=e.hasError,n=e.thrownError,i=e.isStopped;r?t.error(n):i&&t.complete()},e.prototype.asObservable=function(){var t=new L;return t.source=this,t},e.create=function(t,e){return new Z(t,e)},e}(L),Z=function(t){function e(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return r(e,t),e.prototype.next=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===r||r.call(e,t)},e.prototype.error=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===r||r.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,r;return null!==(r=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==r?r:E},e}(K);!function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}r(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){var t=this,e=t.hasError,r=t.thrownError,n=t._value;if(e)throw r;return this._throwIfClosed(),n},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)}}(K);var tt={now:function(){return(tt.delegate||Date).now()},delegate:void 0};!function(t){function e(e,r,n){void 0===e&&(e=1/0),void 0===r&&(r=1/0),void 0===n&&(n=tt);var i=t.call(this)||this;return i._bufferSize=e,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,r),i}r(e,t),e.prototype.next=function(e){var r=this,n=r.isStopped,i=r._buffer,o=r._infiniteTimeWindow,s=r._timestampProvider,u=r._windowTime;n||(i.push(e),!o&&i.push(s.now()+u)),this._trimBuffer(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var e=this._innerSubscribe(t),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!t.closed;i+=r?1:2)t.next(n[i]);return this._checkFinalizedStatuses(t),e},e.prototype._trimBuffer=function(){var t=this,e=t._bufferSize,r=t._timestampProvider,n=t._buffer,i=t._infiniteTimeWindow,o=(i?1:2)*e;if(e<1/0&&o<n.length&&n.splice(0,n.length-o),!i){for(var s=r.now(),u=0,c=1;c<n.length&&n[c]<=s;c+=2)u=c;u&&n.splice(0,u+1)}}}(K),function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._value=null,e._hasValue=!1,e._isComplete=!1,e}r(e,t),e.prototype._checkFinalizedStatuses=function(t){var e=this,r=e.hasError,n=e._hasValue,i=e._value,o=e.thrownError,s=e.isStopped,u=e._isComplete;r?t.error(o):(s||u)&&(n&&t.next(i),t.complete())},e.prototype.next=function(t){this.isStopped||(this._value=t,this._hasValue=!0)},e.prototype.complete=function(){var e=this,r=e._hasValue,n=e._value;e._isComplete||(this._isComplete=!0,r&&t.prototype.next.call(this,n),t.prototype.complete.call(this))}}(K);var et,rt=function(t){function e(e,r){return t.call(this)||this}return r(e,t),e.prototype.schedule=function(t,e){return this},e}(O),nt=function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,c([t,e],u(r)))},it=function(t){return clearInterval(t)},ot=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n.pending=!1,n}return r(e,t),e.prototype.schedule=function(t,e){var r;if(void 0===e&&(e=0),this.closed)return this;this.state=t;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,e)),this.pending=!0,this.delay=e,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,e),this},e.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),nt(t.flush.bind(t,this),r)},e.prototype.recycleAsyncId=function(t,e,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return e;null!=e&&it(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,e);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var r,n=!1;try{this.work(t)}catch(t){n=!0,r=t||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},e.prototype.unsubscribe=function(){if(!this.closed){var e=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,A(n,this),null!=e&&(this.id=this.recycleAsyncId(r,e,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(rt),st=1,ut={};function ct(t){return t in ut&&(delete ut[t],!0)}var at=function(t){var e=st++;return ut[e]=!0,et||(et=Promise.resolve()),et.then((function(){return ct(e)&&t()})),e},lt=function(t){ct(t)},ht={setImmediate:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=ht.delegate;return((null==r?void 0:r.setImmediate)||at).apply(void 0,c([],u(t)))},clearImmediate:function(t){return lt(t)},delegate:void 0},ft=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return r(e,t),e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e._scheduled||(e._scheduled=ht.setImmediate(e.flush.bind(e,void 0))))},e.prototype.recycleAsyncId=function(e,r,n){var i;if(void 0===n&&(n=0),null!=n?n>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);var o=e.actions;null!=r&&(null===(i=o[o.length-1])||void 0===i?void 0:i.id)!==r&&(ht.clearImmediate(r),e._scheduled===r&&(e._scheduled=void 0))},e}(ot),dt=function(){function t(e,r){void 0===r&&(r=t.now),this.schedulerActionCtor=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},t.now=tt.now,t}(),pt=function(t){function e(e,r){void 0===r&&(r=dt.now);var n=t.call(this,e,r)||this;return n.actions=[],n._active=!1,n}return r(e,t),e.prototype.flush=function(t){var e=this.actions;if(this._active)e.push(t);else{var r;this._active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=e.shift());if(this._active=!1,r){for(;t=e.shift();)t.unsubscribe();throw r}}},e}(dt),vt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.flush=function(t){this._active=!0;var e=this._scheduled;this._scheduled=void 0;var r,n=this.actions;t=t||n.shift();do{if(r=t.execute(t.state,t.delay))break}while((t=n[0])&&t.id===e&&n.shift());if(this._active=!1,r){for(;(t=n[0])&&t.id===e&&n.shift();)t.unsubscribe();throw r}},e}(pt);new vt(ft),new pt(ot);var yt=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return r(e,t),e.prototype.schedule=function(e,r){return void 0===r&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!=n&&n>0||null==n&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.flush(this),0)},e}(ot),bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(pt);new bt(yt);var mt=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return r(e,t),e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e._scheduled||(e._scheduled=G.requestAnimationFrame((function(){return e.flush(void 0)}))))},e.prototype.recycleAsyncId=function(e,r,n){var i;if(void 0===n&&(n=0),null!=n?n>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);var o=e.actions;null!=r&&r===e._scheduled&&(null===(i=o[o.length-1])||void 0===i?void 0:i.id)!==r&&(G.cancelAnimationFrame(r),e._scheduled=void 0)},e}(ot),gt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.flush=function(t){var e;this._active=!0,t?e=t.id:(e=this._scheduled,this._scheduled=void 0);var r,n=this.actions;t=t||n.shift();do{if(r=t.execute(t.state,t.delay))break}while((t=n[0])&&t.id===e&&n.shift());if(this._active=!1,r){for(;(t=n[0])&&t.id===e&&n.shift();)t.unsubscribe();throw r}},e}(pt);new gt(mt),function(t){function e(e,r){void 0===e&&(e=_t),void 0===r&&(r=1/0);var n=t.call(this,e,(function(){return n.frame}))||this;return n.maxFrames=r,n.frame=0,n.index=-1,n}r(e,t),e.prototype.flush=function(){for(var t,e,r=this.actions,n=this.maxFrames;(e=r[0])&&e.delay<=n&&(r.shift(),this.frame=e.delay,!(t=e.execute(e.state,e.delay))););if(t){for(;e=r.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10}(pt);var wt,_t=function(t){function e(e,r,n){void 0===n&&(n=e.index+=1);var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.index=n,i.active=!0,i.index=e.index=n,i}return r(e,t),e.prototype.schedule=function(r,n){if(void 0===n&&(n=0),Number.isFinite(n)){if(!this.id)return t.prototype.schedule.call(this,r,n);this.active=!1;var i=new e(this.scheduler,this.work);return this.add(i),i.schedule(r,n)}return O.EMPTY},e.prototype.requestAsyncId=function(t,r,n){void 0===n&&(n=0),this.delay=t.frame+n;var i=t.actions;return i.push(this),i.sort(e.sortActions),1},e.prototype.recycleAsyncId=function(t,e,r){},e.prototype._execute=function(e,r){if(!0===this.active)return t.prototype._execute.call(this,e,r)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(ot);new L((function(t){return t.complete()})),function(t){t.NEXT="N",t.ERROR="E",t.COMPLETE="C"}(wt||(wt={})),S((function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}})),S((function(t){return function(){t(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}})),S((function(t){return function(e){t(this),this.name="NotFoundError",this.message=e}})),S((function(t){return function(e){t(this),this.name="SequenceError",this.message=e}})),S((function(t){return function(e){void 0===e&&(e=null),t(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}})),new L(q);var St,xt="500-599";function At(t,e){var r="^"+e.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(r).test(t)}function Ot(t,e){var r,n,i=e.split(",");try{for(var o=s(i),c=o.next();!c.done;c=o.next()){var a=u(c.value.split("-").map(Number),2),l=a[0],h=a[1];if(t===l&&void 0===h)return!0;if(t>=l&&t<=h)return!0}}catch(t){r={error:t}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1}function Et(t){var e;if(t)try{var r=null===(e=a())||void 0===e?void 0:e.location.href,n=new URL(t,r),i=n.searchParams.toString(),o=n.hash.replace("#",""),s=n.href,u=n.host;return n.hash="",n.search="",{query:i,fragment:o,href:s,hrefWithoutQueryOrHash:n.href,host:u}}catch(t){return}}function kt(t,e){var r;void 0===e&&(e={});var n=Et(t.url);if(!n)return!1;var i,o=n.host;if(!1!==e.ignoreAmplitudeRequests&&(At(o,"*.amplitude.com")||At(o,"amplitude.com")))return!1;if(null===(r=e.ignoreHosts)||void 0===r?void 0:r.find((function(t){return At(o,t)})))return!1;if(!e.captureRules&&void 0!==t.status&&!Ot(t.status,xt))return!1;if(e.captureRules&&(c([],u(e.captureRules),!1).reverse().find((function(e){return i=function(t,e,r){if(!t.hosts||t.hosts.find((function(t){return At(e,t)})))return!((r||0===r)&&!Ot(r,t.statusCodeRange||xt))}(e,o,t.status),void 0!==i})),!i))return!1;return!0}function Tt(t){var e,r,n=t.allObservables,i=t.networkTrackingOptions,o=t.amplitude;return n.networkObservable.pipe((e=function(t){return kt(t.event,i)},V((function(t,n){var i=0;t.subscribe($(n,(function(t){return e.call(r,t,i++)&&n.next(t)})))})))).subscribe((function(t){var e,r,n,i=t.event,s=Et(i.url);if(s){var u=null===(r=i.responseWrapper)||void 0===r?void 0:r.bodySize,c=null===(n=i.requestWrapper)||void 0===n?void 0:n.bodySize,a=((e={})["[Amplitude] URL"]=s.hrefWithoutQueryOrHash,e["[Amplitude] URL Query"]=s.query,e["[Amplitude] URL Fragment"]=s.fragment,e["[Amplitude] Request Method"]=i.method,e["[Amplitude] Status Code"]=i.status,e["[Amplitude] Start Time"]=i.startTime,e["[Amplitude] Completion Time"]=i.endTime,e["[Amplitude] Duration"]=i.duration,e["[Amplitude] Request Body Size"]=c,e["[Amplitude] Response Body Size"]=u,e["[Amplitude] Request Type"]=i.type,e);null==o||o.track("[Amplitude] Network Request",a)}}))}!function(t){t.NetworkObservable="networkObservable"}(St||(St={}));var jt=function(t){void 0===t&&(t={});var e,r="@amplitude/plugin-network-capture-browser",n=[],u=function(){var t,r=new L((function(t){var r=new m((function(e){var r=function(t,e){return{event:t,timestamp:Date.now(),type:e}}(e,"network");t.next(r)}));return w.subscribe(r,e),function(){w.unsubscribe(r)}}));return(t={})[St.NetworkObservable]=r,t};return{name:r,type:"enrichment",setup:function(s,c){return i(void 0,void 0,void 0,(function(){var i,a;return o(this,(function(o){return"undefined"==typeof document||(i=u(),a=Tt({allObservables:i,networkTrackingOptions:t,amplitude:c}),n.push(a),null==(e=null==s?void 0:s.loggerProvider)||e.log("".concat(r," has been successfully added."))),[2]}))}))},execute:function(t){return i(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,t]}))}))},teardown:function(){return i(void 0,void 0,void 0,(function(){var t,e,r,i;return o(this,(function(o){try{for(t=s(n),e=t.next();!e.done;e=t.next())e.value.unsubscribe()}catch(t){r={error:t}}finally{try{e&&!e.done&&(i=t.return)&&i.call(t)}finally{if(r)throw r.error}}return[2]}))}))}}};return t.networkCapturePlugin=jt,t.plugin=jt,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
|
2
2
|
//# sourceMappingURL=amplitude-min.js.map
|
|
Binary file
|