@hot-updater/react-native 1.0.0-rc.1 → 1.0.0-rc.15

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 (227) hide show
  1. package/android/proguard-rules.pro +17 -2
  2. package/android/src/main/java/com/hotupdater/BuiltInAssetResolver.kt +286 -0
  3. package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +651 -637
  4. package/android/src/main/java/com/hotupdater/BundleMetadata.kt +10 -0
  5. package/android/src/main/java/com/hotupdater/HotUpdaterException.kt +0 -13
  6. package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +10 -14
  7. package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryManager.kt +37 -54
  8. package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryState.kt +64 -0
  9. package/android/src/main/java/com/hotupdater/OkHttpDownloadService.kt +19 -0
  10. package/android/src/main/java/com/hotupdater/TarArchiveInputStream.kt +214 -375
  11. package/android/src/main/java/com/hotupdater/TarBrArchiveExtractor.kt +119 -0
  12. package/android/src/newarch/HotUpdater.kt +7 -9
  13. package/android/src/newarch/HotUpdaterModule.kt +40 -20
  14. package/android/src/oldarch/HotUpdater.kt +7 -9
  15. package/android/src/oldarch/HotUpdaterModule.kt +40 -20
  16. package/android/src/test/java/com/hotupdater/BundleFileStorageServiceTest.kt +1126 -74
  17. package/android/src/test/java/com/hotupdater/HotUpdaterImplTest.kt +4 -5
  18. package/android/src/test/java/com/hotupdater/HotUpdaterRecoveryStateTest.kt +97 -0
  19. package/android/src/test/java/com/hotupdater/PendingCrashRecoveryTest.kt +44 -0
  20. package/android/src/test/java/com/hotupdater/TarBrArchiveExtractorTest.kt +206 -0
  21. package/ios/HotUpdater/Internal/BrotliFileDecompressor.swift +167 -0
  22. package/ios/HotUpdater/Internal/BuiltInAssetResolver.swift +196 -0
  23. package/ios/HotUpdater/Internal/BundleFileStorageService.swift +773 -1016
  24. package/ios/HotUpdater/Internal/BundleMetadata.swift +5 -0
  25. package/ios/HotUpdater/Internal/FileUtilities.swift +64 -0
  26. package/ios/HotUpdater/Internal/HotUpdater-Bridging-Header.h +0 -1
  27. package/ios/HotUpdater/Internal/HotUpdater.mm +5 -27
  28. package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +149 -51
  29. package/ios/HotUpdater/Internal/NotificationExtension.swift +0 -2
  30. package/ios/HotUpdater/Internal/TarArchiveExtractor.swift +182 -311
  31. package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +13 -72
  32. package/ios/HotUpdater/Recovery/HotUpdaterRecovery.h +16 -0
  33. package/ios/HotUpdater/Recovery/HotUpdaterRecovery.mm +83 -0
  34. package/ios/HotUpdater/Recovery/HotUpdaterRecoveryHooks.mm +49 -0
  35. package/lib/commonjs/checkForUpdate.js +32 -23
  36. package/lib/commonjs/checkForUpdate.js.map +1 -1
  37. package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js +97 -28
  38. package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js.map +1 -1
  39. package/lib/commonjs/error.js +4 -13
  40. package/lib/commonjs/error.js.map +1 -1
  41. package/lib/commonjs/fetchJSON.js +9 -2
  42. package/lib/commonjs/fetchJSON.js.map +1 -1
  43. package/lib/commonjs/httpClient.js +46 -29
  44. package/lib/commonjs/httpClient.js.map +1 -1
  45. package/lib/commonjs/httpClient.spec.js +57 -5
  46. package/lib/commonjs/httpClient.spec.js.map +1 -1
  47. package/lib/commonjs/index.js +31 -14
  48. package/lib/commonjs/index.js.map +1 -1
  49. package/lib/commonjs/index.spec.js +56 -11
  50. package/lib/commonjs/index.spec.js.map +1 -1
  51. package/lib/commonjs/native.js +15 -14
  52. package/lib/commonjs/native.js.map +1 -1
  53. package/lib/commonjs/native.spec.js +128 -22
  54. package/lib/commonjs/native.spec.js.map +1 -1
  55. package/lib/commonjs/{notifyAppReadyAnalytics.boundary.spec.js → notifyAppReadyInsights.boundary.spec.js} +28 -21
  56. package/lib/commonjs/notifyAppReadyInsights.boundary.spec.js.map +1 -0
  57. package/lib/commonjs/notifyAppReadyInsights.js +188 -0
  58. package/lib/commonjs/notifyAppReadyInsights.js.map +1 -0
  59. package/lib/commonjs/{notifyAppReadyAnalytics.spec.js → notifyAppReadyInsights.spec.js} +161 -29
  60. package/lib/commonjs/notifyAppReadyInsights.spec.js.map +1 -0
  61. package/lib/commonjs/{notifyAppReadyAnalytics.test-utils.js → notifyAppReadyInsights.test-utils.js} +3 -3
  62. package/lib/commonjs/notifyAppReadyInsights.test-utils.js.map +1 -0
  63. package/lib/commonjs/{notifyAppReadyAnalytics.transport.spec.js → notifyAppReadyInsights.transport.spec.js} +14 -7
  64. package/lib/commonjs/notifyAppReadyInsights.transport.spec.js.map +1 -0
  65. package/lib/commonjs/sdkVersion.js +1 -1
  66. package/lib/commonjs/sdkVersion.js.map +1 -1
  67. package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
  68. package/lib/commonjs/store.js +3 -10
  69. package/lib/commonjs/store.js.map +1 -1
  70. package/lib/commonjs/store.notification.spec.js +12 -4
  71. package/lib/commonjs/store.notification.spec.js.map +1 -1
  72. package/lib/commonjs/store.spec.js +2 -136
  73. package/lib/commonjs/store.spec.js.map +1 -1
  74. package/lib/commonjs/wrap.js +11 -12
  75. package/lib/commonjs/wrap.js.map +1 -1
  76. package/lib/commonjs/wrap.spec.js +97 -25
  77. package/lib/commonjs/wrap.spec.js.map +1 -1
  78. package/lib/module/checkForUpdate.js +32 -23
  79. package/lib/module/checkForUpdate.js.map +1 -1
  80. package/lib/module/checkForUpdate.releaseCatalog.spec.js +97 -28
  81. package/lib/module/checkForUpdate.releaseCatalog.spec.js.map +1 -1
  82. package/lib/module/error.js +4 -13
  83. package/lib/module/error.js.map +1 -1
  84. package/lib/module/fetchJSON.js +7 -1
  85. package/lib/module/fetchJSON.js.map +1 -1
  86. package/lib/module/httpClient.js +48 -31
  87. package/lib/module/httpClient.js.map +1 -1
  88. package/lib/module/httpClient.spec.js +57 -5
  89. package/lib/module/httpClient.spec.js.map +1 -1
  90. package/lib/module/index.js +32 -15
  91. package/lib/module/index.js.map +1 -1
  92. package/lib/module/index.spec.js +56 -11
  93. package/lib/module/index.spec.js.map +1 -1
  94. package/lib/module/native.js +13 -12
  95. package/lib/module/native.js.map +1 -1
  96. package/lib/module/native.spec.js +128 -22
  97. package/lib/module/native.spec.js.map +1 -1
  98. package/lib/module/{notifyAppReadyAnalytics.boundary.spec.js → notifyAppReadyInsights.boundary.spec.js} +23 -16
  99. package/lib/module/notifyAppReadyInsights.boundary.spec.js.map +1 -0
  100. package/lib/module/notifyAppReadyInsights.js +181 -0
  101. package/lib/module/notifyAppReadyInsights.js.map +1 -0
  102. package/lib/module/{notifyAppReadyAnalytics.spec.js → notifyAppReadyInsights.spec.js} +153 -21
  103. package/lib/module/notifyAppReadyInsights.spec.js.map +1 -0
  104. package/lib/module/{notifyAppReadyAnalytics.test-utils.js → notifyAppReadyInsights.test-utils.js} +3 -3
  105. package/lib/module/notifyAppReadyInsights.test-utils.js.map +1 -0
  106. package/lib/module/{notifyAppReadyAnalytics.transport.spec.js → notifyAppReadyInsights.transport.spec.js} +11 -4
  107. package/lib/module/notifyAppReadyInsights.transport.spec.js.map +1 -0
  108. package/lib/module/sdkVersion.js +1 -1
  109. package/lib/module/sdkVersion.js.map +1 -1
  110. package/lib/module/specs/NativeHotUpdater.js.map +1 -1
  111. package/lib/module/store.js +3 -10
  112. package/lib/module/store.js.map +1 -1
  113. package/lib/module/store.notification.spec.js +12 -4
  114. package/lib/module/store.notification.spec.js.map +1 -1
  115. package/lib/module/store.spec.js +2 -136
  116. package/lib/module/store.spec.js.map +1 -1
  117. package/lib/module/wrap.js +11 -12
  118. package/lib/module/wrap.js.map +1 -1
  119. package/lib/module/wrap.spec.js +99 -25
  120. package/lib/module/wrap.spec.js.map +1 -1
  121. package/lib/typescript/commonjs/checkForUpdate.d.ts +2 -3
  122. package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/error.d.ts +4 -13
  124. package/lib/typescript/commonjs/error.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/fetchJSON.d.ts +4 -0
  126. package/lib/typescript/commonjs/fetchJSON.d.ts.map +1 -1
  127. package/lib/typescript/commonjs/httpClient.d.ts +6 -6
  128. package/lib/typescript/commonjs/httpClient.d.ts.map +1 -1
  129. package/lib/typescript/commonjs/index.d.ts +4 -7
  130. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/native.d.ts +5 -9
  132. package/lib/typescript/commonjs/native.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts +25 -0
  134. package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts +8 -0
  136. package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts.map +1 -0
  137. package/lib/typescript/commonjs/sdkVersion.d.ts +1 -1
  138. package/lib/typescript/commonjs/sdkVersion.d.ts.map +1 -1
  139. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +8 -35
  140. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
  141. package/lib/typescript/commonjs/store.d.ts +1 -3
  142. package/lib/typescript/commonjs/store.d.ts.map +1 -1
  143. package/lib/typescript/commonjs/wrap.types.d.ts +5 -8
  144. package/lib/typescript/commonjs/wrap.types.d.ts.map +1 -1
  145. package/lib/typescript/module/checkForUpdate.d.ts +2 -3
  146. package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
  147. package/lib/typescript/module/error.d.ts +4 -13
  148. package/lib/typescript/module/error.d.ts.map +1 -1
  149. package/lib/typescript/module/fetchJSON.d.ts +4 -0
  150. package/lib/typescript/module/fetchJSON.d.ts.map +1 -1
  151. package/lib/typescript/module/httpClient.d.ts +6 -6
  152. package/lib/typescript/module/httpClient.d.ts.map +1 -1
  153. package/lib/typescript/module/index.d.ts +4 -7
  154. package/lib/typescript/module/index.d.ts.map +1 -1
  155. package/lib/typescript/module/native.d.ts +5 -9
  156. package/lib/typescript/module/native.d.ts.map +1 -1
  157. package/lib/typescript/module/notifyAppReadyInsights.d.ts +25 -0
  158. package/lib/typescript/module/notifyAppReadyInsights.d.ts.map +1 -0
  159. package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts +8 -0
  160. package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts.map +1 -0
  161. package/lib/typescript/module/sdkVersion.d.ts +1 -1
  162. package/lib/typescript/module/sdkVersion.d.ts.map +1 -1
  163. package/lib/typescript/module/specs/NativeHotUpdater.d.ts +8 -35
  164. package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
  165. package/lib/typescript/module/store.d.ts +1 -3
  166. package/lib/typescript/module/store.d.ts.map +1 -1
  167. package/lib/typescript/module/wrap.types.d.ts +5 -8
  168. package/lib/typescript/module/wrap.types.d.ts.map +1 -1
  169. package/package.json +3 -3
  170. package/src/checkForUpdate.releaseCatalog.spec.ts +137 -61
  171. package/src/checkForUpdate.ts +35 -29
  172. package/src/error.ts +4 -14
  173. package/src/fetchJSON.ts +12 -1
  174. package/src/httpClient.spec.ts +70 -5
  175. package/src/httpClient.ts +78 -64
  176. package/src/index.spec.ts +59 -11
  177. package/src/index.ts +41 -17
  178. package/src/native.spec.ts +133 -22
  179. package/src/native.ts +21 -32
  180. package/src/{notifyAppReadyAnalytics.boundary.spec.ts → notifyAppReadyInsights.boundary.spec.ts} +25 -17
  181. package/src/{notifyAppReadyAnalytics.spec.ts → notifyAppReadyInsights.spec.ts} +141 -22
  182. package/src/{notifyAppReadyAnalytics.test-utils.ts → notifyAppReadyInsights.test-utils.ts} +4 -4
  183. package/src/{notifyAppReadyAnalytics.transport.spec.ts → notifyAppReadyInsights.transport.spec.ts} +13 -5
  184. package/src/notifyAppReadyInsights.ts +293 -0
  185. package/src/sdkVersion.ts +1 -1
  186. package/src/specs/NativeHotUpdater.ts +8 -36
  187. package/src/store.notification.spec.ts +13 -3
  188. package/src/store.spec.ts +0 -157
  189. package/src/store.ts +2 -23
  190. package/src/wrap.spec.ts +109 -31
  191. package/src/wrap.tsx +11 -11
  192. package/src/wrap.types.ts +5 -8
  193. package/android/src/main/java/com/hotupdater/DecompressService.kt +0 -89
  194. package/android/src/main/java/com/hotupdater/DecompressionStrategy.kt +0 -26
  195. package/android/src/main/java/com/hotupdater/TarBrDecompressionStrategy.kt +0 -117
  196. package/android/src/main/java/com/hotupdater/TarGzDecompressionStrategy.kt +0 -117
  197. package/android/src/main/java/com/hotupdater/ZipDecompressionStrategy.kt +0 -192
  198. package/android/src/test/java/com/hotupdater/TarArchiveInputStreamTest.kt +0 -68
  199. package/ios/HotUpdater/Internal/ArchiveExtractionUtilities.swift +0 -178
  200. package/ios/HotUpdater/Internal/DecompressService.swift +0 -112
  201. package/ios/HotUpdater/Internal/DecompressionStrategy.swift +0 -22
  202. package/ios/HotUpdater/Internal/StreamingTarArchiveExtractor.swift +0 -370
  203. package/ios/HotUpdater/Internal/TarBrDecompressionStrategy.swift +0 -39
  204. package/ios/HotUpdater/Internal/TarGzDecompressionStrategy.swift +0 -59
  205. package/ios/HotUpdater/Internal/ZipArchiveExtractor.swift +0 -482
  206. package/ios/HotUpdater/Internal/ZipDecompressionStrategy.swift +0 -56
  207. package/lib/commonjs/notifyAppReadyAnalytics.boundary.spec.js.map +0 -1
  208. package/lib/commonjs/notifyAppReadyAnalytics.js +0 -133
  209. package/lib/commonjs/notifyAppReadyAnalytics.js.map +0 -1
  210. package/lib/commonjs/notifyAppReadyAnalytics.spec.js.map +0 -1
  211. package/lib/commonjs/notifyAppReadyAnalytics.test-utils.js.map +0 -1
  212. package/lib/commonjs/notifyAppReadyAnalytics.transport.spec.js.map +0 -1
  213. package/lib/module/notifyAppReadyAnalytics.boundary.spec.js.map +0 -1
  214. package/lib/module/notifyAppReadyAnalytics.js +0 -128
  215. package/lib/module/notifyAppReadyAnalytics.js.map +0 -1
  216. package/lib/module/notifyAppReadyAnalytics.spec.js.map +0 -1
  217. package/lib/module/notifyAppReadyAnalytics.test-utils.js.map +0 -1
  218. package/lib/module/notifyAppReadyAnalytics.transport.spec.js.map +0 -1
  219. package/lib/typescript/commonjs/notifyAppReadyAnalytics.d.ts +0 -13
  220. package/lib/typescript/commonjs/notifyAppReadyAnalytics.d.ts.map +0 -1
  221. package/lib/typescript/commonjs/notifyAppReadyAnalytics.test-utils.d.ts +0 -8
  222. package/lib/typescript/commonjs/notifyAppReadyAnalytics.test-utils.d.ts.map +0 -1
  223. package/lib/typescript/module/notifyAppReadyAnalytics.d.ts +0 -13
  224. package/lib/typescript/module/notifyAppReadyAnalytics.d.ts.map +0 -1
  225. package/lib/typescript/module/notifyAppReadyAnalytics.test-utils.d.ts +0 -8
  226. package/lib/typescript/module/notifyAppReadyAnalytics.test-utils.d.ts.map +0 -1
  227. package/src/notifyAppReadyAnalytics.ts +0 -194
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { beforeEach, describe, expect, it, vi } from "vitest";
4
- import { createNotifyReadResult, stubNotifyFrame } from "./notifyAppReadyAnalytics.test-utils.js";
4
+ import { createNotifyReadResult, stubNotifyFrame } from "./notifyAppReadyInsights.test-utils.js";
5
5
  const platformState = vi.hoisted(() => ({
6
6
  OS: "ios"
7
7
  }));
