@hot-updater/server 1.0.0-rc.16 → 1.0.0-rc.18

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 (309) hide show
  1. package/dist/adapters/drizzle.cjs +5 -5
  2. package/dist/adapters/drizzle.mjs +4 -4
  3. package/dist/adapters/kysely.cjs +3 -3
  4. package/dist/adapters/kysely.mjs +2 -2
  5. package/dist/adapters/mongodb.cjs +3 -3
  6. package/dist/adapters/mongodb.mjs +2 -2
  7. package/dist/adapters/mongodbAdapter.cjs +19 -1
  8. package/dist/adapters/mongodbAdapter.mjs +19 -1
  9. package/dist/adapters/prisma.cjs +5 -5
  10. package/dist/adapters/prisma.mjs +4 -4
  11. package/dist/assembly/assemblePlugins.cjs +47 -28
  12. package/dist/assembly/assemblePlugins.d.cts +3 -7
  13. package/dist/assembly/assemblePlugins.d.mts +3 -7
  14. package/dist/assembly/assemblePlugins.mjs +46 -27
  15. package/dist/assembly/clientPlugins.cjs +86 -0
  16. package/dist/assembly/clientPlugins.d.cts +16 -0
  17. package/dist/assembly/clientPlugins.d.mts +16 -0
  18. package/dist/assembly/clientPlugins.mjs +86 -0
  19. package/dist/assembly/configError.cjs +7 -0
  20. package/dist/assembly/configError.d.cts +7 -0
  21. package/dist/assembly/configError.d.mts +7 -0
  22. package/dist/assembly/configError.mjs +7 -0
  23. package/dist/assembly/databasePlugins.cjs +5 -1
  24. package/dist/assembly/databasePlugins.d.cts +5 -5
  25. package/dist/assembly/databasePlugins.d.mts +5 -5
  26. package/dist/assembly/databasePlugins.mjs +5 -1
  27. package/dist/assembly/pluginCli.cjs +125 -0
  28. package/dist/assembly/pluginCli.d.cts +59 -0
  29. package/dist/assembly/pluginCli.d.mts +59 -0
  30. package/dist/assembly/pluginCli.mjs +121 -0
  31. package/dist/createHotUpdaterCore.cjs +14 -16
  32. package/dist/createHotUpdaterCore.d.cts +10 -3
  33. package/dist/createHotUpdaterCore.d.mts +10 -3
  34. package/dist/createHotUpdaterCore.mjs +11 -13
  35. package/dist/database/aggregateBatching.cjs +626 -0
  36. package/dist/database/aggregateBatching.d.cts +10 -0
  37. package/dist/database/aggregateBatching.d.mts +10 -0
  38. package/dist/database/aggregateBatching.mjs +625 -0
  39. package/dist/{insights/errors.cjs → database/busy.cjs} +2 -15
  40. package/dist/database/busy.d.cts +12 -0
  41. package/dist/database/busy.d.mts +12 -0
  42. package/dist/{insights/errors.mjs → database/busy.mjs} +3 -14
  43. package/dist/database/database.cjs +22 -3
  44. package/dist/database/database.d.cts +15 -2
  45. package/dist/database/database.d.mts +15 -2
  46. package/dist/database/database.mjs +22 -3
  47. package/dist/database/definitions.d.cts +10 -0
  48. package/dist/database/definitions.d.mts +10 -0
  49. package/dist/database/engine.d.cts +2 -1
  50. package/dist/database/engine.d.mts +2 -1
  51. package/dist/database/engineAggregates.cjs +7 -4
  52. package/dist/database/engineAggregates.mjs +8 -5
  53. package/dist/database/engineReads.cjs +5 -3
  54. package/dist/database/engineReads.mjs +6 -4
  55. package/dist/database/engineTransaction.cjs +2 -6
  56. package/dist/database/engineTransaction.mjs +2 -6
  57. package/dist/database/fence.cjs +2 -1
  58. package/dist/database/fence.mjs +2 -1
  59. package/dist/database/index.cjs +17 -8
  60. package/dist/database/index.d.cts +5 -4
  61. package/dist/database/index.d.mts +5 -4
  62. package/dist/database/index.mjs +6 -5
  63. package/dist/database/kv/kvAdapter.cjs +15 -3
  64. package/dist/database/kv/kvAdapter.d.cts +8 -0
  65. package/dist/database/kv/kvAdapter.d.mts +8 -0
  66. package/dist/database/kv/kvAdapter.mjs +16 -4
  67. package/dist/database/resolveSchema.cjs +4 -1
  68. package/dist/database/resolveSchema.d.cts +1 -1
  69. package/dist/database/resolveSchema.d.mts +1 -1
  70. package/dist/database/resolveSchema.mjs +4 -1
  71. package/dist/database/retention.cjs +92 -0
  72. package/dist/database/retention.mjs +90 -0
  73. package/dist/database/schema.cjs +5 -2
  74. package/dist/database/schema.d.cts +30 -1
  75. package/dist/database/schema.d.mts +30 -1
  76. package/dist/database/schema.mjs +5 -2
  77. package/dist/database/sql/sqlAdapter.cjs +8 -0
  78. package/dist/database/sql/sqlAdapter.mjs +9 -1
  79. package/dist/database/sql/sqlSchema.cjs +56 -0
  80. package/dist/database/sql/sqlSchema.mjs +55 -1
  81. package/dist/db/coreDatabase.cjs +85 -0
  82. package/dist/db/coreDatabase.d.cts +57 -0
  83. package/dist/db/coreDatabase.d.mts +57 -0
  84. package/dist/db/coreDatabase.mjs +78 -0
  85. package/dist/db/index.cjs +11 -3
  86. package/dist/db/index.d.cts +7 -3
  87. package/dist/db/index.d.mts +7 -3
  88. package/dist/db/index.mjs +6 -3
  89. package/dist/db/types.d.cts +3 -3
  90. package/dist/db/types.d.mts +3 -3
  91. package/dist/diff.cjs +3 -0
  92. package/dist/diff.d.cts +2 -0
  93. package/dist/diff.d.mts +2 -0
  94. package/dist/diff.mjs +2 -0
  95. package/dist/handler.cjs +2 -14
  96. package/dist/handler.mjs +1 -13
  97. package/dist/handlerReleaseCatalogRoutes.cjs +21 -2
  98. package/dist/handlerReleaseCatalogRoutes.mjs +21 -2
  99. package/dist/index.cjs +2 -6
  100. package/dist/index.d.cts +4 -7
  101. package/dist/index.d.mts +4 -7
  102. package/dist/index.mjs +2 -4
  103. package/dist/package.cjs +1 -1
  104. package/dist/package.mjs +1 -1
  105. package/dist/{apiKeys.cjs → plugins/api-keys/apiKeys.cjs} +1 -1
  106. package/dist/{apiKeys.d.cts → plugins/api-keys/apiKeys.d.cts} +2 -2
  107. package/dist/{apiKeys.d.mts → plugins/api-keys/apiKeys.d.mts} +2 -2
  108. package/dist/{apiKeys.mjs → plugins/api-keys/apiKeys.mjs} +1 -1
  109. package/dist/plugins/api-keys/cli.cjs +115 -0
  110. package/dist/plugins/api-keys/cli.mjs +114 -0
  111. package/dist/plugins/api-keys/index.cjs +9 -6
  112. package/dist/plugins/api-keys/index.d.cts +4 -5
  113. package/dist/plugins/api-keys/index.d.mts +4 -5
  114. package/dist/plugins/api-keys/index.mjs +9 -7
  115. package/dist/plugins/api-keys/model.d.cts +20 -2
  116. package/dist/plugins/api-keys/model.d.mts +20 -2
  117. package/dist/plugins/definePlugin.cjs +1 -1
  118. package/dist/plugins/definePlugin.d.cts +130 -3
  119. package/dist/plugins/definePlugin.d.mts +130 -3
  120. package/dist/plugins/definePlugin.mjs +1 -1
  121. package/dist/plugins/index.cjs +25 -4
  122. package/dist/plugins/index.d.cts +7 -4
  123. package/dist/plugins/index.d.mts +7 -4
  124. package/dist/plugins/index.mjs +6 -4
  125. package/dist/plugins/insights/contract.cjs +193 -0
  126. package/dist/plugins/insights/contract.mjs +189 -0
  127. package/dist/{insights → plugins/insights}/domain.d.cts +60 -15
  128. package/dist/{insights → plugins/insights}/domain.d.mts +60 -15
  129. package/dist/plugins/insights/errors.cjs +15 -0
  130. package/dist/plugins/insights/errors.mjs +14 -0
  131. package/dist/{insights → plugins/insights}/eventInput.cjs +155 -22
  132. package/dist/{insights → plugins/insights}/eventInput.mjs +155 -22
  133. package/dist/plugins/insights/eventRow.cjs +49 -0
  134. package/dist/plugins/insights/eventRow.d.cts +64 -0
  135. package/dist/plugins/insights/eventRow.d.mts +64 -0
  136. package/dist/plugins/insights/eventRow.mjs +47 -0
  137. package/dist/plugins/insights/index.cjs +106 -26
  138. package/dist/plugins/insights/index.d.cts +130 -27
  139. package/dist/plugins/insights/index.d.mts +130 -27
  140. package/dist/plugins/insights/index.mjs +106 -29
  141. package/dist/plugins/insights/model.cjs +2 -2
  142. package/dist/plugins/insights/model.d.cts +1 -1
  143. package/dist/plugins/insights/model.d.mts +1 -1
  144. package/dist/plugins/insights/model.mjs +1 -1
  145. package/dist/plugins/insights/modelTypes.d.cts +176 -0
  146. package/dist/plugins/insights/modelTypes.d.mts +176 -0
  147. package/dist/plugins/insights/overview.cjs +109 -0
  148. package/dist/plugins/insights/overview.d.cts +15 -0
  149. package/dist/plugins/insights/overview.d.mts +15 -0
  150. package/dist/plugins/insights/overview.mjs +107 -0
  151. package/dist/{insights → plugins/insights}/provider.cjs +33 -14
  152. package/dist/{insights → plugins/insights}/provider.d.cts +2 -2
  153. package/dist/{insights → plugins/insights}/provider.d.mts +2 -2
  154. package/dist/{insights → plugins/insights}/provider.mjs +30 -11
  155. package/dist/{insights → plugins/insights}/queryInput.cjs +2 -2
  156. package/dist/{insights → plugins/insights}/queryInput.mjs +2 -2
  157. package/dist/plugins/insights/reads.cjs +298 -88
  158. package/dist/plugins/insights/reads.d.cts +61 -0
  159. package/dist/plugins/insights/reads.d.mts +61 -0
  160. package/dist/plugins/insights/reads.mjs +298 -90
  161. package/dist/plugins/insights/recordEvent.cjs +223 -39
  162. package/dist/plugins/insights/recordEvent.d.cts +9 -4
  163. package/dist/plugins/insights/recordEvent.d.mts +9 -4
  164. package/dist/plugins/insights/recordEvent.mjs +221 -37
  165. package/dist/{insights → plugins/insights}/routes.cjs +3 -30
  166. package/dist/{insights → plugins/insights}/routes.mjs +4 -28
  167. package/dist/plugins/insights/schema.cjs +182 -40
  168. package/dist/plugins/insights/schema.d.cts +446 -6
  169. package/dist/plugins/insights/schema.d.mts +446 -6
  170. package/dist/plugins/insights/schema.mjs +180 -41
  171. package/dist/plugins/insights/testing/eventRow.d.mts +64 -0
  172. package/dist/plugins/insights/testing/expectInsightsIndex.mjs +18 -0
  173. package/dist/plugins/insights/testing/fixtures.d.mts +8 -0
  174. package/dist/plugins/insights/testing/fixtures.mjs +25 -0
  175. package/dist/plugins/insights/testing/index.d.mts +24 -0
  176. package/dist/plugins/insights/testing/index.mjs +25 -0
  177. package/dist/plugins/insights/testing/insightsModelTests.mjs +714 -0
  178. package/dist/plugins/insights/testing/modelTypes.d.mts +176 -0
  179. package/dist/plugins/insights/testing/setupInsightsHttpTestSuite.d.mts +11 -0
  180. package/dist/plugins/insights/testing/setupInsightsHttpTestSuite.mjs +107 -0
  181. package/dist/plugins/insights/testing/setupInsightsModelTestSuite.d.mts +11 -0
  182. package/dist/plugins/insights/testing/setupInsightsModelTestSuite.mjs +31 -0
  183. package/dist/plugins/insights/testing/types.d.mts +26 -0
  184. package/dist/{insights → plugins/insights}/types.d.cts +3 -2
  185. package/dist/{insights → plugins/insights}/types.d.mts +3 -2
  186. package/package.json +18 -7
  187. package/src/adapters/drizzle.conformance.integration.spec.ts +2 -2
  188. package/src/adapters/drizzle.readBudgets.integration.spec.ts +6 -4
  189. package/src/adapters/drizzle.spec.ts +15 -7
  190. package/src/adapters/drizzle.ts +6 -6
  191. package/src/adapters/kysely.conformance.integration.spec.ts +2 -2
  192. package/src/adapters/kysely.readBudgets.integration.spec.ts +4 -2
  193. package/src/adapters/kysely.spec.ts +13 -9
  194. package/src/adapters/kysely.ts +2 -2
  195. package/src/adapters/mongodb.integration.spec.ts +98 -7
  196. package/src/adapters/mongodb.ts +2 -2
  197. package/src/adapters/mongodbAdapter.ts +14 -0
  198. package/src/adapters/prisma.conformance.integration.spec.ts +2 -2
  199. package/src/adapters/prisma.integration.spec.ts +16 -8
  200. package/src/adapters/prisma.readBudgets.integration.spec.ts +5 -2
  201. package/src/adapters/prisma.spec.ts +17 -9
  202. package/src/adapters/prisma.ts +6 -6
  203. package/src/adapters/prismaTestClients.ts +8 -1
  204. package/src/assembly/assemblePlugins.ts +73 -40
  205. package/src/assembly/assembly.spec.ts +63 -11
  206. package/src/assembly/assembly.types.spec.ts +50 -2
  207. package/src/assembly/clientPlugins.ts +113 -0
  208. package/src/assembly/configError.ts +4 -0
  209. package/src/assembly/databasePlugins.ts +11 -5
  210. package/src/assembly/pluginCli.spec.ts +254 -0
  211. package/src/assembly/pluginCli.ts +248 -0
  212. package/src/assembly/{builtInRoutes.spec.ts → pluginRoutes.spec.ts} +10 -37
  213. package/src/createHotUpdaterCore.ts +21 -17
  214. package/src/database/aggregateBatching.spec.ts +577 -0
  215. package/src/database/aggregateBatching.ts +803 -0
  216. package/src/{insights/errors.spec.ts → database/busy.spec.ts} +2 -5
  217. package/src/{insights/errors.ts → database/busy.ts} +1 -13
  218. package/src/database/database.ts +39 -8
  219. package/src/database/definitions.ts +4 -0
  220. package/src/database/engineAggregates.spec.ts +4 -7
  221. package/src/database/engineAggregates.ts +5 -9
  222. package/src/database/engineReads.ts +7 -5
  223. package/src/database/engineTransaction.ts +1 -7
  224. package/src/database/fence.spec.ts +5 -5
  225. package/src/database/fence.ts +4 -0
  226. package/src/database/index.ts +13 -7
  227. package/src/database/kv/kvAdapter.batching.integration.spec.ts +15 -0
  228. package/src/database/kv/kvAdapter.conformance.integration.spec.ts +2 -0
  229. package/src/database/kv/kvAdapter.spec.ts +128 -1
  230. package/src/database/kv/kvAdapter.ts +30 -1
  231. package/src/database/kv/kvTestStore.ts +28 -1
  232. package/src/database/resolveSchema.ts +4 -1
  233. package/src/database/retention.spec.ts +314 -0
  234. package/src/database/retention.ts +129 -0
  235. package/src/database/schema.ts +44 -0
  236. package/src/database/sql/sqlAdapter.integration.spec.ts +4 -7
  237. package/src/database/sql/sqlAdapter.readBudgets.integration.spec.ts +18 -4
  238. package/src/database/sql/sqlAdapter.spec.ts +91 -3
  239. package/src/database/sql/sqlAdapter.ts +20 -0
  240. package/src/database/sql/sqlSchema.ts +81 -0
  241. package/src/databaseTestSuite.spec.ts +9 -4
  242. package/src/db/coreDatabase.ts +153 -0
  243. package/src/db/engineSql.spec.ts +8 -7
  244. package/src/db/index.ts +19 -2
  245. package/src/db/pluginTables.spec.ts +57 -27
  246. package/src/db/types.ts +3 -3
  247. package/src/diff.ts +6 -0
  248. package/src/handler-standalone.integration.spec.ts +2 -3
  249. package/src/handler.ts +1 -32
  250. package/src/handlerReleaseCatalogRoutes.ts +26 -2
  251. package/src/index.ts +0 -10
  252. package/src/{apiKeys.integration.spec.ts → plugins/api-keys/apiKeys.integration.spec.ts} +4 -4
  253. package/src/{apiKeys.spec.ts → plugins/api-keys/apiKeys.spec.ts} +3 -3
  254. package/src/{apiKeys.ts → plugins/api-keys/apiKeys.ts} +1 -1
  255. package/src/plugins/api-keys/apiKeysPlugin.spec.ts +11 -15
  256. package/src/plugins/api-keys/cli.spec.ts +187 -0
  257. package/src/plugins/api-keys/cli.ts +140 -0
  258. package/src/plugins/api-keys/index.ts +48 -41
  259. package/src/plugins/api-keys/model.ts +21 -2
  260. package/src/plugins/definePlugin.ts +144 -2
  261. package/src/plugins/index.ts +20 -2
  262. package/src/plugins/insights/contract.spec.ts +285 -0
  263. package/src/plugins/insights/contract.ts +372 -0
  264. package/src/{insights → plugins/insights}/domain.ts +73 -15
  265. package/src/plugins/insights/errors.ts +11 -0
  266. package/src/{insights → plugins/insights}/eventInput.ts +189 -29
  267. package/src/plugins/insights/eventRow.ts +209 -0
  268. package/src/plugins/insights/index.ts +181 -45
  269. package/src/{insights → plugins/insights}/insights.integration.spec.ts +330 -34
  270. package/src/plugins/insights/insightsRollout.integration.spec.ts +1 -2
  271. package/src/plugins/insights/model.spec.ts +3 -5
  272. package/src/plugins/insights/model.ts +2 -3
  273. package/src/plugins/insights/modelTypes.ts +197 -0
  274. package/src/plugins/insights/overview.spec.ts +64 -0
  275. package/src/plugins/insights/overview.ts +214 -0
  276. package/src/{insights → plugins/insights}/provider.spec.ts +21 -10
  277. package/src/{insights → plugins/insights}/provider.ts +58 -21
  278. package/src/{insights → plugins/insights}/queryInput.ts +2 -2
  279. package/src/plugins/insights/reads.spec.ts +340 -52
  280. package/src/plugins/insights/reads.ts +453 -123
  281. package/src/plugins/insights/recordEvent.spec.ts +474 -20
  282. package/src/plugins/insights/recordEvent.ts +301 -63
  283. package/src/plugins/insights/retention.spec.ts +115 -0
  284. package/src/{insights → plugins/insights}/routes.ts +1 -31
  285. package/src/plugins/insights/schema.ts +356 -176
  286. package/src/plugins/insights/testing/expectInsightsIndex.spec.ts +42 -0
  287. package/src/plugins/insights/testing/expectInsightsIndex.ts +20 -0
  288. package/src/plugins/insights/testing/fixtures.ts +30 -0
  289. package/src/plugins/insights/testing/index.ts +45 -0
  290. package/src/plugins/insights/testing/insightsModelTests.ts +860 -0
  291. package/src/plugins/insights/testing/setupInsightsHttpTestSuite.ts +152 -0
  292. package/src/plugins/insights/testing/setupInsightsModelTestSuite.ts +36 -0
  293. package/src/plugins/insights/testing/types.ts +30 -0
  294. package/src/{insights → plugins/insights}/types.ts +1 -1
  295. package/src/readBudgets.testFixtures.ts +2 -2
  296. package/src/releaseCatalogRoutes.integration.spec.ts +7 -0
  297. package/src/retention.spec.ts +73 -0
  298. package/src/runtime.spec.ts +11 -12
  299. package/src/runtime.testFixtures.ts +7 -2
  300. package/src/testUtilsMutation.integration.spec.ts +2 -1
  301. package/src/testUtilsPackage.integration.spec.ts +7 -3
  302. package/dist/db/builtInDatabase.cjs +0 -104
  303. package/dist/db/builtInDatabase.d.cts +0 -38
  304. package/dist/db/builtInDatabase.d.mts +0 -38
  305. package/dist/db/builtInDatabase.mjs +0 -97
  306. package/dist/plugins/builtIn.cjs +0 -7
  307. package/dist/plugins/builtIn.mjs +0 -6
  308. package/src/db/builtInDatabase.ts +0 -149
  309. package/src/plugins/builtIn.ts +0 -5
