@amplitude/analytics-react-native 1.0.0 → 1.1.0-beta.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/lib/commonjs/config.js +91 -48
- package/lib/commonjs/config.js.map +1 -1
- package/lib/commonjs/react-native-client.js +37 -25
- package/lib/commonjs/react-native-client.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/config.js +91 -47
- package/lib/module/config.js.map +1 -1
- package/lib/module/react-native-client.js +37 -25
- package/lib/module/react-native-client.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 +16 -11
- package/lib/typescript/config.d.ts.map +1 -1
- package/lib/typescript/react-native-client.d.ts +7 -3
- package/lib/typescript/react-native-client.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 +5 -5
- package/src/config.ts +93 -51
- package/src/react-native-client.ts +31 -24
- package/src/version.ts +1 -1
|
@@ -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,EAOd,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,iBAAiB,EAEjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,IAAI,SAAS,EACrB,YAAY,EACZ,KAAK,EACL,MAAM,EACP,MAAM,4BAA4B,CAAC;AASpC,qBAAa,oBAAqB,SAAQ,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,EAOd,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,iBAAiB,EAEjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,IAAI,SAAS,EACrB,YAAY,EACZ,KAAK,EACL,MAAM,EACP,MAAM,4BAA4B,CAAC;AASpC,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,QAAQ,EAAE,cAAc,CAAgB;IACxC,OAAO,CAAC,qBAAqB,CAAsC;IACnE,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IAGtC,MAAM,EAAE,iBAAiB,CAAC;IAE1B,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;IA2DtE,QAAQ;IAIF,sBAAsB,CAAC,iBAAiB,CAAC,EAAE,kBAAkB,EAAE,YAAY,UAAQ;IAkBzF,SAAS;IAIT,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAcpC,WAAW;IAIX,WAAW,CAAC,QAAQ,EAAE,MAAM;IAc5B,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,YAAY;IAUzD,KAAK;IAKL,YAAY;IAIZ,YAAY,CAAC,SAAS,EAAE,MAAM;IAU9B,OAAO,CAAC,oBAAoB;IAgCtB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IA4B5C,iBAAiB;IAIjB,OAAO,CAAC,uBAAuB;IAiB/B,OAAO,CAAC,8BAA8B;IAItC,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAOnC;CACH;AAED,eAAO,MAAM,cAAc,QAAO,iBAgHjC,CAAC;;AAEF,wBAAgC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.0.0";
|
|
1
|
+
export declare const VERSION = "1.1.0-beta.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,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/analytics-react-native",
|
|
3
|
-
"version": "1.0.0",
|
|
3
|
+
"version": "1.1.0-beta.0",
|
|
4
4
|
"description": "Official React Native SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analytics",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"url": "https://github.com/amplitude/Amplitude-TypeScript/issues"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@amplitude/analytics-client-common": "^0.
|
|
61
|
-
"@amplitude/analytics-core": "^0.
|
|
62
|
-
"@amplitude/analytics-types": "^0.
|
|
60
|
+
"@amplitude/analytics-client-common": "^0.6.0-beta.0",
|
|
61
|
+
"@amplitude/analytics-core": "^0.12.0-beta.0",
|
|
62
|
+
"@amplitude/analytics-types": "^0.17.0-beta.0",
|
|
63
63
|
"@amplitude/ua-parser-js": "^0.7.31",
|
|
64
64
|
"@react-native-async-storage/async-storage": "^1.17.11",
|
|
65
65
|
"tslib": "^2.4.1"
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
]
|
|
90
90
|
]
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "5590f7d77d93362d2f3db6d47116ca502afd1fc4"
|
|
93
93
|
}
|
package/src/config.ts
CHANGED
|
@@ -5,16 +5,9 @@ import {
|
|
|
5
5
|
Storage,
|
|
6
6
|
ReactNativeTrackingOptions,
|
|
7
7
|
UserSession,
|
|
8
|
-
SessionManager as ISessionManager,
|
|
9
8
|
} from '@amplitude/analytics-types';
|
|
10
9
|
import { Config, MemoryStorage, UUID } from '@amplitude/analytics-core';
|
|
11
|
-
import {
|
|
12
|
-
CookieStorage,
|
|
13
|
-
getCookieName,
|
|
14
|
-
getQueryParams,
|
|
15
|
-
SessionManager,
|
|
16
|
-
FetchTransport,
|
|
17
|
-
} from '@amplitude/analytics-client-common';
|
|
10
|
+
import { CookieStorage, getCookieName, getQueryParams, FetchTransport } from '@amplitude/analytics-client-common';
|
|
18
11
|
|
|
19
12
|
import { LocalStorage } from './storage/local-storage';
|
|
20
13
|
|
|
@@ -39,12 +32,11 @@ export const getDefaultConfig = () => {
|
|
|
39
32
|
cookieUpgrade: true,
|
|
40
33
|
disableCookies: false,
|
|
41
34
|
domain: '',
|
|
42
|
-
sessionManager: new SessionManager(cookieStorage, ''),
|
|
43
35
|
sessionTimeout: 5 * 60 * 1000,
|
|
44
36
|
storageProvider: new MemoryStorage<Event[]>(),
|
|
37
|
+
trackingSessionEvents: false,
|
|
45
38
|
trackingOptions,
|
|
46
39
|
transportProvider: new FetchTransport(),
|
|
47
|
-
trackingSessionEvents: false,
|
|
48
40
|
};
|
|
49
41
|
};
|
|
50
42
|
|
|
@@ -59,117 +51,171 @@ export class ReactNativeConfig extends Config implements IReactNativeConfig {
|
|
|
59
51
|
domain: string;
|
|
60
52
|
partnerId?: string;
|
|
61
53
|
sessionTimeout: number;
|
|
62
|
-
trackingOptions: ReactNativeTrackingOptions;
|
|
63
|
-
sessionManager: ISessionManager;
|
|
64
54
|
trackingSessionEvents: boolean;
|
|
55
|
+
trackingOptions: ReactNativeTrackingOptions;
|
|
56
|
+
|
|
57
|
+
// NOTE: These protected properties are used to cache values from async storage
|
|
58
|
+
protected _deviceId?: string;
|
|
59
|
+
protected _lastEventId?: number;
|
|
60
|
+
protected _lastEventTime?: number;
|
|
61
|
+
protected _optOut = false;
|
|
62
|
+
protected _sessionId?: number;
|
|
63
|
+
protected _userId?: string;
|
|
65
64
|
|
|
66
|
-
constructor(apiKey: string,
|
|
65
|
+
constructor(apiKey: string, options?: ReactNativeOptions) {
|
|
67
66
|
const defaultConfig = getDefaultConfig();
|
|
68
67
|
super({
|
|
69
68
|
flushIntervalMillis: 1000,
|
|
70
69
|
flushMaxRetries: 5,
|
|
71
70
|
flushQueueSize: 30,
|
|
71
|
+
transportProvider: defaultConfig.transportProvider,
|
|
72
72
|
...options,
|
|
73
73
|
apiKey,
|
|
74
|
-
storageProvider: options?.storageProvider ?? defaultConfig.storageProvider,
|
|
75
|
-
transportProvider: options?.transportProvider ?? defaultConfig.transportProvider,
|
|
76
74
|
});
|
|
75
|
+
|
|
76
|
+
// NOTE: Define `cookieStorage` first to persist user session
|
|
77
|
+
// user session properties expect `cookieStorage` to be defined
|
|
77
78
|
this.cookieStorage = options?.cookieStorage ?? defaultConfig.cookieStorage;
|
|
78
|
-
this.
|
|
79
|
-
this.
|
|
79
|
+
this.deviceId = options?.deviceId;
|
|
80
|
+
this.lastEventTime = options?.lastEventTime;
|
|
81
|
+
this.optOut = Boolean(options?.optOut);
|
|
82
|
+
this.sessionId = options?.sessionId;
|
|
83
|
+
this.userId = options?.userId;
|
|
80
84
|
|
|
81
85
|
this.appVersion = options?.appVersion;
|
|
82
86
|
this.cookieExpiration = options?.cookieExpiration ?? defaultConfig.cookieExpiration;
|
|
83
87
|
this.cookieSameSite = options?.cookieSameSite ?? defaultConfig.cookieSameSite;
|
|
84
88
|
this.cookieSecure = options?.cookieSecure ?? defaultConfig.cookieSecure;
|
|
85
89
|
this.cookieUpgrade = options?.cookieUpgrade ?? defaultConfig.cookieUpgrade;
|
|
86
|
-
this.deviceId = options?.deviceId;
|
|
87
90
|
this.disableCookies = options?.disableCookies ?? defaultConfig.disableCookies;
|
|
88
91
|
this.domain = options?.domain ?? defaultConfig.domain;
|
|
89
|
-
this.lastEventTime = this.lastEventTime ?? options?.lastEventTime;
|
|
90
|
-
this.optOut = Boolean(options?.optOut);
|
|
91
92
|
this.partnerId = options?.partnerId;
|
|
92
|
-
this.
|
|
93
|
+
this.sessionTimeout = options?.sessionTimeout ?? defaultConfig.sessionTimeout;
|
|
93
94
|
this.trackingOptions = options?.trackingOptions ?? defaultConfig.trackingOptions;
|
|
94
|
-
this.userId = userId;
|
|
95
95
|
this.trackingSessionEvents = options?.trackingSessionEvents ?? defaultConfig.trackingSessionEvents;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
get deviceId() {
|
|
99
|
-
return this.
|
|
99
|
+
return this._deviceId;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
set deviceId(deviceId: string | undefined) {
|
|
103
|
-
this.
|
|
103
|
+
if (this._deviceId !== deviceId) {
|
|
104
|
+
this._deviceId = deviceId;
|
|
105
|
+
this.updateStorage();
|
|
106
|
+
}
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
get userId() {
|
|
107
|
-
return this.
|
|
110
|
+
return this._userId;
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
set userId(userId: string | undefined) {
|
|
111
|
-
this.
|
|
114
|
+
if (this._userId !== userId) {
|
|
115
|
+
this._userId = userId;
|
|
116
|
+
this.updateStorage();
|
|
117
|
+
}
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
get sessionId() {
|
|
115
|
-
return this.
|
|
121
|
+
return this._sessionId;
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
set sessionId(sessionId: number | undefined) {
|
|
119
|
-
this.
|
|
120
|
-
|
|
125
|
+
if (this._sessionId !== sessionId) {
|
|
126
|
+
this._sessionId = sessionId;
|
|
127
|
+
this.updateStorage();
|
|
128
|
+
}
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
get optOut() {
|
|
124
|
-
return this.
|
|
132
|
+
return this._optOut;
|
|
125
133
|
}
|
|
126
134
|
|
|
127
135
|
set optOut(optOut: boolean) {
|
|
128
|
-
this.
|
|
136
|
+
if (this._optOut !== optOut) {
|
|
137
|
+
this._optOut = optOut;
|
|
138
|
+
this.updateStorage();
|
|
139
|
+
}
|
|
129
140
|
}
|
|
130
141
|
|
|
131
142
|
get lastEventTime() {
|
|
132
|
-
return this.
|
|
143
|
+
return this._lastEventTime;
|
|
133
144
|
}
|
|
134
145
|
|
|
135
146
|
set lastEventTime(lastEventTime: number | undefined) {
|
|
136
|
-
this.
|
|
147
|
+
if (this._lastEventTime !== lastEventTime) {
|
|
148
|
+
this._lastEventTime = lastEventTime;
|
|
149
|
+
this.updateStorage();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
get lastEventId() {
|
|
154
|
+
return this._lastEventId;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
set lastEventId(lastEventId: number | undefined) {
|
|
158
|
+
if (this._lastEventId !== lastEventId) {
|
|
159
|
+
this._lastEventId = lastEventId;
|
|
160
|
+
this.updateStorage();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private updateStorage() {
|
|
165
|
+
const cache = {
|
|
166
|
+
deviceId: this._deviceId,
|
|
167
|
+
userId: this._userId,
|
|
168
|
+
sessionId: this._sessionId,
|
|
169
|
+
optOut: this._optOut,
|
|
170
|
+
lastEventTime: this._lastEventTime,
|
|
171
|
+
lastEventId: this._lastEventId,
|
|
172
|
+
};
|
|
173
|
+
void this.cookieStorage?.set(getCookieName(this.apiKey), cache);
|
|
137
174
|
}
|
|
138
175
|
}
|
|
139
176
|
|
|
140
177
|
export const useReactNativeConfig = async (
|
|
141
178
|
apiKey: string,
|
|
142
|
-
userId?: string,
|
|
143
179
|
options?: ReactNativeOptions,
|
|
144
180
|
): Promise<IReactNativeConfig> => {
|
|
145
181
|
const defaultConfig = getDefaultConfig();
|
|
182
|
+
|
|
183
|
+
// create cookie storage
|
|
146
184
|
const domain = options?.domain ?? (await getTopLevelDomain());
|
|
147
185
|
const cookieStorage = await createCookieStorage({ ...options, domain });
|
|
148
|
-
const
|
|
149
|
-
const cookies = await cookieStorage.get(cookieName);
|
|
186
|
+
const previousCookies = await cookieStorage.get(getCookieName(apiKey));
|
|
150
187
|
const queryParams = getQueryParams();
|
|
151
|
-
const sessionManager = await new SessionManager(cookieStorage, apiKey).load();
|
|
152
188
|
|
|
153
|
-
|
|
154
|
-
const
|
|
189
|
+
// reconcile user session
|
|
190
|
+
const deviceId = options?.deviceId ?? queryParams.deviceId ?? previousCookies?.deviceId ?? UUID();
|
|
191
|
+
const lastEventTime = options?.lastEventTime ?? previousCookies?.lastEventTime;
|
|
192
|
+
const optOut = options?.optOut ?? Boolean(previousCookies?.optOut);
|
|
193
|
+
const sessionId = options?.sessionId ?? previousCookies?.sessionId;
|
|
194
|
+
const userId = options?.userId ?? previousCookies?.userId;
|
|
155
195
|
|
|
156
|
-
const config = new ReactNativeConfig(apiKey,
|
|
196
|
+
const config = new ReactNativeConfig(apiKey, {
|
|
157
197
|
...options,
|
|
158
198
|
cookieStorage,
|
|
159
|
-
|
|
160
|
-
deviceId: createDeviceId(cookies?.deviceId, options?.deviceId, queryParams.deviceId),
|
|
199
|
+
deviceId,
|
|
161
200
|
domain,
|
|
162
|
-
|
|
163
|
-
|
|
201
|
+
lastEventTime,
|
|
202
|
+
optOut,
|
|
203
|
+
sessionId,
|
|
164
204
|
storageProvider: await createEventsStorage(options),
|
|
165
|
-
trackingOptions: {
|
|
205
|
+
trackingOptions: {
|
|
206
|
+
...defaultConfig.trackingOptions,
|
|
207
|
+
...options?.trackingOptions,
|
|
208
|
+
},
|
|
166
209
|
transportProvider: options?.transportProvider ?? new FetchTransport(),
|
|
210
|
+
userId,
|
|
167
211
|
});
|
|
168
212
|
|
|
213
|
+
config.lastEventId = previousCookies?.lastEventId;
|
|
214
|
+
|
|
169
215
|
config.loggerProvider?.log(
|
|
170
216
|
`Init: storage=${cookieStorage.constructor.name} restoredSessionId = ${
|
|
171
|
-
|
|
172
|
-
}, optionsSessionId = ${
|
|
217
|
+
previousCookies?.sessionId ?? 'undefined'
|
|
218
|
+
}, optionsSessionId = ${options?.sessionId ?? 'undefined'}`,
|
|
173
219
|
);
|
|
174
220
|
|
|
175
221
|
return config;
|
|
@@ -220,10 +266,6 @@ export const createEventsStorage = async (overrides?: ReactNativeOptions): Promi
|
|
|
220
266
|
return undefined;
|
|
221
267
|
};
|
|
222
268
|
|
|
223
|
-
export const createDeviceId = (idFromCookies?: string, idFromOptions?: string, idFromQueryParams?: string) => {
|
|
224
|
-
return idFromOptions || idFromQueryParams || idFromCookies || UUID();
|
|
225
|
-
};
|
|
226
|
-
|
|
227
269
|
export const getTopLevelDomain = async (url?: string) => {
|
|
228
270
|
if (!(await new CookieStorage<string>().isEnabled()) || (!url && typeof location === 'undefined')) {
|
|
229
271
|
return '';
|
|
@@ -28,29 +28,36 @@ import { isNative } from './utils/platform';
|
|
|
28
28
|
const START_SESSION_EVENT = 'session_start';
|
|
29
29
|
const END_SESSION_EVENT = 'session_end';
|
|
30
30
|
|
|
31
|
-
export class AmplitudeReactNative extends AmplitudeCore
|
|
31
|
+
export class AmplitudeReactNative extends AmplitudeCore {
|
|
32
32
|
appState: AppStateStatus = 'background';
|
|
33
33
|
private appStateChangeHandler: NativeEventSubscription | undefined;
|
|
34
34
|
explicitSessionId: number | undefined;
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
config: ReactNativeConfig;
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
init(apiKey = '', userId?: string, options?: ReactNativeOptions) {
|
|
40
|
+
return returnWrapper(this._init({ ...options, userId, apiKey }));
|
|
41
|
+
}
|
|
42
|
+
protected async _init(options: ReactNativeOptions & { apiKey: string }) {
|
|
37
43
|
// Step 0: Block concurrent initialization
|
|
38
44
|
if (this.initializing) {
|
|
39
45
|
return;
|
|
40
46
|
}
|
|
41
47
|
this.initializing = true;
|
|
42
|
-
this.explicitSessionId = options
|
|
48
|
+
this.explicitSessionId = options.sessionId;
|
|
43
49
|
|
|
44
50
|
// Step 1: Read cookies stored by old SDK
|
|
45
|
-
const oldCookies = await parseOldCookies(apiKey, options);
|
|
51
|
+
const oldCookies = await parseOldCookies(options.apiKey, options);
|
|
46
52
|
|
|
47
53
|
// Step 2: Create react native config
|
|
48
|
-
const reactNativeOptions = await useReactNativeConfig(apiKey,
|
|
54
|
+
const reactNativeOptions = await useReactNativeConfig(options.apiKey, {
|
|
49
55
|
...options,
|
|
50
|
-
deviceId: oldCookies.deviceId ?? options
|
|
56
|
+
deviceId: oldCookies.deviceId ?? options.deviceId,
|
|
51
57
|
sessionId: oldCookies.sessionId,
|
|
52
|
-
optOut: options
|
|
58
|
+
optOut: options.optOut ?? oldCookies.optOut,
|
|
53
59
|
lastEventTime: oldCookies.lastEventTime,
|
|
60
|
+
userId: options.userId || oldCookies.userId,
|
|
54
61
|
});
|
|
55
62
|
await super._init(reactNativeOptions);
|
|
56
63
|
|
|
@@ -68,9 +75,9 @@ export class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
|
68
75
|
|
|
69
76
|
// Step 3: Install plugins
|
|
70
77
|
// Do not track any events before this
|
|
71
|
-
await this.add(new
|
|
72
|
-
await this.add(new
|
|
73
|
-
await this.add(new
|
|
78
|
+
await this.add(new Destination()).promise;
|
|
79
|
+
await this.add(new Context()).promise;
|
|
80
|
+
await this.add(new IdentityEventSender()).promise;
|
|
74
81
|
|
|
75
82
|
// Step 4: Manage session
|
|
76
83
|
this.appState = AppState.currentState;
|
|
@@ -85,7 +92,7 @@ export class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
|
85
92
|
this.initializing = false;
|
|
86
93
|
|
|
87
94
|
// Step 5: Track attributions
|
|
88
|
-
await this.runAttributionStrategy(options
|
|
95
|
+
await this.runAttributionStrategy(options.attribution, isNewSession);
|
|
89
96
|
|
|
90
97
|
// Step 6: Run queued functions
|
|
91
98
|
await this.runQueuedFunctions('dispatchQ');
|
|
@@ -99,7 +106,7 @@ export class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
|
99
106
|
if (isNative()) {
|
|
100
107
|
return;
|
|
101
108
|
}
|
|
102
|
-
const track = this.track.
|
|
109
|
+
const track = (...args: Parameters<typeof this.track>) => this.track(...args).promise;
|
|
103
110
|
const onNewCampaign = this.setSessionId.bind(this, this.currentTimeMillis());
|
|
104
111
|
|
|
105
112
|
const storage = await createFlexibleStorage<Campaign>(this.config);
|
|
@@ -229,9 +236,9 @@ export class AmplitudeReactNative extends AmplitudeCore<ReactNativeConfig> {
|
|
|
229
236
|
}
|
|
230
237
|
|
|
231
238
|
if (event.event_id === undefined) {
|
|
232
|
-
const eventId = (this.config.
|
|
239
|
+
const eventId = (this.config.lastEventId ?? -1) + 1;
|
|
233
240
|
event = { ...event, event_id: eventId };
|
|
234
|
-
this.config.
|
|
241
|
+
this.config.lastEventId = eventId;
|
|
235
242
|
}
|
|
236
243
|
}
|
|
237
244
|
|
|
@@ -281,61 +288,61 @@ export const createInstance = (): ReactNativeClient => {
|
|
|
281
288
|
const client = new AmplitudeReactNative();
|
|
282
289
|
return {
|
|
283
290
|
init: debugWrapper(
|
|
284
|
-
|
|
291
|
+
client.init.bind(client),
|
|
285
292
|
'init',
|
|
286
293
|
getClientLogConfig(client),
|
|
287
294
|
getClientStates(client, ['config']),
|
|
288
295
|
),
|
|
289
296
|
add: debugWrapper(
|
|
290
|
-
|
|
297
|
+
client.add.bind(client),
|
|
291
298
|
'add',
|
|
292
299
|
getClientLogConfig(client),
|
|
293
300
|
getClientStates(client, ['config.apiKey', 'timeline.plugins']),
|
|
294
301
|
),
|
|
295
302
|
remove: debugWrapper(
|
|
296
|
-
|
|
303
|
+
client.remove.bind(client),
|
|
297
304
|
'remove',
|
|
298
305
|
getClientLogConfig(client),
|
|
299
306
|
getClientStates(client, ['config.apiKey', 'timeline.plugins']),
|
|
300
307
|
),
|
|
301
308
|
track: debugWrapper(
|
|
302
|
-
|
|
309
|
+
client.track.bind(client),
|
|
303
310
|
'track',
|
|
304
311
|
getClientLogConfig(client),
|
|
305
312
|
getClientStates(client, ['config.apiKey', 'timeline.queue.length']),
|
|
306
313
|
),
|
|
307
314
|
logEvent: debugWrapper(
|
|
308
|
-
|
|
315
|
+
client.logEvent.bind(client),
|
|
309
316
|
'logEvent',
|
|
310
317
|
getClientLogConfig(client),
|
|
311
318
|
getClientStates(client, ['config.apiKey', 'timeline.queue.length']),
|
|
312
319
|
),
|
|
313
320
|
identify: debugWrapper(
|
|
314
|
-
|
|
321
|
+
client.identify.bind(client),
|
|
315
322
|
'identify',
|
|
316
323
|
getClientLogConfig(client),
|
|
317
324
|
getClientStates(client, ['config.apiKey', 'timeline.queue.length']),
|
|
318
325
|
),
|
|
319
326
|
groupIdentify: debugWrapper(
|
|
320
|
-
|
|
327
|
+
client.groupIdentify.bind(client),
|
|
321
328
|
'groupIdentify',
|
|
322
329
|
getClientLogConfig(client),
|
|
323
330
|
getClientStates(client, ['config.apiKey', 'timeline.queue.length']),
|
|
324
331
|
),
|
|
325
332
|
setGroup: debugWrapper(
|
|
326
|
-
|
|
333
|
+
client.setGroup.bind(client),
|
|
327
334
|
'setGroup',
|
|
328
335
|
getClientLogConfig(client),
|
|
329
336
|
getClientStates(client, ['config.apiKey', 'timeline.queue.length']),
|
|
330
337
|
),
|
|
331
338
|
revenue: debugWrapper(
|
|
332
|
-
|
|
339
|
+
client.revenue.bind(client),
|
|
333
340
|
'revenue',
|
|
334
341
|
getClientLogConfig(client),
|
|
335
342
|
getClientStates(client, ['config.apiKey', 'timeline.queue.length']),
|
|
336
343
|
),
|
|
337
344
|
flush: debugWrapper(
|
|
338
|
-
|
|
345
|
+
client.flush.bind(client),
|
|
339
346
|
'flush',
|
|
340
347
|
getClientLogConfig(client),
|
|
341
348
|
getClientStates(client, ['config.apiKey', 'timeline.queue.length']),
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.0.0';
|
|
1
|
+
export const VERSION = '1.1.0-beta.0';
|