@hot-updater/firebase 1.2.0-rc.56 → 1.2.0-rc.58
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/firebase/functions/index.cjs +260 -166
- package/dist/init/index.cjs +1 -0
- package/dist/init/index.mjs +2 -1
- package/package.json +7 -7
|
@@ -531,14 +531,14 @@ function modularInverse(value, modulus) {
|
|
|
531
531
|
if (r > 1) throw new Error(`No modular inverse for ${value} mod ${modulus}`);
|
|
532
532
|
return positiveMod(t, modulus);
|
|
533
533
|
}
|
|
534
|
-
function getRolloutShuffleParameters(
|
|
535
|
-
let multiplier = positiveMod(hashString(`${
|
|
534
|
+
function getRolloutShuffleParameters(releaseId) {
|
|
535
|
+
let multiplier = positiveMod(hashString(`${releaseId}:multiplier`), 997);
|
|
536
536
|
if (multiplier === 0) multiplier = 1;
|
|
537
537
|
while (gcd(multiplier, NUMERIC_COHORT_SIZE) !== 1) {
|
|
538
538
|
multiplier = positiveMod(multiplier + 1, NUMERIC_COHORT_SIZE);
|
|
539
539
|
if (multiplier === 0) multiplier = 1;
|
|
540
540
|
}
|
|
541
|
-
const offset = positiveMod(hashString(`${
|
|
541
|
+
const offset = positiveMod(hashString(`${releaseId}:offset`), NUMERIC_COHORT_SIZE);
|
|
542
542
|
return {
|
|
543
543
|
multiplier,
|
|
544
544
|
offset,
|
|
@@ -571,16 +571,16 @@ function isValidCohort(cohort) {
|
|
|
571
571
|
const normalized = normalizeCohortValue(cohort);
|
|
572
572
|
return isNumericCohort(normalized) || isCustomCohort(normalized);
|
|
573
573
|
}
|
|
574
|
-
function getNumericCohortRolloutPosition(
|
|
574
|
+
function getNumericCohortRolloutPosition(releaseId, cohortValue) {
|
|
575
575
|
if (cohortValue < 1 || cohortValue > 1e3) throw new Error(`Invalid numeric cohort: ${cohortValue}`);
|
|
576
|
-
const { offset, inverseMultiplier } = getRolloutShuffleParameters(
|
|
576
|
+
const { offset, inverseMultiplier } = getRolloutShuffleParameters(releaseId);
|
|
577
577
|
return positiveMod(inverseMultiplier * (cohortValue - 1 - offset), NUMERIC_COHORT_SIZE);
|
|
578
578
|
}
|
|
579
|
-
function getRolledOutNumericCohorts(
|
|
579
|
+
function getRolledOutNumericCohorts(releaseId, rolloutCohortCount) {
|
|
580
580
|
const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
581
581
|
if (normalizedRolloutCount <= 0) return [];
|
|
582
582
|
if (normalizedRolloutCount >= 1e3) return Array.from({ length: NUMERIC_COHORT_SIZE }, (_, index) => index + 1);
|
|
583
|
-
const { multiplier, offset } = getRolloutShuffleParameters(
|
|
583
|
+
const { multiplier, offset } = getRolloutShuffleParameters(releaseId);
|
|
584
584
|
return Array.from({ length: normalizedRolloutCount }, (_, position) => positiveMod(multiplier * position + offset, NUMERIC_COHORT_SIZE)).map((zeroBasedCohort) => zeroBasedCohort + 1).sort((left, right) => left - right);
|
|
585
585
|
}
|
|
586
586
|
const RELEASE_CATALOG_FALLBACK_POLICY = "BUILTIN_IF_ACTIVE_INELIGIBLE";
|
|
@@ -5199,7 +5199,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
|
|
|
5199
5199
|
};
|
|
5200
5200
|
//#endregion
|
|
5201
5201
|
//#region ../../packages/server/dist/version.mjs
|
|
5202
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
5202
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.58";
|
|
5203
5203
|
//#endregion
|
|
5204
5204
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
5205
5205
|
/**
|
|
@@ -5998,7 +5998,7 @@ const baseBundleIdsOf = (row, range, bundleId, limit) => {
|
|
|
5998
5998
|
};
|
|
5999
5999
|
//#endregion
|
|
6000
6000
|
//#region ../../packages/server/dist/core/reads.mjs
|
|
6001
|
-
const PAGE$
|
|
6001
|
+
const PAGE$5 = 500;
|
|
6002
6002
|
const pick$2 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
|
|
6003
6003
|
const toBundleRow = pick$2([
|
|
6004
6004
|
"id",
|
|
@@ -6095,7 +6095,7 @@ const createCoreReads = (db, storage) => {
|
|
|
6095
6095
|
const page = await db.findMany("bundle_patches", {
|
|
6096
6096
|
index: "byBundle",
|
|
6097
6097
|
where: { bundle_id: row.id },
|
|
6098
|
-
limit: Math.min(count - patches.length, PAGE$
|
|
6098
|
+
limit: Math.min(count - patches.length, PAGE$5),
|
|
6099
6099
|
...cursor === void 0 ? {} : { cursor }
|
|
6100
6100
|
});
|
|
6101
6101
|
patches.push(...page.rows.map(toPatchRow));
|
|
@@ -6321,7 +6321,7 @@ const createCoreReads = (db, storage) => {
|
|
|
6321
6321
|
return (await drain$1((page) => db.findMany("channels", {
|
|
6322
6322
|
index: "all",
|
|
6323
6323
|
where: {},
|
|
6324
|
-
limit: PAGE$
|
|
6324
|
+
limit: PAGE$5,
|
|
6325
6325
|
...page
|
|
6326
6326
|
}))).map(toChannelRow);
|
|
6327
6327
|
},
|
|
@@ -6716,7 +6716,7 @@ const createLabelAllocator = (tx, used, caughtUp) => {
|
|
|
6716
6716
|
};
|
|
6717
6717
|
};
|
|
6718
6718
|
const FILL_BATCH = 25;
|
|
6719
|
-
const PAGE$
|
|
6719
|
+
const PAGE$4 = 500;
|
|
6720
6720
|
/**
|
|
6721
6721
|
* Labels a channel and platform's releases that have none, in ID order,
|
|
6722
6722
|
* which is the order they were created in, and marks its counter filled:
|
|
@@ -6769,7 +6769,7 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
6769
6769
|
channel_id: channelId,
|
|
6770
6770
|
platform
|
|
6771
6771
|
},
|
|
6772
|
-
limit: PAGE$
|
|
6772
|
+
limit: PAGE$4,
|
|
6773
6773
|
...cursor === void 0 ? {} : { cursor }
|
|
6774
6774
|
});
|
|
6775
6775
|
const unlabeled = page.rows.filter((row) => typeof row.label !== "number").map((row) => row.id);
|
|
@@ -6957,7 +6957,7 @@ const pendingLabelPairs = async (db) => {
|
|
|
6957
6957
|
};
|
|
6958
6958
|
//#endregion
|
|
6959
6959
|
//#region ../../packages/server/dist/core/writes.mjs
|
|
6960
|
-
const PAGE$
|
|
6960
|
+
const PAGE$3 = 500;
|
|
6961
6961
|
/** Moves one bundle into or out of its platform's total and the overall total. */
|
|
6962
6962
|
const countBundle = (tx, platform, delta) => {
|
|
6963
6963
|
for (const key of [platform, "*"]) tx.aggregate("bundle_totals", { platform_key: key }, { bundles: delta });
|
|
@@ -6996,7 +6996,7 @@ const replaceBundlePatches = async (tx, bundle, rows, checkNew) => {
|
|
|
6996
6996
|
const page = await tx.findMany("bundle_patches", {
|
|
6997
6997
|
index: "byBundle",
|
|
6998
6998
|
where: { bundle_id: bundle.id },
|
|
6999
|
-
limit: Math.min(count - seen, PAGE$
|
|
6999
|
+
limit: Math.min(count - seen, PAGE$3),
|
|
7000
7000
|
...cursor === void 0 ? {} : { cursor }
|
|
7001
7001
|
});
|
|
7002
7002
|
for (const stored of page.rows) {
|
|
@@ -7560,7 +7560,7 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
7560
7560
|
});
|
|
7561
7561
|
//#endregion
|
|
7562
7562
|
//#region ../../packages/server/dist/core/releases.mjs
|
|
7563
|
-
const PAGE$
|
|
7563
|
+
const PAGE$2 = 500;
|
|
7564
7564
|
const fail$1 = (code, message) => {
|
|
7565
7565
|
throw new ReleaseCatalogMutationError(code, message);
|
|
7566
7566
|
};
|
|
@@ -7595,7 +7595,7 @@ const enabledIn = (scopeKey, cursor) => ({
|
|
|
7595
7595
|
scope_key: scopeKey,
|
|
7596
7596
|
enabled: true
|
|
7597
7597
|
},
|
|
7598
|
-
limit: PAGE$
|
|
7598
|
+
limit: PAGE$2,
|
|
7599
7599
|
...cursor === void 0 ? {} : { cursor }
|
|
7600
7600
|
});
|
|
7601
7601
|
/** A scope's enabled releases, all of them, under the catalog's guard. */
|
|
@@ -9464,7 +9464,8 @@ const createRequestHandler = ({ api, clientPolicy, privateResponses = false, rou
|
|
|
9464
9464
|
let authenticated;
|
|
9465
9465
|
try {
|
|
9466
9466
|
authenticated = await clientPolicy.authenticate(request);
|
|
9467
|
-
} catch {
|
|
9467
|
+
} catch (error) {
|
|
9468
|
+
console.error("Hot Updater client authentication failed:", error);
|
|
9468
9469
|
return errorResponse("Service unavailable", 503);
|
|
9469
9470
|
}
|
|
9470
9471
|
if (!authenticated) return errorResponse("Unauthorized", 401);
|
|
@@ -10009,21 +10010,29 @@ const isLaunch = (row) => {
|
|
|
10009
10010
|
const kinds = metadataOf(row).change?.kinds ?? [];
|
|
10010
10011
|
return kinds.includes("bundle") && !kinds.includes("first_seen") && row.to_release_id !== null;
|
|
10011
10012
|
};
|
|
10013
|
+
const sideRef = (key, releaseId, bundleId) => key === "release" ? releaseId ?? bundleId : bundleId;
|
|
10012
10014
|
/**
|
|
10013
10015
|
* The bundle a stored row's bundle filter matches: `from:<bundle>` for a
|
|
10014
10016
|
* recovery; `to:<bundle>` for a download, an apply, and an update failure;
|
|
10015
10017
|
* `on:<bundle>` for an UNCHANGED row that launched a bundle (`isLaunch`), a
|
|
10016
10018
|
* key no other row uses. None for a failed check, which targets no bundle, a
|
|
10017
|
-
* late row, or any other UNCHANGED row.
|
|
10019
|
+
* late row, or any other UNCHANGED row. Each names its bundle by `key`.
|
|
10018
10020
|
*/
|
|
10019
|
-
const bundleRefsOf = (row) => {
|
|
10021
|
+
const bundleRefsOf = (row, key = "release") => {
|
|
10020
10022
|
if (isFailedCheck(row) || isLateEvent(row)) return [];
|
|
10021
|
-
if (row.type === "RECOVERED") return [`from:${row.from_bundle_id}`];
|
|
10022
|
-
if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${row.to_bundle_id}`] : [];
|
|
10023
|
-
return [`to:${row.to_bundle_id}`];
|
|
10023
|
+
if (row.type === "RECOVERED") return [`from:${sideRef(key, row.from_release_id, row.from_bundle_id)}`];
|
|
10024
|
+
if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${sideRef(key, row.to_release_id, row.to_bundle_id)}`] : [];
|
|
10025
|
+
return [`to:${sideRef(key, row.to_release_id, row.to_bundle_id)}`];
|
|
10024
10026
|
};
|
|
10027
|
+
/**
|
|
10028
|
+
* The hourly outcome rows a stored row counts in, as `[type, bundle ref]`:
|
|
10029
|
+
* its bundle filter's (`bundleRefsOf`), and a download that a launch or
|
|
10030
|
+
* crash implied, in its bundle's download hour, so the download series
|
|
10031
|
+
* covers what the release's downloads count.
|
|
10032
|
+
*/
|
|
10033
|
+
const outcomeRefsOf = (row, key = "release") => [...bundleRefsOf(row, key).map((ref) => [row.type, ref]), ...metadataOf(row).implied_download === true ? [["UPDATE_DOWNLOADED", row.type === "RECOVERED" ? `to:${sideRef(key, row.from_release_id, row.from_bundle_id)}` : `to:${sideRef(key, row.to_release_id, row.to_bundle_id)}`]] : []];
|
|
10025
10034
|
/** The key a bundle filter reads, as `bundleRefsOf` writes it. */
|
|
10026
|
-
const bundleRefOfFilter = (filter) => filter.type === "RECOVERED" ? `from:${filter.
|
|
10035
|
+
const bundleRefOfFilter = (filter) => filter.type === "RECOVERED" ? `from:${filter.fromReleaseId}` : filter.type === "UNCHANGED" ? `on:${filter.toReleaseId}` : `to:${filter.toReleaseId}`;
|
|
10027
10036
|
/**
|
|
10028
10037
|
* Downloads, applies, recoveries, update failures, and the UNCHANGED
|
|
10029
10038
|
* reports that changed what their installation runs, whole. An UNCHANGED
|
|
@@ -10088,7 +10097,11 @@ const bundleEvents = (days) => defineTable({
|
|
|
10088
10097
|
type: "string",
|
|
10089
10098
|
compute: (row) => MOVEMENTS.has(row.type) ? row.install_id : null
|
|
10090
10099
|
},
|
|
10091
|
-
/**
|
|
10100
|
+
/**
|
|
10101
|
+
* The bundle a bundle filter matches (`bundleRefsOf`), by release.
|
|
10102
|
+
* Rows a 1.1 server wrote name the artifact until
|
|
10103
|
+
* `backfillReleaseRefs` rewrites them.
|
|
10104
|
+
*/
|
|
10092
10105
|
bundle_ref: {
|
|
10093
10106
|
type: "string",
|
|
10094
10107
|
multi: true,
|
|
@@ -10407,7 +10420,13 @@ const insightsBuiltinDistribution = (retention) => defineAggregate({
|
|
|
10407
10420
|
},
|
|
10408
10421
|
retention
|
|
10409
10422
|
});
|
|
10410
|
-
/**
|
|
10423
|
+
/**
|
|
10424
|
+
* Latest events by the artifact they came from or went to, bucketed like
|
|
10425
|
+
* the distribution, as 1.1 servers wrote them. Nothing writes or reads it
|
|
10426
|
+
* since a bundle's installations come from `insights_distribution`, which
|
|
10427
|
+
* names the release; it stays declared so retention still empties the rows
|
|
10428
|
+
* a 1.1 server wrote.
|
|
10429
|
+
*/
|
|
10411
10430
|
const insightsLatestByBundle = (retention) => defineAggregate({
|
|
10412
10431
|
platform: {
|
|
10413
10432
|
type: "string",
|
|
@@ -10455,7 +10474,9 @@ const insightsLatestByBundle = (retention) => defineAggregate({
|
|
|
10455
10474
|
* Stored events by outcome and the bundle a bundle filter matches, a row an
|
|
10456
10475
|
* hour, which a failed check has none of; and every stored event, a row a UTC
|
|
10457
10476
|
* day (`DAILY_EVENTS`). Bundle counts sum the hourly rows, and event lists
|
|
10458
|
-
* read either to skip days without events.
|
|
10477
|
+
* read either to skip days without events. `bundle_ref` names the release
|
|
10478
|
+
* (`outcomeRefsOf`); a 1.1 server's rows name the artifact until
|
|
10479
|
+
* `backfillReleaseRefs` moves their counts.
|
|
10459
10480
|
*/
|
|
10460
10481
|
const insightsOutcomes = (retention) => defineAggregate({
|
|
10461
10482
|
platform: {
|
|
@@ -10534,6 +10555,96 @@ const createInsightsSchema = ({ rawDays, dailyDays } = DEFAULT_INSIGHTS_RETENTIO
|
|
|
10534
10555
|
};
|
|
10535
10556
|
createInsightsSchema();
|
|
10536
10557
|
//#endregion
|
|
10558
|
+
//#region ../insights/dist/server/backfill.mjs
|
|
10559
|
+
/**
|
|
10560
|
+
* Stored events read a page, and rewritten up to `BATCH` a transaction. A
|
|
10561
|
+
* store that takes fewer physical writes a transaction, as DynamoDB's 100
|
|
10562
|
+
* items hold fewer than 25 rewrites with their index copies and counts,
|
|
10563
|
+
* refuses the batch before writing anything; it is then rewritten in halves.
|
|
10564
|
+
*/
|
|
10565
|
+
const PAGE$1 = 500;
|
|
10566
|
+
const BATCH = 25;
|
|
10567
|
+
const sameRefs = (stored, refs) => {
|
|
10568
|
+
const values = Array.isArray(stored) ? stored : [];
|
|
10569
|
+
return values.length === refs.length && values.every((value) => refs.includes(value));
|
|
10570
|
+
};
|
|
10571
|
+
/**
|
|
10572
|
+
* Whether a stored event still names its artifact, as a 1.1 server wrote
|
|
10573
|
+
* it: its stored refs are the artifact's and differ from the release's. Its
|
|
10574
|
+
* stored refs are how its outcome rows counted it, so they are what a
|
|
10575
|
+
* rewrite moves, and a rewritten event reads as done.
|
|
10576
|
+
*/
|
|
10577
|
+
const namesArtifact = (row) => {
|
|
10578
|
+
const byKey = (key) => bundleRefsOf(row, key);
|
|
10579
|
+
return sameRefs(row.bundle_ref, byKey("artifact")) && !sameRefs(row.bundle_ref, byKey("release"));
|
|
10580
|
+
};
|
|
10581
|
+
/**
|
|
10582
|
+
* Rewrites the stored events in the raw period whose refs name their
|
|
10583
|
+
* artifact, as 1.1 servers wrote them, to name their release, and moves
|
|
10584
|
+
* their hourly outcome counts with them, each event in the transaction that
|
|
10585
|
+
* rewrites it. Each event carries its own release IDs, so two releases of
|
|
10586
|
+
* one artifact in one scope come apart; an event without a release ID keeps
|
|
10587
|
+
* the bundle ID it reports, as new events do.
|
|
10588
|
+
*
|
|
10589
|
+
* It reads every stored event once and writes only those still to move, so
|
|
10590
|
+
* an interrupted run can run again. `hot-updater db migrate` and `hot-updater
|
|
10591
|
+
* init` run it once a database: when it completes they record the settings
|
|
10592
|
+
* row `insights.releaseRefs`, and later runs read no event. Installation
|
|
10593
|
+
* gauges need nothing: they name releases already.
|
|
10594
|
+
*/
|
|
10595
|
+
const backfillReleaseRefs = async (db, now, { rawDays }, { dryRun = false } = {}) => {
|
|
10596
|
+
const today = now() - now() % DAY_MS$1;
|
|
10597
|
+
let events = 0;
|
|
10598
|
+
const move = async (candidates) => {
|
|
10599
|
+
if (dryRun) {
|
|
10600
|
+
events += candidates.length;
|
|
10601
|
+
return;
|
|
10602
|
+
}
|
|
10603
|
+
const moved = await rewrite(candidates).catch(async (error) => {
|
|
10604
|
+
if (!(error instanceof DatabaseConstraintError) || error.reason !== "too_large" || candidates.length === 1) throw error;
|
|
10605
|
+
const half = Math.ceil(candidates.length / 2);
|
|
10606
|
+
await move(candidates.slice(0, half));
|
|
10607
|
+
await move(candidates.slice(half));
|
|
10608
|
+
return 0;
|
|
10609
|
+
});
|
|
10610
|
+
events += moved;
|
|
10611
|
+
};
|
|
10612
|
+
const rewrite = (candidates) => db.transaction(async (tx) => {
|
|
10613
|
+
const rows = await Promise.all(candidates.map(({ id }) => tx.findOne("bundle_events", { id })));
|
|
10614
|
+
let moved = 0;
|
|
10615
|
+
for (const row of rows) {
|
|
10616
|
+
if (row === null || !namesArtifact(row)) continue;
|
|
10617
|
+
tx.update("bundle_events", row, {});
|
|
10618
|
+
const outcome = (ref, delta) => tx.aggregate("insights_outcomes", {
|
|
10619
|
+
platform: row.platform,
|
|
10620
|
+
channel: row.channel,
|
|
10621
|
+
type: ref[0],
|
|
10622
|
+
bundle_ref: ref[1],
|
|
10623
|
+
bucket_start_ms: row.received_at_ms - row.received_at_ms % HOUR_MS$1
|
|
10624
|
+
}, { events: delta }, { shardBy: row.install_id });
|
|
10625
|
+
for (const ref of outcomeRefsOf(row, "artifact")) outcome(ref, -1);
|
|
10626
|
+
for (const ref of outcomeRefsOf(row, "release")) outcome(ref, 1);
|
|
10627
|
+
moved += 1;
|
|
10628
|
+
}
|
|
10629
|
+
return moved;
|
|
10630
|
+
});
|
|
10631
|
+
for (let day = today - rawDays * DAY_MS$1; day <= today; day += DAY_MS$1) {
|
|
10632
|
+
let cursor;
|
|
10633
|
+
do {
|
|
10634
|
+
const page = await db.findMany("bundle_events", {
|
|
10635
|
+
index: "byDay",
|
|
10636
|
+
where: { day },
|
|
10637
|
+
limit: PAGE$1,
|
|
10638
|
+
...cursor === void 0 ? {} : { cursor }
|
|
10639
|
+
});
|
|
10640
|
+
const stale = page.rows.filter(namesArtifact);
|
|
10641
|
+
for (let start = 0; start < stale.length; start += BATCH) await move(stale.slice(start, start + BATCH));
|
|
10642
|
+
cursor = page.next;
|
|
10643
|
+
} while (cursor !== void 0);
|
|
10644
|
+
}
|
|
10645
|
+
return { events };
|
|
10646
|
+
};
|
|
10647
|
+
//#endregion
|
|
10537
10648
|
//#region ../insights/dist/server/eventRow.mjs
|
|
10538
10649
|
const CHANGE_KINDS = /* @__PURE__ */ new Set([
|
|
10539
10650
|
"first_seen",
|
|
@@ -10630,7 +10741,7 @@ const isBundleFilter = (value, withKind = false) => {
|
|
|
10630
10741
|
"type",
|
|
10631
10742
|
...withKind ? ["kind"] : []
|
|
10632
10743
|
];
|
|
10633
|
-
return value.type === "RECOVERED" ? isText$1(value.
|
|
10744
|
+
return value.type === "RECOVERED" ? isText$1(value.fromReleaseId) && hasOnlyKeys(value, [...keys, "fromReleaseId"]) : (value.type === "UPDATE_DOWNLOADED" || value.type === "UPDATE_APPLIED" || value.type === "UPDATE_FAILED" || value.type === "UNCHANGED") && isText$1(value.toReleaseId) && hasOnlyKeys(value, [...keys, "toReleaseId"]);
|
|
10634
10745
|
};
|
|
10635
10746
|
const isEventFilter = (value) => {
|
|
10636
10747
|
if (!isRecord$3(value)) return false;
|
|
@@ -10731,20 +10842,24 @@ const createValidatedInsightsModel = (model) => ({
|
|
|
10731
10842
|
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
10732
10843
|
"platform",
|
|
10733
10844
|
"channel",
|
|
10734
|
-
"sinceMs"
|
|
10735
|
-
|
|
10736
|
-
]) || !hasScope(input) || !isTimestamp(input.sinceMs) || input.bundle !== void 0 && (!Array.isArray(input.bundle) || input.bundle.length < 1 || input.bundle.length > 2 || input.bundle.some((bundle) => !isRecord$3(bundle) || !hasOnlyKeys(bundle, [
|
|
10737
|
-
"field",
|
|
10738
|
-
"value",
|
|
10739
|
-
"types"
|
|
10740
|
-
]) || bundle.field !== "from_bundle_id" && bundle.field !== "to_bundle_id" || !isText$1(bundle.value) || !Array.isArray(bundle.types) || bundle.types.length === 0 || bundle.types.some((type) => ![
|
|
10741
|
-
"UNCHANGED",
|
|
10742
|
-
"UPDATE_DOWNLOADED",
|
|
10743
|
-
"UPDATE_APPLIED",
|
|
10744
|
-
"RECOVERED"
|
|
10745
|
-
].includes(type))))) invalidQuery();
|
|
10845
|
+
"sinceMs"
|
|
10846
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs)) invalidQuery();
|
|
10746
10847
|
return validateCount(await model.countLatestEvents(input));
|
|
10747
10848
|
},
|
|
10849
|
+
async countReleaseInstallations(input) {
|
|
10850
|
+
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
10851
|
+
"platform",
|
|
10852
|
+
"channel",
|
|
10853
|
+
"sinceMs",
|
|
10854
|
+
"releaseId"
|
|
10855
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs) || !isText$1(input.releaseId)) invalidQuery();
|
|
10856
|
+
const counts = await model.countReleaseInstallations(input);
|
|
10857
|
+
if (!isRecord$3(counts) || !hasOnlyKeys(counts, ["installations", "release"])) invalidResult();
|
|
10858
|
+
return {
|
|
10859
|
+
installations: validateCount(counts.installations),
|
|
10860
|
+
release: validateCount(counts.release)
|
|
10861
|
+
};
|
|
10862
|
+
},
|
|
10748
10863
|
async countEvents(input) {
|
|
10749
10864
|
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
10750
10865
|
"filter",
|
|
@@ -10801,6 +10916,7 @@ const createInsightsModel = (api) => createValidatedInsightsModel({
|
|
|
10801
10916
|
listEvents: api.listEvents,
|
|
10802
10917
|
findLatestEvents: api.findLatestEvents,
|
|
10803
10918
|
countLatestEvents: api.countLatestEvents,
|
|
10919
|
+
countReleaseInstallations: api.countReleaseInstallations,
|
|
10804
10920
|
countEvents: api.countEvents,
|
|
10805
10921
|
countEventSeries: api.countEventSeries,
|
|
10806
10922
|
getReleaseActivity: api.getReleaseActivity,
|
|
@@ -11203,27 +11319,27 @@ const readScope$1 = (input) => {
|
|
|
11203
11319
|
};
|
|
11204
11320
|
const bundleFilter = (input) => {
|
|
11205
11321
|
const scope = readScope$1(input);
|
|
11206
|
-
const
|
|
11322
|
+
const releaseId = requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
11207
11323
|
switch (input.outcome) {
|
|
11208
11324
|
case "downloaded": return {
|
|
11209
11325
|
...scope,
|
|
11210
11326
|
type: "UPDATE_DOWNLOADED",
|
|
11211
|
-
|
|
11327
|
+
toReleaseId: releaseId
|
|
11212
11328
|
};
|
|
11213
11329
|
case "applied": return {
|
|
11214
11330
|
...scope,
|
|
11215
11331
|
type: "UPDATE_APPLIED",
|
|
11216
|
-
|
|
11332
|
+
toReleaseId: releaseId
|
|
11217
11333
|
};
|
|
11218
11334
|
case "recovered": return {
|
|
11219
11335
|
...scope,
|
|
11220
11336
|
type: "RECOVERED",
|
|
11221
|
-
|
|
11337
|
+
fromReleaseId: releaseId
|
|
11222
11338
|
};
|
|
11223
11339
|
case "failed": return {
|
|
11224
11340
|
...scope,
|
|
11225
11341
|
type: "UPDATE_FAILED",
|
|
11226
|
-
|
|
11342
|
+
toReleaseId: releaseId
|
|
11227
11343
|
};
|
|
11228
11344
|
default: throw new InsightsBadRequestError("Invalid Insights outcome.");
|
|
11229
11345
|
}
|
|
@@ -11233,7 +11349,7 @@ const sameFilter = (left, right) => {
|
|
|
11233
11349
|
switch (right.kind) {
|
|
11234
11350
|
case "all": return true;
|
|
11235
11351
|
case "installationMovement": return left.installId === right.installId;
|
|
11236
|
-
case "bundle": return left.platform === right.platform && left.channel === right.channel && left.type === right.type && (right.type === "RECOVERED" ? left.
|
|
11352
|
+
case "bundle": return left.platform === right.platform && left.channel === right.channel && left.type === right.type && (right.type === "RECOVERED" ? left.fromReleaseId === right.fromReleaseId : left.toReleaseId === right.toReleaseId);
|
|
11237
11353
|
}
|
|
11238
11354
|
};
|
|
11239
11355
|
const readEventCursor = (value, filter) => {
|
|
@@ -11270,7 +11386,7 @@ const assertEventRows = (rows, input) => {
|
|
|
11270
11386
|
for (let index = 0; index < rows.length; index += 1) {
|
|
11271
11387
|
const row = rows[index];
|
|
11272
11388
|
const previous = rows[index - 1];
|
|
11273
|
-
if (!row || typeof row.id !== "string" || !isUUIDv7(row.id) || !Number.isSafeInteger(row.received_at_ms) || row.received_at_ms >= input.beforeReceivedAtMs || row.received_at_ms < input.sinceMs || previous !== void 0 && compareEventNewest(previous, row) >= 0 || input.after !== void 0 && !isAfterEventCursor(row, input.after) || input.filter.kind === "installationMovement" && (row.install_id !== input.filter.installId || !isInsightsMovementEvent(row)) || input.filter.kind === "bundle" && (row.platform !== input.filter.platform || row.channel !== input.filter.channel || row.type !== input.filter.type || (input.filter.type === "RECOVERED" ? row.from_bundle_id !== input.filter.
|
|
11389
|
+
if (!row || typeof row.id !== "string" || !isUUIDv7(row.id) || !Number.isSafeInteger(row.received_at_ms) || row.received_at_ms >= input.beforeReceivedAtMs || row.received_at_ms < input.sinceMs || previous !== void 0 && compareEventNewest(previous, row) >= 0 || input.after !== void 0 && !isAfterEventCursor(row, input.after) || input.filter.kind === "installationMovement" && (row.install_id !== input.filter.installId || !isInsightsMovementEvent(row)) || input.filter.kind === "bundle" && (row.platform !== input.filter.platform || row.channel !== input.filter.channel || row.type !== input.filter.type || (input.filter.type === "RECOVERED" ? (row.from_release_id ?? row.from_bundle_id) !== input.filter.fromReleaseId : (row.to_release_id ?? row.to_bundle_id) !== input.filter.toReleaseId))) throw new Error("Insights database returned invalid event rows.");
|
|
11274
11390
|
}
|
|
11275
11391
|
};
|
|
11276
11392
|
/** An `UPDATE_FAILED` row's failure, as the event lists show it. */
|
|
@@ -11311,6 +11427,7 @@ const eventDetails = ({ type, metadata }) => ({
|
|
|
11311
11427
|
...metadata.implied_download === true ? { impliedDownload: true } : {}
|
|
11312
11428
|
});
|
|
11313
11429
|
const toEventHistoryRow = (row) => ({
|
|
11430
|
+
...row.from_release_id == null ? {} : { fromReleaseId: row.from_release_id },
|
|
11314
11431
|
...row.to_release_id == null ? {} : { toReleaseId: row.to_release_id },
|
|
11315
11432
|
...row.metadata.sdk_version == null ? {} : { sdkVersion: row.metadata.sdk_version },
|
|
11316
11433
|
...row.metadata.min_bundle_id === void 0 ? {} : { minBundleId: row.metadata.min_bundle_id },
|
|
@@ -11335,6 +11452,7 @@ const toInstallationRow = (row) => ({
|
|
|
11335
11452
|
cohort: row.metadata.cohort,
|
|
11336
11453
|
installId: row.install_id,
|
|
11337
11454
|
lastKnownBundleId: row.type === "UPDATE_DOWNLOADED" ? row.from_bundle_id : row.to_bundle_id,
|
|
11455
|
+
lastKnownReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.from_release_id : row.to_release_id,
|
|
11338
11456
|
pendingBundleId: row.type === "UPDATE_DOWNLOADED" ? row.to_bundle_id : null,
|
|
11339
11457
|
pendingReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.to_release_id : null,
|
|
11340
11458
|
latestStatus: row.type,
|
|
@@ -11463,46 +11581,33 @@ const createInsightsProvider = (model) => Object.freeze({
|
|
|
11463
11581
|
measuredAtMs: Date.now()
|
|
11464
11582
|
};
|
|
11465
11583
|
};
|
|
11466
|
-
const
|
|
11467
|
-
|
|
11468
|
-
...scope,
|
|
11469
|
-
sinceMs
|
|
11470
|
-
}));
|
|
11471
|
-
if (bundleId === void 0) return {
|
|
11584
|
+
const releaseId = input.releaseId === void 0 ? void 0 : requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
11585
|
+
if (releaseId === void 0) return {
|
|
11472
11586
|
...scope,
|
|
11473
11587
|
window,
|
|
11474
11588
|
sinceMs,
|
|
11475
11589
|
beforeReceivedAtMs,
|
|
11476
|
-
reportingInstallations: await
|
|
11590
|
+
reportingInstallations: await measure(model.countLatestEvents({
|
|
11591
|
+
...scope,
|
|
11592
|
+
sinceMs
|
|
11593
|
+
}))
|
|
11477
11594
|
};
|
|
11595
|
+
const installations = model.countReleaseInstallations({
|
|
11596
|
+
...scope,
|
|
11597
|
+
sinceMs,
|
|
11598
|
+
releaseId
|
|
11599
|
+
}).then(async (counts) => [await measure(Promise.resolve(counts.installations)), await measure(Promise.resolve(counts.release))]);
|
|
11478
11600
|
const countOutcome = (outcome) => measure(model.countEvents({
|
|
11479
11601
|
filter: bundleFilter({
|
|
11480
11602
|
...scope,
|
|
11481
|
-
|
|
11603
|
+
releaseId,
|
|
11482
11604
|
outcome
|
|
11483
11605
|
}),
|
|
11484
11606
|
sinceMs,
|
|
11485
11607
|
beforeReceivedAtMs
|
|
11486
11608
|
}));
|
|
11487
|
-
const [reportingInstallations, bundleInstallations, downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
11488
|
-
|
|
11489
|
-
measure(model.countLatestEvents({
|
|
11490
|
-
...scope,
|
|
11491
|
-
sinceMs,
|
|
11492
|
-
bundle: [{
|
|
11493
|
-
field: "from_bundle_id",
|
|
11494
|
-
value: bundleId,
|
|
11495
|
-
types: ["UPDATE_DOWNLOADED"]
|
|
11496
|
-
}, {
|
|
11497
|
-
field: "to_bundle_id",
|
|
11498
|
-
value: bundleId,
|
|
11499
|
-
types: [
|
|
11500
|
-
"UNCHANGED",
|
|
11501
|
-
"UPDATE_APPLIED",
|
|
11502
|
-
"RECOVERED"
|
|
11503
|
-
]
|
|
11504
|
-
}]
|
|
11505
|
-
})),
|
|
11609
|
+
const [[reportingInstallations, bundleInstallations], downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
11610
|
+
installations,
|
|
11506
11611
|
countOutcome("downloaded"),
|
|
11507
11612
|
countOutcome("applied"),
|
|
11508
11613
|
countOutcome("recovered"),
|
|
@@ -11515,7 +11620,7 @@ const createInsightsProvider = (model) => Object.freeze({
|
|
|
11515
11620
|
beforeReceivedAtMs,
|
|
11516
11621
|
reportingInstallations,
|
|
11517
11622
|
bundle: {
|
|
11518
|
-
|
|
11623
|
+
releaseId,
|
|
11519
11624
|
reportingInstallations: bundleInstallations,
|
|
11520
11625
|
downloadedReports,
|
|
11521
11626
|
appliedReports,
|
|
@@ -11650,17 +11755,10 @@ const gaugeSlot = (head) => ({
|
|
|
11650
11755
|
builtinBundleId: runningBuiltinBundleId(head)
|
|
11651
11756
|
});
|
|
11652
11757
|
/**
|
|
11653
|
-
* The `insights_latest_by_bundle` field of a head's (from, to) pair. A head
|
|
11654
|
-
* matches a `from` and a `to` predicate of one type at once only through its
|
|
11655
|
-
* pair, so this gauge is what a count subtracts to count it once.
|
|
11656
|
-
*/
|
|
11657
|
-
const PAIR_FIELD = "from_to";
|
|
11658
|
-
/** The pair gauge's `bundle_id`: a hash of the two bundle ids, which fit no single 36-character column. */
|
|
11659
|
-
const bundlePairKey = (from, to) => insightsKey(`${from.length}:${from}${to.length}:${to}`);
|
|
11660
|
-
/**
|
|
11661
11758
|
* Moves a head's gauges: the distribution row, and the built-in one when it
|
|
11662
|
-
* runs its build's built-in bundle
|
|
11663
|
-
*
|
|
11759
|
+
* runs its build's built-in bundle; -1 takes back the head an event
|
|
11760
|
+
* replaces. The distribution row names the release the head runs, so it is
|
|
11761
|
+
* also each release's installation gauge.
|
|
11664
11762
|
*/
|
|
11665
11763
|
const countHead = (tx, head, delta) => {
|
|
11666
11764
|
const { bucket, releaseId, builtinBundleId } = gaugeSlot(head);
|
|
@@ -11680,26 +11778,6 @@ const countHead = (tx, head, delta) => {
|
|
|
11680
11778
|
builtin_bundle_id: builtinBundleId,
|
|
11681
11779
|
bucket_start_ms: bucket
|
|
11682
11780
|
}, { latest_installations: delta }, { shardBy });
|
|
11683
|
-
for (const field of ["from_bundle_id", "to_bundle_id"]) {
|
|
11684
|
-
const bundleId = head[field];
|
|
11685
|
-
if (bundleId === null) continue;
|
|
11686
|
-
tx.aggregate("insights_latest_by_bundle", {
|
|
11687
|
-
platform: head.platform,
|
|
11688
|
-
channel: head.channel,
|
|
11689
|
-
bundle_field: field,
|
|
11690
|
-
bundle_id: bundleId,
|
|
11691
|
-
type: head.type,
|
|
11692
|
-
bucket_start_ms: bucket
|
|
11693
|
-
}, { installations: delta }, { shardBy });
|
|
11694
|
-
}
|
|
11695
|
-
if (head.from_bundle_id !== null) tx.aggregate("insights_latest_by_bundle", {
|
|
11696
|
-
platform: head.platform,
|
|
11697
|
-
channel: head.channel,
|
|
11698
|
-
bundle_field: PAIR_FIELD,
|
|
11699
|
-
bundle_id: bundlePairKey(head.from_bundle_id, head.to_bundle_id),
|
|
11700
|
-
type: head.type,
|
|
11701
|
-
bucket_start_ms: bucket
|
|
11702
|
-
}, { installations: delta }, { shardBy });
|
|
11703
11781
|
};
|
|
11704
11782
|
/**
|
|
11705
11783
|
* Where each period's rows go, each with its retention: hours for 90 days,
|
|
@@ -11760,26 +11838,19 @@ const countEvent = (tx, event) => {
|
|
|
11760
11838
|
}
|
|
11761
11839
|
};
|
|
11762
11840
|
/**
|
|
11763
|
-
* A stored event's outcome rows: its bundle filter's hour,
|
|
11764
|
-
*
|
|
11765
|
-
*
|
|
11766
|
-
* hour of that launch or crash, so the download series covers what the
|
|
11767
|
-
* release's downloads count; the launch or crash is its row.
|
|
11841
|
+
* A stored event's outcome rows: its bundle filter's hour, and the download
|
|
11842
|
+
* hour of a download its launch or crash implied, each by release
|
|
11843
|
+
* (`outcomeRefsOf`); and every stored event's UTC day.
|
|
11768
11844
|
*/
|
|
11769
11845
|
const countOutcome = (tx, event) => {
|
|
11770
11846
|
const shardBy = event.install_id;
|
|
11771
|
-
const
|
|
11847
|
+
for (const [type, bundleRef] of outcomeRefsOf(event)) tx.aggregate("insights_outcomes", {
|
|
11772
11848
|
platform: event.platform,
|
|
11773
11849
|
channel: event.channel,
|
|
11774
11850
|
type,
|
|
11775
11851
|
bundle_ref: bundleRef,
|
|
11776
11852
|
bucket_start_ms: hourOf(event.received_at_ms)
|
|
11777
11853
|
}, { events: 1 }, { shardBy });
|
|
11778
|
-
for (const bundleRef of bundleRefsOf(event)) hour(event.type, bundleRef);
|
|
11779
|
-
if (event.metadata.implied_download === true) hour("UPDATE_DOWNLOADED", bundleRefOfFilter({
|
|
11780
|
-
type: "UPDATE_DOWNLOADED",
|
|
11781
|
-
toBundleId: event.type === "RECOVERED" ? event.from_bundle_id : event.to_bundle_id
|
|
11782
|
-
}));
|
|
11783
11854
|
tx.aggregate("insights_outcomes", {
|
|
11784
11855
|
...DAILY_EVENTS,
|
|
11785
11856
|
bucket_start_ms: dayOf(event.received_at_ms)
|
|
@@ -12259,31 +12330,48 @@ const countEventSeries = async (db, input) => {
|
|
|
12259
12330
|
events: count
|
|
12260
12331
|
}));
|
|
12261
12332
|
};
|
|
12262
|
-
/**
|
|
12263
|
-
const
|
|
12264
|
-
if (
|
|
12265
|
-
return
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12333
|
+
/** The distribution rows at or after `start`, a UTC day's start. */
|
|
12334
|
+
const distributionRows = (db, { platform, channel, sinceMs: start }) => {
|
|
12335
|
+
if (start % 864e5 !== 0) throw new DatabaseAdapterInputError("invalid-query");
|
|
12336
|
+
return drain((page) => db.findAggregates("insights_distribution", {
|
|
12337
|
+
index: "byScope",
|
|
12338
|
+
where: {
|
|
12339
|
+
channel,
|
|
12340
|
+
platform
|
|
12341
|
+
},
|
|
12342
|
+
range: { gte: start },
|
|
12343
|
+
limit: PAGE,
|
|
12344
|
+
...page
|
|
12345
|
+
}));
|
|
12274
12346
|
};
|
|
12347
|
+
const installations = (count) => Math.max(0, count);
|
|
12275
12348
|
/**
|
|
12276
12349
|
* Latest events at or after `sinceMs`, a UTC day's start: the gauges count
|
|
12277
12350
|
* each installation in the UTC day of its latest event, so they answer whole
|
|
12278
12351
|
* days only, and a later start is rejected rather than rounded.
|
|
12279
12352
|
*/
|
|
12280
|
-
const countLatestEvents = async (db, input) =>
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12353
|
+
const countLatestEvents = async (db, input) => installations((await distributionRows(db, input)).reduce((sum, row) => sum + row.latest_installations, 0));
|
|
12354
|
+
/**
|
|
12355
|
+
* `countLatestEvents`, and of those the installations it leaves running
|
|
12356
|
+
* `releaseId`, from the same distribution rows in one read: each names the
|
|
12357
|
+
* release its installations run. An ID no row names as a release may be a
|
|
12358
|
+
* built-in bundle's, which a report without a release names, as event
|
|
12359
|
+
* counts match it: its installations outside any release are in the
|
|
12360
|
+
* built-in rows, read only then. Release and bundle IDs never coincide.
|
|
12361
|
+
*/
|
|
12362
|
+
const countReleaseInstallations = async (db, input) => {
|
|
12363
|
+
const { platform, channel, sinceMs: start, releaseId } = input;
|
|
12284
12364
|
let total = 0;
|
|
12285
|
-
|
|
12286
|
-
|
|
12365
|
+
let release = 0;
|
|
12366
|
+
let named = false;
|
|
12367
|
+
for (const row of await distributionRows(db, input)) {
|
|
12368
|
+
total += row.latest_installations;
|
|
12369
|
+
if (row.release_id !== releaseId) continue;
|
|
12370
|
+
named = true;
|
|
12371
|
+
release += row.latest_installations;
|
|
12372
|
+
}
|
|
12373
|
+
if (!named) {
|
|
12374
|
+
const builtin = await drain((page) => db.findAggregates("insights_builtin_distribution", {
|
|
12287
12375
|
index: "byScope",
|
|
12288
12376
|
where: {
|
|
12289
12377
|
channel,
|
|
@@ -12293,33 +12381,12 @@ const countLatestEvents = async (db, input) => {
|
|
|
12293
12381
|
limit: PAGE,
|
|
12294
12382
|
...page
|
|
12295
12383
|
}));
|
|
12296
|
-
|
|
12297
|
-
} else {
|
|
12298
|
-
const gauge = async (bundleField, bundleId, type) => {
|
|
12299
|
-
return (await drain((page) => db.findAggregates("insights_latest_by_bundle", {
|
|
12300
|
-
index: "byBundle",
|
|
12301
|
-
where: {
|
|
12302
|
-
platform,
|
|
12303
|
-
channel,
|
|
12304
|
-
bundle_field: bundleField,
|
|
12305
|
-
bundle_id: bundleId,
|
|
12306
|
-
type
|
|
12307
|
-
},
|
|
12308
|
-
range: { gte: start },
|
|
12309
|
-
limit: PAGE,
|
|
12310
|
-
...page
|
|
12311
|
-
}))).reduce((sum, row) => sum + row.installations, 0);
|
|
12312
|
-
};
|
|
12313
|
-
for (const { field, value, type } of predicates) total += await gauge(field, value, type);
|
|
12314
|
-
for (const from of predicates) {
|
|
12315
|
-
if (from.field !== "from_bundle_id") continue;
|
|
12316
|
-
for (const to of predicates) {
|
|
12317
|
-
if (to.field !== "to_bundle_id" || to.type !== from.type) continue;
|
|
12318
|
-
total -= await gauge(PAIR_FIELD, bundlePairKey(from.value, to.value), from.type);
|
|
12319
|
-
}
|
|
12320
|
-
}
|
|
12384
|
+
for (const row of builtin) if (row.release_id === "" && row.builtin_bundle_id === releaseId) release += row.latest_installations;
|
|
12321
12385
|
}
|
|
12322
|
-
return
|
|
12386
|
+
return {
|
|
12387
|
+
installations: installations(total),
|
|
12388
|
+
release: installations(release)
|
|
12389
|
+
};
|
|
12323
12390
|
};
|
|
12324
12391
|
/** The oldest whole hour and UTC day that hourly and daily rows still hold. */
|
|
12325
12392
|
const retained = (now, { rawDays, dailyDays }) => ({
|
|
@@ -12789,6 +12856,26 @@ const getUpdateFailures = async (db, input, now, retention) => {
|
|
|
12789
12856
|
};
|
|
12790
12857
|
};
|
|
12791
12858
|
//#endregion
|
|
12859
|
+
//#region ../insights/dist/server/wire.mjs
|
|
12860
|
+
/**
|
|
12861
|
+
* The HTTP API calls a release ID `bundleId`, the word users have for it, in
|
|
12862
|
+
* its query parameters and its overview's JSON. The code calls it
|
|
12863
|
+
* `releaseId`; only this module maps between the two names.
|
|
12864
|
+
*/
|
|
12865
|
+
const RELEASE_ID_PARAM = "bundleId";
|
|
12866
|
+
/** An overview as the HTTP API and the CLI's `--json` send it. */
|
|
12867
|
+
const toWireOverview = ({ bundle, ...overview }) => {
|
|
12868
|
+
if (bundle === void 0) return overview;
|
|
12869
|
+
const { releaseId, ...counts } = bundle;
|
|
12870
|
+
return {
|
|
12871
|
+
...overview,
|
|
12872
|
+
bundle: {
|
|
12873
|
+
...counts,
|
|
12874
|
+
bundleId: releaseId
|
|
12875
|
+
}
|
|
12876
|
+
};
|
|
12877
|
+
};
|
|
12878
|
+
//#endregion
|
|
12792
12879
|
//#region ../insights/dist/server/queryInput.mjs
|
|
12793
12880
|
const MAX_PAGE_LIMIT = 100;
|
|
12794
12881
|
const MAX_IDENTITY_LENGTH = 255;
|
|
@@ -12833,7 +12920,7 @@ const readScope = (url) => {
|
|
|
12833
12920
|
const parseEventPageInput = (request) => {
|
|
12834
12921
|
const url = new URL(request.url);
|
|
12835
12922
|
const bundleFields = [
|
|
12836
|
-
|
|
12923
|
+
RELEASE_ID_PARAM,
|
|
12837
12924
|
"outcome",
|
|
12838
12925
|
"platform",
|
|
12839
12926
|
"channel"
|
|
@@ -12844,7 +12931,7 @@ const parseEventPageInput = (request) => {
|
|
|
12844
12931
|
if (outcome !== "downloaded" && outcome !== "applied" && outcome !== "recovered" && outcome !== "failed") throw new InsightsBadRequestError("Invalid 'outcome' query parameter.");
|
|
12845
12932
|
bundle = {
|
|
12846
12933
|
...readScope(url),
|
|
12847
|
-
|
|
12934
|
+
releaseId: readId(url, RELEASE_ID_PARAM, 1024),
|
|
12848
12935
|
outcome
|
|
12849
12936
|
};
|
|
12850
12937
|
}
|
|
@@ -12870,11 +12957,10 @@ const parseReportingOverviewInput = (request) => {
|
|
|
12870
12957
|
const url = new URL(request.url);
|
|
12871
12958
|
const window = readSingle(url, "window") ?? "30d";
|
|
12872
12959
|
if (window !== "24h" && window !== "7d" && window !== "30d") throw new InsightsBadRequestError("Invalid 'window' query parameter.");
|
|
12873
|
-
const bundleId = readSingle(url, "bundleId");
|
|
12874
12960
|
return {
|
|
12875
12961
|
...readScope(url),
|
|
12876
12962
|
window,
|
|
12877
|
-
...bundleId === void 0 ? {} : {
|
|
12963
|
+
...readSingle(url, "bundleId") === void 0 ? {} : { releaseId: readId(url, RELEASE_ID_PARAM, 1024) }
|
|
12878
12964
|
};
|
|
12879
12965
|
};
|
|
12880
12966
|
//#endregion
|
|
@@ -12955,7 +13041,7 @@ const createInsightsRouteHandlers = (provider) => ({
|
|
|
12955
13041
|
await provider.appendBundleEvent(await parseBundleEventRequest(request));
|
|
12956
13042
|
return new Response(null, { status: 204 });
|
|
12957
13043
|
}),
|
|
12958
|
-
getReportingOverview: (_params, request) => query(() => provider.getReportingOverview(parseReportingOverviewInput(request))),
|
|
13044
|
+
getReportingOverview: (_params, request) => query(async () => toWireOverview(await provider.getReportingOverview(parseReportingOverviewInput(request)))),
|
|
12959
13045
|
getInstallation: (params) => run$1(async () => {
|
|
12960
13046
|
const installation = await provider.getInstallation({ installId: requireParam(params, "installId") });
|
|
12961
13047
|
return installation === null ? json$1({ error: "Installation not found" }, 404) : json$1(installation, 200);
|
|
@@ -12977,12 +13063,20 @@ const createInsightsApi = (db, now, retention) => ({
|
|
|
12977
13063
|
listEvents: (input) => listEvents(db, input),
|
|
12978
13064
|
findLatestEvents: (input) => findLatestEvents(db, input),
|
|
12979
13065
|
countLatestEvents: (input) => countLatestEvents(db, input),
|
|
13066
|
+
countReleaseInstallations: (input) => countReleaseInstallations(db, input),
|
|
12980
13067
|
countEvents: (input) => countEvents(db, input),
|
|
12981
13068
|
countEventSeries: (input) => countEventSeries(db, input),
|
|
12982
13069
|
getReleaseActivity: (input) => getReleaseActivity(db, input, now),
|
|
12983
13070
|
getAppUsage: (input) => getAppUsage(db, input, now, retention),
|
|
12984
13071
|
/** A release's or a channel's update failures, and their breakdown over a time range. */
|
|
12985
|
-
getUpdateFailures: (input) => getUpdateFailures(db, input, now, retention)
|
|
13072
|
+
getUpdateFailures: (input) => getUpdateFailures(db, input, now, retention),
|
|
13073
|
+
/**
|
|
13074
|
+
* Moves the stored events a 1.1 server keyed by artifact, and their
|
|
13075
|
+
* outcome counts, to their release, reading every stored event of the
|
|
13076
|
+
* raw period: `hot-updater db migrate` and `hot-updater init` run it once
|
|
13077
|
+
* a database, and an interrupted run can run again.
|
|
13078
|
+
*/
|
|
13079
|
+
backfillReleaseRefs: (options) => backfillReleaseRefs(db, now, retention, options)
|
|
12986
13080
|
});
|
|
12987
13081
|
/** `GET /failures`'s query: a scope, an optional release, and a time range or none. */
|
|
12988
13082
|
const readFailuresQuery = (url) => {
|
package/dist/init/index.cjs
CHANGED
|
@@ -7950,6 +7950,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
|
|
|
7950
7950
|
try {
|
|
7951
7951
|
await migrateFirebaseDatabase(databaseConfig, server.plugins);
|
|
7952
7952
|
await (0, _hot_updater_cli_tools.fillReleaseLabels)(server);
|
|
7953
|
+
await (0, _hot_updater_cli_tools.backfillInsightsReleaseRefs)(server);
|
|
7953
7954
|
clientCredential = await (0, _hot_updater_cli_tools.provisionClientCredential)(server, {
|
|
7954
7955
|
env: initInputEnv,
|
|
7955
7956
|
name: "Firebase init"
|
package/dist/init/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { ConfigBuilder, HOT_UPDATER_SERVER_PACKAGE_VERSION_ENV, InitError, LegacyInfrastructureError, MissingInitInputsError, assembleServer, assertInfrastructureGenerationAtUrl, assertInitProviderInputs, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, fillReleaseLabels, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveHotUpdaterServerVersion, resolveInitProviderInput, resolvePackageVersion, transformEnv, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
|
|
4
|
+
import { ConfigBuilder, HOT_UPDATER_SERVER_PACKAGE_VERSION_ENV, InitError, LegacyInfrastructureError, MissingInitInputsError, assembleServer, assertInfrastructureGenerationAtUrl, assertInitProviderInputs, backfillInsightsReleaseRefs, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, fillReleaseLabels, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveHotUpdaterServerVersion, resolveInitProviderInput, resolvePackageVersion, transformEnv, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
|
|
5
5
|
import { apiKeys, insights, remoteConfig } from "@hot-updater/server/plugins";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
|
|
@@ -7943,6 +7943,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
|
|
|
7943
7943
|
try {
|
|
7944
7944
|
await migrateFirebaseDatabase(databaseConfig, server.plugins);
|
|
7945
7945
|
await fillReleaseLabels(server);
|
|
7946
|
+
await backfillInsightsReleaseRefs(server);
|
|
7946
7947
|
clientCredential = await provisionClientCredential(server, {
|
|
7947
7948
|
env: initInputEnv,
|
|
7948
7949
|
name: "Firebase init"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/firebase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.58",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"types": "dist/index.d.cts",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"hono": "4.12.34",
|
|
40
40
|
"google-auth-library": "10.7.0",
|
|
41
|
-
"@hot-updater/cli-tools": "1.2.0-rc.
|
|
42
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
43
|
-
"@hot-updater/
|
|
44
|
-
"@hot-updater/
|
|
41
|
+
"@hot-updater/cli-tools": "1.2.0-rc.58",
|
|
42
|
+
"@hot-updater/protocol": "1.2.0-rc.58",
|
|
43
|
+
"@hot-updater/server": "1.2.0-rc.58",
|
|
44
|
+
"@hot-updater/plugin-core": "1.2.0-rc.58"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"firebase-tools": "15.29.0",
|
|
57
57
|
"fkill": "^9.0.0",
|
|
58
58
|
"mime": "^4.0.4",
|
|
59
|
-
"@hot-updater/mock": "1.2.0-rc.
|
|
60
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
59
|
+
"@hot-updater/mock": "1.2.0-rc.58",
|
|
60
|
+
"@hot-updater/test-utils": "1.2.0-rc.58"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"firebase-admin": ">=11.10.0",
|