@@ -1,4 +1,4 @@
1
- require("../../insights/provider.cjs");
1
+ require("./provider.cjs");
2
2
  const require_schema = require("./schema.cjs");
3
3
  const require_recordEvent = require("./recordEvent.cjs");
4
4
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
@@ -185,29 +185,14 @@ const latestPredicates = (bundle) => {
185
185
  type
186
186
  }]))).values()];
187
187
  };
188
- /** Heads whose latest event falls in [sinceMs, end), a partial hour: those events' installs, then their heads. */
189
- const countPartialHeads = async (db, input, predicates, end) => {
190
- const events = await drain((page) => db.findMany("bundle_events", {
191
- index: "recent",
192
- where: {
193
- channel: input.channel,
194
- platform: input.platform,
195
- day: dayFloor(input.sinceMs)
196
- },
197
- range: {
198
- gte: input.sinceMs,
199
- lt: end
200
- },
201
- limit: PAGE,
202
- ...page
203
- }));
204
- const ids = new Set(events.map(({ id }) => id));
205
- return (await Promise.all([...new Set(events.map(({ install_id }) => install_id))].map((install) => db.findOne("bundle_event_heads", { install_id: install })))).filter((head) => head !== null && ids.has(head.id) && (predicates === void 0 || predicates.some(({ field, value, type }) => head[field] === value && head.type === type))).length;
206
- };
207
- /** Latest events at or after `sinceMs`: whole hours from gauges, the first partial hour from heads. */
188
+ /**
189
+ * Latest events at or after `sinceMs`, a UTC day's start: the gauges count
190
+ * each installation in the UTC day of its latest event, so they answer whole
191
+ * days only, and a later start is rejected rather than rounded.
192
+ */
208
193
  const countLatestEvents = async (db, input) => {
209
- const { platform, channel, sinceMs } = input;
210
- const start = hourCeil(sinceMs);
194
+ const { platform, channel, sinceMs: start } = input;
195
+ if (start % 864e5 !== 0) throw new _hot_updater_plugin_core.DatabasePluginInputError("invalid-query");
211
196
  const predicates = latestPredicates(input.bundle);
212
197
  let total = 0;
213
198
  if (predicates === void 0) {
@@ -247,12 +232,34 @@ const countLatestEvents = async (db, input) => {
247
232
  }
248
233
  }
249
234
  }
