@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
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["add","getDeviceId","getSessionId","getUserId","groupIdentify","identify","init","logEvent","remove","revenue","setDeviceId","setGroup","setOptOut","setSessionId","
|
|
1
|
+
{"version":3,"names":["add","flush","getDeviceId","getSessionId","getUserId","groupIdentify","identify","init","logEvent","remove","revenue","setDeviceId","setGroup","setOptOut","setSessionId","setUserId","track","Revenue","Identify","Types"],"sources":["index.ts"],"sourcesContent":["export {\n add,\n flush,\n getDeviceId,\n getSessionId,\n getUserId,\n groupIdentify,\n identify,\n init,\n logEvent,\n remove,\n revenue,\n setDeviceId,\n setGroup,\n setOptOut,\n setSessionId,\n setUserId,\n track,\n} from './react-native-client';\nexport { Revenue, Identify } from '@amplitude/analytics-core';\n// Hack - react-native apps have trouble with:\n// export * as Types from '@amplitude/analytics-types\nimport * as Types from '@amplitude/analytics-types';\nexport { Types };\n"],"mappings":"AAAA,SACEA,GADF,EAEEC,KAFF,EAGEC,WAHF,EAIEC,YAJF,EAKEC,SALF,EAMEC,aANF,EAOEC,QAPF,EAQEC,IARF,EASEC,QATF,EAUEC,MAVF,EAWEC,OAXF,EAYEC,WAZF,EAaEC,QAbF,EAcEC,SAdF,EAeEC,YAfF,EAgBEC,SAhBF,EAiBEC,KAjBF,QAkBO,uBAlBP;AAmBA,SAASC,OAAT,EAAkBC,QAAlB,QAAkC,2BAAlC,C,CACA;AACA;;AACA,OAAO,KAAKC,KAAZ,MAAuB,4BAAvB;AACA,SAASA,KAAT"}
|
|
@@ -25,7 +25,7 @@ export class Context {
|
|
|
25
25
|
|
|
26
26
|
_defineProperty(this, "nativeModule", NativeModules.AmplitudeReactNative);
|
|
27
27
|
|
|
28
|
-
_defineProperty(this, "library", `amplitude-ts/${VERSION}`);
|
|
28
|
+
_defineProperty(this, "library", `amplitude-react-native-ts/${VERSION}`);
|
|
29
29
|
|
|
30
30
|
let agent;
|
|
31
31
|
/* istanbul ignore else */
|
|
@@ -60,10 +60,10 @@ export class Context {
|
|
|
60
60
|
const nativeContext = await ((_this$nativeModule = this.nativeModule) === null || _this$nativeModule === void 0 ? void 0 : _this$nativeModule.getApplicationContext());
|
|
61
61
|
const appVersion = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.version) || this.config.appVersion;
|
|
62
62
|
const platform = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.platform) || BROWSER_PLATFORM;
|
|
63
|
-
const osName = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.
|
|
64
|
-
const osVersion = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.
|
|
65
|
-
const deviceVendor = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.
|
|
66
|
-
const deviceModel = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.
|
|
63
|
+
const osName = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.osName) || this.uaResult.browser.name;
|
|
64
|
+
const osVersion = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.osVersion) || this.uaResult.browser.version;
|
|
65
|
+
const deviceVendor = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.deviceManufacturer) || this.uaResult.device.vendor;
|
|
66
|
+
const deviceModel = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.deviceModel) || this.uaResult.device.model || this.uaResult.os.name;
|
|
67
67
|
const language = (nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.language) || getLanguage();
|
|
68
68
|
const carrier = nativeContext === null || nativeContext === void 0 ? void 0 : nativeContext.carrier;
|
|
69
69
|
const event = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PluginType","UAParser","UUID","getLanguage","VERSION","NativeModules","BROWSER_PLATFORM","IP_ADDRESS","Context","constructor","BEFORE","AmplitudeReactNative","agent","navigator","userAgent","uaResult","getResult","setup","config","Promise","resolve","undefined","execute","context","isSessionValid","sessionId","Date","now","lastEventTime","time","getTime","nativeContext","nativeModule","getApplicationContext","appVersion","version","platform","osName","
|
|
1
|
+
{"version":3,"names":["PluginType","UAParser","UUID","getLanguage","VERSION","NativeModules","BROWSER_PLATFORM","IP_ADDRESS","Context","constructor","BEFORE","AmplitudeReactNative","agent","navigator","userAgent","uaResult","getResult","setup","config","Promise","resolve","undefined","execute","context","isSessionValid","sessionId","Date","now","lastEventTime","time","getTime","nativeContext","nativeModule","getApplicationContext","appVersion","version","platform","osName","browser","name","osVersion","deviceVendor","deviceManufacturer","device","vendor","deviceModel","model","os","language","carrier","event","user_id","userId","device_id","deviceId","session_id","app_version","trackingOptions","os_name","os_version","device_manufacturer","device_model","ipAddress","ip","insert_id","partner_id","partnerId","plan","event_id","eventId","library","timeSinceLastEvent","sessionTimeout"],"sources":["context.ts"],"sourcesContent":["import { BeforePlugin, ReactNativeConfig, Event, PluginType } from '@amplitude/analytics-types';\nimport UAParser from '@amplitude/ua-parser-js';\nimport { UUID } from '@amplitude/analytics-core';\nimport { getLanguage } from '../utils/language';\nimport { VERSION } from '../version';\nimport { NativeModules } from 'react-native';\n\nconst BROWSER_PLATFORM = 'Web';\nconst IP_ADDRESS = '$remote';\n\ntype NativeContext = {\n version: string;\n platform: string;\n language: string;\n osName: string;\n osVersion: string;\n deviceBrand: string;\n deviceManufacturer: string;\n deviceModel: string;\n carrier: string;\n};\n\nexport interface AmplitudeReactNative {\n getApplicationContext(): Promise<NativeContext>;\n}\n\nexport class Context implements BeforePlugin {\n name = 'context';\n type = PluginType.BEFORE as const;\n\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: ReactNativeConfig;\n eventId = 0;\n uaResult: UAParser.IResult;\n nativeModule: AmplitudeReactNative | undefined = NativeModules.AmplitudeReactNative as\n | AmplitudeReactNative\n | undefined;\n library = `amplitude-react-native-ts/${VERSION}`;\n\n constructor() {\n let agent: string | undefined;\n /* istanbul ignore else */\n if (typeof navigator !== 'undefined') {\n agent = navigator.userAgent;\n }\n this.uaResult = new UAParser(agent).getResult();\n }\n\n setup(config: ReactNativeConfig): Promise<undefined> {\n this.config = config;\n return Promise.resolve(undefined);\n }\n\n async execute(context: Event): Promise<Event> {\n /**\n * Manages user session triggered by new events\n */\n if (!this.isSessionValid()) {\n // Creates new session\n this.config.sessionId = Date.now();\n } // else use previously creates session\n // Updates last event time to extend time-based session\n this.config.lastEventTime = Date.now();\n const time = new Date().getTime();\n const nativeContext = await this.nativeModule?.getApplicationContext();\n const appVersion = nativeContext?.version || this.config.appVersion;\n const platform = nativeContext?.platform || BROWSER_PLATFORM;\n const osName = nativeContext?.osName || this.uaResult.browser.name;\n const osVersion = nativeContext?.osVersion || this.uaResult.browser.version;\n const deviceVendor = nativeContext?.deviceManufacturer || this.uaResult.device.vendor;\n const deviceModel = nativeContext?.deviceModel || this.uaResult.device.model || this.uaResult.os.name;\n const language = nativeContext?.language || getLanguage();\n const carrier = nativeContext?.carrier;\n\n const event: Event = {\n user_id: this.config.userId,\n device_id: this.config.deviceId,\n session_id: this.config.sessionId,\n time,\n ...(this.config.appVersion && { app_version: appVersion }),\n ...(this.config.trackingOptions.platform && { platform: platform }),\n ...(this.config.trackingOptions.osName && { os_name: osName }),\n ...(this.config.trackingOptions.osVersion && { os_version: osVersion }),\n ...(this.config.trackingOptions.deviceManufacturer && { device_manufacturer: deviceVendor }),\n ...(this.config.trackingOptions.deviceModel && { device_model: deviceModel }),\n ...(this.config.trackingOptions.language && { language: language }),\n ...(this.config.trackingOptions.carrier && { carrier: carrier }),\n ...(this.config.trackingOptions.ipAddress && { ip: IP_ADDRESS }),\n insert_id: UUID(),\n partner_id: this.config.partnerId,\n plan: this.config.plan,\n ...context,\n event_id: this.eventId++,\n library: this.library,\n };\n return event;\n }\n\n isSessionValid() {\n const lastEventTime = this.config.lastEventTime || Date.now();\n const timeSinceLastEvent = Date.now() - lastEventTime;\n return timeSinceLastEvent < this.config.sessionTimeout;\n }\n}\n"],"mappings":";;AAAA,SAAiDA,UAAjD,QAAmE,4BAAnE;AACA,OAAOC,QAAP,MAAqB,yBAArB;AACA,SAASC,IAAT,QAAqB,2BAArB;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,OAAT,QAAwB,YAAxB;AACA,SAASC,aAAT,QAA8B,cAA9B;AAEA,MAAMC,gBAAgB,GAAG,KAAzB;AACA,MAAMC,UAAU,GAAG,SAAnB;AAkBA,OAAO,MAAMC,OAAN,CAAsC;EAI3C;EACA;EACA;EASAC,WAAW,GAAG;IAAA,8BAdP,SAcO;;IAAA,8BAbPT,UAAU,CAACU,MAaJ;;IAAA;;IAAA,iCAPJ,CAOI;;IAAA;;IAAA,sCALmCL,aAAa,CAACM,oBAKjD;;IAAA,iCAFH,6BAA4BP,OAAQ,EAEjC;;IACZ,IAAIQ,KAAJ;IACA;;IACA,IAAI,OAAOC,SAAP,KAAqB,WAAzB,EAAsC;MACpCD,KAAK,GAAGC,SAAS,CAACC,SAAlB;IACD;;IACD,KAAKC,QAAL,GAAgB,IAAId,QAAJ,CAAaW,KAAb,EAAo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,eAAZ,CAA4BT,QAA5B,IAAwC;QAAEA,QAAQ,EAAEA;MAAZ,CAA5C,CAXmB;MAYnB,IAAI,KAAK9B,MAAL,CAAYuC,eAAZ,CAA4BR,OAA5B,IAAuC;QAAEA,OAAO,EAAEA;MAAX,CAA3C,CAZmB;MAanB,IAAI,KAAK/B,MAAL,CAAYuC,eAAZ,CAA4BK,SAA5B,IAAyC;QAAEC,EAAE,EAAExD;MAAN,CAA7C,CAbmB;MAcnByD,SAAS,EAAE9D,IAAI,EAdI;MAenB+D,UAAU,EAAE,KAAK/C,MAAL,CAAYgD,SAfL;MAgBnBC,IAAI,EAAE,KAAKjD,MAAL,CAAYiD,IAhBC;MAiBnB,GAAG5C,OAjBgB;MAkBnB6C,QAAQ,EAAE,KAAKC,OAAL,EAlBS;MAmBnBC,OAAO,EAAE,KAAKA;IAnBK,CAArB;IAqBA,OAAOpB,KAAP;EACD;;EAED1B,cAAc,GAAG;IACf,MAAMI,aAAa,GAAG,KAAKV,MAAL,CAAYU,aAAZ,IAA6BF,IAAI,CAACC,GAAL,EAAnD;IACA,MAAM4C,kBAAkB,GAAG7C,IAAI,CAACC,GAAL,KAAaC,aAAxC;IACA,OAAO2C,kBAAkB,GAAG,KAAKrD,MAAL,CAAYsD,cAAxC;EACD;;AA9E0C"}
|
|
@@ -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().updateUserProperties(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","updateUserProperties","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().updateUserProperties(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,oBAAlC,CAAuDH,cAAvD,EAAuEI,MAAvE;IACD;;IACD,OAAOL,OAAP;EACD;;EAEDM,KAAK,CAACC,CAAD,EAAgC;IACnC,OAAOC,OAAO,CAACC,OAAR,CAAgBC,SAAhB,CAAP;EACD;;AAhBsD"}
|
|
@@ -1,9 +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';
|
|
6
|
+
import { isNative } from './utils/platform';
|
|
7
|
+
import { IdentityEventSender } from './plugins/identity';
|
|
8
|
+
import { getAnalyticsConnector } from './utils/analytics-connector';
|
|
7
9
|
export class AmplitudeReactNative extends AmplitudeCore {
|
|
8
10
|
async init(apiKey, userId, options) {
|
|
9
11
|
var _oldCookies$deviceId, _oldCookies$sessionId, _options$optOut;
|
|
@@ -27,11 +29,20 @@ export class AmplitudeReactNative extends AmplitudeCore {
|
|
|
27
29
|
// 2) Previous session expired
|
|
28
30
|
this.config.sessionId = Date.now();
|
|
29
31
|
isNewSession = true;
|
|
30
|
-
}
|
|
31
|
-
// Do not track any events before this
|
|
32
|
+
}
|
|
32
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
|
|
33
43
|
|
|
34
44
|
await this.add(new Context());
|
|
45
|
+
await this.add(new IdentityEventSender());
|
|
35
46
|
await this.add(new Destination()); // Step 5: Track attributions
|
|
36
47
|
|
|
37
48
|
await this.runAttributionStrategy(options === null || options === void 0 ? void 0 : options.attribution, isNewSession);
|
|
@@ -39,6 +50,11 @@ export class AmplitudeReactNative extends AmplitudeCore {
|
|
|
39
50
|
|
|
40
51
|
async runAttributionStrategy(attributionConfig) {
|
|
41
52
|
let isNewSession = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
53
|
+
|
|
54
|
+
if (isNative()) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
42
58
|
const track = this.track.bind(this);
|
|
43
59
|
const onNewCampaign = this.setSessionId.bind(this, Date.now());
|
|
44
60
|
const storage = await createFlexibleStorage(this.config);
|
|
@@ -56,6 +72,9 @@ export class AmplitudeReactNative extends AmplitudeCore {
|
|
|
56
72
|
|
|
57
73
|
setUserId(userId) {
|
|
58
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();
|
|
59
78
|
}
|
|
60
79
|
|
|
61
80
|
getDeviceId() {
|
|
@@ -64,6 +83,9 @@ export class AmplitudeReactNative extends AmplitudeCore {
|
|
|
64
83
|
|
|
65
84
|
setDeviceId(deviceId) {
|
|
66
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();
|
|
67
89
|
}
|
|
68
90
|
|
|
69
91
|
regenerateDeviceId() {
|
|
@@ -83,40 +105,6 @@ export class AmplitudeReactNative extends AmplitudeCore {
|
|
|
83
105
|
this.config.optOut = optOut;
|
|
84
106
|
}
|
|
85
107
|
|
|
86
|
-
setTransport(transport) {
|
|
87
|
-
this.config.transportProvider = createTransport(transport);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
identify(identify, eventOptions) {
|
|
91
|
-
if (isInstanceProxy(identify)) {
|
|
92
|
-
const queue = identify._q;
|
|
93
|
-
identify._q = [];
|
|
94
|
-
identify = convertProxyObjectToRealObject(new Identify(), queue);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return super.identify(identify, eventOptions);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
groupIdentify(groupType, groupName, identify, eventOptions) {
|
|
101
|
-
if (isInstanceProxy(identify)) {
|
|
102
|
-
const queue = identify._q;
|
|
103
|
-
identify._q = [];
|
|
104
|
-
identify = convertProxyObjectToRealObject(new Identify(), queue);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return super.groupIdentify(groupType, groupName, identify, eventOptions);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
revenue(revenue, eventOptions) {
|
|
111
|
-
if (isInstanceProxy(revenue)) {
|
|
112
|
-
const queue = revenue._q;
|
|
113
|
-
revenue._q = [];
|
|
114
|
-
revenue = convertProxyObjectToRealObject(new Revenue(), queue);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return super.revenue(revenue, eventOptions);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
108
|
}
|
|
121
109
|
const client = new AmplitudeReactNative();
|
|
122
110
|
/**
|
|
@@ -311,19 +299,16 @@ export const setSessionId = client.setSessionId.bind(client);
|
|
|
311
299
|
|
|
312
300
|
export const setOptOut = client.setOptOut.bind(client);
|
|
313
301
|
/**
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* ```typescript
|
|
317
|
-
* // Use Fetch API
|
|
318
|
-
* setTransport('fetch');
|
|
302
|
+
* Flush and send all the events which haven't been sent.
|
|
319
303
|
*
|
|
320
|
-
|
|
321
|
-
*
|
|
304
|
+
*```typescript
|
|
305
|
+
* // Send all the unsent events
|
|
306
|
+
* flush();
|
|
322
307
|
*
|
|
323
|
-
* //
|
|
324
|
-
*
|
|
308
|
+
* // alternatively, this tracking method is awaitable
|
|
309
|
+
* await flush().promise;
|
|
325
310
|
* ```
|
|
326
311
|
*/
|
|
327
312
|
|
|
328
|
-
export const
|
|
313
|
+
export const flush = returnWrapper(client.flush.bind(client));
|
|
329
314
|
//# sourceMappingURL=react-native-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AmplitudeCore","Destination","Identify","Revenue","returnWrapper","convertProxyObjectToRealObject","isInstanceProxy","Context","useReactNativeConfig","createTransport","createDeviceId","createFlexibleStorage","parseOldCookies","CampaignTracker","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"],"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';\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 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"],"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;AAEA,OAAO,MAAMC,oBAAN,SAAmCd,aAAnC,CAAoE;EAC/D,MAAJe,IAAI,CAACC,MAAD,EAAiBC,MAAjB,EAAkC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AMZ,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"}
|
|
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,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A;;AACA,OAAO,MAAMH,kBAAkB,GAAGG,MAAM,CAACH,kBAAP,CAA0BZ,IAA1B,CAA+Be,MAA/B,CAA3B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMF,YAAY,GAAGE,MAAM,CAACF,YAAP,CAAoBb,IAApB,CAAyBe,MAAzB,CAArB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMb,YAAY,GAAGa,MAAM,CAACb,YAAP,CAAoBF,IAApB,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
|
|
|
@@ -37,14 +32,19 @@ export class CookieStorage {
|
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
async get(key) {
|
|
40
|
-
|
|
35
|
+
let value = await this.getRaw(key);
|
|
41
36
|
|
|
42
37
|
if (!value) {
|
|
43
38
|
return undefined;
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
try {
|
|
47
|
-
|
|
42
|
+
try {
|
|
43
|
+
value = decodeURIComponent(atob(value));
|
|
44
|
+
} catch {// value not encoded
|
|
45
|
+
} // eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
46
|
+
|
|
47
|
+
|
|
48
48
|
return JSON.parse(value);
|
|
49
49
|
} catch {
|
|
50
50
|
/* istanbul ignore next */
|
|
@@ -77,7 +77,7 @@ export class CookieStorage {
|
|
|
77
77
|
expireDate = date;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
let str = `${key}=${JSON.stringify(value)}`;
|
|
80
|
+
let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;
|
|
81
81
|
|
|
82
82
|
if (expireDate) {
|
|
83
83
|
str += `; expires=${expireDate.toUTCString()}`;
|
|
@@ -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","JSON","parse","cookie","document","split","match","find","c","indexOf","substring","length","expirationDays","expires","expireDate","date","setTime","getTime","str","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,OAA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Aa0C,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.11';
|
|
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.11';\n"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAG,cAAhB"}
|
|
@@ -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,5 +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
|
|
87
|
+
export declare const getTopLevelDomain: (url?: string | undefined) => Promise<string>;
|
|
90
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,
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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,5 +1,4 @@
|
|
|
1
|
-
export { add, 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
3
|
import * as Types from '@amplitude/analytics-types';
|
|
5
4
|
export { Types };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,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;AAG9D,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,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"}
|