@amplitude/analytics-react-native 1.7.0-video-analytics.0 → 1.8.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 (41) hide show
  1. package/lib/commonjs/diagnostics/diagnostics-storage.js +161 -0
  2. package/lib/commonjs/diagnostics/diagnostics-storage.js.map +1 -0
  3. package/lib/commonjs/lib-prefix.js +8 -0
  4. package/lib/commonjs/lib-prefix.js.map +1 -0
  5. package/lib/commonjs/plugins/context.js +2 -1
  6. package/lib/commonjs/plugins/context.js.map +1 -1
  7. package/lib/commonjs/react-native-client.js +18 -4
  8. package/lib/commonjs/react-native-client.js.map +1 -1
  9. package/lib/commonjs/storage/local-storage.js +2 -1
  10. package/lib/commonjs/storage/local-storage.js.map +1 -1
  11. package/lib/commonjs/version.js +1 -1
  12. package/lib/commonjs/version.js.map +1 -1
  13. package/lib/module/diagnostics/diagnostics-storage.js +154 -0
  14. package/lib/module/diagnostics/diagnostics-storage.js.map +1 -0
  15. package/lib/module/lib-prefix.js +2 -0
  16. package/lib/module/lib-prefix.js.map +1 -0
  17. package/lib/module/plugins/context.js +2 -1
  18. package/lib/module/plugins/context.js.map +1 -1
  19. package/lib/module/react-native-client.js +19 -5
  20. package/lib/module/react-native-client.js.map +1 -1
  21. package/lib/module/storage/local-storage.js +1 -1
  22. package/lib/module/storage/local-storage.js.map +1 -1
  23. package/lib/module/version.js +1 -1
  24. package/lib/module/version.js.map +1 -1
  25. package/lib/typescript/diagnostics/diagnostics-storage.d.ts +41 -0
  26. package/lib/typescript/diagnostics/diagnostics-storage.d.ts.map +1 -0
  27. package/lib/typescript/lib-prefix.d.ts +2 -0
  28. package/lib/typescript/lib-prefix.d.ts.map +1 -0
  29. package/lib/typescript/plugins/context.d.ts.map +1 -1
  30. package/lib/typescript/react-native-client.d.ts.map +1 -1
  31. package/lib/typescript/storage/local-storage.d.ts +7 -0
  32. package/lib/typescript/storage/local-storage.d.ts.map +1 -1
  33. package/lib/typescript/version.d.ts +1 -1
  34. package/lib/typescript/version.d.ts.map +1 -1
  35. package/package.json +3 -3
  36. package/src/diagnostics/diagnostics-storage.ts +180 -0
  37. package/src/lib-prefix.ts +1 -0
  38. package/src/plugins/context.ts +2 -1
  39. package/src/react-native-client.ts +23 -4
  40. package/src/storage/local-storage.ts +2 -2
  41. package/src/version.ts +1 -1
@@ -8,6 +8,7 @@ import {
8
8
  } from '@amplitude/analytics-core';
9
9
  import UAParser from '@amplitude/ua-parser-js';
10
10
  import { VERSION } from '../version';
11
+ import { LIBPREFIX } from '../lib-prefix';
11
12
  import { NativeModules } from 'react-native';
12
13
 
13
14
  const BROWSER_PLATFORM = 'Web';
@@ -46,7 +47,7 @@ export class Context implements BeforePlugin {
46
47
  nativeModule: AmplitudeReactNative | undefined = NativeModules.AmplitudeReactNative as
47
48
  | AmplitudeReactNative
48
49
  | undefined;
49
- library = `amplitude-react-native-ts/${VERSION}`;
50
+ library = `${LIBPREFIX}/${VERSION}`;
50
51
 
51
52
  constructor() {
52
53
  let agent: string | undefined;
@@ -34,11 +34,15 @@ import {
34
34
  NetworkTrackingOptions,
35
35
  normalizeNetworkCaptureRules,
36
36
  safeJsonStringify,
37
+ DiagnosticsClient,
37
38
  } from '@amplitude/analytics-core';
38
39
  import { plugin as networkCapturePlugin } from '@amplitude/plugin-network-capture-browser';
39
40
  import { CampaignTracker } from './campaign/campaign-tracker';
40
41
  import { Context } from './plugins/context';
41
42
  import { networkConnectivityCheckerPlugin } from './plugins/network-connectivity-checker';
43
+ import { ReactNativeDiagnosticsStorage } from './diagnostics/diagnostics-storage';
44
+ import { LIBPREFIX } from './lib-prefix';
45
+ import { VERSION } from './version';
42
46
  import { useReactNativeConfig, createCookieStorage, shouldFetchRemoteConfig } from './config';
43
47
  import { updateReactNativeConfigWithRemoteConfig } from './config/joined-config';
44
48
  import { parseOldCookies } from './cookie-migration';
@@ -191,6 +195,21 @@ export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeCl
191
195
  }
192
196
  }
