@amplitude/analytics-react-native 1.4.14 → 1.5.0
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 +2 -2
- package/lib/commonjs/campaign/campaign-tracker.js +105 -0
- package/lib/commonjs/campaign/campaign-tracker.js.map +1 -0
- package/lib/commonjs/campaign/types.js +6 -0
- package/lib/commonjs/campaign/types.js.map +1 -0
- package/lib/commonjs/config.js +12 -35
- package/lib/commonjs/config.js.map +1 -1
- package/lib/commonjs/cookie-migration/index.js +2 -2
- package/lib/commonjs/cookie-migration/index.js.map +1 -1
- package/lib/commonjs/index.js +7 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/migration/remnant-data-migration.js +2 -7
- package/lib/commonjs/migration/remnant-data-migration.js.map +1 -1
- package/lib/commonjs/plugins/context.js +18 -14
- package/lib/commonjs/plugins/context.js.map +1 -1
- package/lib/commonjs/react-native-client.js +48 -45
- package/lib/commonjs/react-native-client.js.map +1 -1
- package/lib/commonjs/storage/local-storage.js +3 -3
- package/lib/commonjs/storage/local-storage.js.map +1 -1
- package/lib/commonjs/types.js +175 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/typings/browser-snippet.d.js.map +1 -1
- package/lib/commonjs/typings/ua-parser.d.js.map +1 -1
- package/lib/commonjs/utils/platform.js.map +1 -1
- package/lib/commonjs/version.js +1 -2
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/campaign/campaign-tracker.js +98 -0
- package/lib/module/campaign/campaign-tracker.js.map +1 -0
- package/lib/module/campaign/types.js +2 -0
- package/lib/module/campaign/types.js.map +1 -0
- package/lib/module/config.js +4 -27
- package/lib/module/config.js.map +1 -1
- package/lib/module/cookie-migration/index.js +1 -1
- package/lib/module/cookie-migration/index.js.map +1 -1
- package/lib/module/index.js +4 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/migration/remnant-data-migration.js +2 -7
- package/lib/module/migration/remnant-data-migration.js.map +1 -1
- package/lib/module/plugins/context.js +16 -12
- package/lib/module/plugins/context.js.map +1 -1
- package/lib/module/react-native-client.js +43 -39
- package/lib/module/react-native-client.js.map +1 -1
- package/lib/module/storage/local-storage.js +1 -1
- package/lib/module/storage/local-storage.js.map +1 -1
- package/lib/module/types.js +3 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/typings/browser-snippet.d.js.map +1 -1
- package/lib/module/typings/ua-parser.d.js.map +1 -1
- package/lib/module/utils/platform.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/campaign/campaign-tracker.d.ts +85 -0
- package/lib/typescript/campaign/campaign-tracker.d.ts.map +1 -0
- package/lib/typescript/campaign/types.d.ts +11 -0
- package/lib/typescript/campaign/types.d.ts.map +1 -0
- package/lib/typescript/config.d.ts +1 -3
- package/lib/typescript/config.d.ts.map +1 -1
- package/lib/typescript/cookie-migration/index.d.ts +2 -2
- package/lib/typescript/cookie-migration/index.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/migration/remnant-data-migration.d.ts +2 -2
- package/lib/typescript/migration/remnant-data-migration.d.ts.map +1 -1
- package/lib/typescript/plugins/context.d.ts +2 -2
- package/lib/typescript/plugins/context.d.ts.map +1 -1
- package/lib/typescript/react-native-client.d.ts +15 -5
- package/lib/typescript/react-native-client.d.ts.map +1 -1
- package/lib/typescript/storage/local-storage.d.ts +1 -1
- package/lib/typescript/storage/local-storage.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +2 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +3 -5
- package/src/campaign/campaign-tracker.ts +130 -0
- package/src/campaign/types.ts +13 -0
- package/src/config.ts +10 -5
- package/src/cookie-migration/index.ts +2 -3
- package/src/index.ts +4 -4
- package/src/migration/remnant-data-migration.ts +2 -2
- package/src/plugins/context.ts +15 -6
- package/src/react-native-client.ts +31 -15
- package/src/storage/local-storage.ts +1 -2
- package/src/types.ts +31 -0
- package/src/typings/browser-snippet.d.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["typings/ua-parser.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","isWeb","OS","isNative"],"sourceRoot":"
|
|
1
|
+
{"version":3,"names":["Platform","isWeb","OS","isNative"],"sourceRoot":"../../../src","sources":["utils/platform.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,KAAK,GAAGA,CAAA,KAAe;EAClC,OAAOD,QAAQ,CAACE,EAAE,KAAK,KAAK;AAC9B,CAAC;AAED,OAAO,MAAMC,QAAQ,GAAGA,CAAA,KAAe;EACrC,OAAO,CAACF,KAAK,CAAC,CAAC;AACjB,CAAC","ignoreList":[]}
|
package/lib/module/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '1.
|
|
1
|
+
export const VERSION = '1.5.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VERSION"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"names":["VERSION"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAG,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Storage, Campaign, CampaignParser as ICampaignParser } from '@amplitude/analytics-core';
|
|
2
|
+
import { CampaignTracker as ICampaignTracker, CampaignTrackFunction, CampaignTrackerOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated
|
|
5
|
+
* Campaign tracker has mixed logic from built-in and plugin web attribution
|
|
6
|
+
* features. Do not add more features here. The plan moving foward is to consolidate logic
|
|
7
|
+
* in @amplitude/plugin-web-attribution-browser with backward compatibility.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CampaignTracker implements ICampaignTracker {
|
|
10
|
+
storage: Storage<Campaign>;
|
|
11
|
+
storageKey: string;
|
|
12
|
+
parser: ICampaignParser;
|
|
13
|
+
track: CampaignTrackFunction;
|
|
14
|
+
onNewCampaign: (campaign: Campaign) => unknown;
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
trackNewCampaigns: boolean;
|
|
17
|
+
trackPageViews: boolean;
|
|
18
|
+
excludeReferrers: string[];
|
|
19
|
+
initialEmptyValue: string;
|
|
20
|
+
constructor(apiKey: string, options: CampaignTrackerOptions);
|
|
21
|
+
isNewCampaign(current: Campaign, previous: Campaign | undefined, ignoreSubdomainInReferrer?: boolean): boolean;
|
|
22
|
+
saveCampaignToStorage(campaign: Campaign): Promise<void>;
|
|
23
|
+
getCampaignFromStorage(): Promise<Campaign | undefined>;
|
|
24
|
+
createCampaignEvent(campaign: Campaign): {
|
|
25
|
+
event_type: string;
|
|
26
|
+
event_properties?: {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
} | undefined;
|
|
29
|
+
user_properties: {
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
};
|
|
32
|
+
group_properties?: {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
} | undefined;
|
|
35
|
+
user_id?: string | undefined;
|
|
36
|
+
device_id?: string | undefined;
|
|
37
|
+
time?: number | undefined;
|
|
38
|
+
location_lat?: number | undefined;
|
|
39
|
+
location_lng?: number | undefined;
|
|
40
|
+
app_version?: string | undefined;
|
|
41
|
+
version_name?: string | undefined;
|
|
42
|
+
library?: string | undefined;
|
|
43
|
+
platform?: string | undefined;
|
|
44
|
+
os_name?: string | undefined;
|
|
45
|
+
os_version?: string | undefined;
|
|
46
|
+
device_brand?: string | undefined;
|
|
47
|
+
device_manufacturer?: string | undefined;
|
|
48
|
+
device_model?: string | undefined;
|
|
49
|
+
carrier?: string | undefined;
|
|
50
|
+
country?: string | undefined;
|
|
51
|
+
region?: string | undefined;
|
|
52
|
+
city?: string | undefined;
|
|
53
|
+
dma?: string | undefined;
|
|
54
|
+
idfa?: string | undefined;
|
|
55
|
+
idfv?: string | undefined;
|
|
56
|
+
adid?: string | undefined;
|
|
57
|
+
android_id?: string | undefined;
|
|
58
|
+
language?: string | undefined;
|
|
59
|
+
ip?: string | undefined;
|
|
60
|
+
price?: number | undefined;
|
|
61
|
+
quantity?: number | undefined;
|
|
62
|
+
revenue?: number | undefined;
|
|
63
|
+
receipt?: string | undefined;
|
|
64
|
+
receiptSig?: string | undefined;
|
|
65
|
+
productId?: string | undefined;
|
|
66
|
+
revenueType?: string | undefined;
|
|
67
|
+
currency?: string | undefined;
|
|
68
|
+
event_id?: number | undefined;
|
|
69
|
+
session_id?: number | undefined;
|
|
70
|
+
insert_id?: string | undefined;
|
|
71
|
+
plan?: import("@amplitude/analytics-core").Plan | undefined;
|
|
72
|
+
ingestion_metadata?: import("@amplitude/analytics-core/lib/esm/types/event/ingestion-metadata").IngestionMetadataEventProperty | undefined;
|
|
73
|
+
partner_id?: string | undefined;
|
|
74
|
+
user_agent?: string | undefined;
|
|
75
|
+
android_app_set_id?: string | undefined;
|
|
76
|
+
extra?: {
|
|
77
|
+
[key: string]: any;
|
|
78
|
+
} | undefined;
|
|
79
|
+
groups?: {
|
|
80
|
+
[key: string]: any;
|
|
81
|
+
} | undefined;
|
|
82
|
+
};
|
|
83
|
+
send(isNewSession: boolean): Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=campaign-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaign-tracker.d.ts","sourceRoot":"","sources":["../../../src/campaign/campaign-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,OAAO,EACP,QAAQ,EACR,cAAc,IAAI,eAAe,EAOlC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE7G;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IACtD,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,qBAAqB,CAAC;IAC7B,aAAa,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC;IAE/C,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;gBAEd,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB;IAiB3D,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAAE,yBAAyB,UAAQ;IAgB5F,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD,sBAAsB,IAAI,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;IAI7D,mBAAmB,CAAC,QAAQ,EAAE,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6BhC,IAAI,CAAC,YAAY,EAAE,OAAO;CAejC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Campaign, ReactNativeAttributionOptions, Storage, BaseEvent } from '@amplitude/analytics-core';
|
|
2
|
+
export interface CampaignTrackerOptions extends ReactNativeAttributionOptions {
|
|
3
|
+
storage: Storage<Campaign>;
|
|
4
|
+
track: CampaignTrackFunction;
|
|
5
|
+
onNewCampaign: (campaign: Campaign) => unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface CampaignTracker extends CampaignTrackerOptions {
|
|
8
|
+
send(force: boolean): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export type CampaignTrackFunction = (event: BaseEvent) => Promise<unknown>;
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/campaign/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,6BAA6B,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAExG,MAAM,WAAW,sBAAuB,SAAQ,6BAA6B;IAC3E,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,KAAK,EAAE,qBAAqB,CAAC;IAC7B,aAAa,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC;CAChD;AAED,MAAM,WAAW,eAAgB,SAAQ,sBAAsB;IAC7D,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED,MAAM,MAAM,qBAAqB,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Config, MemoryStorage } from '@amplitude/analytics-core';
|
|
3
|
-
import { FetchTransport } from '@amplitude/analytics-client-common';
|
|
1
|
+
import { Config, MemoryStorage, ReactNativeConfig as IReactNativeConfig, ReactNativeTrackingOptions, Event, ReactNativeOptions, Storage, UserSession, FetchTransport } from '@amplitude/analytics-core';
|
|
4
2
|
export declare const getDefaultConfig: () => {
|
|
5
3
|
cookieExpiration: number;
|
|
6
4
|
cookieSameSite: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,aAAa,EAEb,iBAAiB,IAAI,kBAAkB,EACvC,0BAA0B,EAC1B,KAAK,EACL,kBAAkB,EAClB,OAAO,EACP,WAAW,EAIX,cAAc,EACf,MAAM,2BAA2B,CAAC;AAKnC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;CA8B5B,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,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,eAAe,EAAE,0BAA0B,CAAC;IAG5C,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,OAAO,UAAS;IAC1B,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEf,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB;IAiCxD,IAAI,QAAQ,IAIW,MAAM,GAAG,SAAS,CAFxC;IAED,IAAI,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAKxC;IAED,IAAI,MAAM,IAIS,MAAM,GAAG,SAAS,CAFpC;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAKpC;IAED,IAAI,SAAS,IAIY,MAAM,GAAG,SAAS,CAF1C;IAED,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAK1C;IAED,IAAI,MAAM,IAIS,OAAO,CAFzB;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,EAKzB;IAED,IAAI,aAAa,IAIgB,MAAM,GAAG,SAAS,CAFlD;IAED,IAAI,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,EAKlD;IAED,IAAI,WAAW,IAIc,MAAM,GAAG,SAAS,CAF9C;IAED,IAAI,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAK9C;IAED,OAAO,CAAC,aAAa;CAWtB;AAED,eAAO,MAAM,oBAAoB,WACvB,MAAM,YACJ,kBAAkB,KAC3B,QAAQ,kBAAkB,CA4D5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,kBAClB,kBAAkB;;;;;;;;;;;;;yBAS/B,CAAC;AAkBF,eAAO,MAAM,mBAAmB,eAAsB,kBAAkB,KAAG,QAAQ,QAAQ,KAAK,EAAE,CAAC,GAAG,SAAS,CAe9G,CAAC;AAEF,eAAO,MAAM,iBAAiB,SAAgB,MAAM,oBA6BnD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const parseOldCookies: (apiKey: string, options?:
|
|
1
|
+
import { UserSession, ReactNativeOptions } from '@amplitude/analytics-core';
|
|
2
|
+
export declare const parseOldCookies: (apiKey: string, options?: ReactNativeOptions) => Promise<UserSession>;
|
|
3
3
|
export declare const parseTime: (num: string) => number | undefined;
|
|
4
4
|
export declare const decode: (value?: string) => string | undefined;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cookie-migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cookie-migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAoB,MAAM,2BAA2B,CAAC;AAG9F,eAAO,MAAM,eAAe,WAAkB,MAAM,YAAY,kBAAkB,KAAG,QAAQ,WAAW,CAyBvG,CAAC;AAEF,eAAO,MAAM,SAAS,QAAS,MAAM,uBAMpC,CAAC;AAEF,eAAO,MAAM,MAAM,WAAY,MAAM,KAAG,MAAM,GAAG,SAShD,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { createInstance } from './react-native-client';
|
|
2
|
-
export declare const add: (plugin:
|
|
2
|
+
export declare const add: (plugin: import("@amplitude/analytics-core").Plugin<import("@amplitude/analytics-core").ReactNativeClient, import("@amplitude/analytics-core").ReactNativeConfig>) => import("@amplitude/analytics-core").AmplitudeReturn<void>, flush: () => import("@amplitude/analytics-core").AmplitudeReturn<void>, getDeviceId: () => string | undefined, getSessionId: () => number | undefined, getUserId: () => string | undefined, groupIdentify: (groupType: string, groupName: string | string[], identify: import("@amplitude/analytics-core").IIdentify, eventOptions?: import("@amplitude/analytics-core").EventOptions | undefined) => import("@amplitude/analytics-core").AmplitudeReturn<import("@amplitude/analytics-core").Result>, identify: (identify: import("@amplitude/analytics-core").IIdentify, eventOptions?: import("@amplitude/analytics-core").EventOptions | undefined) => import("@amplitude/analytics-core").AmplitudeReturn<import("@amplitude/analytics-core").Result>, init: (apiKey: string, userId?: string | undefined, options?: import("@amplitude/analytics-core").ReactNativeOptions | undefined) => import("@amplitude/analytics-core").AmplitudeReturn<void>, logEvent: (eventInput: string | import("@amplitude/analytics-core").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-core").EventOptions | undefined) => import("@amplitude/analytics-core").AmplitudeReturn<import("@amplitude/analytics-core").Result>, remove: (pluginName: string) => import("@amplitude/analytics-core").AmplitudeReturn<void>, reset: () => void, revenue: (revenue: import("@amplitude/analytics-core").IRevenue, eventOptions?: import("@amplitude/analytics-core").EventOptions | undefined) => import("@amplitude/analytics-core").AmplitudeReturn<import("@amplitude/analytics-core").Result>, setDeviceId: (deviceId: string) => void, setGroup: (groupType: string, groupName: string | string[], eventOptions?: import("@amplitude/analytics-core").EventOptions | undefined) => import("@amplitude/analytics-core").AmplitudeReturn<import("@amplitude/analytics-core").Result>, setOptOut: (optOut: boolean) => void, setSessionId: (sessionId: number) => void, setUserId: (userId: string | undefined) => void, track: (eventInput: string | import("@amplitude/analytics-core").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-core").EventOptions | undefined) => import("@amplitude/analytics-core").AmplitudeReturn<import("@amplitude/analytics-core").Result>, extendSession: () => void;
|
|
3
3
|
export { Revenue, Identify } from '@amplitude/analytics-core';
|
|
4
|
-
|
|
5
|
-
export { Types };
|
|
4
|
+
export * as Types from './types';
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,eAAO,MACL,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,eAAO,MACL,GAAG,mOACH,KAAK,mEACL,WAAW,4BACX,YAAY,4BACZ,SAAS,4BACT,aAAa,8RACb,QAAQ,6OACR,IAAI,4LACJ,QAAQ,2SACR,MAAM,qFACN,KAAK,cACL,OAAO,2OACP,WAAW,8BACX,QAAQ,qOACR,SAAS,6BACT,YAAY,+BACZ,SAAS,wCACT,KAAK,2SACL,aAAa,YACL,CAAC;AACX,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAI9D,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Event,
|
|
1
|
+
import { Event, ILogger, Storage, UserSession } from '@amplitude/analytics-core';
|
|
2
2
|
export default class RemnantDataMigration {
|
|
3
3
|
private apiKey;
|
|
4
4
|
private instanceName;
|
|
@@ -7,7 +7,7 @@ export default class RemnantDataMigration {
|
|
|
7
7
|
private logger;
|
|
8
8
|
eventsStorageKey: string;
|
|
9
9
|
private readonly nativeModule;
|
|
10
|
-
constructor(apiKey: string, instanceName: string | undefined, storage: Storage<Event[]> | undefined, firstRunSinceUpgrade: boolean, logger:
|
|
10
|
+
constructor(apiKey: string, instanceName: string | undefined, storage: Storage<Event[]> | undefined, firstRunSinceUpgrade: boolean, logger: ILogger | undefined);
|
|
11
11
|
execute(): Promise<Omit<UserSession, 'optOut'>>;
|
|
12
12
|
private moveEvents;
|
|
13
13
|
private moveIdentifies;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remnant-data-migration.d.ts","sourceRoot":"","sources":["../../../src/migration/remnant-data-migration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"remnant-data-migration.d.ts","sourceRoot":"","sources":["../../../src/migration/remnant-data-migration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAWjF,MAAM,CAAC,OAAO,OAAO,oBAAoB;IAKrC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,MAAM;IARhB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuB;gBAG1C,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,EACrC,oBAAoB,EAAE,OAAO,EAC7B,MAAM,EAAE,OAAO,GAAG,SAAS;IAO/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;YAevC,UAAU;YAIV,cAAc;YAId,yBAAyB;YAIzB,kBAAkB;IAShC,OAAO,CAAC,gBAAgB;YAQV,gBAAgB;IA4B9B,OAAO,CAAC,kBAAkB;CAoE3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BeforePlugin, ReactNativeConfig, Event,
|
|
1
|
+
import { BeforePlugin, ReactNativeConfig, Event, ReactNativeTrackingOptions } from '@amplitude/analytics-core';
|
|
2
2
|
import UAParser from '@amplitude/ua-parser-js';
|
|
3
3
|
type NativeContext = {
|
|
4
4
|
version: string;
|
|
@@ -20,7 +20,7 @@ export interface AmplitudeReactNative {
|
|
|
20
20
|
}
|
|
21
21
|
export declare class Context implements BeforePlugin {
|
|
22
22
|
name: string;
|
|
23
|
-
type:
|
|
23
|
+
type: "before";
|
|
24
24
|
config: ReactNativeConfig;
|
|
25
25
|
uaResult: UAParser.IResult;
|
|
26
26
|
nativeModule: AmplitudeReactNative | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,0BAA0B,EAG3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAO/C,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,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;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,qBAAqB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACpF;AAED,qBAAa,OAAQ,YAAW,YAAY;IAC1C,IAAI,SAA4C;IAChD,IAAI,WAAqB;IAKzB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC3B,YAAY,EAAE,oBAAoB,GAAG,SAAS,CAEhC;IACd,OAAO,SAA0C;;IAYjD,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC;IAK9C,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;CAyD9C"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { AppStateStatus } from 'react-native';
|
|
2
|
-
import { AmplitudeCore } from '@amplitude/analytics-core';
|
|
3
|
-
|
|
4
|
-
export declare class AmplitudeReactNative extends AmplitudeCore implements ReactNativeClient {
|
|
2
|
+
import { AmplitudeCore, ReactNativeConfig, ReactNativeOptions, ReactNativeAttributionOptions as AttributionOptions, IIdentify, EventOptions, Event, Result, ReactNativeClient, AnalyticsClient } from '@amplitude/analytics-core';
|
|
3
|
+
export declare class AmplitudeReactNative extends AmplitudeCore implements ReactNativeClient, AnalyticsClient {
|
|
5
4
|
appState: AppStateStatus;
|
|
6
5
|
private appStateChangeHandler;
|
|
7
6
|
explicitSessionId: number | undefined;
|
|
8
7
|
config: ReactNativeConfig;
|
|
9
|
-
|
|
8
|
+
userProperties: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
} | undefined;
|
|
11
|
+
init(apiKey?: string, userId?: string, options?: ReactNativeOptions): import("@amplitude/analytics-core").AmplitudeReturn<void>;
|
|
10
12
|
protected _init(options: ReactNativeOptions & {
|
|
11
13
|
apiKey: string;
|
|
12
14
|
}): Promise<void>;
|
|
@@ -16,9 +18,17 @@ export declare class AmplitudeReactNative extends AmplitudeCore implements React
|
|
|
16
18
|
setUserId(userId: string | undefined): void;
|
|
17
19
|
getDeviceId(): string | undefined;
|
|
18
20
|
setDeviceId(deviceId: string): void;
|
|
19
|
-
identify(identify: IIdentify, eventOptions?: EventOptions): import("@amplitude/analytics-
|
|
21
|
+
identify(identify: IIdentify, eventOptions?: EventOptions): import("@amplitude/analytics-core").AmplitudeReturn<Result>;
|
|
20
22
|
reset(): void;
|
|
21
23
|
getSessionId(): number | undefined;
|
|
24
|
+
getIdentity(): {
|
|
25
|
+
userId: string | undefined;
|
|
26
|
+
deviceId: string | undefined;
|
|
27
|
+
userProperties: {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
} | undefined;
|
|
30
|
+
};
|
|
31
|
+
getOptOut(): boolean;
|
|
22
32
|
setSessionId(sessionId: number): void;
|
|
23
33
|
extendSession(): void;
|
|
24
34
|
private setSessionIdInternal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native-client.d.ts","sourceRoot":"","sources":["../../src/react-native-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,cAAc,EAA2B,MAAM,cAAc,CAAC;AACjF,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"react-native-client.d.ts","sourceRoot":"","sources":["../../src/react-native-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,cAAc,EAA2B,MAAM,cAAc,CAAC;AACjF,OAAO,EACL,aAAa,EAOb,iBAAiB,EACjB,kBAAkB,EAClB,6BAA6B,IAAI,kBAAkB,EACnD,SAAS,EACT,YAAY,EACZ,KAAK,EACL,MAAM,EACN,iBAAiB,EAOjB,eAAe,EAChB,MAAM,2BAA2B,CAAC;AAUnC,qBAAa,oBAAqB,SAAQ,aAAc,YAAW,iBAAiB,EAAE,eAAe;IACnG,QAAQ,EAAE,cAAc,CAAgB;IACxC,OAAO,CAAC,qBAAqB,CAAsC;IACnE,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IAGtC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,cAAc,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,SAAS,CAAC;IAEnD,IAAI,CAAC,MAAM,SAAK,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB;cAG/C,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;IA6DtE,QAAQ;IAIF,sBAAsB,CAAC,iBAAiB,CAAC,EAAE,kBAAkB,EAAE,YAAY,UAAQ;IAkBzF,SAAS;IAIT,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IASpC,WAAW;IAIX,WAAW,CAAC,QAAQ,EAAE,MAAM;IAS5B,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,YAAY;IAUzD,KAAK;IAKL,YAAY;IAIZ,WAAW;;;;;;;IAQX,SAAS;IAIT,YAAY,CAAC,SAAS,EAAE,MAAM;IAU9B,aAAa;IAQb,OAAO,CAAC,oBAAoB;IAgCtB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAsC5C,iBAAiB;IAIjB,OAAO,CAAC,uBAAuB;IAa/B,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,8BAA8B;IAItC,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAWnC;IAEF,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,cAAc;CAGvB;AAED,eAAO,MAAM,cAAc,QAAO,iBAsHjC,CAAC;;AAEF,wBAAgC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../../src/storage/local-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../../src/storage/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,2BAA2B,CAAC;AAGpE,qBAAa,YAAY,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IAC1C,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAqB7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAcxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { AmplitudeReturn, BaseEvent, EventOptions, ReactNativeClient, ReactNativeAttributionOptions, ReactNativeOptions, ReactNativeConfig, ReactNativeTrackingOptions, Event, IdentifyEvent, GroupIdentifyEvent, IdentifyOperation, SpecialEventType, IIdentify, IRevenue, RevenueProperty, ILogger, LogLevel, Plugin, BeforePlugin, EnrichmentPlugin, DestinationPlugin, Result, ServerZoneType, ServerZone, IdentityStorageType, Storage, TransportType, } from '@amplitude/analytics-core';
|
|
2
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,6BAA6B,EAC7B,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,EAC1B,KAAK,EACL,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,eAAe,EACf,OAAO,EACP,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,OAAO,EACP,aAAa,GACd,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.5.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/analytics-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Official React Native SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analytics",
|
|
@@ -58,9 +58,7 @@
|
|
|
58
58
|
"url": "https://github.com/amplitude/Amplitude-TypeScript/issues"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@amplitude/analytics-
|
|
62
|
-
"@amplitude/analytics-core": "^1.2.8",
|
|
63
|
-
"@amplitude/analytics-types": "^1.4.0",
|
|
61
|
+
"@amplitude/analytics-core": "^2.19.0",
|
|
64
62
|
"@amplitude/ua-parser-js": "^0.7.31",
|
|
65
63
|
"@react-native-async-storage/async-storage": "^1.17.11",
|
|
66
64
|
"tslib": "^2.4.1"
|
|
@@ -90,5 +88,5 @@
|
|
|
90
88
|
]
|
|
91
89
|
]
|
|
92
90
|
},
|
|
93
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "410b9b7e27540f10653e68048024ec1a733b09ac"
|
|
94
92
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createIdentifyEvent,
|
|
3
|
+
Identify,
|
|
4
|
+
Storage,
|
|
5
|
+
Campaign,
|
|
6
|
+
CampaignParser as ICampaignParser,
|
|
7
|
+
BaseEvent,
|
|
8
|
+
getCookieName as getStorageKey,
|
|
9
|
+
BASE_CAMPAIGN,
|
|
10
|
+
EMPTY_VALUE,
|
|
11
|
+
MKTG,
|
|
12
|
+
CampaignParser,
|
|
13
|
+
} from '@amplitude/analytics-core';
|
|
14
|
+
import { CampaignTracker as ICampaignTracker, CampaignTrackFunction, CampaignTrackerOptions } from './types';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
* Campaign tracker has mixed logic from built-in and plugin web attribution
|
|
19
|
+
* features. Do not add more features here. The plan moving foward is to consolidate logic
|
|
20
|
+
* in @amplitude/plugin-web-attribution-browser with backward compatibility.
|
|
21
|
+
*/
|
|
22
|
+
export class CampaignTracker implements ICampaignTracker {
|
|
23
|
+
storage: Storage<Campaign>;
|
|
24
|
+
storageKey: string;
|
|
25
|
+
parser: ICampaignParser;
|
|
26
|
+
track: CampaignTrackFunction;
|
|
27
|
+
onNewCampaign: (campaign: Campaign) => unknown;
|
|
28
|
+
|
|
29
|
+
disabled: boolean;
|
|
30
|
+
trackNewCampaigns: boolean;
|
|
31
|
+
trackPageViews: boolean;
|
|
32
|
+
excludeReferrers: string[];
|
|
33
|
+
initialEmptyValue: string;
|
|
34
|
+
|
|
35
|
+
constructor(apiKey: string, options: CampaignTrackerOptions) {
|
|
36
|
+
this.storage = options.storage;
|
|
37
|
+
this.storageKey = getStorageKey(apiKey, MKTG);
|
|
38
|
+
this.parser = new CampaignParser();
|
|
39
|
+
this.track = options.track;
|
|
40
|
+
this.onNewCampaign = options.onNewCampaign;
|
|
41
|
+
|
|
42
|
+
this.disabled = Boolean(options.disabled);
|
|
43
|
+
this.trackNewCampaigns = Boolean(options.trackNewCampaigns);
|
|
44
|
+
this.trackPageViews = Boolean(options.trackPageViews);
|
|
45
|
+
this.excludeReferrers = options.excludeReferrers ?? [];
|
|
46
|
+
if (typeof location !== 'undefined') {
|
|
47
|
+
this.excludeReferrers.unshift(location.hostname);
|
|
48
|
+
}
|
|
49
|
+
this.initialEmptyValue = options.initialEmptyValue ?? EMPTY_VALUE;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
isNewCampaign(current: Campaign, previous: Campaign | undefined, ignoreSubdomainInReferrer = false) {
|
|
53
|
+
const { referrer, referring_domain, ...currentCampaign } = current;
|
|
54
|
+
const { referrer: _previous_referrer, referring_domain: prevReferringDomain, ...previousCampaign } = previous || {};
|
|
55
|
+
|
|
56
|
+
if (current.referring_domain && this.excludeReferrers.includes(current.referring_domain)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const hasNewCampaign = JSON.stringify(currentCampaign) !== JSON.stringify(previousCampaign);
|
|
61
|
+
const hasNewDomain = ignoreSubdomainInReferrer
|
|
62
|
+
? domainWithoutSubdomain(referring_domain || '') !== domainWithoutSubdomain(prevReferringDomain || '')
|
|
63
|
+
: referring_domain !== prevReferringDomain;
|
|
64
|
+
|
|
65
|
+
return !previous || hasNewCampaign || hasNewDomain;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async saveCampaignToStorage(campaign: Campaign): Promise<void> {
|
|
69
|
+
await this.storage.set(this.storageKey, campaign);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async getCampaignFromStorage(): Promise<Campaign | undefined> {
|
|
73
|
+
return await this.storage.get(this.storageKey);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
createCampaignEvent(campaign: Campaign) {
|
|
77
|
+
const campaignParameters: Campaign = {
|
|
78
|
+
// This object definition allows undefined keys to be iterated on
|
|
79
|
+
// in .reduce() to build indentify object
|
|
80
|
+
...BASE_CAMPAIGN,
|
|
81
|
+
...campaign,
|
|
82
|
+
};
|
|
83
|
+
const identifyEvent = Object.entries(campaignParameters).reduce((identify, [key, value]) => {
|
|
84
|
+
identify.setOnce(`initial_${key}`, value || this.initialEmptyValue);
|
|
85
|
+
if (value) {
|
|
86
|
+
return identify.set(key, value);
|
|
87
|
+
}
|
|
88
|
+
return identify.unset(key);
|
|
89
|
+
}, new Identify());
|
|
90
|
+
|
|
91
|
+
const pageViewEvent: BaseEvent = {
|
|
92
|
+
event_type: 'Page View',
|
|
93
|
+
event_properties: {
|
|
94
|
+
page_title: /* istanbul ignore next */ (typeof document !== 'undefined' && document.title) || '',
|
|
95
|
+
page_location: /* istanbul ignore next */ (typeof location !== 'undefined' && location.href) || '',
|
|
96
|
+
page_path: /* istanbul ignore next */ (typeof location !== 'undefined' && location.pathname) || '',
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
...createIdentifyEvent(identifyEvent),
|
|
101
|
+
...(this.trackPageViews && pageViewEvent),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async send(isNewSession: boolean) {
|
|
106
|
+
if (this.disabled) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const currentCampaign = await this.parser.parse();
|
|
110
|
+
const previousCampaign = await this.getCampaignFromStorage();
|
|
111
|
+
if (!isNewSession) {
|
|
112
|
+
if (!this.trackNewCampaigns || !this.isNewCampaign(currentCampaign, previousCampaign)) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
this.onNewCampaign(currentCampaign);
|
|
116
|
+
}
|
|
117
|
+
await this.track(this.createCampaignEvent(currentCampaign));
|
|
118
|
+
await this.saveCampaignToStorage(currentCampaign);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const domainWithoutSubdomain = (domain: string) => {
|
|
123
|
+
const parts = domain.split('.');
|
|
124
|
+
|
|
125
|
+
if (parts.length <= 2) {
|
|
126
|
+
return domain;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return parts.slice(parts.length - 2, parts.length).join('.');
|
|
130
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Campaign, ReactNativeAttributionOptions, Storage, BaseEvent } from '@amplitude/analytics-core';
|
|
2
|
+
|
|
3
|
+
export interface CampaignTrackerOptions extends ReactNativeAttributionOptions {
|
|
4
|
+
storage: Storage<Campaign>;
|
|
5
|
+
track: CampaignTrackFunction;
|
|
6
|
+
onNewCampaign: (campaign: Campaign) => unknown;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface CampaignTracker extends CampaignTrackerOptions {
|
|
10
|
+
send(force: boolean): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type CampaignTrackFunction = (event: BaseEvent) => Promise<unknown>;
|
package/src/config.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Config,
|
|
3
|
+
MemoryStorage,
|
|
4
|
+
UUID,
|
|
5
|
+
ReactNativeConfig as IReactNativeConfig,
|
|
6
|
+
ReactNativeTrackingOptions,
|
|
2
7
|
Event,
|
|
3
8
|
ReactNativeOptions,
|
|
4
|
-
ReactNativeConfig as IReactNativeConfig,
|
|
5
9
|
Storage,
|
|
6
|
-
ReactNativeTrackingOptions,
|
|
7
10
|
UserSession,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
CookieStorage,
|
|
12
|
+
getCookieName,
|
|
13
|
+
getQueryParams,
|
|
14
|
+
FetchTransport,
|
|
15
|
+
} from '@amplitude/analytics-core';
|
|
11
16
|
|
|
12
17
|
import { LocalStorage } from './storage/local-storage';
|
|
13
18
|
import RemnantDataMigration from './migration/remnant-data-migration';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getOldCookieName } from '@amplitude/analytics-client-common';
|
|
1
|
+
import { UserSession, ReactNativeOptions, getOldCookieName } from '@amplitude/analytics-core';
|
|
3
2
|
import { createCookieStorage, getDefaultConfig, getTopLevelDomain } from '../config';
|
|
4
3
|
|
|
5
|
-
export const parseOldCookies = async (apiKey: string, options?:
|
|
4
|
+
export const parseOldCookies = async (apiKey: string, options?: ReactNativeOptions): Promise<UserSession> => {
|
|
6
5
|
const storage = await createCookieStorage<string>({
|
|
7
6
|
...options,
|
|
8
7
|
domain: options?.disableCookies ? '' : options?.domain ?? (await getTopLevelDomain()),
|
package/src/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ export const {
|
|
|
23
23
|
extendSession,
|
|
24
24
|
} = client;
|
|
25
25
|
export { Revenue, Identify } from '@amplitude/analytics-core';
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
export
|
|
26
|
+
|
|
27
|
+
// Export types to maintain backward compatibility with `analytics-types`.
|
|
28
|
+
// In the next major version, only export customer-facing types to reduce the public API surface.
|
|
29
|
+
export * as Types from './types';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NativeModules } from 'react-native';
|
|
2
|
-
import { Event,
|
|
2
|
+
import { Event, ILogger, Storage, UserSession } from '@amplitude/analytics-core';
|
|
3
3
|
import { STORAGE_PREFIX } from '@amplitude/analytics-core';
|
|
4
4
|
|
|
5
5
|
type LegacyEventKind = 'event' | 'identify' | 'interceptedIdentify';
|
|
@@ -19,7 +19,7 @@ export default class RemnantDataMigration {
|
|
|
19
19
|
private instanceName: string | undefined,
|
|
20
20
|
private storage: Storage<Event[]> | undefined,
|
|
21
21
|
private firstRunSinceUpgrade: boolean,
|
|
22
|
-
private logger:
|
|
22
|
+
private logger: ILogger | undefined,
|
|
23
23
|
) {
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
25
25
|
this.eventsStorageKey = `${STORAGE_PREFIX}_${this.apiKey.substring(0, 10)}`;
|
package/src/plugins/context.ts
CHANGED
|
@@ -2,12 +2,11 @@ import {
|
|
|
2
2
|
BeforePlugin,
|
|
3
3
|
ReactNativeConfig,
|
|
4
4
|
Event,
|
|
5
|
-
PluginType,
|
|
6
5
|
ReactNativeTrackingOptions,
|
|
7
|
-
|
|
6
|
+
UUID,
|
|
7
|
+
getLanguage,
|
|
8
|
+
} from '@amplitude/analytics-core';
|
|
8
9
|
import UAParser from '@amplitude/ua-parser-js';
|
|
9
|
-
import { UUID } from '@amplitude/analytics-core';
|
|
10
|
-
import { getLanguage } from '@amplitude/analytics-client-common';
|
|
11
10
|
import { VERSION } from '../version';
|
|
12
11
|
import { NativeModules } from 'react-native';
|
|
13
12
|
|
|
@@ -35,8 +34,8 @@ export interface AmplitudeReactNative {
|
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
export class Context implements BeforePlugin {
|
|
38
|
-
name = 'context';
|
|
39
|
-
type =
|
|
37
|
+
name = '@amplitude/plugin-context-react-native';
|
|
38
|
+
type = 'before' as const;
|
|
40
39
|
|
|
41
40
|
// this.config is defined in setup() which will always be called first
|
|
42
41
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -54,6 +53,7 @@ export class Context implements BeforePlugin {
|
|
|
54
53
|
if (typeof navigator !== 'undefined') {
|
|
55
54
|
agent = navigator.userAgent;
|
|
56
55
|
}
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
57
57
|
this.uaResult = new UAParser(agent).getResult();
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -67,9 +67,13 @@ export class Context implements BeforePlugin {
|
|
|
67
67
|
const nativeContext = await this.nativeModule?.getApplicationContext(this.config.trackingOptions);
|
|
68
68
|
const appVersion = this.config.appVersion || nativeContext?.version;
|
|
69
69
|
const platform = nativeContext?.platform || BROWSER_PLATFORM;
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
|
70
71
|
const osName = nativeContext?.osName || this.uaResult.browser.name;
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
|
71
73
|
const osVersion = nativeContext?.osVersion || this.uaResult.browser.version;
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
|
72
75
|
const deviceVendor = nativeContext?.deviceManufacturer || this.uaResult.device.vendor;
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
|
73
77
|
const deviceModel = nativeContext?.deviceModel || this.uaResult.device.model || this.uaResult.os.name;
|
|
74
78
|
const language = nativeContext?.language || getLanguage();
|
|
75
79
|
const country = nativeContext?.country;
|
|
@@ -85,10 +89,15 @@ export class Context implements BeforePlugin {
|
|
|
85
89
|
time,
|
|
86
90
|
...(appVersion && { app_version: appVersion }),
|
|
87
91
|
...(this.config.trackingOptions.platform && { platform: platform }),
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
88
93
|
...(this.config.trackingOptions.osName && { os_name: osName }),
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
89
95
|
...(this.config.trackingOptions.osVersion && { os_version: osVersion }),
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
90
97
|
...(this.config.trackingOptions.deviceManufacturer && { device_manufacturer: deviceVendor }),
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
91
99
|
...(this.config.trackingOptions.deviceModel && { device_model: deviceModel }),
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
92
101
|
...(this.config.trackingOptions.language && { language: language }),
|
|
93
102
|
...(this.config.trackingOptions.country && { country: country }),
|
|
94
103
|
...(this.config.trackingOptions.carrier && { carrier: carrier }),
|