@hot-updater/cloudflare 1.0.0-rc.34 → 1.0.0-rc.36

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.
package/dist/index.d.cts CHANGED
@@ -69,6 +69,8 @@ type DatabaseBundleEventMetadata = DatabaseJsonObject & {
69
69
  readonly update_strategy: "fingerprint" | "appVersion" | null;
70
70
  readonly fingerprint_hash: string | null;
71
71
  readonly sdk_version: string | null;
72
+ /** The native build's built-in bundle ID, when the SDK reports it. */
73
+ readonly min_bundle_id?: string;
72
74
  /** `UPDATE_FAILED`: what failed. */
73
75
  readonly failure?: BundleEventFailure;
74
76
  readonly http_response?: DatabaseHttpResponse;
@@ -244,7 +246,10 @@ interface InsightsGetAppUsageResult {
244
246
  readonly bundleDistribution: readonly {
245
247
  readonly appVersion: string;
246
248
  readonly platform: "ios" | "android";
249
+ /** The release the installations run; null for none. */
247
250
  readonly releaseId: string | null;
251
+ /** The native build's built-in bundle, when they run it. */
252
+ readonly builtinBundleId: string | null;
248
253
  readonly installations: number;
249
254
  }[];
250
255
  readonly measuredAtMs: number;
@@ -575,6 +580,38 @@ declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPl
575
580
  readonly sort: readonly ["bucket_start_ms"];
576
581
  };
577
582
  }, never, readonly ["channel", "platform", "app_version", "release_id", "bucket_start_ms"]>;