250
- return sinceMs < start ? total + await countPartialHeads(db, input, predicates, start) : total;
235
+ return Math.max(0, total);
251
236
  };
252
- /** Periods covering [start, end): whole UTC days when `days` and the window is over 48 hours, hours elsewhere. */
253
- const periodsOf = (range, days) => {
254
- const { start, end } = range;
255
- if (!days || end - start <= 1728e5) return [{
237
+ /** The oldest whole hour and UTC day that hourly and daily rows still hold. */
238
+ const retained = (now, { rawDays, dailyDays }) => ({
239
+ hour: hourCeil(now - rawDays * require_schema.DAY_MS),
240
+ day: dayCeil(now - dailyDays * require_schema.DAY_MS)
241
+ });
242
+ /**
243
+ * Whether the rows a window reads still hold all of it; an older start is
244
+ * partial from `oldest`, the first bucket its rows keep.
245
+ */
246
+ const coverageOf = (start, oldest) => start === void 0 || start >= oldest ? {
247
+ kind: "complete",
248
+ sinceMs: 0
249
+ } : {
250
+ kind: "partial",
251
+ sinceMs: oldest
252
+ };
253
+ /**
254
+ * Periods covering [start, end): whole UTC days when `days` and the window is
255
+ * over 48 hours, hours elsewhere. Hourly rows start at `hour`, the raw
256
+ * period ago, so with `days` an edge older than that reads its whole UTC day
257
+ * from the daily rows.
258
+ */
259
+ const periodsOf = (range, days, hour) => {
260
+ const start = days && range.start < hour ? dayFloor(range.start) : range.start;
261
+ const end = days && range.end < hour ? dayCeil(range.end) : range.end;
262
+ if (!days || end - start <= 1728e5 && start >= hour) return [{
256
263
  periodKind: "hour",
257
264
  start,
258
265
  end
@@ -277,15 +284,24 @@ const periodsOf = (range, days) => {
277
284
  }
278
285
  ].filter((period) => period.start < period.end);
279
286
  };
280
- /** Every overview or sketch row of one identity over [start, end), mixing day and hour periods. */
281
- const windowRows = async (db, model, parts, range, days) => {
287
+ /** The hourly and daily aggregates of counters, and of sketches. */
288
+ const COUNTERS = {
289
+ hour: "insights_overview",
290
+ day: "insights_overview_daily"
291
+ };
292
+ const SKETCHES = {
293
+ hour: "insights_sketches",
294
+ day: "insights_sketches_daily"
295
+ };
296
+ /** Every counter or sketch row of one identity over [start, end), mixing day and hour periods. */
297
+ const windowRows = async (db, models, parts, range, days, hour) => {
282
298
  const rows = [];
283
- for (const period of periodsOf(range, days)) {
299
+ for (const period of periodsOf(range, days, hour)) {
284
300
  const identity = require_recordEvent.insightsIdentity({
285
301
  ...parts,
286
302
  periodKind: period.periodKind
287
303
  });
288
- rows.push(...await drain((page) => db.findAggregates(model, {
304
+ rows.push(...await drain((page) => db.findAggregates(models[period.periodKind], {
289
305
  index: "window",
290
306
  where: { identity },
291
307
  range: {
@@ -298,8 +314,8 @@ const windowRows = async (db, model, parts, range, days) => {
298
314
  }
299
315
  return rows;
300
316
  };
301
- const counterRows = (...args) => windowRows(args[0], "insights_overview", args[1], args[2], args[3]);
302
- const sketchRows = (...args) => windowRows(args[0], "insights_sketches", args[1], args[2], args[3]);
317
+ const counterRows = (...[db, ...args]) => windowRows(db, COUNTERS, ...args);
318
+ const sketchRows = (...[db, ...args]) => windowRows(db, SKETCHES, ...args);
303
319
  const releaseParts = (release) => ({
304
320
  scopeKind: "release",
305
321
  releaseKind: "specific",
@@ -315,7 +331,7 @@ const lifetimeMetrics = async (db, release) => {
315
331
  ...releaseParts(release),
316
332
  periodKind: "lifetime"
317
333
  });
318
- const [lifetime] = (await db.findAggregates("insights_overview", {
334
+ const [lifetime] = (await db.findAggregates("insights_overview_lifetime", {
319
335
  index: "window",
320
336
  where: { identity },
321
337
  range: {
@@ -331,8 +347,8 @@ const lifetimeMetrics = async (db, release) => {
331
347
  };
332
348
  };
333
349
  /** Counters, unique users, and a per-UTC-day series over a window. */
334
- const rangedMetrics = async (db, parts, range, days) => {
335
- const [counters, sketches] = await Promise.all([counterRows(db, parts, range, days), sketchRows(db, parts, range, days)]);
350
+ const rangedMetrics = async (db, parts, users, range, days, hour) => {
351
+ const [counters, sketches] = await Promise.all([counterRows(db, parts, range, days, hour), sketchRows(db, users.parts, range, days, hour)]);
336
352
  const series = /* @__PURE__ */ new Map();
337
353
  for (const row of counters) {
338
354
  const day = dayFloor(row.bucket_start_ms);
@@ -349,63 +365,81 @@ const rangedMetrics = async (db, parts, range, days) => {
349
365
  downloads: total("downloads"),
350
366
  launches: total("launches"),
351
367
  failedLaunches: total("failed_launches"),
352
- uniqueUsers: (0, _hot_updater_plugin_core_internal.countInsightsDistinct)((0, _hot_updater_plugin_core_internal.mergeInsightsDistinct)(sketches.map((row) => row.launch_users))),
368
+ uniqueUsers: (0, _hot_updater_plugin_core_internal.countDistinct)((0, _hot_updater_plugin_core_internal.mergeDistinct)(sketches.map((row) => row[users.field]))),
353
369
  series: [...series].sort(([left], [right]) => left - right).map(([startMs, point]) => ({
354
370
  startMs,
355
371
  ...point
356
372
  }))
357
373
  };
358
374
  };
359
- const getReleaseActivity = async (db, input, now) => {
375
+ /** A channel and platform's usage rows, of every app version or of one. */
376
+ const usageParts = (channel, platform, appVersion) => ({
377
+ scopeKind: "usage",
378
+ releaseKind: "all",
379
+ releaseId: "",
380
+ channel,
381
+ platform,
382
+ appVersionKind: appVersion === void 0 ? "all" : "specific",
383
+ appVersion: appVersion ?? ""
384
+ });
385
+ const getReleaseActivity = async (db, input, now, retention) => {
386
+ const at = now();
387
+ const kept = retained(at, retention);
388
+ const data = input.scope !== void 0 ? [{
389
+ scope: input.scope,
390
+ metrics: await rangedMetrics(db, {
391
+ scopeKind: "channel",
392
+ releaseKind: "all",
393
+ releaseId: "",
394
+ channel: input.scope.channel,
395
+ platform: input.scope.platform,
396
+ appVersionKind: "all",
397
+ appVersion: ""
398
+ }, {
399
+ parts: usageParts(input.scope.channel, input.scope.platform),
400
+ field: "activity_users"
401
+ }, input.timeRange, true, kept.hour)
402
+ }] : await Promise.all(input.releases.map(async (release) => ({
403
+ release,
404
+ metrics: input.timeRange === void 0 ? await lifetimeMetrics(db, release) : await rangedMetrics(db, releaseParts(release), {
405
+ parts: releaseParts(release),
406
+ field: "launch_users"
407
+ }, input.timeRange, false, kept.hour)
408
+ })));
409
+ const oldest = kept[input.scope === void 0 ? "hour" : "day"];
360
410
  return {
361
- coverage: {
362
- kind: "complete",
363
- sinceMs: 0
364
- },
365
- data: input.scope !== void 0 ? [{
366
- scope: input.scope,
367
- metrics: await rangedMetrics(db, {
368
- scopeKind: "channel",
369
- releaseKind: "all",
370
- releaseId: "",
371
- channel: input.scope.channel,
372
- platform: input.scope.platform,
373
- appVersionKind: "all",
374
- appVersion: ""
375
- }, input.timeRange, true)
376
- }] : await Promise.all(input.releases.map(async (release) => ({
377
- release,
378
- metrics: input.timeRange === void 0 ? await lifetimeMetrics(db, release) : await rangedMetrics(db, releaseParts(release), input.timeRange, false)
379
- }))),
380
- measuredAtMs: now()
411
+ coverage: coverageOf(input.timeRange?.start, oldest),
412
+ data,
413
+ measuredAtMs: at
381
414
  };
382
415
  };
383
- const byInstallations = (values) => [...values].map(([name, installations]) => ({
416
+ /**
417
+ * Entries with installations, most first. Batched gauges sum signed shard
418
+ * rows, so a version or platform everyone left can read 0, and is left out.
419
+ */
420
+ const byInstallations = (values) => [...values].flatMap(([name, installations]) => installations > 0 ? [{
384
421
  name,
385
422
  installations
386
- })).sort((left, right) => right.installations - left.installations || left.name.localeCompare(right.name, "en", { numeric: true }));
387
- const getAppUsage = async (db, input, now) => {
423
+ }] : []).sort((left, right) => right.installations - left.installations || left.name.localeCompare(right.name, "en", { numeric: true }));
424
+ const getAppUsage = async (db, input, now, retention) => {
388
425
  const { timeRange, intervalMs } = input;
389
- const usage = await sketchRows(db, {
390
- scopeKind: "usage",
391
- releaseKind: "all",
392
- releaseId: "",
393
- channel: input.channel,
394
- platform: input.platform,
395
- appVersionKind: input.appVersion === void 0 ? "all" : "specific",
396
- appVersion: input.appVersion ?? ""
397
- }, timeRange, intervalMs % 864e5 === 0 && timeRange.start % 864e5 === 0);
426
+ const at = now();
427
+ const kept = retained(at, retention);
428
+ const days = intervalMs % 864e5 === 0 && timeRange.start % 864e5 === 0;
429
+ const reported = input.platform === "all" ? ["ios", "android"] : [input.platform];
430
+ const usage = (await Promise.all(reported.map((platform) => sketchRows(db, usageParts(input.channel, platform, input.appVersion), timeRange, days, kept.hour)))).flat();
431
+ const range = {
432
+ gte: dayFloor(timeRange.start),
433
+ lt: timeRange.end
434
+ };
398
435
  const distribution = [];
399
- for (const platform of input.platform === "all" ? ["ios", "android"] : [input.platform]) distribution.push(...await drain((page) => input.appVersion === void 0 ? db.findAggregates("insights_distribution", {
436
+ for (const platform of reported) distribution.push(...await drain((page) => input.appVersion === void 0 ? db.findAggregates("insights_distribution", {
400
437
  index: "byScope",
401
438
  where: {
402
439
  channel: input.channel,
403
440
  platform
404
441
  },
405
- range: {
406
- gte: timeRange.start,
407
- lt: timeRange.end
408
- },
442
+ range,
409
443
  limit: PAGE,
410
444
  ...page
411
445
  }) : db.findAggregates("insights_distribution", {
@@ -415,17 +449,14 @@ const getAppUsage = async (db, input, now) => {
415
449
  platform,
416
450
  app_version: input.appVersion
417
451
  },
418
- range: {
419
- gte: timeRange.start,
420
- lt: timeRange.end
421
- },
452
+ range,
422
453
  limit: PAGE,
423
454
  ...page
424
455
  })));
425
456
  const points = [];
426
457
  for (let start = timeRange.start; start < timeRange.end; start += intervalMs) points.push({
427
458
  startMs: start,
428
- installations: (0, _hot_updater_plugin_core_internal.countInsightsDistinct)((0, _hot_updater_plugin_core_internal.mergeInsightsDistinct)(usage.filter((row) => row.bucket_start_ms >= start && row.bucket_start_ms < start + intervalMs).map((row) => row.activity_users)))
459
+ installations: (0, _hot_updater_plugin_core_internal.countDistinct)((0, _hot_updater_plugin_core_internal.mergeDistinct)(usage.filter((row) => row.bucket_start_ms >= start && row.bucket_start_ms < start + intervalMs).map((row) => row.activity_users)))
429
460
  });
430
461
  const versions = /* @__PURE__ */ new Map();
431
462
  const platforms = /* @__PURE__ */ new Map();
@@ -449,23 +480,202 @@ const getAppUsage = async (db, input, now) => {
449
480
  }
450
481
  const sortedVersions = byInstallations(versions);
451
482
  return {
452
- coverage: {
453
- kind: "complete",
454
- sinceMs: 0
455
- },
456
- activeInstallations: (0, _hot_updater_plugin_core_internal.countInsightsDistinct)((0, _hot_updater_plugin_core_internal.mergeInsightsDistinct)(usage.map((row) => row.activity_users))),
483
+ coverage: coverageOf(timeRange.start, kept[days ? "day" : "hour"]),
484
+ activeInstallations: (0, _hot_updater_plugin_core_internal.countDistinct)((0, _hot_updater_plugin_core_internal.mergeDistinct)(usage.map((row) => row.activity_users))),
457
485
  points,
458
486
  appVersions: sortedVersions.map(({ name }) => name),
459
487
  versions: sortedVersions,
460
488
  platforms: byInstallations(platforms),
461
- bundleDistribution: [...bundles.values()],
462
- measuredAtMs: now()
489
+ bundleDistribution: [...bundles.values()].filter(({ installations }) => installations > 0),
490
+ measuredAtMs: at
491
+ };
492
+ };
493
+ /** The longest period the failures read covers: the console's longest, 30 days. */
494
+ const UPDATE_FAILURES_RANGE_MS = 30 * require_schema.DAY_MS;
495
+ const isRange = (range) => range === void 0 || Number.isSafeInteger(range.start) && Number.isSafeInteger(range.end) && range.start >= 0 && range.start < range.end && range.end - range.start <= UPDATE_FAILURES_RANGE_MS;
496
+ const isText = (value, maxLength) => typeof value === "string" && value.length > 0 && value.length <= maxLength;
497
+ const failed = (...rows) => (0, _hot_updater_plugin_core_internal.countDistinct)((0, _hot_updater_plugin_core_internal.mergeDistinct)(rows.flat().map((row) => row.failed_users)));
498
+ /** Entries of a count map, most first, then in key order. */
499
+ const mostFirst = (counts) => [...counts].sort(([leftKey, left], [rightKey, right]) => right.events - left.events || (0, _hot_updater_plugin_core_internal.compareUtf8)(leftKey, rightKey)).map(([, entry]) => entry);
500
+ /** Failure rows as their breakdown, and recovery rows as exit reasons. */
501
+ const breakdownOf = (rows) => {
502
+ const failures = /* @__PURE__ */ new Map();
503
+ const exits = /* @__PURE__ */ new Map();
504
+ for (const { stage, reason, detail, events } of rows) {
505
+ if (events <= 0) continue;
506
+ if (stage === "launch") {
507
+ const exit = exits.get(reason) ?? {
508
+ value: reason,
509
+ events: 0
510
+ };
511
+ exit.events += events;
512
+ exits.set(reason, exit);
513
+ continue;
514
+ }
515
+ const key = JSON.stringify([stage, reason]);
516
+ const entry = failures.get(key) ?? {
517
+ value: {
518
+ stage,
519
+ reason
520
+ },
521
+ events: 0,
522
+ details: /* @__PURE__ */ new Map()
523
+ };
524
+ entry.events += events;
525
+ const known = entry.details.get(detail) ?? {
526
+ value: detail,
527
+ events: 0
528
+ };
529
+ known.events += events;
530
+ entry.details.set(detail, known);
531
+ failures.set(key, entry);
532
+ }
533
+ return {
534
+ breakdown: mostFirst(failures).map(({ value, events }) => {
535
+ const { details } = failures.get(JSON.stringify([value.stage, value.reason]));
536
+ return {
537
+ ...value,
538
+ events,
539
+ details: mostFirst(details).map(({ value: detail, events }) => {
540
+ const [resource, httpStatus, originCode, transport] = JSON.parse(detail);
541
+ return {
542
+ resource,
543
+ httpStatus,
544
+ originCode,
545
+ transport,
546
+ events
547
+ };
548
+ })
549
+ };
550
+ }),
551
+ byExitReason: mostFirst(exits).map(({ value, events }) => ({
552
+ exitReason: value,
553
+ events
554
+ }))
555
+ };
556
+ };
557
+ /**
558
+ * A release's or a channel's update failures. Since a release's first
559
+ * report: its lifetime counters and failed installations. Over a time range
560
+ * of at most 30 days: failures, failed checks, the breakdown by stage,
561
+ * reason, and detail, and recoveries by exit reason, all summed from the
562
+ * breakdown's hourly rows; downloads and failed launches from the counters;
563
+ * failed installations from their sketches. A release reads hourly rows, a
564
+ * channel daily rows past 48 hours like its activity; the breakdown's rows
565
+ * are hourly, so its coverage is the raw period's.
566
+ */
567
+ const getUpdateFailures = async (db, input, now, retention) => {
568
+ const { platform, channel, releaseId, timeRange } = input;
569
+ if (platform !== "ios" && platform !== "android" || !isText(channel, 1024) || releaseId !== void 0 && !isText(releaseId, 36) || !isRange(timeRange) || releaseId === void 0 && timeRange === void 0) throw new _hot_updater_plugin_core.DatabasePluginInputError("invalid-query");
570
+ const at = now();
571
+ const kept = retained(at, retention);
572
+ const channelParts = {
573
+ ...usageParts(channel, platform),
574
+ scopeKind: "channel"
575
+ };
576
+ const parts = releaseId === void 0 ? channelParts : releaseParts({
577
+ releaseId,
578
+ platform,
579
+ channel
580
+ });
581
+ const failure = {
582
+ ...parts,
583
+ scopeKind: "failure"
584
+ };
585
+ if (timeRange === void 0) {
586
+ const where = (from) => ({ identity: require_recordEvent.insightsIdentity({
587
+ ...from,
588
+ periodKind: "lifetime"
589
+ }) });
590
+ const [counters, sketches] = await Promise.all([db.findAggregates("insights_overview_lifetime", {
591
+ index: "window",
592
+ where: where(parts),
593
+ range: {
594
+ gte: 0,
595
+ lte: 0
596
+ },
597
+ limit: PAGE
598
+ }), db.findAggregates("insights_sketches_lifetime", {
599
+ index: "window",
600
+ where: where(failure),
601
+ range: {
602
+ gte: 0,
603
+ lte: 0
604
+ },
605
+ limit: PAGE
606
+ })]);
607
+ const lifetime = counters.rows[0];
608
+ return {
609
+ coverage: {
610
+ kind: "complete",
611
+ sinceMs: 0
612
+ },
613
+ measuredAtMs: at,
614
+ failedUpdates: lifetime?.failed_updates ?? 0,
615
+ failedInstallations: (0, _hot_updater_plugin_core_internal.countDistinct)((0, _hot_updater_plugin_core_internal.mergeDistinct)(sketches.rows.map((row) => row.failed_users))),
616
+ downloads: lifetime?.downloads ?? 0,
617
+ patchDownloads: lifetime?.patch_downloads ?? 0,
618
+ patchFallbacks: lifetime?.patch_fallbacks ?? 0
619
+ };
620
+ }
621
+ const days = releaseId === void 0;
622
+ const window = [
623
+ timeRange,
624
+ days,
625
+ kept.hour
626
+ ];
627
+ const [counters, failures, checks, active, rows] = await Promise.all([
628
+ counterRows(db, parts, ...window),
629
+ sketchRows(db, failure, ...window),
630
+ days ? sketchRows(db, {
631
+ ...channelParts,
632
+ scopeKind: "check"
633
+ }, ...window) : [],
634
+ days ? sketchRows(db, usageParts(channel, platform), ...window) : [],
635
+ drain((page) => db.findAggregates("insights_failures", {
636
+ index: "byScope",
637
+ where: {
638
+ platform,
639
+ channel
640
+ },
641
+ range: {
642
+ gte: timeRange.start,
643
+ lt: timeRange.end
644
+ },
645
+ limit: PAGE,
646
+ ...page
647
+ }))
648
+ ]);
649
+ const total = (field) => counters.reduce((sum, row) => sum + row[field], 0);
650
+ const scoped = releaseId === void 0 ? rows : rows.filter((row) => row.release_id === releaseId);
651
+ const failuresAt = (counted) => scoped.reduce((sum, row) => sum + (counted(row.stage) ? Math.max(0, row.events) : 0), 0);
652
+ const { breakdown, byExitReason } = breakdownOf(scoped);
653
+ return {
654
+ coverage: coverageOf(timeRange.start, kept.hour),
655
+ measuredAtMs: at,
656
+ failedUpdates: failuresAt((stage) => stage !== "check" && stage !== "launch"),
657
+ failedInstallations: failed(failures),
658
+ downloads: total("downloads"),
659
+ patchDownloads: total("patch_downloads"),
660
+ patchFallbacks: total("patch_fallbacks"),
661
+ ...days ? { checks: {
662
+ failures: failuresAt((stage) => stage === "check"),
663
+ failedInstallations: failed(checks),
664
+ activeInstallations: (0, _hot_updater_plugin_core_internal.countDistinct)((0, _hot_updater_plugin_core_internal.mergeDistinct)(active.map((row) => row.activity_users)))
665
+ } } : {},
666
+ breakdown,
667
+ recoveries: {
668
+ failedLaunches: total("failed_launches"),
669
+ byExitReason
670
+ }
463
671
  };
464
672
  };
465
673
  //#endregion
674
+ exports.UPDATE_FAILURES_RANGE_MS = UPDATE_FAILURES_RANGE_MS;
466
675
  exports.countEvents = countEvents;
467
676
  exports.countLatestEvents = countLatestEvents;
468
677
  exports.findLatestEvents = findLatestEvents;
469
678
  exports.getAppUsage = getAppUsage;
470
679
  exports.getReleaseActivity = getReleaseActivity;
680
+ exports.getUpdateFailures = getUpdateFailures;
471
681
  exports.listEvents = listEvents;
@@ -0,0 +1,61 @@
1
+ import "../../database/database.cjs";
2
+ import "./eventRow.cjs";
3
+ import { InsightsCoverage, InsightsTimeRange } from "./modelTypes.cjs";
4
+ import "./schema.cjs";
5
+ //#region src/plugins/insights/reads.d.ts
6
+ interface InsightsUpdateFailuresInput {
7
+ readonly platform: "ios" | "android";
8
+ readonly channel: string;
9
+ /** A release's failures; without it, the channel's, which need a time range. */
10
+ readonly releaseId?: string;
11
+ /** Without it, a release's failures since its first report. */
12
+ readonly timeRange?: InsightsTimeRange;
13
+ }
14
+ /** Update failures of one stage and reason, and what else their clients knew. */
15
+ interface InsightsFailureBreakdown {
16
+ readonly stage: string;
17
+ readonly reason: string;
18
+ readonly events: number;
19
+ /** By resource, HTTP status, origin code, and transport, most first. */
20
+ readonly details: readonly {
21
+ readonly resource: string | null;
22
+ readonly httpStatus: number | null;
23
+ readonly originCode: string | null;
24
+ readonly transport: string | null;
25
+ readonly events: number;
26
+ }[];
27
+ }
28
+ interface InsightsUpdateFailures {
29
+ readonly coverage: InsightsCoverage;
30
+ readonly measuredAtMs: number;
31
+ /** Update failures other than failed checks: each client reports one at most once a UTC day. */
32
+ readonly failedUpdates: number;
33
+ /** Installations with such a failure, estimated. */
34
+ readonly failedInstallations: number;
35
+ /** Download reports: each installation reports a bundle's download once. */
36
+ readonly downloads: number;
37
+ /** Downloads a patch delivered, and those that fell back from a patch to files or the archive. */
38
+ readonly patchDownloads: number;
39
+ readonly patchFallbacks: number;
40
+ /** A channel's failed update checks, installations with one, and its active installations, estimated. */
41
+ readonly checks?: {
42
+ readonly failures: number;
43
+ readonly failedInstallations: number;
44
+ readonly activeInstallations: number;
45
+ };
46
+ /** Over a time range: failures by stage and reason, most first. */
47
+ readonly breakdown?: readonly InsightsFailureBreakdown[];
48
+ /**
49
+ * Over a time range: failed launches, and the recoveries whose crashed
50
+ * process exited for a reason Android 11+ reported, by reason, most first.
51
+ */
52
+ readonly recoveries?: {
53
+ readonly failedLaunches: number;
54
+ readonly byExitReason: readonly {
55
+ readonly exitReason: string;
56
+ readonly events: number;
57
+ }[];
58
+ };
59
+ }
60
+ //#endregion
61
+ export { InsightsFailureBreakdown, InsightsUpdateFailures, InsightsUpdateFailuresInput };
@@ -0,0 +1,61 @@
1
+ import "../../database/database.mjs";
2
+ import "./eventRow.mjs";
3
+ import { InsightsCoverage, InsightsTimeRange } from "./modelTypes.mjs";
4
+ import "./schema.mjs";
5
+ //#region src/plugins/insights/reads.d.ts
6
+ interface InsightsUpdateFailuresInput {
7
+ readonly platform: "ios" | "android";
8
+ readonly channel: string;
9
+ /** A release's failures; without it, the channel's, which need a time range. */
10
+ readonly releaseId?: string;
11
+ /** Without it, a release's failures since its first report. */
12
+ readonly timeRange?: InsightsTimeRange;
13
+ }
14
+ /** Update failures of one stage and reason, and what else their clients knew. */
15
+ interface InsightsFailureBreakdown {
16
+ readonly stage: string;
17
+ readonly reason: string;
18
+ readonly events: number;
19
+ /** By resource, HTTP status, origin code, and transport, most first. */
20
+ readonly details: readonly {
21
+ readonly resource: string | null;
22
+ readonly httpStatus: number | null;
23
+ readonly originCode: string | null;
24
+ readonly transport: string | null;
25
+ readonly events: number;
26
+ }[];
27
+ }
28
+ interface InsightsUpdateFailures {
29
+ readonly coverage: InsightsCoverage;
30
+ readonly measuredAtMs: number;
31
+ /** Update failures other than failed checks: each client reports one at most once a UTC day. */
32
+ readonly failedUpdates: number;
33
+ /** Installations with such a failure, estimated. */
34
+ readonly failedInstallations: number;
35
+ /** Download reports: each installation reports a bundle's download once. */
36
+ readonly downloads: number;
37
+ /** Downloads a patch delivered, and those that fell back from a patch to files or the archive. */
38
+ readonly patchDownloads: number;
39
+ readonly patchFallbacks: number;
40
+ /** A channel's failed update checks, installations with one, and its active installations, estimated. */
41
+ readonly checks?: {
42
+ readonly failures: number;
43
+ readonly failedInstallations: number;
44
+ readonly activeInstallations: number;
45
+ };
46
+ /** Over a time range: failures by stage and reason, most first. */
47
+ readonly breakdown?: readonly InsightsFailureBreakdown[];
48
+ /**
49
+ * Over a time range: failed launches, and the recoveries whose crashed
50
+ * process exited for a reason Android 11+ reported, by reason, most first.
51
+ */
52
+ readonly recoveries?: {
53
+ readonly failedLaunches: number;
54
+ readonly byExitReason: readonly {
55
+ readonly exitReason: string;
56
+ readonly events: number;
57
+ }[];
58
+ };
59
+ }
60
+ //#endregion
61
+ export { InsightsFailureBreakdown, InsightsUpdateFailures, InsightsUpdateFailuresInput };