@amplitude/analytics-react-native 1.7.0-video-analytics.0 → 1.7.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 +15 -1
  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 +16 -2
  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 +20 -1
  40. package/src/storage/local-storage.ts +2 -2
  41. package/src/version.ts +1 -1
@@ -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
 
@@ -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
 
@@ -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.7.0';