583
+ readonly insights_builtin_distribution: import("@hot-updater/plugin-core").AggregateDefinition<{
584
+ readonly channel: {
585
+ readonly type: "string";
586
+ };
587
+ readonly platform: {
588
+ readonly type: "string";
589
+ readonly maxLength: 16;
590
+ };
591
+ readonly app_version: {
592
+ readonly type: "string";
593
+ };
594
+ readonly release_id: {
595
+ readonly type: "string";
596
+ readonly maxLength: 36;
597
+ };
598
+ readonly builtin_bundle_id: {
599
+ readonly type: "string";
600
+ readonly maxLength: 36;
601
+ };
602
+ readonly bucket_start_ms: {
603
+ readonly type: "integer";
604
+ };
605
+ }, "latest_installations", {
606
+ readonly byScope: {
607
+ readonly eq: readonly ["channel", "platform"];
608
+ readonly sort: readonly ["bucket_start_ms"];
609
+ };
610
+ readonly byVersion: {
611
+ readonly eq: readonly ["channel", "platform", "app_version"];
612
+ readonly sort: readonly ["bucket_start_ms"];
613
+ };
614
+ }, never, readonly ["channel", "platform", "app_version", "release_id", "builtin_bundle_id", "bucket_start_ms"]>;
578
615
  readonly insights_latest_by_bundle: import("@hot-updater/plugin-core").AggregateDefinition<{
579
616
  readonly platform: {
580
617
  readonly type: "string";
package/dist/index.d.mts CHANGED
@@ -69,6 +69,8 @@ type DatabaseBundleEventMetadata = DatabaseJsonObject & {
69
69
  readonly update_strategy: "fingerprint" | "appVersion" | null;
70
70
  readonly fingerprint_hash: string | null;
71
71
  readonly sdk_version: string | null;
72
+ /** The native build's built-in bundle ID, when the SDK reports it. */
73
+ readonly min_bundle_id?: string;
72
74
  /** `UPDATE_FAILED`: what failed. */
73
75
  readonly failure?: BundleEventFailure;
74
76
  readonly http_response?: DatabaseHttpResponse;
@@ -244,7 +246,10 @@ interface InsightsGetAppUsageResult {
244
246
  readonly bundleDistribution: readonly {
245
247
  readonly appVersion: string;
246
248
  readonly platform: "ios" | "android";
249
+ /** The release the installations run; null for none. */
247
250
  readonly releaseId: string | null;
251
+ /** The native build's built-in bundle, when they run it. */
252
+ readonly builtinBundleId: string | null;
248
253
  readonly installations: number;
249
254
  }[];
250
255
  readonly measuredAtMs: number;
@@ -575,6 +580,38 @@ declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPl
575
580
  readonly sort: readonly ["bucket_start_ms"];
576
581
  };
577
582
  }, never, readonly ["channel", "platform", "app_version", "release_id", "bucket_start_ms"]>;
583
+ readonly insights_builtin_distribution: import("@hot-updater/plugin-core").AggregateDefinition<{
584
+ readonly channel: {
585
+ readonly type: "string";
586
+ };
587
+ readonly platform: {
588
+ readonly type: "string";
589
+ readonly maxLength: 16;
590
+ };
591
+ readonly app_version: {
592
+ readonly type: "string";
593
+ };
594
+ readonly release_id: {
595
+ readonly type: "string";
596
+ readonly maxLength: 36;
597
+ };
598
+ readonly builtin_bundle_id: {
599
+ readonly type: "string";
600
+ readonly maxLength: 36;
601
+ };
602
+ readonly bucket_start_ms: {
603
+ readonly type: "integer";
604
+ };
605
+ }, "latest_installations", {
606
+ readonly byScope: {
607
+ readonly eq: readonly ["channel", "platform"];
608
+ readonly sort: readonly ["bucket_start_ms"];
609
+ };
610
+ readonly byVersion: {
611
+ readonly eq: readonly ["channel", "platform", "app_version"];
612
+ readonly sort: readonly ["bucket_start_ms"];
613
+ };
614
+ }, never, readonly ["channel", "platform", "app_version", "release_id", "builtin_bundle_id", "bucket_start_ms"]>;
578
615
  readonly insights_latest_by_bundle: import("@hot-updater/plugin-core").AggregateDefinition<{
579
616
  readonly platform: {
580
617
  readonly type: "string";
@@ -57,6 +57,8 @@ type DatabaseBundleEventMetadata = DatabaseJsonObject & {
57
57
  readonly update_strategy: "fingerprint" | "appVersion" | null;
58
58
  readonly fingerprint_hash: string | null;
59
59
  readonly sdk_version: string | null;
60
+ /** The native build's built-in bundle ID, when the SDK reports it. */
61
+ readonly min_bundle_id?: string;
60
62
  /** `UPDATE_FAILED`: what failed. */
61
63
  readonly failure?: BundleEventFailure;
62
64
  readonly http_response?: DatabaseHttpResponse;
@@ -232,7 +234,10 @@ interface InsightsGetAppUsageResult {
232
234
  readonly bundleDistribution: readonly {
233
235
  readonly appVersion: string;
234
236
  readonly platform: "ios" | "android";
237
+ /** The release the installations run; null for none. */
235
238
  readonly releaseId: string | null;
239
+ /** The native build's built-in bundle, when they run it. */
240
+ readonly builtinBundleId: string | null;
236
241
  readonly installations: number;
237
242
  }[];
238
243
  readonly measuredAtMs: number;
@@ -563,6 +568,38 @@ declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPl
563
568
  readonly sort: readonly ["bucket_start_ms"];
564
569
  };
565
570
  }, never, readonly ["channel", "platform", "app_version", "release_id", "bucket_start_ms"]>;
571
+ readonly insights_builtin_distribution: import("@hot-updater/plugin-core").AggregateDefinition<{
572
+ readonly channel: {
573
+ readonly type: "string";
574
+ };
575
+ readonly platform: {
576
+ readonly type: "string";
577
+ readonly maxLength: 16;
578
+ };
579
+ readonly app_version: {
580
+ readonly type: "string";
581
+ };
582
+ readonly release_id: {
583
+ readonly type: "string";
584
+ readonly maxLength: 36;
585
+ };
586
+ readonly builtin_bundle_id: {
587
+ readonly type: "string";
588
+ readonly maxLength: 36;
589
+ };
590
+ readonly bucket_start_ms: {
591
+ readonly type: "integer";
592
+ };
593
+ }, "latest_installations", {
594
+ readonly byScope: {
595
+ readonly eq: readonly ["channel", "platform"];
596
+ readonly sort: readonly ["bucket_start_ms"];
597
+ };
598
+ readonly byVersion: {
599
+ readonly eq: readonly ["channel", "platform", "app_version"];
600
+ readonly sort: readonly ["bucket_start_ms"];
601
+ };
602
+ }, never, readonly ["channel", "platform", "app_version", "release_id", "builtin_bundle_id", "bucket_start_ms"]>;
566
603
  readonly insights_latest_by_bundle: import("@hot-updater/plugin-core").AggregateDefinition<{
567
604
  readonly platform: {
568
605
  readonly type: "string";
@@ -57,6 +57,8 @@ type DatabaseBundleEventMetadata = DatabaseJsonObject & {
57
57
  readonly update_strategy: "fingerprint" | "appVersion" | null;
58
58
  readonly fingerprint_hash: string | null;
59
59
  readonly sdk_version: string | null;
60
+ /** The native build's built-in bundle ID, when the SDK reports it. */
61
+ readonly min_bundle_id?: string;
60
62
  /** `UPDATE_FAILED`: what failed. */
61
63
  readonly failure?: BundleEventFailure;
62
64
  readonly http_response?: DatabaseHttpResponse;
@@ -232,7 +234,10 @@ interface InsightsGetAppUsageResult {
232
234
  readonly bundleDistribution: readonly {
233
235
  readonly appVersion: string;
234
236
  readonly platform: "ios" | "android";
237
+ /** The release the installations run; null for none. */
235
238
  readonly releaseId: string | null;
239
+ /** The native build's built-in bundle, when they run it. */
240
+ readonly builtinBundleId: string | null;
236
241
  readonly installations: number;
237
242
  }[];
238
243
  readonly measuredAtMs: number;
@@ -563,6 +568,38 @@ declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPl
563
568
  readonly sort: readonly ["bucket_start_ms"];
564
569
  };
565
570
  }, never, readonly ["channel", "platform", "app_version", "release_id", "bucket_start_ms"]>;
571
+ readonly insights_builtin_distribution: import("@hot-updater/plugin-core").AggregateDefinition<{
572
+ readonly channel: {
573
+ readonly type: "string";
574
+ };
575
+ readonly platform: {
576
+ readonly type: "string";
577
+ readonly maxLength: 16;
578
+ };
579
+ readonly app_version: {
580
+ readonly type: "string";
581
+ };
582
+ readonly release_id: {
583
+ readonly type: "string";
584
+ readonly maxLength: 36;
585
+ };
586
+ readonly builtin_bundle_id: {
587
+ readonly type: "string";
588
+ readonly maxLength: 36;
589
+ };
590
+ readonly bucket_start_ms: {
591
+ readonly type: "integer";
592
+ };
593
+ }, "latest_installations", {
594
+ readonly byScope: {
595
+ readonly eq: readonly ["channel", "platform"];
596
+ readonly sort: readonly ["bucket_start_ms"];
597
+ };
598
+ readonly byVersion: {
599
+ readonly eq: readonly ["channel", "platform", "app_version"];
600
+ readonly sort: readonly ["bucket_start_ms"];
601
+ };
602
+ }, never, readonly ["channel", "platform", "app_version", "release_id", "builtin_bundle_id", "bucket_start_ms"]>;
566
603
  readonly insights_latest_by_bundle: import("@hot-updater/plugin-core").AggregateDefinition<{
567
604
  readonly platform: {
568
605
  readonly type: "string";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/cloudflare",
3
3
  "type": "module",
4
- "version": "1.0.0-rc.34",
4
+ "version": "1.0.0-rc.36",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -56,10 +56,10 @@
56
56
  "cloudflare": "4.2.0",
57
57
  "hono": "4.12.34",
58
58
  "uuidv7": "^1.0.2",
59
- "@hot-updater/cli-tools": "1.0.0-rc.34",
60
- "@hot-updater/protocol": "1.0.0-rc.30",
61
- "@hot-updater/plugin-core": "1.0.0-rc.30",
62
- "@hot-updater/server": "1.0.0-rc.34"
59
+ "@hot-updater/cli-tools": "1.0.0-rc.36",
60
+ "@hot-updater/protocol": "1.0.0-rc.36",
61
+ "@hot-updater/plugin-core": "1.0.0-rc.36",
62
+ "@hot-updater/server": "1.0.0-rc.36"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@cloudflare/vitest-pool-workers": "0.13.0",
@@ -75,7 +75,7 @@
75
75
  "vitest": "4.1.4",
76
76
  "wrangler": "^4.69.0",
77
77
  "xdg-app-paths": "^8.3.0",
78
- "@hot-updater/test-utils": "1.0.0-rc.32"
78
+ "@hot-updater/test-utils": "1.0.0-rc.36"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsdown && pnpm build:worker",
package/sql/bundles.sql CHANGED
@@ -78,6 +78,14 @@ CREATE INDEX IF NOT EXISTS "insights_distribution_byVersion" ON "insights_distri
78
78
 
79
79
  CREATE INDEX IF NOT EXISTS "insights_distribution__retention" ON "insights_distribution" ("bucket_start_ms", "channel", "platform", "app_version", "release_id", "_shard");
80
80
 
81
+ CREATE TABLE IF NOT EXISTS "insights_builtin_distribution" ("channel" TEXT NOT NULL, "platform" TEXT NOT NULL, "app_version" TEXT NOT NULL, "release_id" TEXT NOT NULL, "builtin_bundle_id" TEXT NOT NULL, "bucket_start_ms" INTEGER NOT NULL, "_shard" INTEGER NOT NULL, "latest_installations" INTEGER NOT NULL, "_v" INTEGER NOT NULL DEFAULT 0, PRIMARY KEY ("channel", "platform", "app_version", "release_id", "builtin_bundle_id", "bucket_start_ms", "_shard"));
82
+
83
+ CREATE INDEX IF NOT EXISTS "insights_builtin_distribution_byScope" ON "insights_builtin_distribution" ("channel", "platform", "bucket_start_ms", "app_version", "release_id", "builtin_bundle_id", "_shard");
84
+
85
+ CREATE INDEX IF NOT EXISTS "insights_builtin_distribution_byVersion" ON "insights_builtin_distribution" ("channel", "platform", "app_version", "bucket_start_ms", "release_id", "builtin_bundle_id", "_shard");
86
+
87
+ CREATE INDEX IF NOT EXISTS "insights_builtin_distribution__retention" ON "insights_builtin_distribution" ("bucket_start_ms", "channel", "platform", "app_version", "release_id", "builtin_bundle_id", "_shard");
88
+
81
89
  CREATE TABLE IF NOT EXISTS "insights_latest_by_bundle" ("platform" TEXT NOT NULL, "channel" TEXT NOT NULL, "bundle_field" TEXT NOT NULL, "bundle_id" TEXT NOT NULL, "type" TEXT NOT NULL, "bucket_start_ms" INTEGER NOT NULL, "_shard" INTEGER NOT NULL, "installations" INTEGER NOT NULL, "_v" INTEGER NOT NULL DEFAULT 0, PRIMARY KEY ("platform", "channel", "bundle_field", "bundle_id", "type", "bucket_start_ms", "_shard"));
82
90
 
83
91
  CREATE INDEX IF NOT EXISTS "insights_latest_by_bundle__retention" ON "insights_latest_by_bundle" ("bucket_start_ms", "platform", "channel", "bundle_field", "bundle_id", "type", "_shard");
@@ -1 +1 @@
1
- This folder contains the built output assets for the worker "hot-updater" generated at 2026-10-06T05:52:53.630Z.
1
+ This folder contains the built output assets for the worker "hot-updater" generated at 2026-10-06T19:12:49.460Z.
@@ -4511,7 +4511,7 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
4511
4511
  }, "createSqlAdapter");
4512
4512
 
4513
4513
  // ../../packages/server/dist/package.mjs
4514
- var version = "1.0.0-rc.34";
4514
+ var version = "1.0.0-rc.36";
4515
4515
 
4516
4516
  // ../../packages/server/dist/version.mjs
4517
4517
  var HOT_UPDATER_SERVER_VERSION = version;
@@ -9557,8 +9557,13 @@ var isOptional = /* @__PURE__ */ __name((value, key, valid) => !Object.hasOwn(va
9557
9557
  var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
9558
9558
  var isDatabaseHttpResponse = /* @__PURE__ */ __name((value) => isDatabaseJsonObject(value) && (value.resource === "catalog" || value.resource === "artifact") && isString(value.path) && Number.isSafeInteger(value.status) && (value.body === null || isString(value.body)) && typeof value.body_truncated === "boolean" && Number.isSafeInteger(value.received_at_ms), "isDatabaseHttpResponse");
9559
9559
  var isDatabaseBundleEventFailure = /* @__PURE__ */ __name((value) => isDatabaseJsonObject(value) && isString(value.stage) && isString(value.reason) && isOptional(value, "resource", isString) && isOptional(value, "http_status", (status) => Number.isSafeInteger(status)) && isOptional(value, "transport", isString) && isOptional(value, "origin_code", isString) && isOptional(value, "error_message", isString) && isOptional(value, "error_stack", isString), "isDatabaseBundleEventFailure");
9560
- var isDatabaseBundleEventMetadata = /* @__PURE__ */ __name((value) => isDatabaseJsonObject(value) && typeof value.cohort === "string" && (value.update_strategy === null || value.update_strategy === "fingerprint" || value.update_strategy === "appVersion") && (value.fingerprint_hash === null || typeof value.fingerprint_hash === "string") && (value.sdk_version === null || typeof value.sdk_version === "string") && isOptional(value, "failure", isDatabaseBundleEventFailure) && isOptional(value, "http_response", isDatabaseHttpResponse) && isOptional(value, "delivery", isString) && isOptional(value, "patch_fallback", (flag) => typeof flag === "boolean"), "isDatabaseBundleEventMetadata");
9560
+ var isDatabaseBundleEventMetadata = /* @__PURE__ */ __name((value) => isDatabaseJsonObject(value) && typeof value.cohort === "string" && (value.update_strategy === null || value.update_strategy === "fingerprint" || value.update_strategy === "appVersion") && (value.fingerprint_hash === null || typeof value.fingerprint_hash === "string") && (value.sdk_version === null || typeof value.sdk_version === "string") && isOptional(value, "min_bundle_id", isString) && isOptional(value, "failure", isDatabaseBundleEventFailure) && isOptional(value, "http_response", isDatabaseHttpResponse) && isOptional(value, "delivery", isString) && isOptional(value, "patch_fallback", (flag) => typeof flag === "boolean"), "isDatabaseBundleEventMetadata");
9561
9561
  var isRecord5 = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRecord");
9562
+ var runningBuiltinBundleId = /* @__PURE__ */ __name((row) => {
9563
+ const running = row.type === "UPDATE_DOWNLOADED" ? row.from_bundle_id : row.to_bundle_id;
9564
+ const builtin = isRecord5(row.metadata) ? row.metadata.min_bundle_id : null;
9565
+ return typeof builtin === "string" && running === builtin ? builtin : null;
9566
+ }, "runningBuiltinBundleId");
9562
9567
  var isIdentity = /* @__PURE__ */ __name((value) => typeof value === "string" && value.length > 0 && value.length <= 255, "isIdentity");
9563
9568
  var isTextOrNull2 = /* @__PURE__ */ __name((value) => value === null || typeof value === "string", "isTextOrNull");
9564
9569
  var BUNDLE_EVENT_FIELDS = {
@@ -9836,6 +9841,7 @@ function readEventId(payload) {
9836
9841
  return value;
9837
9842
  }
9838
9843
  __name(readEventId, "readEventId");
9844
+ var readMinBundleId = /* @__PURE__ */ __name((value) => typeof value === "string" && value.length > 0 && value.length <= 36 ? value : null, "readMinBundleId");
9839
9845
  var oneOf = /* @__PURE__ */ __name((values, value) => values.includes(value) ? value : "unknown", "oneOf");
9840
9846
  var STAGES = [
9841
9847
  "check",
@@ -9957,6 +9963,7 @@ function requireEvent(payload) {
9957
9963
  cohort: requireStringField(payload, "cohort"),
9958
9964
  fingerprintHash: requireNullableStringField(payload, "fingerprintHash"),
9959
9965
  sdkVersion: payload.sdkVersion === void 0 ? null : requireNullableStringField(payload, "sdkVersion"),
9966
+ minBundleId: readMinBundleId(payload.minBundleId),
9960
9967
  fromReleaseId: requireNullableStringField(payload, "fromReleaseId"),
9961
9968
  toReleaseId: requireNullableStringField(payload, "toReleaseId")
9962
9969
  };
@@ -10043,6 +10050,7 @@ function createBundleEventRow(input) {
10043
10050
  cohort: input.cohort,
10044
10051
  fingerprint_hash: input.fingerprintHash,
10045
10052
  sdk_version: input.sdkVersion ?? null,
10053
+ ...input.minBundleId ? { min_bundle_id: input.minBundleId } : {},
10046
10054
  update_strategy: input.updateStrategy
10047
10055
  };
10048
10056
  switch (input.type) {
@@ -10267,6 +10275,7 @@ var eventDetails = /* @__PURE__ */ __name(({ type, metadata }) => ({
10267
10275
  var toEventHistoryRow = /* @__PURE__ */ __name((row) => ({
10268
10276
  ...row.to_release_id == null ? {} : { toReleaseId: row.to_release_id },
10269
10277
  ...row.metadata.sdk_version == null ? {} : { sdkVersion: row.metadata.sdk_version },
10278
+ ...row.metadata.min_bundle_id === void 0 ? {} : { minBundleId: row.metadata.min_bundle_id },
10270
10279
  appVersion: row.app_version,
10271
10280
  channel: row.channel,
10272
10281
  cohort: row.metadata.cohort,
@@ -10282,6 +10291,7 @@ var toEventHistoryRow = /* @__PURE__ */ __name((row) => ({
10282
10291
  }), "toEventHistoryRow");
10283
10292
  var toInstallationRow = /* @__PURE__ */ __name((row) => ({
10284
10293
  ...eventDetails(row).httpResponse ? { httpResponse: eventDetails(row).httpResponse } : {},
10294
+ ...row.metadata.min_bundle_id === void 0 ? {} : { minBundleId: row.metadata.min_bundle_id },
10285
10295
  appVersion: row.app_version,
10286
10296
  channel: row.channel,
10287
10297
  cohort: row.metadata.cohort,
@@ -10775,6 +10785,50 @@ var insightsDistribution = /* @__PURE__ */ __name((retention) => defineAggregate
10775
10785
  },
10776
10786
  retention
10777
10787
  }), "insightsDistribution");
10788
+ var insightsBuiltinDistribution = /* @__PURE__ */ __name((retention) => defineAggregate({
10789
+ channel: { type: "string" },
10790
+ platform: {
10791
+ type: "string",
10792
+ maxLength: 16
10793
+ },
10794
+ app_version: { type: "string" },
10795
+ release_id: {
10796
+ type: "string",
10797
+ maxLength: 36
10798
+ },
10799
+ builtin_bundle_id: {
10800
+ type: "string",
10801
+ maxLength: 36
10802
+ },
10803
+ bucket_start_ms: { type: "integer" }
10804
+ }, {
10805
+ key: [
10806
+ "channel",
10807
+ "platform",
10808
+ "app_version",
10809
+ "release_id",
10810
+ "builtin_bundle_id",
10811
+ "bucket_start_ms"
10812
+ ],
10813
+ gauges: ["latest_installations"],
10814
+ shards: GAUGE_SHARDS,
10815
+ batched: true,
10816
+ indexes: {
10817
+ byScope: {
10818
+ eq: ["channel", "platform"],
10819
+ sort: ["bucket_start_ms"]
10820
+ },
10821
+ byVersion: {
10822
+ eq: [
10823
+ "channel",
10824
+ "platform",
10825
+ "app_version"
10826
+ ],
10827
+ sort: ["bucket_start_ms"]
10828
+ }
10829
+ },
10830
+ retention
10831
+ }), "insightsBuiltinDistribution");
10778
10832
  var insightsLatestByBundle = /* @__PURE__ */ __name((retention) => defineAggregate({
10779
10833
  platform: {
10780
10834
  type: "string",
@@ -10877,6 +10931,7 @@ var createInsightsSchema = /* @__PURE__ */ __name(({ rawDays, dailyDays } = DEFA
10877
10931
  insights_overview_lifetime: lifetimeCounters(),
10878
10932
  insights_sketches_lifetime: lifetimeSketches(),
10879
10933
  insights_distribution: insightsDistribution(daily),
10934
+ insights_builtin_distribution: insightsBuiltinDistribution(daily),
10880
10935
  insights_latest_by_bundle: insightsLatestByBundle(daily),
10881
10936
  insights_outcomes: insightsOutcomes(hourly),
10882
10937
  insights_failures: insightsFailures(hourly)
@@ -10994,12 +11049,13 @@ var insightsIdentity = /* @__PURE__ */ __name((identity) => insightsOverviewId({
10994
11049
  }), "insightsIdentity");
10995
11050
  var gaugeSlot = /* @__PURE__ */ __name((head) => ({
10996
11051
  bucket: dayOf(head.received_at_ms),
10997
- releaseId: head.type === "UPDATE_DOWNLOADED" ? head.from_release_id : head.to_release_id
11052
+ releaseId: head.type === "UPDATE_DOWNLOADED" ? head.from_release_id : head.to_release_id,
11053
+ builtinBundleId: runningBuiltinBundleId(head)
10998
11054
  }), "gaugeSlot");
10999
11055
  var PAIR_FIELD = "from_to";
11000
11056
  var bundlePairKey = /* @__PURE__ */ __name((from, to) => insightsKey(`${from.length}:${from}${to.length}:${to}`), "bundlePairKey");
11001
11057
  var countHead = /* @__PURE__ */ __name((tx, head, delta) => {
11002
- const { bucket, releaseId } = gaugeSlot(head);
11058
+ const { bucket, releaseId, builtinBundleId } = gaugeSlot(head);
11003
11059
  const shardBy = head.install_id;
11004
11060
  tx.aggregate("insights_distribution", {
11005
11061
  channel: head.channel,
@@ -11008,6 +11064,14 @@ var countHead = /* @__PURE__ */ __name((tx, head, delta) => {
11008
11064
  release_id: releaseId ?? "",
11009
11065
  bucket_start_ms: bucket
11010
11066
  }, { latest_installations: delta }, { shardBy });
11067
+ if (builtinBundleId !== null) tx.aggregate("insights_builtin_distribution", {
11068
+ channel: head.channel,
11069
+ platform: head.platform,
11070
+ app_version: head.app_version,
11071
+ release_id: releaseId ?? "",
11072
+ builtin_bundle_id: builtinBundleId,
11073
+ bucket_start_ms: bucket
11074
+ }, { latest_installations: delta }, { shardBy });
11011
11075
  for (const field of ["from_bundle_id", "to_bundle_id"]) {
11012
11076
  const bundleId = head[field];
11013
11077
  if (bundleId === null) continue;
@@ -11567,26 +11631,49 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
11567
11631
  lt: timeRange.end
11568
11632
  };
11569
11633
  const distribution = [];
11570
- for (const platform of reported) distribution.push(...await drain2((page2) => input.appVersion === void 0 ? db.findAggregates("insights_distribution", {
11571
- index: "byScope",
11572
- where: {
11573
- channel: input.channel,
11574
- platform
11575
- },
11576
- range,
11577
- limit: PAGE4,
11578
- ...page2
11579
- }) : db.findAggregates("insights_distribution", {
11580
- index: "byVersion",
11581
- where: {
11582
- channel: input.channel,
11583
- platform,
11584
- app_version: input.appVersion
11585
- },
11586
- range,
11587
- limit: PAGE4,
11588
- ...page2
11589
- })));
11634
+ const builtinDistribution = [];
11635
+ for (const platform of reported) {
11636
+ distribution.push(...await drain2((page2) => input.appVersion === void 0 ? db.findAggregates("insights_distribution", {
11637
+ index: "byScope",
11638
+ where: {
11639
+ channel: input.channel,
11640
+ platform
11641
+ },
11642
+ range,
11643
+ limit: PAGE4,
11644
+ ...page2
11645
+ }) : db.findAggregates("insights_distribution", {
11646
+ index: "byVersion",
11647
+ where: {
11648
+ channel: input.channel,
11649
+ platform,
11650
+ app_version: input.appVersion
11651
+ },
11652
+ range,
11653
+ limit: PAGE4,
11654
+ ...page2
11655
+ })));
11656
+ builtinDistribution.push(...await drain2((page2) => input.appVersion === void 0 ? db.findAggregates("insights_builtin_distribution", {
11657
+ index: "byScope",
11658
+ where: {
11659
+ channel: input.channel,
11660
+ platform
11661
+ },
11662
+ range,
11663
+ limit: PAGE4,
11664
+ ...page2
11665
+ }) : db.findAggregates("insights_builtin_distribution", {
11666
+ index: "byVersion",
11667
+ where: {
11668
+ channel: input.channel,
11669
+ platform,
11670
+ app_version: input.appVersion
11671
+ },
11672
+ range,
11673
+ limit: PAGE4,
11674
+ ...page2
11675
+ })));
11676
+ }
11590
11677
  const points = [];
11591
11678
  for (let start = timeRange.start; start < timeRange.end; start += intervalMs) points.push({
11592
11679
  startMs: start,
@@ -11595,22 +11682,31 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
11595
11682
  const versions = /* @__PURE__ */ new Map();
11596
11683
  const platforms = /* @__PURE__ */ new Map();
11597
11684
  const bundles = /* @__PURE__ */ new Map();
11598
- for (const row of distribution) {
11599
- const count = row.latest_installations;
11600
- versions.set(row.app_version, (versions.get(row.app_version) ?? 0) + count);
11601
- platforms.set(row.platform, (platforms.get(row.platform) ?? 0) + count);
11602
- const releaseId = row.release_id === "" ? null : row.release_id;
11685
+ const countBundle2 = /* @__PURE__ */ __name((row, releaseId, builtinBundleId, count) => {
11603
11686
  const key = JSON.stringify([
11604
11687
  row.app_version,
11605
11688
  row.platform,
11606
- releaseId
11689
+ releaseId,
11690
+ builtinBundleId
11607
11691
  ]);
11608
11692
  bundles.set(key, {
11609
11693
  appVersion: row.app_version,
11610
11694
  platform: row.platform,
11611
11695
  releaseId,
11696
+ builtinBundleId,
11612
11697
  installations: (bundles.get(key)?.installations ?? 0) + count
11613
11698
  });
11699
+ }, "countBundle");
11700
+ for (const row of distribution) {
11701
+ const count = row.latest_installations;
11702
+ versions.set(row.app_version, (versions.get(row.app_version) ?? 0) + count);
11703
+ platforms.set(row.platform, (platforms.get(row.platform) ?? 0) + count);
11704
+ countBundle2(row, row.release_id || null, null, count);
11705
+ }
11706
+ for (const row of builtinDistribution) {
11707
+ const releaseId = row.release_id || null;
11708
+ countBundle2(row, releaseId, null, -row.latest_installations);
11709
+ countBundle2(row, releaseId, row.builtin_bundle_id, row.latest_installations);
11614
11710
  }
11615
11711
  const sortedVersions = byInstallations(versions);
11616
11712
  return {