@amplitude/analytics-react-native 0.0.1-dev.6 → 0.0.1-dev.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 +150 -0
- package/android/src/main/java/com/amplitude/reactnative/AmplitudeReactNativeModule.kt +5 -5
- package/ios/AmplitudeReactNative.swift +4 -4
- package/lib/commonjs/attribution/campaign-tracker.js +1 -1
- package/lib/commonjs/attribution/campaign-tracker.js.map +1 -1
- package/lib/commonjs/config.js +2 -22
- package/lib/commonjs/config.js.map +1 -1
- package/lib/commonjs/index.js +2 -16
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugins/context.js +4 -4
- 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 +23 -57
- package/lib/commonjs/react-native-client.js.map +1 -1
- package/lib/commonjs/storage/cookie.js +1 -6
- 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 +1 -15
- package/lib/module/config.js.map +1 -1
- package/lib/module/index.js +3 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugins/context.js +4 -4
- 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 +21 -55
- package/lib/module/react-native-client.js.map +1 -1
- package/lib/module/storage/cookie.js +1 -6
- 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 +1 -4
- package/lib/typescript/config.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -4
- 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 +7 -26
- 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/package.json +1 -2
- package/src/attribution/campaign-tracker.ts +1 -1
- package/src/config.ts +1 -14
- package/src/index.ts +1 -4
- package/src/plugins/context.ts +9 -9
- package/src/plugins/identity.ts +21 -0
- package/src/react-native-client.ts +26 -60
- package/src/storage/cookie.ts +1 -4
- 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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import { PluginType } from '@amplitude/analytics-types';
|
|
4
|
+
import { getAnalyticsConnector } from '../utils/analytics-connector';
|
|
5
|
+
export class IdentityEventSender {
|
|
6
|
+
constructor() {
|
|
7
|
+
_defineProperty(this, "name", 'identity');
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "type", PluginType.BEFORE);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "identityStore", getAnalyticsConnector().identityStore);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async execute(context) {
|
|
15
|
+
const userProperties = context.user_properties;
|
|
16
|
+
|
|
17
|
+
if (userProperties) {
|
|
18
|
+
this.identityStore.editIdentity().setUserProperties(userProperties).commit();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setup(_) {
|
|
25
|
+
return Promise.resolve(undefined);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PluginType","getAnalyticsConnector","IdentityEventSender","BEFORE","identityStore","execute","context","userProperties","user_properties","editIdentity","setUserProperties","commit","setup","_","Promise","resolve","undefined"],"sources":["identity.ts"],"sourcesContent":["import { BeforePlugin, PluginType, Event, Config } from '@amplitude/analytics-types';\nimport { getAnalyticsConnector } from '../utils/analytics-connector';\n\nexport class IdentityEventSender implements BeforePlugin {\n name = 'identity';\n type = PluginType.BEFORE as const;\n\n identityStore = getAnalyticsConnector().identityStore;\n\n async execute(context: Event): Promise<Event> {\n const userProperties = context.user_properties as Record<string, any>;\n if (userProperties) {\n this.identityStore.editIdentity().setUserProperties(userProperties).commit();\n }\n return context;\n }\n\n setup(_: Config): Promise<undefined> {\n return Promise.resolve(undefined);\n }\n}\n"],"mappings":";;AAAA,SAAuBA,UAAvB,QAAwD,4BAAxD;AACA,SAASC,qBAAT,QAAsC,8BAAtC;AAEA,OAAO,MAAMC,mBAAN,CAAkD;EAAA;IAAA,8BAChD,UADgD;;IAAA,8BAEhDF,UAAU,CAACG,MAFqC;;IAAA,uCAIvCF,qBAAqB,GAAGG,aAJe;EAAA;;EAM1C,MAAPC,OAAO,CAACC,OAAD,EAAiC;IAC5C,MAAMC,cAAc,GAAGD,OAAO,CAACE,eAA/B;;IACA,IAAID,cAAJ,EAAoB;MAClB,KAAKH,aAAL,CAAmBK,YAAnB,GAAkCC,iBAAlC,CAAoDH,cAApD,EAAoEI,MAApE;IACD;;IACD,OAAOL,OAAP;EACD;;EAEDM,KAAK,CAACC,CAAD,EAAgC;IACnC,OAAOC,OAAO,CAACC,OAAR,CAAgBC,SAAhB,CAAP;EACD;;AAhBsD"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { AmplitudeCore, Destination,
|
|
2
|
-
import { convertProxyObjectToRealObject, isInstanceProxy } from './utils/snippet-helper';
|
|
1
|
+
import { AmplitudeCore, Destination, returnWrapper } from '@amplitude/analytics-core';
|
|
3
2
|
import { Context } from './plugins/context';
|
|
4
|
-
import { useReactNativeConfig,
|
|
3
|
+
import { useReactNativeConfig, createDeviceId, createFlexibleStorage } from './config';
|
|
5
4
|
import { parseOldCookies } from './cookie-migration';
|
|
6
5
|
import { CampaignTracker } from './attribution/campaign-tracker';
|
|
7
6
|
import { isNative } from './utils/platform';
|
|
7
|
+
import { IdentityEventSender } from './plugins/identity';
|
|
8
|
+
import { getAnalyticsConnector } from './utils/analytics-connector';
|
|
8
9
|
export class AmplitudeReactNative extends AmplitudeCore {
|
|
9
10
|
async init(apiKey, userId, options) {
|
|
10
11
|
var _oldCookies$deviceId, _oldCookies$sessionId, _options$optOut;
|
|
@@ -28,11 +29,20 @@ export class AmplitudeReactNative extends AmplitudeCore {
|
|
|
28
29
|
// 2) Previous session expired
|
|
29
30
|
this.config.sessionId = Date.now();
|
|
30
31
|
isNewSession = true;
|
|
31
|
-
}
|
|
32
|
-
// Do not track any events before this
|
|
32
|
+
}
|
|
33
33
|
|
|
34
|
+
const connector = getAnalyticsConnector();
|
|
35
|
+
connector.eventBridge.setEventReceiver(event => {
|
|
36
|
+
void this.track(event.eventType, event.eventProperties);
|
|
37
|
+
});
|
|
38
|
+
connector.identityStore.setIdentity({
|
|
39
|
+
userId: this.config.userId,
|
|
40
|
+
deviceId: this.config.deviceId
|
|
41
|
+
}); // Step 4: Install plugins
|
|
42
|
+
// Do not track any events before this
|
|
34
43
|
|
|
35
44
|
await this.add(new Context());
|
|
45
|
+
await this.add(new IdentityEventSender());
|
|
36
46
|
await this.add(new Destination()); // Step 5: Track attributions
|
|
37
47
|
|
|
38
48
|
await this.runAttributionStrategy(options === null || options === void 0 ? void 0 : options.attribution, isNewSession);
|
|
@@ -62,6 +72,9 @@ export class AmplitudeReactNative extends AmplitudeCore {
|
|
|
62
72
|
|
|
63
73
|
setUserId(userId) {
|
|
64
74
|
this.config.userId = userId;
|
|
75
|
+
getAnalyticsConnector().identityStore.editIdentity() // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
.setUserId(userId).commit();
|
|
65
78
|
}
|
|
66
79
|
|
|
67
80
|
getDeviceId() {
|
|
@@ -70,6 +83,9 @@ export class AmplitudeReactNative extends AmplitudeCore {
|
|
|
70
83
|
|
|
71
84
|
setDeviceId(deviceId) {
|
|
72
85
|
this.config.deviceId = deviceId;
|
|
86
|
+
getAnalyticsConnector().identityStore.editIdentity() // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
.setDeviceId(deviceId).commit();
|
|
73
89
|
}
|
|
74
90
|
|
|
75
91
|
regenerateDeviceId() {
|
|
@@ -89,40 +105,6 @@ export class AmplitudeReactNative extends AmplitudeCore {
|
|
|
89
105
|
this.config.optOut = optOut;
|
|
90
106
|
}
|
|
91
107
|
|
|
92
|
-
setTransport(transport) {
|
|
93
|
-
this.config.transportProvider = createTransport(transport);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
identify(identify, eventOptions) {
|
|
97
|
-
if (isInstanceProxy(identify)) {
|
|
98
|
-
const queue = identify._q;
|
|
99
|
-
identify._q = [];
|
|
100
|
-
identify = convertProxyObjectToRealObject(new Identify(), queue);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return super.identify(identify, eventOptions);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
groupIdentify(groupType, groupName, identify, eventOptions) {
|
|
107
|
-
if (isInstanceProxy(identify)) {
|
|
108
|
-
const queue = identify._q;
|
|
109
|
-
identify._q = [];
|
|
110
|
-
identify = convertProxyObjectToRealObject(new Identify(), queue);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return super.groupIdentify(groupType, groupName, identify, eventOptions);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
revenue(revenue, eventOptions) {
|
|
117
|
-
if (isInstanceProxy(revenue)) {
|
|
118
|
-
const queue = revenue._q;
|
|
119
|
-
revenue._q = [];
|
|
120
|
-
revenue = convertProxyObjectToRealObject(new Revenue(), queue);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return super.revenue(revenue, eventOptions);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
108
|
}
|
|
127
109
|
const client = new AmplitudeReactNative();
|
|
128
110
|
/**
|
|
@@ -316,22 +298,6 @@ export const setSessionId = client.setSessionId.bind(client);
|
|
|
316
298
|
*/
|
|
317
299
|
|
|
318
300
|
export const setOptOut = client.setOptOut.bind(client);
|
|
319
|
-
/**
|
|
320
|
-
* Sets the network transport type for events.
|
|
321
|
-
*
|
|
322
|
-
* ```typescript
|
|
323
|
-
* // Use Fetch API
|
|
324
|
-
* setTransport('fetch');
|
|
325
|
-
*
|
|
326
|
-
* // Use XMLHttpRequest API
|
|
327
|
-
* setTransport('xhr');
|
|
328
|
-
*
|
|
329
|
-
* // Use navigator.sendBeacon API
|
|
330
|
-
* setTransport('beacon');
|
|
331
|
-
* ```
|
|
332
|
-
*/
|
|
333
|
-
|
|
334
|
-
export const setTransport = client.setTransport.bind(client);
|
|
335
301
|
/**
|
|
336
302
|
* Flush and send all the events which haven't been sent.
|
|
337
303
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AmplitudeCore","Destination","Identify","Revenue","returnWrapper","convertProxyObjectToRealObject","isInstanceProxy","Context","useReactNativeConfig","createTransport","createDeviceId","createFlexibleStorage","parseOldCookies","CampaignTracker","isNative","AmplitudeReactNative","init","apiKey","userId","options","oldCookies","reactNativeOptions","deviceId","sessionId","optOut","lastEventTime","undefined","isNewSession","config","Date","now","sessionTimeout","add","runAttributionStrategy","attribution","attributionConfig","track","bind","onNewCampaign","setSessionId","storage","campaignTracker","send","getUserId","setUserId","getDeviceId","setDeviceId","regenerateDeviceId","getSessionId","setOptOut","setTransport","transport","transportProvider","identify","eventOptions","queue","_q","groupIdentify","groupType","groupName","revenue","client","remove","logEvent","setGroup","flush"],"sources":["react-native-client.ts"],"sourcesContent":["import { AmplitudeCore, Destination, Identify, Revenue, returnWrapper } from '@amplitude/analytics-core';\nimport {\n ReactNativeConfig,\n Campaign,\n EventOptions,\n Identify as IIdentify,\n Result,\n Revenue as IRevenue,\n TransportType,\n ReactNativeOptions,\n AdditionalReactNativeOptions,\n AttributionReactNativeOptions,\n} from '@amplitude/analytics-types';\nimport { convertProxyObjectToRealObject, isInstanceProxy } from './utils/snippet-helper';\nimport { Context } from './plugins/context';\nimport { useReactNativeConfig, createTransport, createDeviceId, createFlexibleStorage } from './config';\nimport { parseOldCookies } from './cookie-migration';\nimport { CampaignTracker } from './attribution/campaign-tracker';\nimport { isNative } from './utils/platform';\n\nexport class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {\n async init(apiKey: string, userId?: string, options?: ReactNativeOptions & AdditionalReactNativeOptions) {\n // Step 1: Read cookies stored by old SDK\n const oldCookies = await parseOldCookies(apiKey, options);\n\n // Step 2: Create react native config\n const reactNativeOptions = await useReactNativeConfig(apiKey, userId || oldCookies.userId, {\n ...options,\n deviceId: oldCookies.deviceId ?? options?.deviceId,\n sessionId: oldCookies.sessionId ?? options?.sessionId,\n optOut: options?.optOut ?? oldCookies.optOut,\n lastEventTime: oldCookies.lastEventTime,\n });\n await super.init(undefined, undefined, reactNativeOptions);\n\n // Step 3: Manage session\n let isNewSession = false;\n if (\n !this.config.sessionId ||\n (this.config.lastEventTime && Date.now() - this.config.lastEventTime > this.config.sessionTimeout)\n ) {\n // Either\n // 1) No previous session; or\n // 2) Previous session expired\n this.config.sessionId = Date.now();\n isNewSession = true;\n }\n\n // Step 4: Install plugins\n // Do not track any events before this\n await this.add(new Context());\n await this.add(new Destination());\n\n // Step 5: Track attributions\n await this.runAttributionStrategy(options?.attribution, isNewSession);\n }\n\n async runAttributionStrategy(attributionConfig?: AttributionReactNativeOptions, isNewSession = false) {\n if (isNative()) {\n return;\n }\n const track = this.track.bind(this);\n const onNewCampaign = this.setSessionId.bind(this, Date.now());\n\n const storage = await createFlexibleStorage<Campaign>(this.config);\n const campaignTracker = new CampaignTracker(this.config.apiKey, {\n ...attributionConfig,\n storage,\n track,\n onNewCampaign,\n });\n\n await campaignTracker.send(isNewSession);\n }\n\n getUserId() {\n return this.config.userId;\n }\n\n setUserId(userId: string | undefined) {\n this.config.userId = userId;\n }\n\n getDeviceId() {\n return this.config.deviceId;\n }\n\n setDeviceId(deviceId: string) {\n this.config.deviceId = deviceId;\n }\n\n regenerateDeviceId() {\n const deviceId = createDeviceId();\n this.setDeviceId(deviceId);\n }\n\n getSessionId() {\n return this.config.sessionId;\n }\n\n setSessionId(sessionId: number) {\n this.config.sessionId = sessionId;\n }\n\n setOptOut(optOut: boolean) {\n this.config.optOut = optOut;\n }\n\n setTransport(transport: TransportType) {\n this.config.transportProvider = createTransport(transport);\n }\n\n identify(identify: IIdentify, eventOptions?: EventOptions): Promise<Result> {\n if (isInstanceProxy(identify)) {\n const queue = identify._q;\n identify._q = [];\n identify = convertProxyObjectToRealObject(new Identify(), queue);\n }\n return super.identify(identify, eventOptions);\n }\n\n groupIdentify(\n groupType: string,\n groupName: string | string[],\n identify: IIdentify,\n eventOptions?: EventOptions,\n ): Promise<Result> {\n if (isInstanceProxy(identify)) {\n const queue = identify._q;\n identify._q = [];\n identify = convertProxyObjectToRealObject(new Identify(), queue);\n }\n return super.groupIdentify(groupType, groupName, identify, eventOptions);\n }\n\n revenue(revenue: IRevenue, eventOptions?: EventOptions) {\n if (isInstanceProxy(revenue)) {\n const queue = revenue._q;\n revenue._q = [];\n revenue = convertProxyObjectToRealObject(new Revenue(), queue);\n }\n return super.revenue(revenue, eventOptions);\n }\n}\n\nconst client = new AmplitudeReactNative();\n\n/**\n * Initializes the Amplitude SDK with your apiKey, userId and optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, USER_ID, options).promise;\n * ```\n */\nexport const init = returnWrapper(client.init.bind(client));\n\n/**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {...};\n * amplitude.add(plugin);\n * ```\n */\nexport const add = returnWrapper(client.add.bind(client));\n\n/**\n * Removes a plugin.\n *\n * ```typescript\n * amplitude.remove('myPlugin');\n * ```\n */\nexport const remove = returnWrapper(client.remove.bind(client));\n\n/**\n * Tracks user-defined event, with specified type, optional event properties and optional overwrites.\n *\n * ```typescript\n * // event tracking with event type only\n * track('Page Load');\n *\n * // event tracking with event type and additional event properties\n * track('Page Load', { loadTime: 1000 });\n *\n * // event tracking with event type, additional event properties, and overwritten event options\n * track('Page Load', { loadTime: 1000 }, { sessionId: -1 });\n *\n * // alternatively, this tracking method is awaitable\n * const result = await track('Page Load').promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const track = returnWrapper(client.track.bind(client));\n\n/**\n * Alias for track()\n */\nexport const logEvent = returnWrapper(client.logEvent.bind(client));\n\n/**\n * Sends an identify event containing user property operations\n *\n * ```typescript\n * const id = new Identify();\n * id.set('colors', ['rose', 'gold']);\n * identify(id);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await identify(id).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const identify = returnWrapper(client.identify.bind(client));\n\n/**\n * Sends a group identify event containing group property operations.\n *\n * ```typescript\n * const id = new Identify();\n * id.set('skills', ['js', 'ts']);\n * const groupType = 'org';\n * const groupName = 'engineering';\n * groupIdentify(groupType, groupName, id);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await groupIdentify(groupType, groupName, id).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const groupIdentify = returnWrapper(client.groupIdentify.bind(client));\nexport const setGroup = returnWrapper(client.setGroup.bind(client));\n\n/**\n * Sends a revenue event containing revenue property operations.\n *\n * ```typescript\n * const rev = new Revenue();\n * rev.setRevenue(100);\n * revenue(rev);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await revenue(rev).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const revenue = returnWrapper(client.revenue.bind(client));\n\n/**\n * Returns current user ID.\n *\n * ```typescript\n * const userId = getUserId();\n * ```\n */\nexport const getUserId = client.getUserId.bind(client);\n\n/**\n * Sets a new user ID.\n *\n * ```typescript\n * setUserId('userId');\n * ```\n */\nexport const setUserId = client.setUserId.bind(client);\n\n/**\n * Returns current device ID.\n *\n * ```typescript\n * const deviceId = getDeviceId();\n * ```\n */\nexport const getDeviceId = client.getDeviceId.bind(client);\n\n/**\n * Sets a new device ID.\n * When setting a custom device ID, make sure the value is sufficiently unique.\n * A uuid is recommended.\n *\n * ```typescript\n * setDeviceId('deviceId');\n * ```\n */\nexport const setDeviceId = client.setDeviceId.bind(client);\n\n/**\n * Regenerates a new random deviceId for current user. Note: this is not recommended unless you know what you\n * are doing. This can be used in conjunction with `setUserId(undefined)` to anonymize users after they log out.\n * With an `unefined` userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.\n *\n * ```typescript\n * regenerateDeviceId();\n * ```\n */\nexport const regenerateDeviceId = client.regenerateDeviceId.bind(client);\n\n/**\n * Returns current session ID.\n *\n * ```typescript\n * const sessionId = getSessionId();\n * ```\n */\nexport const getSessionId = client.getSessionId.bind(client);\n\n/**\n * Sets a new session ID.\n * When settign a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp).\n *\n * ```typescript\n * setSessionId(Date.now());\n * ```\n */\nexport const setSessionId = client.setSessionId.bind(client);\n\n/**\n * Sets a new optOut config value. This toggles event tracking on/off.\n *\n *```typescript\n * // Stops tracking\n * setOptOut(true);\n *\n * // Starts/resumes tracking\n * setOptOut(false);\n * ```\n */\nexport const setOptOut = client.setOptOut.bind(client);\n\n/**\n * Sets the network transport type for events.\n *\n * ```typescript\n * // Use Fetch API\n * setTransport('fetch');\n *\n * // Use XMLHttpRequest API\n * setTransport('xhr');\n *\n * // Use navigator.sendBeacon API\n * setTransport('beacon');\n * ```\n */\nexport const setTransport = client.setTransport.bind(client);\n\n/**\n * Flush and send all the events which haven't been sent.\n *\n *```typescript\n * // Send all the unsent events\n * flush();\n *\n * // alternatively, this tracking method is awaitable\n * await flush().promise;\n * ```\n */\nexport const flush = returnWrapper(client.flush.bind(client));\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,WAAxB,EAAqCC,QAArC,EAA+CC,OAA/C,EAAwDC,aAAxD,QAA6E,2BAA7E;AAaA,SAASC,8BAAT,EAAyCC,eAAzC,QAAgE,wBAAhE;AACA,SAASC,OAAT,QAAwB,mBAAxB;AACA,SAASC,oBAAT,EAA+BC,eAA/B,EAAgDC,cAAhD,EAAgEC,qBAAhE,QAA6F,UAA7F;AACA,SAASC,eAAT,QAAgC,oBAAhC;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,QAAT,QAAyB,kBAAzB;AAEA,OAAO,MAAMC,oBAAN,SAAmCf,aAAnC,CAAoE;EAC/D,MAAJgB,IAAI,CAACC,MAAD,EAAiBC,MAAjB,EAAkCC,OAAlC,EAA+F;IAAA;;IACvG;IACA,MAAMC,UAAU,GAAG,MAAMR,eAAe,CAACK,MAAD,EAASE,OAAT,CAAxC,CAFuG,CAIvG;;IACA,MAAME,kBAAkB,GAAG,MAAMb,oBAAoB,CAACS,MAAD,EAASC,MAAM,IAAIE,UAAU,CAACF,MAA9B,EAAsC,EACzF,GAAGC,OADsF;MAEzFG,QAAQ,0BAAEF,UAAU,CAACE,QAAb,uEAAyBH,OAAzB,aAAyBA,OAAzB,uBAAyBA,OAAO,CAAEG,QAF+C;MAGzFC,SAAS,2BAAEH,UAAU,CAACG,SAAb,yEAA0BJ,OAA1B,aAA0BA,OAA1B,uBAA0BA,OAAO,CAAEI,SAH6C;MAIzFC,MAAM,qBAAEL,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEK,MAAX,6DAAqBJ,UAAU,CAAC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B,CAAsBwB,MAAtB,CAAlB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMhB,WAAW,GAAGgB,MAAM,CAAChB,WAAP,CAAmBR,IAAnB,CAAwBwB,MAAxB,CAApB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMf,WAAW,GAAGe,MAAM,CAACf,WAAP,CAAmBT,IAAnB,CAAwBwB,MAAxB,CAApB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMd,kBAAkB,GAAGc,MAAM,CAACd,kBAAP,CAA0BV,IAA1B,CAA+BwB,MAA/B,CAA3B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMb,YAAY,GAAGa,MAAM,CAACb,YAAP,CAAoBX,IAApB,CAAyBwB,MAAzB,CAArB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMtB,YAAY,GAAGsB,MAAM,CAACtB,YAAP,CAAoBF,IAApB,CAAyBwB,MAAzB,CAArB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMZ,SAAS,GAAGY,MAAM,CAACZ,SAAP,CAAiBZ,IAAjB,CAAsBwB,MAAtB,CAAlB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMX,YAAY,GAAGW,MAAM,CAACX,YAAP,CAAoBb,IAApB,CAAyBwB,MAAzB,CAArB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMI,KAAK,GAAG7D,aAAa,CAACyD,MAAM,CAACI,KAAP,CAAa5B,IAAb,CAAkBwB,MAAlB,CAAD,CAA3B"}
|
|
1
|
+
{"version":3,"names":["AmplitudeCore","Destination","returnWrapper","Context","useReactNativeConfig","createDeviceId","createFlexibleStorage","parseOldCookies","CampaignTracker","isNative","IdentityEventSender","getAnalyticsConnector","AmplitudeReactNative","init","apiKey","userId","options","oldCookies","reactNativeOptions","deviceId","sessionId","optOut","lastEventTime","undefined","isNewSession","config","Date","now","sessionTimeout","connector","eventBridge","setEventReceiver","event","track","eventType","eventProperties","identityStore","setIdentity","add","runAttributionStrategy","attribution","attributionConfig","bind","onNewCampaign","setSessionId","storage","campaignTracker","send","getUserId","setUserId","editIdentity","commit","getDeviceId","setDeviceId","regenerateDeviceId","getSessionId","setOptOut","client","remove","logEvent","identify","groupIdentify","setGroup","revenue","flush"],"sources":["react-native-client.ts"],"sourcesContent":["import { AmplitudeCore, Destination, returnWrapper } from '@amplitude/analytics-core';\nimport {\n ReactNativeConfig,\n Campaign,\n ReactNativeOptions,\n AdditionalReactNativeOptions,\n AttributionReactNativeOptions,\n} from '@amplitude/analytics-types';\nimport { Context } from './plugins/context';\nimport { useReactNativeConfig, createDeviceId, createFlexibleStorage } from './config';\nimport { parseOldCookies } from './cookie-migration';\nimport { CampaignTracker } from './attribution/campaign-tracker';\nimport { isNative } from './utils/platform';\nimport { IdentityEventSender } from './plugins/identity';\nimport { getAnalyticsConnector } from './utils/analytics-connector';\n\nexport class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {\n async init(apiKey: string, userId?: string, options?: ReactNativeOptions & AdditionalReactNativeOptions) {\n // Step 1: Read cookies stored by old SDK\n const oldCookies = await parseOldCookies(apiKey, options);\n\n // Step 2: Create react native config\n const reactNativeOptions = await useReactNativeConfig(apiKey, userId || oldCookies.userId, {\n ...options,\n deviceId: oldCookies.deviceId ?? options?.deviceId,\n sessionId: oldCookies.sessionId ?? options?.sessionId,\n optOut: options?.optOut ?? oldCookies.optOut,\n lastEventTime: oldCookies.lastEventTime,\n });\n await super.init(undefined, undefined, reactNativeOptions);\n\n // Step 3: Manage session\n let isNewSession = false;\n if (\n !this.config.sessionId ||\n (this.config.lastEventTime && Date.now() - this.config.lastEventTime > this.config.sessionTimeout)\n ) {\n // Either\n // 1) No previous session; or\n // 2) Previous session expired\n this.config.sessionId = Date.now();\n isNewSession = true;\n }\n\n const connector = getAnalyticsConnector();\n connector.eventBridge.setEventReceiver((event) => {\n void this.track(event.eventType, event.eventProperties);\n });\n connector.identityStore.setIdentity({\n userId: this.config.userId,\n deviceId: this.config.deviceId,\n });\n\n // Step 4: Install plugins\n // Do not track any events before this\n await this.add(new Context());\n await this.add(new IdentityEventSender());\n await this.add(new Destination());\n\n // Step 5: Track attributions\n await this.runAttributionStrategy(options?.attribution, isNewSession);\n }\n\n async runAttributionStrategy(attributionConfig?: AttributionReactNativeOptions, isNewSession = false) {\n if (isNative()) {\n return;\n }\n const track = this.track.bind(this);\n const onNewCampaign = this.setSessionId.bind(this, Date.now());\n\n const storage = await createFlexibleStorage<Campaign>(this.config);\n const campaignTracker = new CampaignTracker(this.config.apiKey, {\n ...attributionConfig,\n storage,\n track,\n onNewCampaign,\n });\n\n await campaignTracker.send(isNewSession);\n }\n\n getUserId() {\n return this.config.userId;\n }\n\n setUserId(userId: string | undefined) {\n this.config.userId = userId;\n getAnalyticsConnector()\n .identityStore.editIdentity()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n .setUserId(userId)\n .commit();\n }\n\n getDeviceId() {\n return this.config.deviceId;\n }\n\n setDeviceId(deviceId: string) {\n this.config.deviceId = deviceId;\n getAnalyticsConnector()\n .identityStore.editIdentity()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n .setDeviceId(deviceId)\n .commit();\n }\n\n regenerateDeviceId() {\n const deviceId = createDeviceId();\n this.setDeviceId(deviceId);\n }\n\n getSessionId() {\n return this.config.sessionId;\n }\n\n setSessionId(sessionId: number) {\n this.config.sessionId = sessionId;\n }\n\n setOptOut(optOut: boolean) {\n this.config.optOut = optOut;\n }\n}\n\nconst client = new AmplitudeReactNative();\n\n/**\n * Initializes the Amplitude SDK with your apiKey, userId and optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, USER_ID, options).promise;\n * ```\n */\nexport const init = returnWrapper(client.init.bind(client));\n\n/**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {...};\n * amplitude.add(plugin);\n * ```\n */\nexport const add = returnWrapper(client.add.bind(client));\n\n/**\n * Removes a plugin.\n *\n * ```typescript\n * amplitude.remove('myPlugin');\n * ```\n */\nexport const remove = returnWrapper(client.remove.bind(client));\n\n/**\n * Tracks user-defined event, with specified type, optional event properties and optional overwrites.\n *\n * ```typescript\n * // event tracking with event type only\n * track('Page Load');\n *\n * // event tracking with event type and additional event properties\n * track('Page Load', { loadTime: 1000 });\n *\n * // event tracking with event type, additional event properties, and overwritten event options\n * track('Page Load', { loadTime: 1000 }, { sessionId: -1 });\n *\n * // alternatively, this tracking method is awaitable\n * const result = await track('Page Load').promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const track = returnWrapper(client.track.bind(client));\n\n/**\n * Alias for track()\n */\nexport const logEvent = returnWrapper(client.logEvent.bind(client));\n\n/**\n * Sends an identify event containing user property operations\n *\n * ```typescript\n * const id = new Identify();\n * id.set('colors', ['rose', 'gold']);\n * identify(id);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await identify(id).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const identify = returnWrapper(client.identify.bind(client));\n\n/**\n * Sends a group identify event containing group property operations.\n *\n * ```typescript\n * const id = new Identify();\n * id.set('skills', ['js', 'ts']);\n * const groupType = 'org';\n * const groupName = 'engineering';\n * groupIdentify(groupType, groupName, id);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await groupIdentify(groupType, groupName, id).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const groupIdentify = returnWrapper(client.groupIdentify.bind(client));\nexport const setGroup = returnWrapper(client.setGroup.bind(client));\n\n/**\n * Sends a revenue event containing revenue property operations.\n *\n * ```typescript\n * const rev = new Revenue();\n * rev.setRevenue(100);\n * revenue(rev);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await revenue(rev).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const revenue = returnWrapper(client.revenue.bind(client));\n\n/**\n * Returns current user ID.\n *\n * ```typescript\n * const userId = getUserId();\n * ```\n */\nexport const getUserId = client.getUserId.bind(client);\n\n/**\n * Sets a new user ID.\n *\n * ```typescript\n * setUserId('userId');\n * ```\n */\nexport const setUserId = client.setUserId.bind(client);\n\n/**\n * Returns current device ID.\n *\n * ```typescript\n * const deviceId = getDeviceId();\n * ```\n */\nexport const getDeviceId = client.getDeviceId.bind(client);\n\n/**\n * Sets a new device ID.\n * When setting a custom device ID, make sure the value is sufficiently unique.\n * A uuid is recommended.\n *\n * ```typescript\n * setDeviceId('deviceId');\n * ```\n */\nexport const setDeviceId = client.setDeviceId.bind(client);\n\n/**\n * Regenerates a new random deviceId for current user. Note: this is not recommended unless you know what you\n * are doing. This can be used in conjunction with `setUserId(undefined)` to anonymize users after they log out.\n * With an `unefined` userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.\n *\n * ```typescript\n * regenerateDeviceId();\n * ```\n */\nexport const regenerateDeviceId = client.regenerateDeviceId.bind(client);\n\n/**\n * Returns current session ID.\n *\n * ```typescript\n * const sessionId = getSessionId();\n * ```\n */\nexport const getSessionId = client.getSessionId.bind(client);\n\n/**\n * Sets a new session ID.\n * When settign a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp).\n *\n * ```typescript\n * setSessionId(Date.now());\n * ```\n */\nexport const setSessionId = client.setSessionId.bind(client);\n\n/**\n * Sets a new optOut config value. This toggles event tracking on/off.\n *\n *```typescript\n * // Stops tracking\n * setOptOut(true);\n *\n * // Starts/resumes tracking\n * setOptOut(false);\n * ```\n */\nexport const setOptOut = client.setOptOut.bind(client);\n\n/**\n * Flush and send all the events which haven't been sent.\n *\n *```typescript\n * // Send all the unsent events\n * flush();\n *\n * // alternatively, this tracking method is awaitable\n * await flush().promise;\n * ```\n */\nexport const flush = returnWrapper(client.flush.bind(client));\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,WAAxB,EAAqCC,aAArC,QAA0D,2BAA1D;AAQA,SAASC,OAAT,QAAwB,mBAAxB;AACA,SAASC,oBAAT,EAA+BC,cAA/B,EAA+CC,qBAA/C,QAA4E,UAA5E;AACA,SAASC,eAAT,QAAgC,oBAAhC;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,mBAAT,QAAoC,oBAApC;AACA,SAASC,qBAAT,QAAsC,6BAAtC;AAEA,OAAO,MAAMC,oBAAN,SAAmCZ,aAAnC,CAAoE;EAC/D,MAAJa,IAAI,CAACC,MAAD,EAAiBC,MAAjB,EAAkCC,OAAlC,EAA+F;IAAA;;IACvG;IACA,MAAMC,UAAU,GAAG,MAAMV,eAAe,CAACO,MAAD,EAASE,OAAT,CAAxC,CAFuG,CAIvG;;IACA,MAAME,kBAAkB,GAAG,MAAMd,oBAAoB,CAACU,MAAD,EAASC,MAAM,IAAIE,UAAU,CAACF,MAA9B,EAAsC,EACzF,GAAGC,OADsF;MAEzFG,QAAQ,0BAAEF,UAAU,CAACE,QAAb,uEAAyBH,OAAzB,aAAyBA,OAAzB,uBAAyBA,OAAO,CAAEG,QAF+C;MAGzFC,SAAS,2BAAEH,UAAU,CAACG,SAAb,yEAA0BJ,OAA1B,aAA0BA,OAA1B,uBAA0BA,OAAO,CAAEI,SAH6C;MAIzFC,MAAM,qBAAEL,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEK,MAAX,6DAAqBJ,UAAU,CAACI,MAJmD;MAKzFC,aAAa,EAAEL,UAAU,CAACK;IAL+D,CAAtC,CAArD;IAOA,MA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B,CAAyBe,MAAzB,CAArB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMD,SAAS,GAAGC,MAAM,CAACD,SAAP,CAAiBd,IAAjB,CAAsBe,MAAtB,CAAlB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMO,KAAK,GAAG9D,aAAa,CAACuD,MAAM,CAACO,KAAP,CAAatB,IAAb,CAAkBe,MAAlB,CAAD,CAA3B"}
|
|
@@ -10,13 +10,8 @@ export class CookieStorage {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async isEnabled() {
|
|
13
|
-
if (isNative()) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
13
|
/* istanbul ignore if */
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (typeof window === 'undefined') {
|
|
14
|
+
if (isNative() || typeof window === 'undefined') {
|
|
20
15
|
return false;
|
|
21
16
|
}
|
|
22
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isNative","CookieStorage","constructor","options","isEnabled","window","random","String","Date","now","testStrorage","testKey","set","value","get","remove","key","getRaw","undefined","decodeURIComponent","atob","JSON","parse","cookie","document","split","match","find","c","indexOf","substring","length","expirationDays","expires","expireDate","date","setTime","getTime","str","btoa","encodeURIComponent","stringify","toUTCString","domain","secure","sameSite","reset"],"sources":["cookie.ts"],"sourcesContent":["import { Storage, CookieStorageOptions } from '@amplitude/analytics-types';\nimport { isNative } from '../utils/platform';\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n\n constructor(options?: CookieStorageOptions) {\n this.options = { ...options };\n }\n\n async isEnabled(): Promise<boolean> {\n
|
|
1
|
+
{"version":3,"names":["isNative","CookieStorage","constructor","options","isEnabled","window","random","String","Date","now","testStrorage","testKey","set","value","get","remove","key","getRaw","undefined","decodeURIComponent","atob","JSON","parse","cookie","document","split","match","find","c","indexOf","substring","length","expirationDays","expires","expireDate","date","setTime","getTime","str","btoa","encodeURIComponent","stringify","toUTCString","domain","secure","sameSite","reset"],"sources":["cookie.ts"],"sourcesContent":["import { Storage, CookieStorageOptions } from '@amplitude/analytics-types';\nimport { isNative } from '../utils/platform';\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n\n constructor(options?: CookieStorageOptions) {\n this.options = { ...options };\n }\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (isNative() || typeof window === 'undefined') {\n return false;\n }\n\n const random = String(Date.now());\n const testStrorage = new CookieStorage<string>();\n const testKey = 'AMP_TEST';\n try {\n await testStrorage.set(testKey, random);\n const value = await testStrorage.get(testKey);\n return value === random;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStrorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n let value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n try {\n try {\n value = decodeURIComponent(atob(value));\n } catch {\n // value not encoded\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(value);\n } catch {\n /* istanbul ignore next */\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const cookie = window.document.cookie.split('; ');\n const match = cookie.find((c) => c.indexOf(key + '=') === 0);\n if (!match) {\n return undefined;\n }\n return match.substring(key.length + 1);\n }\n\n async set(key: string, value: T | null): Promise<void> {\n try {\n const expirationDays = this.options.expirationDays ?? 0;\n const expires = value !== null ? expirationDays : -1;\n let expireDate: Date | undefined = undefined;\n if (expires) {\n const date = new Date();\n date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);\n expireDate = date;\n }\n let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;\n if (expireDate) {\n str += `; expires=${expireDate.toUTCString()}`;\n }\n str += '; path=/';\n if (this.options.domain) {\n str += `; domain=${this.options.domain}`;\n }\n if (this.options.secure) {\n str += '; Secure';\n }\n if (this.options.sameSite) {\n str += `; SameSite=${this.options.sameSite}`;\n }\n window.document.cookie = str;\n } catch {\n //\n }\n }\n\n async remove(key: string): Promise<void> {\n await this.set(key, null);\n }\n\n async reset(): Promise<void> {\n return;\n }\n}\n"],"mappings":";;AACA,SAASA,QAAT,QAAyB,mBAAzB;AAEA,OAAO,MAAMC,aAAN,CAA6C;EAGlDC,WAAW,CAACC,OAAD,EAAiC;IAAA;;IAC1C,KAAKA,OAAL,GAAe,EAAE,GAAGA;IAAL,CAAf;EACD;;EAEc,MAATC,SAAS,GAAqB;IAClC;IACA,IAAIJ,QAAQ,MAAM,OAAOK,MAAP,KAAkB,WAApC,EAAiD;MAC/C,OAAO,KAAP;IACD;;IAED,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACC,GAAL,EAAD,CAArB;IACA,MAAMC,YAAY,GAAG,IAAIT,aAAJ,EAArB;IACA,MAAMU,OAAO,GAAG,UAAhB;;IACA,IAAI;MACF,MAAMD,YAAY,CAACE,GAAb,CAAiBD,OAAjB,EAA0BL,MAA1B,CAAN;MACA,MAAMO,KAAK,GAAG,MAAMH,YAAY,CAACI,GAAb,CAAiBH,OAAjB,CAApB;MACA,OAAOE,KAAK,KAAKP,MAAjB;IACD,CAJD,CAIE,MAAM;MACN;MACA,OAAO,KAAP;IACD,CAPD,SAOU;MACR,MAAMI,YAAY,CAACK,MAAb,CAAoBJ,OAApB,CAAN;IACD;EACF;;EAEQ,MAAHG,GAAG,CAACE,GAAD,EAAsC;IAC7C,IAAIH,KAAK,GAAG,MAAM,KAAKI,MAAL,CAAYD,GAAZ,CAAlB;;IACA,IAAI,CAACH,KAAL,EAAY;MACV,OAAOK,SAAP;IACD;;IACD,IAAI;MACF,IAAI;QACFL,KAAK,GAAGM,kBAAkB,CAACC,IAAI,CAACP,KAAD,CAAL,CAA1B;MACD,CAFD,CAEE,MAAM,CACN;MACD,CALC,CAMF;;;MACA,OAAOQ,IAAI,CAACC,KAAL,CAAWT,KAAX,CAAP;IACD,CARD,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B;QACvBL,GAAG,IAAK,YAAW,KAAKnC,OAAL,CAAawC,MAAO,EAAvC;MACD;;MACD,IAAI,KAAKxC,OAAL,CAAayC,MAAjB,EAAyB;QACvBN,GAAG,IAAI,UAAP;MACD;;MACD,IAAI,KAAKnC,OAAL,CAAa0C,QAAjB,EAA2B;QACzBP,GAAG,IAAK,cAAa,KAAKnC,OAAL,CAAa0C,QAAS,EAA3C;MACD;;MACDxC,MAAM,CAACmB,QAAP,CAAgBD,MAAhB,GAAyBe,GAAzB;IACD,CAxBD,CAwBE,MAAM,CACN;IACD;EACF;;EAEW,MAANvB,MAAM,CAACC,GAAD,EAA6B;IACvC,MAAM,KAAKJ,GAAL,CAASI,GAAT,EAAc,IAAd,CAAN;EACD;;EAEU,MAAL8B,KAAK,GAAkB;IAC3B;EACD;;AA5FiD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AnalyticsConnector","getAnalyticsConnector","getInstance"],"sources":["analytics-connector.ts"],"sourcesContent":["import { AnalyticsConnector } from '@amplitude/analytics-connector';\n\nexport const getAnalyticsConnector = (): AnalyticsConnector => {\n return AnalyticsConnector.getInstance('$default_instance');\n};\n"],"mappings":"AAAA,SAASA,kBAAT,QAAmC,gCAAnC;AAEA,OAAO,MAAMC,qBAAqB,GAAG,MAA0B;EAC7D,OAAOD,kBAAkB,CAACE,WAAnB,CAA+B,mBAA/B,CAAP;AACD,CAFM"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { isNative } from './platform';
|
|
2
2
|
export const getQueryParams = () => {
|
|
3
|
-
if (isNative()) {
|
|
4
|
-
return {};
|
|
5
|
-
}
|
|
6
3
|
/* istanbul ignore if */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (typeof window === 'undefined') {
|
|
4
|
+
if (isNative() || typeof window === 'undefined') {
|
|
10
5
|
return {};
|
|
11
6
|
}
|
|
12
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isNative","getQueryParams","window","pairs","location","search","substring","split","filter","Boolean","params","reduce","acc","curr","key","value","decodeURIComponent"],"sources":["query-params.ts"],"sourcesContent":["import { isNative } from './platform';\n\nexport const getQueryParams = (): Record<string, string | undefined> => {\n
|
|
1
|
+
{"version":3,"names":["isNative","getQueryParams","window","pairs","location","search","substring","split","filter","Boolean","params","reduce","acc","curr","key","value","decodeURIComponent"],"sources":["query-params.ts"],"sourcesContent":["import { isNative } from './platform';\n\nexport const getQueryParams = (): Record<string, string | undefined> => {\n /* istanbul ignore if */\n if (isNative() || typeof window === 'undefined') {\n return {};\n }\n const pairs = window.location.search.substring(1).split('&').filter(Boolean);\n const params = pairs.reduce<Record<string, string | undefined>>((acc, curr) => {\n const [key, value = ''] = curr.split('=', 2);\n if (!value) {\n return acc;\n }\n acc[decodeURIComponent(key)] = decodeURIComponent(value);\n return acc;\n }, {});\n return params;\n};\n"],"mappings":"AAAA,SAASA,QAAT,QAAyB,YAAzB;AAEA,OAAO,MAAMC,cAAc,GAAG,MAA0C;EACtE;EACA,IAAID,QAAQ,MAAM,OAAOE,MAAP,KAAkB,WAApC,EAAiD;IAC/C,OAAO,EAAP;EACD;;EACD,MAAMC,KAAK,GAAGD,MAAM,CAACE,QAAP,CAAgBC,MAAhB,CAAuBC,SAAvB,CAAiC,CAAjC,EAAoCC,KAApC,CAA0C,GAA1C,EAA+CC,MAA/C,CAAsDC,OAAtD,CAAd;EACA,MAAMC,MAAM,GAAGP,KAAK,CAACQ,MAAN,CAAiD,CAACC,GAAD,EAAMC,IAAN,KAAe;IAC7E,MAAM,CAACC,GAAD,EAAMC,KAAK,GAAG,EAAd,IAAoBF,IAAI,CAACN,KAAL,CAAW,GAAX,EAAgB,CAAhB,CAA1B;;IACA,IAAI,CAACQ,KAAL,EAAY;MACV,OAAOH,GAAP;IACD;;IACDA,GAAG,CAACI,kBAAkB,CAACF,GAAD,CAAnB,CAAH,GAA+BE,kBAAkB,CAACD,KAAD,CAAjD;IACA,OAAOH,GAAP;EACD,CAPc,EAOZ,EAPY,CAAf;EAQA,OAAOF,MAAP;AACD,CAfM"}
|
package/lib/module/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.0.1-dev.
|
|
1
|
+
export const VERSION = '0.0.1-dev.9';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["export const VERSION = '0.0.1-dev.
|
|
1
|
+
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["export const VERSION = '0.0.1-dev.9';\n"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAG,aAAhB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Event, ReactNativeOptions, ReactNativeConfig as IReactNativeConfig, Storage, TrackingOptions,
|
|
1
|
+
import { Event, ReactNativeOptions, ReactNativeConfig as IReactNativeConfig, Storage, TrackingOptions, UserSession, SessionManager as ISessionManager } from '@amplitude/analytics-types';
|
|
2
2
|
import { Config, MemoryStorage } from '@amplitude/analytics-core';
|
|
3
3
|
import { FetchTransport } from './transports/fetch';
|
|
4
|
-
import { XHRTransport } from './transports/xhr';
|
|
5
|
-
import { SendBeaconTransport } from './transports/send-beacon';
|
|
6
4
|
import { SessionManager } from './session-manager';
|
|
7
5
|
export declare const getDefaultConfig: () => {
|
|
8
6
|
cookieExpiration: number;
|
|
@@ -86,6 +84,5 @@ export declare const createCookieStorage: (overrides?: ReactNativeOptions | unde
|
|
|
86
84
|
export declare const createFlexibleStorage: <T>(options: ReactNativeOptions) => Promise<Storage<T>>;
|
|
87
85
|
export declare const createEventsStorage: (overrides?: ReactNativeOptions | undefined) => Promise<Storage<Event[]>>;
|
|
88
86
|
export declare const createDeviceId: (idFromCookies?: string | undefined, idFromOptions?: string | undefined, idFromQueryParams?: string | undefined) => string;
|
|
89
|
-
export declare const createTransport: (transport?: TransportType | undefined) => FetchTransport | XHRTransport | SendBeaconTransport;
|
|
90
87
|
export declare const getTopLevelDomain: (url?: string | undefined) => Promise<string>;
|
|
91
88
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,kBAAkB,EAClB,iBAAiB,IAAI,kBAAkB,EACvC,OAAO,EACP,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,kBAAkB,EAClB,iBAAiB,IAAI,kBAAkB,EACvC,OAAO,EACP,eAAe,EACf,WAAW,EACX,cAAc,IAAI,eAAe,EAClC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAQ,MAAM,2BAA2B,CAAC;AAGxE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B5B,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,MAAO,YAAW,kBAAkB;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACpC,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;IACjC,cAAc,EAAE,eAAe,CAAC;gBAEpB,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB;IA2BzE,IAAI,QAAQ,IAIW,MAAM,GAAG,SAAS,CAFxC;IAED,IAAI,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAExC;IAED,IAAI,MAAM,IAIS,MAAM,GAAG,SAAS,CAFpC;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAEpC;IAED,IAAI,SAAS,IAIY,MAAM,GAAG,SAAS,CAF1C;IAED,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAE1C;IAED,IAAI,MAAM,IAIS,OAAO,CAFzB;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,EAEzB;IAED,IAAI,aAAa,IAIgB,MAAM,GAAG,SAAS,CAFlD;IAED,IAAI,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,EAElD;CACF;AAED,eAAO,MAAM,oBAAoB,WACvB,MAAM,4EAGb,QAAQ,kBAAkB,CAqB5B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;MAG7B,QAAQ,QAAQ,WAAW,CAAC,CAO9B,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAAsB,kBAAkB,wBAczE,CAAC;AAEF,eAAO,MAAM,mBAAmB,kDAA2C,QAAQ,QAAQ,KAAK,EAAE,CAAC,CASlG,CAAC;AAEF,eAAO,MAAM,cAAc,4HAE1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,+CA0B7B,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export { add, flush, getDeviceId, getSessionId, getUserId, groupIdentify, identify, init, logEvent, remove, revenue, setDeviceId, setGroup, setOptOut, setSessionId,
|
|
2
|
-
export { runQueuedFunctions } from './utils/snippet-helper';
|
|
1
|
+
export { add, flush, getDeviceId, getSessionId, getUserId, groupIdentify, identify, init, logEvent, remove, revenue, setDeviceId, setGroup, setOptOut, setSessionId, setUserId, track, } from './react-native-client';
|
|
3
2
|
export { Revenue, Identify } from '@amplitude/analytics-core';
|
|
4
|
-
|
|
5
|
-
export { Types };
|
|
3
|
+
export * as Types from '@amplitude/analytics-types';
|
|
6
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,SAAS,EACT,KAAK,GACN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC"}
|
|
@@ -4,11 +4,11 @@ declare type NativeContext = {
|
|
|
4
4
|
version: string;
|
|
5
5
|
platform: string;
|
|
6
6
|
language: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
osName: string;
|
|
8
|
+
osVersion: string;
|
|
9
|
+
deviceBrand: string;
|
|
10
|
+
deviceManufacturer: string;
|
|
11
|
+
deviceModel: string;
|
|
12
12
|
carrier: string;
|
|
13
13
|
};
|
|
14
14
|
export interface AmplitudeReactNative {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAS/C,aAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAS/C,aAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,qBAAqB,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACjD;AAED,qBAAa,OAAQ,YAAW,YAAY;IAC1C,IAAI,SAAa;IACjB,IAAI,oBAA8B;IAKlC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,SAAK;IACZ,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC3B,YAAY,EAAE,oBAAoB,GAAG,SAAS,CAEhC;IACd,OAAO,SAA0C;;IAWjD,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC;IAK9C,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IA6C7C,cAAc;CAKf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BeforePlugin, PluginType, Event, Config } from '@amplitude/analytics-types';
|
|
2
|
+
export declare class IdentityEventSender implements BeforePlugin {
|
|
3
|
+
name: string;
|
|
4
|
+
type: PluginType.BEFORE;
|
|
5
|
+
identityStore: import("@amplitude/analytics-connector/dist/types/src/identityStore").IdentityStoreImpl;
|
|
6
|
+
execute(context: Event): Promise<Event>;
|
|
7
|
+
setup(_: Config): Promise<undefined>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/plugins/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGrF,qBAAa,mBAAoB,YAAW,YAAY;IACtD,IAAI,SAAc;IAClB,IAAI,oBAA8B;IAElC,aAAa,0FAAyC;IAEhD,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAQ7C,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAGrC"}
|
|
@@ -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.
|
|
@@ -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<Promise<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<Promise<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<Promise<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
|
*
|
|
@@ -191,21 +187,6 @@ export declare const setSessionId: (sessionId: number) => void;
|
|
|
191
187
|
* ```
|
|
192
188
|
*/
|
|
193
189
|
export declare const setOptOut: (optOut: boolean) => void;
|
|
194
|
-
/**
|
|
195
|
-
* Sets the network transport type for events.
|
|
196
|
-
*
|
|
197
|
-
* ```typescript
|
|
198
|
-
* // Use Fetch API
|
|
199
|
-
* setTransport('fetch');
|
|
200
|
-
*
|
|
201
|
-
* // Use XMLHttpRequest API
|
|
202
|
-
* setTransport('xhr');
|
|
203
|
-
*
|
|
204
|
-
* // Use navigator.sendBeacon API
|
|
205
|
-
* setTransport('beacon');
|
|
206
|
-
* ```
|
|
207
|
-
*/
|
|
208
|
-
export declare const setTransport: (transport: TransportType) => void;
|
|
209
190
|
/**
|
|
210
191
|
* Flush and send all the events which haven't been sent.
|
|
211
192
|
*
|
|
@@ -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,EAA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AmC,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.9";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
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.9",
|
|
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"
|
|
@@ -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 = () => {
|
|
@@ -154,7 +151,7 @@ export const useReactNativeConfig = async (
|
|
|
154
151
|
sessionId: (await cookieStorage.get(cookieName))?.sessionId ?? options?.sessionId,
|
|
155
152
|
storageProvider: await createEventsStorage(options),
|
|
156
153
|
trackingOptions: { ...defaultConfig.trackingOptions, ...options?.trackingOptions },
|
|
157
|
-
transportProvider: options?.transportProvider ??
|
|
154
|
+
transportProvider: options?.transportProvider ?? new FetchTransport(),
|
|
158
155
|
});
|
|
159
156
|
};
|
|
160
157
|
|
|
@@ -201,16 +198,6 @@ export const createDeviceId = (idFromCookies?: string, idFromOptions?: string, i
|
|
|
201
198
|
return idFromOptions || idFromQueryParams || idFromCookies || UUID();
|
|
202
199
|
};
|
|
203
200
|
|
|
204
|
-
export const createTransport = (transport?: TransportType) => {
|
|
205
|
-
if (transport === TransportType.XHR) {
|
|
206
|
-
return new XHRTransport();
|
|
207
|
-
}
|
|
208
|
-
if (transport === TransportType.SendBeacon) {
|
|
209
|
-
return new SendBeaconTransport();
|
|
210
|
-
}
|
|
211
|
-
return getDefaultConfig().transportProvider;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
201
|
export const getTopLevelDomain = async (url?: string) => {
|
|
215
202
|
if (!(await new CookieStorage<string>().isEnabled()) || (!url && typeof location === 'undefined')) {
|
|
216
203
|
return '';
|