@amplitude/analytics-react-native 1.4.14 → 1.5.1
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
|
@@ -7,25 +7,23 @@ import {
|
|
|
7
7
|
debugWrapper,
|
|
8
8
|
getClientLogConfig,
|
|
9
9
|
getClientStates,
|
|
10
|
-
} from '@amplitude/analytics-core';
|
|
11
|
-
import {
|
|
12
|
-
CampaignTracker,
|
|
13
|
-
IdentityEventSender,
|
|
14
|
-
getAnalyticsConnector,
|
|
15
|
-
setConnectorDeviceId,
|
|
16
|
-
setConnectorUserId,
|
|
17
|
-
} from '@amplitude/analytics-client-common';
|
|
18
|
-
import {
|
|
19
10
|
ReactNativeConfig,
|
|
20
|
-
Campaign,
|
|
21
11
|
ReactNativeOptions,
|
|
22
|
-
AttributionOptions,
|
|
23
|
-
|
|
24
|
-
Identify as IIdentify,
|
|
12
|
+
ReactNativeAttributionOptions as AttributionOptions,
|
|
13
|
+
IIdentify,
|
|
25
14
|
EventOptions,
|
|
26
15
|
Event,
|
|
27
16
|
Result,
|
|
28
|
-
|
|
17
|
+
ReactNativeClient,
|
|
18
|
+
Campaign,
|
|
19
|
+
IdentityEventSender,
|
|
20
|
+
getAnalyticsConnector,
|
|
21
|
+
setConnectorDeviceId,
|
|
22
|
+
setConnectorUserId,
|
|
23
|
+
SpecialEventType,
|
|
24
|
+
AnalyticsClient,
|
|
25
|
+
} from '@amplitude/analytics-core';
|
|
26
|
+
import { CampaignTracker } from './campaign/campaign-tracker';
|
|
29
27
|
import { Context } from './plugins/context';
|
|
30
28
|
import { useReactNativeConfig, createCookieStorage } from './config';
|
|
31
29
|
import { parseOldCookies } from './cookie-migration';
|
|
@@ -34,13 +32,14 @@ import { isNative } from './utils/platform';
|
|
|
34
32
|
const START_SESSION_EVENT = 'session_start';
|
|
35
33
|
const END_SESSION_EVENT = 'session_end';
|
|
36
34
|
|
|
37
|
-
export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeClient {
|
|
35
|
+
export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeClient, AnalyticsClient {
|
|
38
36
|
appState: AppStateStatus = 'background';
|
|
39
37
|
private appStateChangeHandler: NativeEventSubscription | undefined;
|
|
40
38
|
explicitSessionId: number | undefined;
|
|
41
39
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
40
|
// @ts-ignore
|
|
43
41
|
config: ReactNativeConfig;
|
|
42
|
+
userProperties: { [key: string]: any } | undefined;
|
|
44
43
|
|
|
45
44
|
init(apiKey = '', userId?: string, options?: ReactNativeOptions) {
|
|
46
45
|
return returnWrapper(this._init({ ...options, userId, apiKey }));
|
|
@@ -173,6 +172,18 @@ export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeCl
|
|
|
173
172
|
return this.config?.sessionId;
|
|
174
173
|
}
|
|
175
174
|
|
|
175
|
+
getIdentity() {
|
|
176
|
+
return {
|
|
177
|
+
userId: this.getUserId(),
|
|
178
|
+
deviceId: this.getDeviceId(),
|
|
179
|
+
userProperties: this.userProperties,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
getOptOut() {
|
|
184
|
+
return this.config?.optOut;
|
|
185
|
+
}
|
|
186
|
+
|
|
176
187
|
setSessionId(sessionId: number) {
|
|
177
188
|
if (!this.config) {
|
|
178
189
|
this.q.push(this.setSessionId.bind(this, sessionId));
|
|
@@ -253,6 +264,11 @@ export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeCl
|
|
|
253
264
|
}
|
|
254
265
|
}
|
|
255
266
|
|
|
267
|
+
// Set user properties
|
|
268
|
+
if (event.event_type === SpecialEventType.IDENTIFY && event.user_properties) {
|
|
269
|
+
this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);
|
|
270
|
+
}
|
|
271
|
+
|
|
256
272
|
return super.process(event);
|
|
257
273
|
}
|
|
258
274
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getGlobalScope } from '@amplitude/analytics-
|
|
2
|
-
import { Storage } from '@amplitude/analytics-types';
|
|
1
|
+
import { Storage, getGlobalScope } from '@amplitude/analytics-core';
|
|
3
2
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
4
3
|
|
|
5
4
|
export class LocalStorage<T> implements Storage<T> {
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/unbound-method */
|
|
2
|
+
export {
|
|
3
|
+
AmplitudeReturn,
|
|
4
|
+
BaseEvent,
|
|
5
|
+
EventOptions,
|
|
6
|
+
ReactNativeClient,
|
|
7
|
+
ReactNativeAttributionOptions,
|
|
8
|
+
ReactNativeOptions,
|
|
9
|
+
ReactNativeConfig,
|
|
10
|
+
ReactNativeTrackingOptions,
|
|
11
|
+
Event,
|
|
12
|
+
IdentifyEvent,
|
|
13
|
+
GroupIdentifyEvent,
|
|
14
|
+
IdentifyOperation,
|
|
15
|
+
SpecialEventType,
|
|
16
|
+
IIdentify,
|
|
17
|
+
IRevenue,
|
|
18
|
+
RevenueProperty,
|
|
19
|
+
ILogger,
|
|
20
|
+
LogLevel,
|
|
21
|
+
Plugin,
|
|
22
|
+
BeforePlugin,
|
|
23
|
+
EnrichmentPlugin,
|
|
24
|
+
DestinationPlugin,
|
|
25
|
+
Result,
|
|
26
|
+
ServerZoneType,
|
|
27
|
+
ServerZone,
|
|
28
|
+
IdentityStorageType,
|
|
29
|
+
Storage,
|
|
30
|
+
TransportType,
|
|
31
|
+
} from '@amplitude/analytics-core';
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.
|
|
1
|
+
export const VERSION = '1.5.1';
|