@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.
Files changed (86) hide show
  1. package/README.md +2 -2
  2. package/lib/commonjs/campaign/campaign-tracker.js +105 -0
  3. package/lib/commonjs/campaign/campaign-tracker.js.map +1 -0
  4. package/lib/commonjs/campaign/types.js +6 -0
  5. package/lib/commonjs/campaign/types.js.map +1 -0
  6. package/lib/commonjs/config.js +12 -35
  7. package/lib/commonjs/config.js.map +1 -1
  8. package/lib/commonjs/cookie-migration/index.js +2 -2
  9. package/lib/commonjs/cookie-migration/index.js.map +1 -1
  10. package/lib/commonjs/index.js +7 -4
  11. package/lib/commonjs/index.js.map +1 -1
  12. package/lib/commonjs/migration/remnant-data-migration.js +2 -7
  13. package/lib/commonjs/migration/remnant-data-migration.js.map +1 -1
  14. package/lib/commonjs/plugins/context.js +18 -14
  15. package/lib/commonjs/plugins/context.js.map +1 -1
  16. package/lib/commonjs/react-native-client.js +48 -45
  17. package/lib/commonjs/react-native-client.js.map +1 -1
  18. package/lib/commonjs/storage/local-storage.js +3 -3
  19. package/lib/commonjs/storage/local-storage.js.map +1 -1
  20. package/lib/commonjs/types.js +175 -0
  21. package/lib/commonjs/types.js.map +1 -0
  22. package/lib/commonjs/typings/browser-snippet.d.js.map +1 -1
  23. package/lib/commonjs/typings/ua-parser.d.js.map +1 -1
  24. package/lib/commonjs/utils/platform.js.map +1 -1
  25. package/lib/commonjs/version.js +1 -2
  26. package/lib/commonjs/version.js.map +1 -1
  27. package/lib/module/campaign/campaign-tracker.js +98 -0
  28. package/lib/module/campaign/campaign-tracker.js.map +1 -0
  29. package/lib/module/campaign/types.js +2 -0
  30. package/lib/module/campaign/types.js.map +1 -0
  31. package/lib/module/config.js +4 -27
  32. package/lib/module/config.js.map +1 -1
  33. package/lib/module/cookie-migration/index.js +1 -1
  34. package/lib/module/cookie-migration/index.js.map +1 -1
  35. package/lib/module/index.js +4 -4
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/module/migration/remnant-data-migration.js +2 -7
  38. package/lib/module/migration/remnant-data-migration.js.map +1 -1
  39. package/lib/module/plugins/context.js +16 -12
  40. package/lib/module/plugins/context.js.map +1 -1
  41. package/lib/module/react-native-client.js +43 -39
  42. package/lib/module/react-native-client.js.map +1 -1
  43. package/lib/module/storage/local-storage.js +1 -1
  44. package/lib/module/storage/local-storage.js.map +1 -1
  45. package/lib/module/types.js +3 -0
  46. package/lib/module/types.js.map +1 -0
  47. package/lib/module/typings/browser-snippet.d.js.map +1 -1
  48. package/lib/module/typings/ua-parser.d.js.map +1 -1
  49. package/lib/module/utils/platform.js.map +1 -1
  50. package/lib/module/version.js +1 -1
  51. package/lib/module/version.js.map +1 -1
  52. package/lib/typescript/campaign/campaign-tracker.d.ts +85 -0
  53. package/lib/typescript/campaign/campaign-tracker.d.ts.map +1 -0
  54. package/lib/typescript/campaign/types.d.ts +11 -0
  55. package/lib/typescript/campaign/types.d.ts.map +1 -0
  56. package/lib/typescript/config.d.ts +1 -3
  57. package/lib/typescript/config.d.ts.map +1 -1
  58. package/lib/typescript/cookie-migration/index.d.ts +2 -2
  59. package/lib/typescript/cookie-migration/index.d.ts.map +1 -1
  60. package/lib/typescript/index.d.ts +2 -3
  61. package/lib/typescript/index.d.ts.map +1 -1
  62. package/lib/typescript/migration/remnant-data-migration.d.ts +2 -2
  63. package/lib/typescript/migration/remnant-data-migration.d.ts.map +1 -1
  64. package/lib/typescript/plugins/context.d.ts +2 -2
  65. package/lib/typescript/plugins/context.d.ts.map +1 -1
  66. package/lib/typescript/react-native-client.d.ts +15 -5
  67. package/lib/typescript/react-native-client.d.ts.map +1 -1
  68. package/lib/typescript/storage/local-storage.d.ts +1 -1
  69. package/lib/typescript/storage/local-storage.d.ts.map +1 -1
  70. package/lib/typescript/types.d.ts +2 -0
  71. package/lib/typescript/types.d.ts.map +1 -0
  72. package/lib/typescript/version.d.ts +1 -1
  73. package/lib/typescript/version.d.ts.map +1 -1
  74. package/package.json +3 -5
  75. package/src/campaign/campaign-tracker.ts +130 -0
  76. package/src/campaign/types.ts +13 -0
  77. package/src/config.ts +10 -5
  78. package/src/cookie-migration/index.ts +2 -3
  79. package/src/index.ts +4 -4
  80. package/src/migration/remnant-data-migration.ts +2 -2
  81. package/src/plugins/context.ts +15 -6
  82. package/src/react-native-client.ts +31 -15
  83. package/src/storage/local-storage.ts +1 -2
  84. package/src/types.ts +31 -0
  85. package/src/typings/browser-snippet.d.ts +1 -1
  86. 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
- ReactNativeClient,
24
- Identify as IIdentify,
12
+ ReactNativeAttributionOptions as AttributionOptions,
13
+ IIdentify,
25
14
  EventOptions,
26
15
  Event,
27
16
  Result,
28
- } from '@amplitude/analytics-types';
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-client-common';
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';
@@ -1,4 +1,4 @@
1
- import { InstanceProxy } from '@amplitude/analytics-types';
1
+ import { InstanceProxy } from '@amplitude/analytics-core';
2
2
 
3
3
  declare global {
4
4
  // globalThis only includes `var` declarations
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.4.14';
1
+ export const VERSION = '1.5.0';