@@ -31,6 +31,7 @@ const mocks = vi.hoisted(() => ({
31
31
  getAppVersion: vi.fn(() => "1.0.0"),
32
32
  getBundleId: vi.fn(() => "bundle-id"),
33
33
  getChannel: vi.fn(() => "production"),
34
+ getActiveUpdateState: vi.fn(),
34
35
  getCohort: vi.fn(() => "123"),
35
36
  getFingerprintHash: vi.fn(() => "fingerprint-hash"),
36
37
  getInstallId: vi.fn(() => "install-id"),
@@ -46,6 +47,7 @@ vi.mock("./native", () => ({
46
47
  getAppVersion: mocks.getAppVersion,
47
48
  getBundleId: mocks.getBundleId,
48
49
  getChannel: mocks.getChannel,
50
+ getActiveUpdateState: mocks.getActiveUpdateState,
49
51
  getCohort: mocks.getCohort,
50
52
  getFingerprintHash: mocks.getFingerprintHash,
51
53
  getInstallId: mocks.getInstallId,
@@ -57,19 +59,19 @@ vi.mock("./specs/NativeHotUpdater", () => ({
57
59
  default: nativePersistence
58
60
  }));
59
61
  const createClient = () => {
60
- const sendAnalyticsEvent = vi.fn().mockResolvedValue(undefined);
62
+ const sendInsightsEvent = vi.fn().mockResolvedValue(undefined);
61
63
  return {
62
64
  client: {
63
65
  createSession: vi.fn(async () => ({
64
66
  fetchReleaseCatalog: vi.fn(),
65
67
  resolveArtifact: vi.fn(),
66
- sendAnalyticsEvent
68
+ sendInsightsEvent
67
69
  }))
68
70
  },
69
- sendAnalyticsEvent
71
+ sendInsightsEvent
70
72
  };
71
73
  };
72
- describe("automatic notifyAppReady analytics boundaries", () => {
74
+ describe("automatic notifyAppReady insights boundaries", () => {
73
75
  beforeEach(() => {
74
76
  vi.resetModules();
75
77
  vi.unstubAllGlobals();
@@ -82,6 +84,11 @@ describe("automatic notifyAppReady analytics boundaries", () => {
82
84
  mocks.getAppVersion.mockReturnValue("1.0.0");
83
85
  mocks.getBundleId.mockReturnValue("bundle-id");
84
86
  mocks.getChannel.mockReturnValue("production");
87
+ mocks.getActiveUpdateState.mockReturnValue({
88
+ activeSelection: null,
89
+ stableSelection: null,
90
+ verificationPending: false
91
+ });
85
92
  mocks.getCohort.mockReturnValue("123");
86
93
  mocks.getFingerprintHash.mockReturnValue("fingerprint-hash");
87
94
  mocks.getInstallId.mockReturnValue("install-id");
@@ -100,7 +107,7 @@ describe("automatic notifyAppReady analytics boundaries", () => {
100
107
  init
101
108
  } = await import("./wrap");
102
109
  init({
103
- analytics: true,
110
+ insights: true,
104
111
  client: {
105
112
  createSession: vi.fn(async () => {
106
113
  throw new Error("baseURL unavailable");
@@ -114,7 +121,7 @@ describe("automatic notifyAppReady analytics boundaries", () => {
114
121
  expect(onNotifyAppReady).toHaveBeenCalledWith({
115
122
  status: "UNCHANGED"
116
123
  });
117
- expect(warn).toHaveBeenCalledWith("[HotUpdater] Automatic notifyAppReady analytics failed:", expect.objectContaining({
124
+ expect(warn).toHaveBeenCalledWith("[HotUpdater] Automatic notifyAppReady insights failed:", expect.objectContaining({
118
125
  message: "baseURL unavailable"
119
126
  }));
120
127
  warn.mockRestore();
@@ -141,24 +148,24 @@ describe("automatic notifyAppReady analytics boundaries", () => {
141
148
  }
142
149
  const {
143
150
  client,
144
- sendAnalyticsEvent
151
+ sendInsightsEvent
145
152
  } = createClient();
146
153
  const {
147
154
  init
148
155
  } = await import("./wrap");
149
156
  init({
150
- analytics: true,
157
+ insights: true,
151
158
  client,
152
159
  onError,
153
160
  onNotifyAppReady
154
161
  });
155
162
  await vi.runOnlyPendingTimersAsync();
156
- expect(sendAnalyticsEvent).not.toHaveBeenCalled();
163
+ expect(sendInsightsEvent).not.toHaveBeenCalled();
157
164
  expect(onError).not.toHaveBeenCalled();
158
165
  expect(onNotifyAppReady).toHaveBeenCalledWith({
159
166
  status: "UNCHANGED"
160
167
  });
161
- expect(warn).toHaveBeenCalledWith("[HotUpdater] Automatic notifyAppReady analytics failed:", expect.any(Error));
168
+ expect(warn).toHaveBeenCalledWith("[HotUpdater] Automatic notifyAppReady insights failed:", expect.any(Error));
162
169
  warn.mockRestore();
163
170
  });
164
171
  it.each([{
@@ -183,24 +190,24 @@ describe("automatic notifyAppReady analytics boundaries", () => {
183
190
  }
184
191
  const {
185
192
  client,
186
- sendAnalyticsEvent
193
+ sendInsightsEvent
187
194
  } = createClient();
188
195
  const {
189
196
  init
190
197
  } = await import("./wrap");
191
198
  init({
192
- analytics: true,
199
+ insights: true,
193
200
  client,
194
201
  onError,
195
202
  onNotifyAppReady
196
203
  });
197
204
  await vi.runOnlyPendingTimersAsync();
198
- expect(sendAnalyticsEvent).not.toHaveBeenCalled();
205
+ expect(sendInsightsEvent).not.toHaveBeenCalled();
199
206
  expect(onError).not.toHaveBeenCalled();
200
207
  expect(onNotifyAppReady).toHaveBeenCalledWith({
201
208
  status: "UNCHANGED"
202
209
  });
203
- expect(warn).toHaveBeenCalledWith("[HotUpdater] Automatic notifyAppReady analytics failed:", expect.any(Error));
210
+ expect(warn).toHaveBeenCalledWith("[HotUpdater] Automatic notifyAppReady insights failed:", expect.any(Error));
204
211
  warn.mockRestore();
205
212
  });
206
213
  it.each(["ios", "android"])("reads persisted install id through native.ts across JS module resets on %s", async platform => {
@@ -214,4 +221,4 @@ describe("automatic notifyAppReady analytics boundaries", () => {
214
221
  expect(nativePersistence.getInstallId).toHaveBeenCalledTimes(2);
215
222
  });
216
223
  });
217
- //# sourceMappingURL=notifyAppReadyAnalytics.boundary.spec.js.map
224
+ //# sourceMappingURL=notifyAppReadyInsights.boundary.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["beforeEach","describe","expect","it","vi","createNotifyReadResult","stubNotifyFrame","platformState","hoisted","OS","mock","NativeEventEmitter","Platform","nativePersistence","persistedInstallId","getConstants","fn","APP_VERSION","CHANNEL","DEFAULT_CHANNEL","FINGERPRINT_HASH","MIN_BUNDLE_ID","getInstallId","setPersistedInstallId","installId","mocks","addListener","checkForUpdate","getAppVersion","getBundleId","getChannel","getActiveUpdateState","getCohort","getFingerprintHash","getPersistedUserIdentity","readNotifyAppReady","reload","default","createClient","sendInsightsEvent","mockResolvedValue","undefined","client","createSession","fetchReleaseCatalog","resolveArtifact","resetModules","unstubAllGlobals","useRealTimers","Object","values","mockReset","mockReturnValue","activeSelection","stableSelection","verificationPending","mockClear","warn","spyOn","console","mockImplementation","onError","onNotifyAppReady","init","insights","Error","runOnlyPendingTimersAsync","not","toHaveBeenCalled","toHaveBeenCalledWith","status","objectContaining","message","mockRestore","each","label","value","any","platform","native","importActual","toBe","nativeAfterReset","toHaveBeenCalledTimes"],"sourceRoot":"../../src","sources":["notifyAppReadyInsights.boundary.spec.ts"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAA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List":[]}
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+
3
+ import { Platform } from "react-native";
4
+ import { getActiveUpdateState, getAppVersion, getBundleId, getChannel, getCohort, getFingerprintHash, getInstallId, getPersistedUserIdentity, readNotifyAppReady } from "./native.js";
5
+ let didAttemptAutomaticInsights = false;
6
+ let didDownload = false;
7
+ let readinessPromise;
8
+ const waitForNextFrame = () => new Promise(resolve => {
9
+ const requestAnimationFrame = globalThis?.requestAnimationFrame;
10
+ if (requestAnimationFrame) {
11
+ requestAnimationFrame(() => resolve());
12
+ return;
13
+ }
14
+ void Promise.resolve().then(resolve);
15
+ });
16
+ const assertNever = value => {
17
+ throw new Error(`[HotUpdater] Unexpected notifyAppReady status: ${value}`);
18
+ };
19
+ const buildNotifyAppReadyInsightsParams = (nativeResult, insightsEvent, options) => {
20
+ const appVersion = getAppVersion();
21
+ if (!appVersion) {
22
+ throw new Error("[HotUpdater] Automatic insights requires a non-null native app version.");
23
+ }
24
+ const {
25
+ userId,
26
+ username
27
+ } = getPersistedUserIdentity();
28
+ const installId = getInstallId();
29
+ if (!installId) {
30
+ throw new Error("[HotUpdater] Automatic insights requires a non-null native install id.");
31
+ }
32
+ const platform = Platform.OS === "android" ? "android" : "ios";
33
+ const commonParams = {
34
+ appVersion,
35
+ channel: getChannel(),
36
+ cohort: getCohort(),
37
+ fingerprintHash: getFingerprintHash(),
38
+ fromReleaseId: insightsEvent?.fromReleaseId ?? null,
39
+ installId,
40
+ platform,
41
+ requestHeaders: options.requestHeaders,
42
+ requestTimeout: options.requestTimeout,
43
+ toReleaseId: insightsEvent?.toReleaseId ?? null,
44
+ ...(userId != null ? {
45
+ userId
46
+ } : {}),
47
+ ...(username != null ? {
48
+ username
49
+ } : {})
50
+ };
51
+ switch (nativeResult.status) {
52
+ case "UNCHANGED":
53
+ {
54
+ const bundleId = getBundleId();
55
+ if (!bundleId) {
56
+ throw new Error("[HotUpdater] Automatic insights requires a non-null current bundle id.");
57
+ }
58
+ const state = getActiveUpdateState();
59
+ const runningSelection = [state.activeSelection, state.stableSelection].find(selection => selection?.bundleId === bundleId && selection.channel === commonParams.channel);
60
+ return {
61
+ ...commonParams,
62
+ fromBundleId: null,
63
+ toBundleId: bundleId,
64
+ toReleaseId: runningSelection?.releaseId ?? null,
65
+ type: "UNCHANGED",
66
+ updateStrategy: null
67
+ };
68
+ }
69
+ case "UPDATE_APPLIED":
70
+ case "RECOVERED":
71
+ if (!insightsEvent) {
72
+ throw new Error("[HotUpdater] Native launch report is missing persisted metadata required for automatic insights.");
73
+ }
74
+ switch (insightsEvent.type) {
75
+ case "UPDATE_APPLIED":
76
+ return {
77
+ ...commonParams,
78
+ fromBundleId: insightsEvent.fromBundleId,
79
+ toBundleId: insightsEvent.toBundleId,
80
+ type: "UPDATE_APPLIED",
81
+ updateStrategy: insightsEvent.updateStrategy
82
+ };
83
+ case "RECOVERED":
84
+ return {
85
+ ...commonParams,
86
+ fromBundleId: insightsEvent.fromBundleId,
87
+ toBundleId: insightsEvent.toBundleId,
88
+ type: "RECOVERED",
89
+ updateStrategy: insightsEvent.updateStrategy
90
+ };
91
+ default:
92
+ return assertNever(insightsEvent.type);
93
+ }
94
+ default:
95
+ return assertNever(nativeResult);
96
+ }
97
+ };
98
+ let lastInsightsReport = Promise.resolve();
99
+ const sendInsights = (options, params) => {
100
+ lastInsightsReport = lastInsightsReport.catch(() => {}).then(async () => {
101
+ const session = await options.client.createSession();
102
+ await session.sendInsightsEvent(params);
103
+ });
104
+ return lastInsightsReport;
105
+ };
106
+ const maybeSendAutomaticInsights = async (options, nativeResult, insightsEvent) => {
107
+ if (!options.insights || didAttemptAutomaticInsights || nativeResult.status === "UNCHANGED" && (options.reportUnchanged === false || didDownload)) {
108
+ return;
109
+ }
110
+ didAttemptAutomaticInsights = true;
111
+ if (nativeResult.status !== "UNCHANGED" && !insightsEvent) {
112
+ throw new Error("[HotUpdater] Native launch report is missing persisted metadata required for automatic insights.");
113
+ }
114
+ await sendInsights(options, buildNotifyAppReadyInsightsParams(nativeResult, insightsEvent, options));
115
+ };
116
+ const notifyAppReady = async options => {
117
+ try {
118
+ let nativeReadResult;
119
+ do {
120
+ await waitForNextFrame();
121
+ nativeReadResult = readNotifyAppReady();
122
+ } while (nativeReadResult.pending);
123
+ const {
124
+ insightsEvent,
125
+ result: nativeResult
126
+ } = nativeReadResult;
127
+ try {
128
+ await maybeSendAutomaticInsights(options, nativeResult, insightsEvent);
129
+ } catch (error) {
130
+ const warning = error instanceof Error ? error : new Error(String(error));
131
+ console.warn("[HotUpdater] Automatic notifyAppReady insights failed:", warning);
132
+ }
133
+ options.onNotifyAppReady?.(nativeResult);
134
+ return nativeResult;
135
+ } catch (error) {
136
+ const normalizedError = error instanceof Error ? error : new Error(String(error));
137
+ options.onError?.(error);
138
+ console.warn("[HotUpdater] Failed to notify app ready:", normalizedError);
139
+ return undefined;
140
+ }
141
+ };
142
+ export const handleNotifyAppReady = options => {
143
+ readinessPromise = notifyAppReady(options);
144
+ return readinessPromise;
145
+ };
146
+
147
+ /** Called after an automatic update check finds no download or transition. */
148
+ export const reportNoChange = async options => {
149
+ try {
150
+ await maybeSendAutomaticInsights(options, {
151
+ status: "UNCHANGED"
152
+ }, null);
153
+ } catch (error) {
154
+ console.warn("[HotUpdater] Automatic no-change insights failed:", error);
155
+ }
156
+ };
157
+ let lastDownloadedSelection;
158
+
159
+ /** Report only after the manifest update has been verified and staged successfully. */
160
+ export const reportBundleDownloaded = async (options, transition) => {
161
+ if (!options.insights || transition.fromBundleId === transition.toBundleId) return;
162
+ const key = JSON.stringify([transition.channel, transition.toReleaseId, transition.toBundleId]);
163
+ if (lastDownloadedSelection === key) return;
164
+ lastDownloadedSelection = key;
165
+ // A later init/mount in this JS runtime must not overwrite pending apply with UNCHANGED.
166
+ didDownload = true;
167
+ try {
168
+ await readinessPromise;
169
+ const common = buildNotifyAppReadyInsightsParams({
170
+ status: "UNCHANGED"
171
+ }, null, options);
172
+ await sendInsights(options, {
173
+ ...common,
174
+ ...transition,
175
+ type: "UPDATE_DOWNLOADED"
176
+ });
177
+ } catch (error) {
178
+ console.warn("[HotUpdater] Download insights failed:", error);
179
+ }
180
+ };
181
+ //# sourceMappingURL=notifyAppReadyInsights.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","getActiveUpdateState","getAppVersion","getBundleId","getChannel","getCohort","getFingerprintHash","getInstallId","getPersistedUserIdentity","readNotifyAppReady","didAttemptAutomaticInsights","didDownload","readinessPromise","waitForNextFrame","Promise","resolve","requestAnimationFrame","globalThis","then","assertNever","value","Error","buildNotifyAppReadyInsightsParams","nativeResult","insightsEvent","options","appVersion","userId","username","installId","platform","OS","commonParams","channel","cohort","fingerprintHash","fromReleaseId","requestHeaders","requestTimeout","toReleaseId","status","bundleId","state","runningSelection","activeSelection","stableSelection","find","selection","fromBundleId","toBundleId","releaseId","type","updateStrategy","lastInsightsReport","sendInsights","params","catch","session","client","createSession","sendInsightsEvent","maybeSendAutomaticInsights","insights","reportUnchanged","notifyAppReady","nativeReadResult","pending","result","error","warning","String","console","warn","onNotifyAppReady","normalizedError","onError","undefined","handleNotifyAppReady","reportNoChange","lastDownloadedSelection","reportBundleDownloaded","transition","key","JSON","stringify","common"],"sourceRoot":"../../src","sources":["notifyAppReadyInsights.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAIvC,SACEC,oBAAoB,EACpBC,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,kBAAkB,EAClBC,YAAY,EACZC,wBAAwB,EAGxBC,kBAAkB,QACb,aAAU;AAcjB,IAAIC,2BAA2B,GAAG,KAAK;AACvC,IAAIC,WAAW,GAAG,KAAK;AACvB,IAAIC,gBAAuE;AAE3E,MAAMC,gBAAgB,GAAGA,CAAA,KACvB,IAAIC,OAAO,CAAQC,OAAO,IAAK;EAC7B,MAAMC,qBAAqB,GACzBC,UAAU,EAGTD,qBAAqB;EAExB,IAAIA,qBAAqB,EAAE;IACzBA,qBAAqB,CAAC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O,MAAMC,sBAAsB,GAAG,MAAAA,CACpCvD,OAGC,EACDwD,UAOC,KACiB;EAClB,IAAI,CAACxD,OAAO,CAACqC,QAAQ,IAAImB,UAAU,CAACjC,YAAY,KAAKiC,UAAU,CAAChC,UAAU,EACxE;EACF,MAAMiC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAAC,CACzBH,UAAU,CAAChD,OAAO,EAClBgD,UAAU,CAAC1C,WAAW,EACtB0C,UAAU,CAAChC,UAAU,CACtB,CAAC;EACF,IAAI8B,uBAAuB,KAAKG,GAAG,EAAE;EACrCH,uBAAuB,GAAGG,GAAG;EAC7B;EACAvE,WAAW,GAAG,IAAI;EAClB,IAAI;IACF,MAAMC,gBAAgB;IACtB,MAAMyE,MAAM,GAAG/D,iCAAiC,CAC9C;MAAEkB,MAAM,EAAE;IAAY,CAAC,EACvB,IAAI,EACJf,OACF,CAAC;IACD,MAAM6B,YAAY,CAAC7B,OAAO,EAAE;MAC1B,GAAG4D,MAAM;MACT,GAAGJ,UAAU;MACb9B,IAAI,EAAE;IACR,CAAC,CAAC;EACJ,CAAC,CAAC,OAAOiB,KAAK,EAAE;IACdG,OAAO,CAACC,IAAI,CAAC,wCAAwC,EAAEJ,KAAK,CAAC;EAC/D;AACF,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { beforeEach, describe, expect, it, vi } from "vitest";
4
- import { createNotifyReadResult, stubNotifyFrame } from "./notifyAppReadyAnalytics.test-utils.js";
4
+ import { createNotifyReadResult, stubNotifyFrame } from "./notifyAppReadyInsights.test-utils.js";
5
5
  vi.mock("react-native", () => ({
6
6
  Platform: {
7
7
  OS: "ios"
@@ -13,6 +13,7 @@ const mocks = vi.hoisted(() => ({
13
13
  getAppVersion: vi.fn(() => "1.0.0"),
14
14
  getBundleId: vi.fn(() => "bundle-id"),
15
15
  getChannel: vi.fn(() => "production"),
16
+ getActiveUpdateState: vi.fn(),
16
17
  getCohort: vi.fn(() => "123"),
17
18
  getFingerprintHash: vi.fn(() => "fingerprint-hash"),
18
19
  getInstallId: vi.fn(() => "install-id"),
@@ -28,6 +29,7 @@ vi.mock("./native", () => ({
28
29
  getAppVersion: mocks.getAppVersion,
29
30
  getBundleId: mocks.getBundleId,
30
31
  getChannel: mocks.getChannel,
32
+ getActiveUpdateState: mocks.getActiveUpdateState,
31
33
  getCohort: mocks.getCohort,
32
34
  getFingerprintHash: mocks.getFingerprintHash,
33
35
  getInstallId: mocks.getInstallId,
@@ -36,19 +38,19 @@ vi.mock("./native", () => ({
36
38
  reload: mocks.reload
37
39
  }));
38
40
  const createClient = () => {
39
- const sendAnalyticsEvent = vi.fn().mockResolvedValue(undefined);
41
+ const sendInsightsEvent = vi.fn().mockResolvedValue(undefined);
40
42
  return {
41
43
  client: {
42
44
  createSession: vi.fn(async () => ({
43
45
  fetchReleaseCatalog: vi.fn(),
44
46
  resolveArtifact: vi.fn(),
45
- sendAnalyticsEvent
47
+ sendInsightsEvent
46
48
  }))
47
49
  },
48
- sendAnalyticsEvent
50
+ sendInsightsEvent
49
51
  };
50
52
  };
51
- describe("automatic notifyAppReady analytics", () => {
53
+ describe("automatic notifyAppReady insights", () => {
52
54
  beforeEach(() => {
53
55
  vi.resetModules();
54
56
  vi.unstubAllGlobals();
@@ -60,12 +62,142 @@ describe("automatic notifyAppReady analytics", () => {
60
62
  mocks.addListener.mockReturnValue(() => {});
61
63
  mocks.getBundleId.mockReturnValue("bundle-id");
62
64
  mocks.getChannel.mockReturnValue("production");
65
+ mocks.getActiveUpdateState.mockReturnValue({
66
+ activeSelection: null,
67
+ stableSelection: null,
68
+ verificationPending: false
69
+ });
63
70
  mocks.getCohort.mockReturnValue("123");
64
71
  mocks.getFingerprintHash.mockReturnValue("fingerprint-hash");
65
72
  mocks.getInstallId.mockReturnValue("install-id");
66
73
  mocks.getPersistedUserIdentity.mockReturnValue({});
67
74
  mocks.readNotifyAppReady.mockReturnValue(createNotifyReadResult());
68
75
  });
76
+ it.each([{
77
+ label: "running selection",
78
+ pending: false,
79
+ channel: "production",
80
+ expected: "release-running"
81
+ }, {
82
+ label: "staged selection",
83
+ pending: true,
84
+ channel: "production",
85
+ expected: "release-running"
86
+ }, {
87
+ label: "another channel",
88
+ pending: false,
89
+ channel: "preview",
90
+ expected: null
91
+ }])("attributes an unchanged launch with $label", async ({
92
+ pending,
93
+ channel,
94
+ expected
95
+ }) => {
96
+ const running = {
97
+ kind: "BUNDLE",
98
+ releaseId: "release-running",
99
+ bundleId: "bundle-id",
100
+ channel
101
+ };
102
+ mocks.getActiveUpdateState.mockReturnValue({
103
+ activeSelection: pending ? {
104
+ ...running,
105
+ releaseId: "release-pending",
106
+ bundleId: "bundle-pending"
107
+ } : running,
108
+ stableSelection: pending ? running : null,
109
+ verificationPending: pending
110
+ });
111
+ const {
112
+ reportNoChange
113
+ } = await import("./notifyAppReadyInsights");
114
+ const {
115
+ client,
116
+ sendInsightsEvent
117
+ } = createClient();
118
+ await reportNoChange({
119
+ client,
120
+ insights: true
121
+ });
122
+ expect(sendInsightsEvent).toHaveBeenCalledWith(expect.objectContaining({
123
+ type: "UNCHANGED",
124
+ toBundleId: "bundle-id",
125
+ toReleaseId: expected
126
+ }));
127
+ });
128
+ it("orders download after in-flight startup reporting and suppresses a later no-change report", async () => {
129
+ const {
130
+ handleNotifyAppReady,
131
+ reportBundleDownloaded,
132
+ reportNoChange
133
+ } = await import("./notifyAppReadyInsights");
134
+ const {
135
+ client,
136
+ sendInsightsEvent
137
+ } = createClient();
138
+ let finishStartup;
139
+ sendInsightsEvent.mockImplementationOnce(() => new Promise(resolve => {
140
+ finishStartup = resolve;
141
+ }));
142
+ const options = {
143
+ client,
144
+ insights: true
145
+ };
146
+ const startup = handleNotifyAppReady(options);
147
+ await vi.waitFor(() => expect(sendInsightsEvent).toHaveBeenCalledOnce());
148
+ const download = reportBundleDownloaded(options, {
149
+ fromBundleId: "bundle-id",
150
+ fromReleaseId: null,
151
+ toBundleId: "next-bundle",
152
+ toReleaseId: "next-release",
153
+ channel: "production",
154
+ updateStrategy: "appVersion"
155
+ });
156
+ await Promise.resolve();
157
+ expect(sendInsightsEvent).toHaveBeenCalledOnce();
158
+ finishStartup();
159
+ await Promise.all([startup, download]);
160
+ await reportNoChange(options);
161
+ expect(sendInsightsEvent.mock.calls.map(([params]) => params.type)).toEqual(["UNCHANGED", "UPDATE_DOWNLOADED"]);
162
+ });
163
+ it("reports selecting a previous download again after a different pending bundle", async () => {
164
+ const {
165
+ reportBundleDownloaded
166
+ } = await import("./notifyAppReadyInsights");
167
+ const {
168
+ client,
169
+ sendInsightsEvent
170
+ } = createClient();
171
+ const transition = {
172
+ fromBundleId: "bundle-id",
173
+ fromReleaseId: null,
174
+ toBundleId: "next-bundle",
175
+ toReleaseId: "next-release",
176
+ channel: "production",
177
+ updateStrategy: "appVersion"
178
+ };
179
+ await reportBundleDownloaded({
180
+ client,
181
+ insights: true
182
+ }, transition);
183
+ await reportBundleDownloaded({
184
+ client,
185
+ insights: true
186
+ }, transition);
187
+ await reportBundleDownloaded({
188
+ client,
189
+ insights: true
190
+ }, {
191
+ ...transition,
192
+ toBundleId: "other-bundle",
193
+ toReleaseId: "other-release"
194
+ });
195
+ await reportBundleDownloaded({
196
+ client,
197
+ insights: true
198
+ }, transition);
199
+ expect(sendInsightsEvent.mock.calls.map(([params]) => params.toBundleId)).toEqual(["next-bundle", "other-bundle", "next-bundle"]);
200
+ });
69
201
  it("sends UPDATE_APPLIED with transition metadata and invokes readiness", async () => {
70
202
  stubNotifyFrame();
71
203
  mocks.getPersistedUserIdentity.mockReturnValue({
@@ -84,14 +216,14 @@ describe("automatic notifyAppReady analytics", () => {
84
216
  }));
85
217
  const {
86
218
  client,
87
- sendAnalyticsEvent
219
+ sendInsightsEvent
88
220
  } = createClient();
89
221
  const onNotifyAppReady = vi.fn();
90
222
  const {
91
223
  init
92
224
  } = await import("./wrap");
93
225
  init({
94
- analytics: true,
226
+ insights: true,
95
227
  onNotifyAppReady,
96
228
  requestHeaders: {
97
229
  Authorization: "Bearer token"
@@ -100,7 +232,7 @@ describe("automatic notifyAppReady analytics", () => {
100
232
  client
101
233
  });
102
234
  await vi.runOnlyPendingTimersAsync();
103
- expect(sendAnalyticsEvent).toHaveBeenCalledWith({
235
+ expect(sendInsightsEvent).toHaveBeenCalledWith({
104
236
  appVersion: "1.0.0",
105
237
  channel: "production",
106
238
  cohort: "123",
@@ -140,19 +272,19 @@ describe("automatic notifyAppReady analytics", () => {
140
272
  }));
141
273
  const {
142
274
  client,
143
- sendAnalyticsEvent
275
+ sendInsightsEvent
144
276
  } = createClient();
145
277
  const onNotifyAppReady = vi.fn();
146
278
  const {
147
279
  init
148
280
  } = await import("./wrap");
149
281
  init({
150
- analytics: true,
282
+ insights: true,
151
283
  client,
152
284
  onNotifyAppReady
153
285
  });
154
286
  await vi.runOnlyPendingTimersAsync();
155
- expect(sendAnalyticsEvent).toHaveBeenCalledWith({
287
+ expect(sendInsightsEvent).toHaveBeenCalledWith({
156
288
  appVersion: "1.0.0",
157
289
  channel: "production",
158
290
  cohort: "123",
@@ -178,25 +310,25 @@ describe("automatic notifyAppReady analytics", () => {
178
310
  stubNotifyFrame();
179
311
  const {
180
312
  client,
181
- sendAnalyticsEvent
313
+ sendInsightsEvent
182
314
  } = createClient();
183
315
  const onNotifyAppReady = vi.fn();
184
316
  const {
185
317
  init
186
318
  } = await import("./wrap");
187
319
  init({
188
- analytics: true,
320
+ insights: true,
189
321
  client,
190
322
  onNotifyAppReady
191
323
  });
192
324
  init({
193
- analytics: true,
325
+ insights: true,
194
326
  client,
195
327
  onNotifyAppReady
196
328
  });
197
329
  await vi.runOnlyPendingTimersAsync();
198
- expect(sendAnalyticsEvent).toHaveBeenCalledTimes(1);
199
- expect(sendAnalyticsEvent).toHaveBeenCalledWith({
330
+ expect(sendInsightsEvent).toHaveBeenCalledTimes(1);
331
+ expect(sendInsightsEvent).toHaveBeenCalledWith({
200
332
  appVersion: "1.0.0",
201
333
  channel: "production",
202
334
  cohort: "123",
@@ -220,26 +352,26 @@ describe("automatic notifyAppReady analytics", () => {
220
352
  status: "UNCHANGED"
221
353
  });
222
354
  });
223
- it("skips automatic analytics when disabled while preserving readiness", async () => {
355
+ it("skips automatic insights when disabled while preserving readiness", async () => {
224
356
  stubNotifyFrame();
225
357
  const {
226
358
  client,
227
- sendAnalyticsEvent
359
+ sendInsightsEvent
228
360
  } = createClient();
229
361
  const onNotifyAppReady = vi.fn();
230
362
  const {
231
363
  init
232
364
  } = await import("./wrap");
233
365
  init({
234
- analytics: false,
366
+ insights: false,
235
367
  client,
236
368
  onNotifyAppReady
237
369
  });
238
370
  await vi.runOnlyPendingTimersAsync();
239
- expect(sendAnalyticsEvent).not.toHaveBeenCalled();
371
+ expect(sendInsightsEvent).not.toHaveBeenCalled();
240
372
  expect(onNotifyAppReady).toHaveBeenCalledWith({
241
373
  status: "UNCHANGED"
242
374
  });
243
375
  });
244
376
  });
245
- //# sourceMappingURL=notifyAppReadyAnalytics.spec.js.map
377
+ //# sourceMappingURL=notifyAppReadyInsights.spec.js.map