@amplitude/analytics-react-native 0.0.1-dev.0 → 0.0.1-dev.11
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 +150 -0
- package/android/build.gradle +7 -9
- package/android/src/main/java/com/amplitude/reactnative/AmplitudeReactNativeModule.kt +5 -5
- package/ios/AmplitudeReactNative-Bridging-Header.h +0 -4
- package/ios/AmplitudeReactNative.swift +5 -4
- package/ios/AppleContextProvider.swift +1 -1
- package/lib/commonjs/attribution/campaign-tracker.js +1 -1
- package/lib/commonjs/attribution/campaign-tracker.js.map +1 -1
- package/lib/commonjs/config.js +35 -17
- package/lib/commonjs/config.js.map +1 -1
- package/lib/commonjs/index.js +6 -14
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugins/context.js +5 -5
- package/lib/commonjs/plugins/context.js.map +1 -1
- package/lib/commonjs/plugins/identity.js +40 -0
- package/lib/commonjs/plugins/identity.js.map +1 -0
- package/lib/commonjs/react-native-client.js +37 -50
- package/lib/commonjs/react-native-client.js.map +1 -1
- package/lib/commonjs/storage/cookie.js +9 -9
- package/lib/commonjs/storage/cookie.js.map +1 -1
- package/lib/commonjs/utils/analytics-connector.js +15 -0
- package/lib/commonjs/utils/analytics-connector.js.map +1 -0
- package/lib/commonjs/utils/query-params.js +1 -6
- package/lib/commonjs/utils/query-params.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/attribution/campaign-tracker.js +1 -1
- package/lib/module/attribution/campaign-tracker.js.map +1 -1
- package/lib/module/config.js +33 -12
- package/lib/module/config.js.map +1 -1
- package/lib/module/index.js +4 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugins/context.js +5 -5
- package/lib/module/plugins/context.js.map +1 -1
- package/lib/module/plugins/identity.js +29 -0
- package/lib/module/plugins/identity.js.map +1 -0
- package/lib/module/react-native-client.js +34 -49
- package/lib/module/react-native-client.js.map +1 -1
- package/lib/module/storage/cookie.js +9 -9
- package/lib/module/storage/cookie.js.map +1 -1
- package/lib/module/utils/analytics-connector.js +5 -0
- package/lib/module/utils/analytics-connector.js.map +1 -0
- package/lib/module/utils/query-params.js +1 -6
- package/lib/module/utils/query-params.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/config.d.ts +2 -4
- package/lib/typescript/config.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/plugins/context.d.ts +5 -5
- package/lib/typescript/plugins/context.d.ts.map +1 -1
- package/lib/typescript/plugins/identity.d.ts +9 -0
- package/lib/typescript/plugins/identity.d.ts.map +1 -0
- package/lib/typescript/react-native-client.d.ts +17 -24
- package/lib/typescript/react-native-client.d.ts.map +1 -1
- package/lib/typescript/storage/cookie.d.ts.map +1 -1
- package/lib/typescript/utils/analytics-connector.d.ts +3 -0
- package/lib/typescript/utils/analytics-connector.d.ts.map +1 -0
- package/lib/typescript/utils/query-params.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/attribution/campaign-tracker.ts +1 -1
- package/src/config.ts +28 -11
- package/src/index.ts +3 -2
- package/src/plugins/context.ts +10 -10
- package/src/plugins/identity.ts +21 -0
- package/src/react-native-client.ts +37 -54
- package/src/storage/cookie.ts +8 -6
- package/src/utils/analytics-connector.ts +5 -0
- package/src/utils/query-params.ts +1 -4
- package/src/version.ts +1 -1
- package/lib/commonjs/constants.js +0 -31
- package/lib/commonjs/constants.js.map +0 -1
- package/lib/commonjs/transports/send-beacon.js +0 -43
- package/lib/commonjs/transports/send-beacon.js.map +0 -1
- package/lib/commonjs/transports/xhr.js +0 -54
- package/lib/commonjs/transports/xhr.js.map +0 -1
- package/lib/commonjs/utils/snippet-helper.js +0 -56
- package/lib/commonjs/utils/snippet-helper.js.map +0 -1
- package/lib/module/constants.js +0 -13
- package/lib/module/constants.js.map +0 -1
- package/lib/module/transports/send-beacon.js +0 -33
- package/lib/module/transports/send-beacon.js.map +0 -1
- package/lib/module/transports/xhr.js +0 -44
- package/lib/module/transports/xhr.js.map +0 -1
- package/lib/module/utils/snippet-helper.js +0 -41
- package/lib/module/utils/snippet-helper.js.map +0 -1
- package/lib/typescript/constants.d.ts +0 -13
- package/lib/typescript/constants.d.ts.map +0 -1
- package/lib/typescript/transports/send-beacon.d.ts +0 -6
- package/lib/typescript/transports/send-beacon.d.ts.map +0 -1
- package/lib/typescript/transports/xhr.d.ts +0 -7
- package/lib/typescript/transports/xhr.d.ts.map +0 -1
- package/lib/typescript/utils/snippet-helper.d.ts +0 -16
- package/lib/typescript/utils/snippet-helper.d.ts.map +0 -1
- package/src/constants.ts +0 -14
- package/src/transports/send-beacon.ts +0 -34
- package/src/transports/xhr.ts +0 -36
- package/src/utils/snippet-helper.ts +0 -35
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AmplitudeCore } from '@amplitude/analytics-core';
|
|
2
|
-
import { ReactNativeConfig,
|
|
2
|
+
import { ReactNativeConfig, ReactNativeOptions, AdditionalReactNativeOptions, AttributionReactNativeOptions } from '@amplitude/analytics-types';
|
|
3
3
|
export declare class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
4
4
|
init(apiKey: string, userId?: string, options?: ReactNativeOptions & AdditionalReactNativeOptions): Promise<void>;
|
|
5
5
|
runAttributionStrategy(attributionConfig?: AttributionReactNativeOptions, isNewSession?: boolean): Promise<void>;
|
|
@@ -11,10 +11,6 @@ export declare class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfi
|
|
|
11
11
|
getSessionId(): number | undefined;
|
|
12
12
|
setSessionId(sessionId: number): void;
|
|
13
13
|
setOptOut(optOut: boolean): void;
|
|
14
|
-
setTransport(transport: TransportType): void;
|
|
15
|
-
identify(identify: IIdentify, eventOptions?: EventOptions): Promise<Result>;
|
|
16
|
-
groupIdentify(groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions): Promise<Result>;
|
|
17
|
-
revenue(revenue: IRevenue, eventOptions?: EventOptions): Promise<Result>;
|
|
18
14
|
}
|
|
19
15
|
/**
|
|
20
16
|
* Initializes the Amplitude SDK with your apiKey, userId and optional configurations.
|
|
@@ -24,7 +20,7 @@ export declare class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfi
|
|
|
24
20
|
* await init(API_KEY, USER_ID, options).promise;
|
|
25
21
|
* ```
|
|
26
22
|
*/
|
|
27
|
-
export declare const init: (apiKey: string, userId?: string | undefined, options?: (ReactNativeOptions & AdditionalReactNativeOptions) | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<void
|
|
23
|
+
export declare const init: (apiKey: string, userId?: string | undefined, options?: (ReactNativeOptions & AdditionalReactNativeOptions) | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
28
24
|
/**
|
|
29
25
|
* Adds a new plugin.
|
|
30
26
|
*
|
|
@@ -33,7 +29,7 @@ export declare const init: (apiKey: string, userId?: string | undefined, options
|
|
|
33
29
|
* amplitude.add(plugin);
|
|
34
30
|
* ```
|
|
35
31
|
*/
|
|
36
|
-
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<void
|
|
32
|
+
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
37
33
|
/**
|
|
38
34
|
* Removes a plugin.
|
|
39
35
|
*
|
|
@@ -41,7 +37,7 @@ export declare const add: (plugin: import("@amplitude/analytics-types").Plugin)
|
|
|
41
37
|
* amplitude.remove('myPlugin');
|
|
42
38
|
* ```
|
|
43
39
|
*/
|
|
44
|
-
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<void
|
|
40
|
+
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
45
41
|
/**
|
|
46
42
|
* Tracks user-defined event, with specified type, optional event properties and optional overwrites.
|
|
47
43
|
*
|
|
@@ -62,11 +58,11 @@ export declare const remove: (pluginName: string) => import("@amplitude/analytic
|
|
|
62
58
|
* console.log(result.message); // "Event tracked successfully"
|
|
63
59
|
* ```
|
|
64
60
|
*/
|
|
65
|
-
export declare const track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result
|
|
61
|
+
export declare const track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
66
62
|
/**
|
|
67
63
|
* Alias for track()
|
|
68
64
|
*/
|
|
69
|
-
export declare const logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result
|
|
65
|
+
export declare const logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
70
66
|
/**
|
|
71
67
|
* Sends an identify event containing user property operations
|
|
72
68
|
*
|
|
@@ -82,7 +78,7 @@ export declare const logEvent: (eventInput: string | import("@amplitude/analytic
|
|
|
82
78
|
* console.log(result.message); // "Event tracked successfully"
|
|
83
79
|
* ```
|
|
84
80
|
*/
|
|
85
|
-
export declare const identify: (identify:
|
|
81
|
+
export declare const identify: (identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
86
82
|
/**
|
|
87
83
|
* Sends a group identify event containing group property operations.
|
|
88
84
|
*
|
|
@@ -100,8 +96,8 @@ export declare const identify: (identify: IIdentify, eventOptions?: EventOptions
|
|
|
100
96
|
* console.log(result.message); // "Event tracked successfully"
|
|
101
97
|
* ```
|
|
102
98
|
*/
|
|
103
|
-
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify:
|
|
104
|
-
export declare const setGroup: (groupType: string, groupName: string | string[]) => import("@amplitude/analytics-types").AmplitudeReturn<Result
|
|
99
|
+
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
100
|
+
export declare const setGroup: (groupType: string, groupName: string | string[]) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
105
101
|
/**
|
|
106
102
|
* Sends a revenue event containing revenue property operations.
|
|
107
103
|
*
|
|
@@ -117,7 +113,7 @@ export declare const setGroup: (groupType: string, groupName: string | string[])
|
|
|
117
113
|
* console.log(result.message); // "Event tracked successfully"
|
|
118
114
|
* ```
|
|
119
115
|
*/
|
|
120
|
-
export declare const revenue: (revenue:
|
|
116
|
+
export declare const revenue: (revenue: import("@amplitude/analytics-types").Revenue, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
121
117
|
/**
|
|
122
118
|
* Returns current user ID.
|
|
123
119
|
*
|
|
@@ -192,18 +188,15 @@ export declare const setSessionId: (sessionId: number) => void;
|
|
|
192
188
|
*/
|
|
193
189
|
export declare const setOptOut: (optOut: boolean) => void;
|
|
194
190
|
/**
|
|
195
|
-
*
|
|
191
|
+
* Flush and send all the events which haven't been sent.
|
|
196
192
|
*
|
|
197
|
-
|
|
198
|
-
* //
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* // Use XMLHttpRequest API
|
|
202
|
-
* setTransport('xhr');
|
|
193
|
+
*```typescript
|
|
194
|
+
* // Send all the unsent events
|
|
195
|
+
* flush();
|
|
203
196
|
*
|
|
204
|
-
* //
|
|
205
|
-
*
|
|
197
|
+
* // alternatively, this tracking method is awaitable
|
|
198
|
+
* await flush().promise;
|
|
206
199
|
* ```
|
|
207
200
|
*/
|
|
208
|
-
export declare const
|
|
201
|
+
export declare const flush: () => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
209
202
|
//# sourceMappingURL=react-native-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native-client.d.ts","sourceRoot":"","sources":["../../src/react-native-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"react-native-client.d.ts","sourceRoot":"","sources":["../../src/react-native-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA8B,MAAM,2BAA2B,CAAC;AACtF,OAAO,EACL,iBAAiB,EAEjB,kBAAkB,EAClB,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,4BAA4B,CAAC;AASpC,qBAAa,oBAAqB,SAAQ,aAAa,CAAC,iBAAiB,CAAC;IAClE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,4BAA4B;IA8CjG,sBAAsB,CAAC,iBAAiB,CAAC,EAAE,6BAA6B,EAAE,YAAY,UAAQ;IAkBpG,SAAS;IAIT,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAUpC,WAAW;IAIX,WAAW,CAAC,QAAQ,EAAE,MAAM;IAU5B,kBAAkB;IAKlB,YAAY;IAIZ,YAAY,CAAC,SAAS,EAAE,MAAM;IAI9B,SAAS,CAAC,MAAM,EAAE,OAAO;CAG1B;AAID;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,iMAA0C,CAAC;AAE5D;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,8HAAyC,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,6FAA4C,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK,sTAA2C,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,QAAQ,sTAA8C,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,uPAA8C,CAAC;AAEpE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,wSAAmD,CAAC;AAC9E,eAAO,MAAM,QAAQ,iKAA8C,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,qPAA6C,CAAC;AAElE;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,0BAAgC,CAAC;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,WA1KF,MAAM,GAAG,SAAS,SA0KgB,CAAC;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,0BAAkC,CAAC;AAE3D;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,aAhLA,MAAM,SAgL4B,CAAC;AAE3D;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,YAAyC,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,0BAAmC,CAAC;AAE7D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,cA3LC,MAAM,SA2L4B,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,WApMF,OAAO,SAoM2B,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,2EAA2C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/storage/cookie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAG3E,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IACjD,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAIpC,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/storage/cookie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAG3E,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IACjD,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAIpC,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAqB7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAmBxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAShD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BhD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics-connector.d.ts","sourceRoot":"","sources":["../../../src/utils/analytics-connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,eAAO,MAAM,qBAAqB,QAAO,kBAExC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../src/utils/query-params.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,QAAO,OAAO,MAAM,EAAE,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../src/utils/query-params.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,QAAO,OAAO,MAAM,EAAE,MAAM,GAAG,SAAS,CAelE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.1-dev.
|
|
1
|
+
export declare const VERSION = "0.0.1-dev.11";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -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,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/analytics-react-native",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.11",
|
|
4
4
|
"description": "Official React Native SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analytics",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"android",
|
|
50
50
|
"ios",
|
|
51
51
|
"amplitude-react-native.podspec",
|
|
52
|
-
"!lib/typescript/example",
|
|
53
52
|
"!android/build",
|
|
54
53
|
"!ios/build",
|
|
55
54
|
"!**/test"
|
|
@@ -59,8 +58,8 @@
|
|
|
59
58
|
},
|
|
60
59
|
"dependencies": {
|
|
61
60
|
"@amplitude/analytics-connector": "1.4.4",
|
|
62
|
-
"@amplitude/analytics-core": "^0.
|
|
63
|
-
"@amplitude/analytics-types": "^0.
|
|
61
|
+
"@amplitude/analytics-core": "^0.6.1",
|
|
62
|
+
"@amplitude/analytics-types": "^0.5.1",
|
|
64
63
|
"@amplitude/ua-parser-js": "^0.7.31",
|
|
65
64
|
"tslib": "^2.3.1",
|
|
66
65
|
"@react-native-async-storage/async-storage": "^1.17.7"
|
|
@@ -34,7 +34,7 @@ export class CampaignTracker implements ICampaignTracker {
|
|
|
34
34
|
|
|
35
35
|
this.disabled = Boolean(options.disabled);
|
|
36
36
|
this.trackNewCampaigns = Boolean(options.trackNewCampaigns);
|
|
37
|
-
this.trackPageViews =
|
|
37
|
+
this.trackPageViews = Boolean(options.trackPageViews);
|
|
38
38
|
this.excludeReferrers = options.excludeReferrers ?? [];
|
|
39
39
|
if (typeof location !== 'undefined') {
|
|
40
40
|
this.excludeReferrers.unshift(location.hostname);
|
package/src/config.ts
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
ReactNativeConfig as IReactNativeConfig,
|
|
5
5
|
Storage,
|
|
6
6
|
TrackingOptions,
|
|
7
|
-
TransportType,
|
|
8
7
|
UserSession,
|
|
9
8
|
SessionManager as ISessionManager,
|
|
10
9
|
} from '@amplitude/analytics-types';
|
|
@@ -15,8 +14,6 @@ import { FetchTransport } from './transports/fetch';
|
|
|
15
14
|
import { LocalStorage } from './storage/local-storage';
|
|
16
15
|
import { getCookieName } from './utils/cookie-name';
|
|
17
16
|
import { getQueryParams } from './utils/query-params';
|
|
18
|
-
import { XHRTransport } from './transports/xhr';
|
|
19
|
-
import { SendBeaconTransport } from './transports/send-beacon';
|
|
20
17
|
import { SessionManager } from './session-manager';
|
|
21
18
|
|
|
22
19
|
export const getDefaultConfig = () => {
|
|
@@ -137,7 +134,8 @@ export const useReactNativeConfig = async (
|
|
|
137
134
|
options?: ReactNativeOptions,
|
|
138
135
|
): Promise<IReactNativeConfig> => {
|
|
139
136
|
const defaultConfig = getDefaultConfig();
|
|
140
|
-
const
|
|
137
|
+
const domain = options?.domain ?? (await getTopLevelDomain());
|
|
138
|
+
const cookieStorage = await createCookieStorage({ ...options, domain });
|
|
141
139
|
const cookieName = getCookieName(apiKey);
|
|
142
140
|
const cookies = await cookieStorage.get(cookieName);
|
|
143
141
|
const queryParams = getQueryParams();
|
|
@@ -148,11 +146,12 @@ export const useReactNativeConfig = async (
|
|
|
148
146
|
cookieStorage,
|
|
149
147
|
sessionManager,
|
|
150
148
|
deviceId: createDeviceId(cookies?.deviceId, options?.deviceId, queryParams.deviceId),
|
|
149
|
+
domain,
|
|
151
150
|
optOut: options?.optOut ?? Boolean(cookies?.optOut),
|
|
152
151
|
sessionId: (await cookieStorage.get(cookieName))?.sessionId ?? options?.sessionId,
|
|
153
152
|
storageProvider: await createEventsStorage(options),
|
|
154
153
|
trackingOptions: { ...defaultConfig.trackingOptions, ...options?.trackingOptions },
|
|
155
|
-
transportProvider: options?.transportProvider ??
|
|
154
|
+
transportProvider: options?.transportProvider ?? new FetchTransport(),
|
|
156
155
|
});
|
|
157
156
|
};
|
|
158
157
|
|
|
@@ -199,12 +198,30 @@ export const createDeviceId = (idFromCookies?: string, idFromOptions?: string, i
|
|
|
199
198
|
return idFromOptions || idFromQueryParams || idFromCookies || UUID();
|
|
200
199
|
};
|
|
201
200
|
|
|
202
|
-
export const
|
|
203
|
-
if (
|
|
204
|
-
return
|
|
201
|
+
export const getTopLevelDomain = async (url?: string) => {
|
|
202
|
+
if (!(await new CookieStorage<string>().isEnabled()) || (!url && typeof location === 'undefined')) {
|
|
203
|
+
return '';
|
|
205
204
|
}
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
|
|
206
|
+
const host = url ?? location.hostname;
|
|
207
|
+
const parts = host.split('.');
|
|
208
|
+
const levels = [];
|
|
209
|
+
const storageKey = 'AMP_TLDTEST';
|
|
210
|
+
|
|
211
|
+
for (let i = parts.length - 2; i >= 0; --i) {
|
|
212
|
+
levels.push(parts.slice(i).join('.'));
|
|
208
213
|
}
|
|
209
|
-
|
|
214
|
+
for (let i = 0; i < levels.length; i++) {
|
|
215
|
+
const domain = levels[i];
|
|
216
|
+
const options = { domain: '.' + domain };
|
|
217
|
+
const storage = new CookieStorage<number>(options);
|
|
218
|
+
await storage.set(storageKey, 1);
|
|
219
|
+
const value = await storage.get(storageKey);
|
|
220
|
+
if (value) {
|
|
221
|
+
await storage.remove(storageKey);
|
|
222
|
+
return '.' + domain;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return '';
|
|
210
227
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export {
|
|
2
2
|
add,
|
|
3
|
+
flush,
|
|
3
4
|
getDeviceId,
|
|
4
5
|
getSessionId,
|
|
5
6
|
getUserId,
|
|
@@ -13,11 +14,11 @@ export {
|
|
|
13
14
|
setGroup,
|
|
14
15
|
setOptOut,
|
|
15
16
|
setSessionId,
|
|
16
|
-
setTransport,
|
|
17
17
|
setUserId,
|
|
18
18
|
track,
|
|
19
19
|
} from './react-native-client';
|
|
20
|
-
export { runQueuedFunctions } from './utils/snippet-helper';
|
|
21
20
|
export { Revenue, Identify } from '@amplitude/analytics-core';
|
|
21
|
+
// Hack - react-native apps have trouble with:
|
|
22
|
+
// export * as Types from '@amplitude/analytics-types
|
|
22
23
|
import * as Types from '@amplitude/analytics-types';
|
|
23
24
|
export { Types };
|
package/src/plugins/context.ts
CHANGED
|
@@ -12,11 +12,11 @@ type NativeContext = {
|
|
|
12
12
|
version: string;
|
|
13
13
|
platform: string;
|
|
14
14
|
language: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
osName: string;
|
|
16
|
+
osVersion: string;
|
|
17
|
+
deviceBrand: string;
|
|
18
|
+
deviceManufacturer: string;
|
|
19
|
+
deviceModel: string;
|
|
20
20
|
carrier: string;
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -37,7 +37,7 @@ export class Context implements BeforePlugin {
|
|
|
37
37
|
nativeModule: AmplitudeReactNative | undefined = NativeModules.AmplitudeReactNative as
|
|
38
38
|
| AmplitudeReactNative
|
|
39
39
|
| undefined;
|
|
40
|
-
library = `amplitude-ts/${VERSION}`;
|
|
40
|
+
library = `amplitude-react-native-ts/${VERSION}`;
|
|
41
41
|
|
|
42
42
|
constructor() {
|
|
43
43
|
let agent: string | undefined;
|
|
@@ -67,10 +67,10 @@ export class Context implements BeforePlugin {
|
|
|
67
67
|
const nativeContext = await this.nativeModule?.getApplicationContext();
|
|
68
68
|
const appVersion = nativeContext?.version || this.config.appVersion;
|
|
69
69
|
const platform = nativeContext?.platform || BROWSER_PLATFORM;
|
|
70
|
-
const osName = nativeContext?.
|
|
71
|
-
const osVersion = nativeContext?.
|
|
72
|
-
const deviceVendor = nativeContext?.
|
|
73
|
-
const deviceModel = nativeContext?.
|
|
70
|
+
const osName = nativeContext?.osName || this.uaResult.browser.name;
|
|
71
|
+
const osVersion = nativeContext?.osVersion || this.uaResult.browser.version;
|
|
72
|
+
const deviceVendor = nativeContext?.deviceManufacturer || this.uaResult.device.vendor;
|
|
73
|
+
const deviceModel = nativeContext?.deviceModel || this.uaResult.device.model || this.uaResult.os.name;
|
|
74
74
|
const language = nativeContext?.language || getLanguage();
|
|
75
75
|
const carrier = nativeContext?.carrier;
|
|
76
76
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BeforePlugin, PluginType, Event, Config } from '@amplitude/analytics-types';
|
|
2
|
+
import { getAnalyticsConnector } from '../utils/analytics-connector';
|
|
3
|
+
|
|
4
|
+
export class IdentityEventSender implements BeforePlugin {
|
|
5
|
+
name = 'identity';
|
|
6
|
+
type = PluginType.BEFORE as const;
|
|
7
|
+
|
|
8
|
+
identityStore = getAnalyticsConnector().identityStore;
|
|
9
|
+
|
|
10
|
+
async execute(context: Event): Promise<Event> {
|
|
11
|
+
const userProperties = context.user_properties as Record<string, any>;
|
|
12
|
+
if (userProperties) {
|
|
13
|
+
this.identityStore.editIdentity().updateUserProperties(userProperties).commit();
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
setup(_: Config): Promise<undefined> {
|
|
19
|
+
return Promise.resolve(undefined);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { AmplitudeCore, Destination,
|
|
1
|
+
import { AmplitudeCore, Destination, returnWrapper } from '@amplitude/analytics-core';
|
|
2
2
|
import {
|
|
3
3
|
ReactNativeConfig,
|
|
4
4
|
Campaign,
|
|
5
|
-
EventOptions,
|
|
6
|
-
Identify as IIdentify,
|
|
7
|
-
Result,
|
|
8
|
-
Revenue as IRevenue,
|
|
9
|
-
TransportType,
|
|
10
5
|
ReactNativeOptions,
|
|
11
6
|
AdditionalReactNativeOptions,
|
|
12
7
|
AttributionReactNativeOptions,
|
|
13
8
|
} from '@amplitude/analytics-types';
|
|
14
|
-
import { convertProxyObjectToRealObject, isInstanceProxy } from './utils/snippet-helper';
|
|
15
9
|
import { Context } from './plugins/context';
|
|
16
|
-
import { useReactNativeConfig,
|
|
10
|
+
import { useReactNativeConfig, createDeviceId, createFlexibleStorage } from './config';
|
|
17
11
|
import { parseOldCookies } from './cookie-migration';
|
|
18
12
|
import { CampaignTracker } from './attribution/campaign-tracker';
|
|
13
|
+
import { isNative } from './utils/platform';
|
|
14
|
+
import { IdentityEventSender } from './plugins/identity';
|
|
15
|
+
import { getAnalyticsConnector } from './utils/analytics-connector';
|
|
19
16
|
|
|
20
17
|
export class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
21
18
|
async init(apiKey: string, userId?: string, options?: ReactNativeOptions & AdditionalReactNativeOptions) {
|
|
@@ -45,9 +42,19 @@ export class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
|
45
42
|
isNewSession = true;
|
|
46
43
|
}
|
|
47
44
|
|
|
45
|
+
const connector = getAnalyticsConnector();
|
|
46
|
+
connector.eventBridge.setEventReceiver((event) => {
|
|
47
|
+
void this.track(event.eventType, event.eventProperties);
|
|
48
|
+
});
|
|
49
|
+
connector.identityStore.setIdentity({
|
|
50
|
+
userId: this.config.userId,
|
|
51
|
+
deviceId: this.config.deviceId,
|
|
52
|
+
});
|
|
53
|
+
|
|
48
54
|
// Step 4: Install plugins
|
|
49
55
|
// Do not track any events before this
|
|
50
56
|
await this.add(new Context());
|
|
57
|
+
await this.add(new IdentityEventSender());
|
|
51
58
|
await this.add(new Destination());
|
|
52
59
|
|
|
53
60
|
// Step 5: Track attributions
|
|
@@ -55,6 +62,9 @@ export class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
async runAttributionStrategy(attributionConfig?: AttributionReactNativeOptions, isNewSession = false) {
|
|
65
|
+
if (isNative()) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
58
68
|
const track = this.track.bind(this);
|
|
59
69
|
const onNewCampaign = this.setSessionId.bind(this, Date.now());
|
|
60
70
|
|
|
@@ -75,6 +85,12 @@ export class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
|
75
85
|
|
|
76
86
|
setUserId(userId: string | undefined) {
|
|
77
87
|
this.config.userId = userId;
|
|
88
|
+
getAnalyticsConnector()
|
|
89
|
+
.identityStore.editIdentity()
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
.setUserId(userId)
|
|
93
|
+
.commit();
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
getDeviceId() {
|
|
@@ -83,6 +99,12 @@ export class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
|
83
99
|
|
|
84
100
|
setDeviceId(deviceId: string) {
|
|
85
101
|
this.config.deviceId = deviceId;
|
|
102
|
+
getAnalyticsConnector()
|
|
103
|
+
.identityStore.editIdentity()
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
.setDeviceId(deviceId)
|
|
107
|
+
.commit();
|
|
86
108
|
}
|
|
87
109
|
|
|
88
110
|
regenerateDeviceId() {
|
|
@@ -101,42 +123,6 @@ export class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
|
101
123
|
setOptOut(optOut: boolean) {
|
|
102
124
|
this.config.optOut = optOut;
|
|
103
125
|
}
|
|
104
|
-
|
|
105
|
-
setTransport(transport: TransportType) {
|
|
106
|
-
this.config.transportProvider = createTransport(transport);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
identify(identify: IIdentify, eventOptions?: EventOptions): Promise<Result> {
|
|
110
|
-
if (isInstanceProxy(identify)) {
|
|
111
|
-
const queue = identify._q;
|
|
112
|
-
identify._q = [];
|
|
113
|
-
identify = convertProxyObjectToRealObject(new Identify(), queue);
|
|
114
|
-
}
|
|
115
|
-
return super.identify(identify, eventOptions);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
groupIdentify(
|
|
119
|
-
groupType: string,
|
|
120
|
-
groupName: string | string[],
|
|
121
|
-
identify: IIdentify,
|
|
122
|
-
eventOptions?: EventOptions,
|
|
123
|
-
): Promise<Result> {
|
|
124
|
-
if (isInstanceProxy(identify)) {
|
|
125
|
-
const queue = identify._q;
|
|
126
|
-
identify._q = [];
|
|
127
|
-
identify = convertProxyObjectToRealObject(new Identify(), queue);
|
|
128
|
-
}
|
|
129
|
-
return super.groupIdentify(groupType, groupName, identify, eventOptions);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
revenue(revenue: IRevenue, eventOptions?: EventOptions) {
|
|
133
|
-
if (isInstanceProxy(revenue)) {
|
|
134
|
-
const queue = revenue._q;
|
|
135
|
-
revenue._q = [];
|
|
136
|
-
revenue = convertProxyObjectToRealObject(new Revenue(), queue);
|
|
137
|
-
}
|
|
138
|
-
return super.revenue(revenue, eventOptions);
|
|
139
|
-
}
|
|
140
126
|
}
|
|
141
127
|
|
|
142
128
|
const client = new AmplitudeReactNative();
|
|
@@ -333,17 +319,14 @@ export const setSessionId = client.setSessionId.bind(client);
|
|
|
333
319
|
export const setOptOut = client.setOptOut.bind(client);
|
|
334
320
|
|
|
335
321
|
/**
|
|
336
|
-
*
|
|
322
|
+
* Flush and send all the events which haven't been sent.
|
|
337
323
|
*
|
|
338
|
-
|
|
339
|
-
* //
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
* // Use XMLHttpRequest API
|
|
343
|
-
* setTransport('xhr');
|
|
324
|
+
*```typescript
|
|
325
|
+
* // Send all the unsent events
|
|
326
|
+
* flush();
|
|
344
327
|
*
|
|
345
|
-
* //
|
|
346
|
-
*
|
|
328
|
+
* // alternatively, this tracking method is awaitable
|
|
329
|
+
* await flush().promise;
|
|
347
330
|
* ```
|
|
348
331
|
*/
|
|
349
|
-
export const
|
|
332
|
+
export const flush = returnWrapper(client.flush.bind(client));
|
package/src/storage/cookie.ts
CHANGED
|
@@ -9,11 +9,8 @@ export class CookieStorage<T> implements Storage<T> {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
async isEnabled(): Promise<boolean> {
|
|
12
|
-
if (isNative()) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
12
|
/* istanbul ignore if */
|
|
16
|
-
if (typeof window === 'undefined') {
|
|
13
|
+
if (isNative() || typeof window === 'undefined') {
|
|
17
14
|
return false;
|
|
18
15
|
}
|
|
19
16
|
|
|
@@ -33,11 +30,16 @@ export class CookieStorage<T> implements Storage<T> {
|
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
async get(key: string): Promise<T | undefined> {
|
|
36
|
-
|
|
33
|
+
let value = await this.getRaw(key);
|
|
37
34
|
if (!value) {
|
|
38
35
|
return undefined;
|
|
39
36
|
}
|
|
40
37
|
try {
|
|
38
|
+
try {
|
|
39
|
+
value = decodeURIComponent(atob(value));
|
|
40
|
+
} catch {
|
|
41
|
+
// value not encoded
|
|
42
|
+
}
|
|
41
43
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
42
44
|
return JSON.parse(value);
|
|
43
45
|
} catch {
|
|
@@ -65,7 +67,7 @@ export class CookieStorage<T> implements Storage<T> {
|
|
|
65
67
|
date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);
|
|
66
68
|
expireDate = date;
|
|
67
69
|
}
|
|
68
|
-
let str = `${key}=${JSON.stringify(value)}`;
|
|
70
|
+
let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;
|
|
69
71
|
if (expireDate) {
|
|
70
72
|
str += `; expires=${expireDate.toUTCString()}`;
|
|
71
73
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { isNative } from './platform';
|
|
2
2
|
|
|
3
3
|
export const getQueryParams = (): Record<string, string | undefined> => {
|
|
4
|
-
if (isNative()) {
|
|
5
|
-
return {};
|
|
6
|
-
}
|
|
7
4
|
/* istanbul ignore if */
|
|
8
|
-
if (typeof window === 'undefined') {
|
|
5
|
+
if (isNative() || typeof window === 'undefined') {
|
|
9
6
|
return {};
|
|
10
7
|
}
|
|
11
8
|
const pairs = window.location.search.substring(1).split('&').filter(Boolean);
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.0.1-dev.
|
|
1
|
+
export const VERSION = '0.0.1-dev.11';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.UTM_TERM = exports.UTM_SOURCE = exports.UTM_MEDIUM = exports.UTM_CONTENT = exports.UTM_CAMPAIGN = exports.UTMZ_TERM = exports.UTMZ_SOURCE = exports.UTMZ_MEDIUM = exports.UTMZ_CONTENT = exports.UTMZ_CAMPAIGN = exports.GCLID = exports.FBCLID = void 0;
|
|
7
|
-
const UTM_SOURCE = 'utm_source';
|
|
8
|
-
exports.UTM_SOURCE = UTM_SOURCE;
|
|
9
|
-
const UTM_MEDIUM = 'utm_medium';
|
|
10
|
-
exports.UTM_MEDIUM = UTM_MEDIUM;
|
|
11
|
-
const UTM_CAMPAIGN = 'utm_campaign';
|
|
12
|
-
exports.UTM_CAMPAIGN = UTM_CAMPAIGN;
|
|
13
|
-
const UTM_TERM = 'utm_term';
|
|
14
|
-
exports.UTM_TERM = UTM_TERM;
|
|
15
|
-
const UTM_CONTENT = 'utm_content';
|
|
16
|
-
exports.UTM_CONTENT = UTM_CONTENT;
|
|
17
|
-
const UTMZ_SOURCE = 'utmcsr';
|
|
18
|
-
exports.UTMZ_SOURCE = UTMZ_SOURCE;
|
|
19
|
-
const UTMZ_MEDIUM = 'utmcmd';
|
|
20
|
-
exports.UTMZ_MEDIUM = UTMZ_MEDIUM;
|
|
21
|
-
const UTMZ_CAMPAIGN = 'utmccn';
|
|
22
|
-
exports.UTMZ_CAMPAIGN = UTMZ_CAMPAIGN;
|
|
23
|
-
const UTMZ_TERM = 'utmctr';
|
|
24
|
-
exports.UTMZ_TERM = UTMZ_TERM;
|
|
25
|
-
const UTMZ_CONTENT = 'utmcct';
|
|
26
|
-
exports.UTMZ_CONTENT = UTMZ_CONTENT;
|
|
27
|
-
const GCLID = 'gclid';
|
|
28
|
-
exports.GCLID = GCLID;
|
|
29
|
-
const FBCLID = 'fbclid';
|
|
30
|
-
exports.FBCLID = FBCLID;
|
|
31
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["UTM_SOURCE","UTM_MEDIUM","UTM_CAMPAIGN","UTM_TERM","UTM_CONTENT","UTMZ_SOURCE","UTMZ_MEDIUM","UTMZ_CAMPAIGN","UTMZ_TERM","UTMZ_CONTENT","GCLID","FBCLID"],"sources":["constants.ts"],"sourcesContent":["export const UTM_SOURCE = 'utm_source';\nexport const UTM_MEDIUM = 'utm_medium';\nexport const UTM_CAMPAIGN = 'utm_campaign';\nexport const UTM_TERM = 'utm_term';\nexport const UTM_CONTENT = 'utm_content';\n\nexport const UTMZ_SOURCE = 'utmcsr';\nexport const UTMZ_MEDIUM = 'utmcmd';\nexport const UTMZ_CAMPAIGN = 'utmccn';\nexport const UTMZ_TERM = 'utmctr';\nexport const UTMZ_CONTENT = 'utmcct';\n\nexport const GCLID = 'gclid';\nexport const FBCLID = 'fbclid';\n"],"mappings":";;;;;;AAAO,MAAMA,UAAU,GAAG,YAAnB;;AACA,MAAMC,UAAU,GAAG,YAAnB;;AACA,MAAMC,YAAY,GAAG,cAArB;;AACA,MAAMC,QAAQ,GAAG,UAAjB;;AACA,MAAMC,WAAW,GAAG,aAApB;;AAEA,MAAMC,WAAW,GAAG,QAApB;;AACA,MAAMC,WAAW,GAAG,QAApB;;AACA,MAAMC,aAAa,GAAG,QAAtB;;AACA,MAAMC,SAAS,GAAG,QAAlB;;AACA,MAAMC,YAAY,GAAG,QAArB;;AAEA,MAAMC,KAAK,GAAG,OAAd;;AACA,MAAMC,MAAM,GAAG,QAAf"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SendBeaconTransport = void 0;
|
|
7
|
-
|
|
8
|
-
var _analyticsCore = require("@amplitude/analytics-core");
|
|
9
|
-
|
|
10
|
-
class SendBeaconTransport extends _analyticsCore.BaseTransport {
|
|
11
|
-
async send(serverUrl, payload) {
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
/* istanbul ignore if */
|
|
14
|
-
if (typeof window === 'undefined' || typeof window.navigator === 'undefined' || typeof window.navigator.sendBeacon === 'undefined') {
|
|
15
|
-
throw new Error('SendBeaconTransport is not supported');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
const data = JSON.stringify(payload);
|
|
20
|
-
const success = window.navigator.sendBeacon(serverUrl, JSON.stringify(payload));
|
|
21
|
-
|
|
22
|
-
if (success) {
|
|
23
|
-
return resolve(this.buildResponse({
|
|
24
|
-
code: 200,
|
|
25
|
-
events_ingested: payload.events.length,
|
|
26
|
-
payload_size_bytes: data.length,
|
|
27
|
-
server_upload_time: Date.now()
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return resolve(this.buildResponse({
|
|
32
|
-
code: 500
|
|
33
|
-
}));
|
|
34
|
-
} catch (e) {
|
|
35
|
-
reject(e);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
exports.SendBeaconTransport = SendBeaconTransport;
|
|
43
|
-
//# sourceMappingURL=send-beacon.js.map
|