193
197
 
198
+ // Step 0.3: Initialize diagnostics client as early as possible so it can record failures
199
+ // during config setup. Mirrors the browser SDK; storage is injected because RN has no
200
+ // IndexedDB. Options are left at their defaults (enabled, sample rate 0), which keeps the
201
+ // client inert until the remote config gate above is turned on.
202
+ const diagnosticsClient = new DiagnosticsClient(
203
+ options.apiKey,
204
+ loggerProvider,
205
+ serverZone,
206
+ undefined,
207
+ new ReactNativeDiagnosticsStorage(options.apiKey, loggerProvider),
208
+ );
209
+ diagnosticsClient.setTag('library', `${LIBPREFIX}/${VERSION}`);
210
+ diagnosticsClient.setTag('platform', 'ReactNative');
211
+ diagnosticsClient.setTag('os', Platform.OS);
212
+
194
213
  // Step 1: Read cookies stored by old SDK
195
214
  const oldCookies = await parseOldCookies(options.apiKey, options);
196
215
 
@@ -268,7 +287,7 @@ export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeCl
268
287
  // Set up the analytics connector to integrate with the experiment SDK.
269
288
  // Send events from the experiment SDK and forward identifies to the
270
289
  // identity store.
271
- const connector = getAnalyticsConnector();
290
+ const connector = getAnalyticsConnector(this.config.instanceName);
272
291
  connector.identityStore.setIdentity({
273
292
  userId: this.config.userId,
274
293
  deviceId: this.config.deviceId,
@@ -281,7 +300,7 @@ export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeCl
281
300
  if (this.config.offline !== OfflineDisabled) {
282
301
  await this.add(networkConnectivityCheckerPlugin()).promise;
283
302
  }
284
- await this.add(new Destination()).promise;
303
+ await this.add(new Destination({ diagnosticsClient })).promise;
285
304
  await this.add(new Context()).promise;
286
305
  await this.add(new IdentityEventSender()).promise;
287
306
 
@@ -374,7 +393,7 @@ export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeCl
374
393
  return;
375
394
  }
376
395
  this.config.userId = userId;
377
- setConnectorUserId(userId);
396
+ setConnectorUserId(userId, this.config.instanceName);
378
397
  }
379
398
 
380
399
  getDeviceId() {
@@ -387,7 +406,7 @@ export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeCl
387
406
  return;
388
407
  }
389
408
  this.config.deviceId = deviceId;
390
- setConnectorDeviceId(deviceId);
409
+ setConnectorDeviceId(deviceId, this.config.instanceName);
391
410
  }
392
411
 
393
412
  identify(identify: IIdentify, eventOptions?: EventOptions) {
@@ -1,6 +1,6 @@
1
1
  import { Storage, getGlobalScope } from '@amplitude/analytics-core';
2
2
 
3
- interface AsyncStorageLike {
3
+ export interface AsyncStorageLike {
4
4
  getItem(key: string): Promise<string | null>;
5
5
  setItem(key: string, value: string): Promise<void>;
6
6
  removeItem(key: string): Promise<void>;
@@ -25,7 +25,7 @@ interface AsyncStorageLike {
25
25
  // for the success-case caching that `require()` gives us for free.
26
26
  let asyncStorage: AsyncStorageLike | null | undefined = undefined;
27
27
 
28
- const getAsyncStorage = (): AsyncStorageLike | null | undefined => {
28
+ export const getAsyncStorage = (): AsyncStorageLike | null | undefined => {
29
29
  if (asyncStorage !== undefined) {
30
30
  return asyncStorage;
31
31
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.7.0-video-analytics.0';
1
+ export const VERSION = '1.8.0';