@hot-updater/firebase 1.2.0-rc.57 → 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 +258 -165
- 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. */
|
|
@@ -10010,21 +10010,29 @@ const isLaunch = (row) => {
|
|
|
10010
10010
|
const kinds = metadataOf(row).change?.kinds ?? [];
|
|
10011
10011
|
return kinds.includes("bundle") && !kinds.includes("first_seen") && row.to_release_id !== null;
|
|
10012
10012
|
};
|
|
10013
|
+
const sideRef = (key, releaseId, bundleId) => key === "release" ? releaseId ?? bundleId : bundleId;
|
|
10013
10014
|
/**
|
|
10014
10015
|
* The bundle a stored row's bundle filter matches: `from:<bundle>` for a
|
|
10015
10016
|
* recovery; `to:<bundle>` for a download, an apply, and an update failure;
|
|
10016
10017
|
* `on:<bundle>` for an UNCHANGED row that launched a bundle (`isLaunch`), a
|
|
10017
10018
|
* key no other row uses. None for a failed check, which targets no bundle, a
|
|
10018
|
-
* late row, or any other UNCHANGED row.
|
|
10019
|
+
* late row, or any other UNCHANGED row. Each names its bundle by `key`.
|
|
10019
10020
|
*/
|
|
10020
|
-
const bundleRefsOf = (row) => {
|
|
10021
|
+
const bundleRefsOf = (row, key = "release") => {
|
|
10021
10022
|
if (isFailedCheck(row) || isLateEvent(row)) return [];
|
|
10022
|
-
if (row.type === "RECOVERED") return [`from:${row.from_bundle_id}`];
|
|
10023
|
-
if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${row.to_bundle_id}`] : [];
|
|
10024
|
-
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)}`];
|
|
10025
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)}`]] : []];
|
|
10026
10034
|
/** The key a bundle filter reads, as `bundleRefsOf` writes it. */
|
|
10027
|
-
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}`;
|
|
10028
10036
|
/**
|
|
10029
10037
|
* Downloads, applies, recoveries, update failures, and the UNCHANGED
|
|
10030
10038
|
* reports that changed what their installation runs, whole. An UNCHANGED
|
|
@@ -10089,7 +10097,11 @@ const bundleEvents = (days) => defineTable({
|
|
|
10089
10097
|
type: "string",
|
|
10090
10098
|
compute: (row) => MOVEMENTS.has(row.type) ? row.install_id : null
|
|
10091
10099
|
},
|
|
10092
|
-
/**
|
|
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
|
+
*/
|
|
10093
10105
|
bundle_ref: {
|
|
10094
10106
|
type: "string",
|
|
10095
10107
|
multi: true,
|
|
@@ -10408,7 +10420,13 @@ const insightsBuiltinDistribution = (retention) => defineAggregate({
|
|
|
10408
10420
|
},
|
|
10409
10421
|
retention
|
|
10410
10422
|
});
|
|
10411
|
-
/**
|
|
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
|
+
*/
|
|
10412
10430
|
const insightsLatestByBundle = (retention) => defineAggregate({
|
|
10413
10431
|
platform: {
|
|
10414
10432
|
type: "string",
|
|
@@ -10456,7 +10474,9 @@ const insightsLatestByBundle = (retention) => defineAggregate({
|
|
|
10456
10474
|
* Stored events by outcome and the bundle a bundle filter matches, a row an
|
|
10457
10475
|
* hour, which a failed check has none of; and every stored event, a row a UTC
|
|
10458
10476
|
* day (`DAILY_EVENTS`). Bundle counts sum the hourly rows, and event lists
|
|
10459
|
-
* 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.
|
|
10460
10480
|
*/
|
|
10461
10481
|
const insightsOutcomes = (retention) => defineAggregate({
|
|
10462
10482
|
platform: {
|
|
@@ -10535,6 +10555,96 @@ const createInsightsSchema = ({ rawDays, dailyDays } = DEFAULT_INSIGHTS_RETENTIO
|
|
|
10535
10555
|
};
|
|
10536
10556
|
createInsightsSchema();
|
|
10537
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
|
|
10538
10648
|
//#region ../insights/dist/server/eventRow.mjs
|
|
10539
10649
|
const CHANGE_KINDS = /* @__PURE__ */ new Set([
|
|
10540
10650
|
"first_seen",
|
|
@@ -10631,7 +10741,7 @@ const isBundleFilter = (value, withKind = false) => {
|
|
|
10631
10741
|
"type",
|
|
10632
10742
|
...withKind ? ["kind"] : []
|
|
10633
10743
|
];
|
|
10634
|
-
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"]);
|
|
10635
10745
|
};
|
|
10636
10746
|
const isEventFilter = (value) => {
|
|
10637
10747
|
if (!isRecord$3(value)) return false;
|
|
@@ -10732,20 +10842,24 @@ const createValidatedInsightsModel = (model) => ({
|
|
|
10732
10842
|
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
10733
10843
|
"platform",
|
|
10734
10844
|
"channel",
|
|
10735
|
-
"sinceMs"
|
|
10736
|
-
|
|
10737
|
-
]) || !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, [
|
|
10738
|
-
"field",
|
|
10739
|
-
"value",
|
|
10740
|
-
"types"
|
|
10741
|
-
]) || 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) => ![
|
|
10742
|
-
"UNCHANGED",
|
|
10743
|
-
"UPDATE_DOWNLOADED",
|
|
10744
|
-
"UPDATE_APPLIED",
|
|
10745
|
-
"RECOVERED"
|
|
10746
|
-
].includes(type))))) invalidQuery();
|
|
10845
|
+
"sinceMs"
|
|
10846
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs)) invalidQuery();
|
|
10747
10847
|
return validateCount(await model.countLatestEvents(input));
|
|
10748
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
|
+
},
|
|
10749
10863
|
async countEvents(input) {
|
|
10750
10864
|
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
10751
10865
|
"filter",
|
|
@@ -10802,6 +10916,7 @@ const createInsightsModel = (api) => createValidatedInsightsModel({
|
|
|
10802
10916
|
listEvents: api.listEvents,
|
|
10803
10917
|
findLatestEvents: api.findLatestEvents,
|
|
10804
10918
|
countLatestEvents: api.countLatestEvents,
|
|
10919
|
+
countReleaseInstallations: api.countReleaseInstallations,
|
|
10805
10920
|
countEvents: api.countEvents,
|
|
10806
10921
|
countEventSeries: api.countEventSeries,
|
|
10807
10922
|
getReleaseActivity: api.getReleaseActivity,
|
|
@@ -11204,27 +11319,27 @@ const readScope$1 = (input) => {
|
|
|
11204
11319
|
};
|
|
11205
11320
|
const bundleFilter = (input) => {
|
|
11206
11321
|
const scope = readScope$1(input);
|
|
11207
|
-
const
|
|
11322
|
+
const releaseId = requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
11208
11323
|
switch (input.outcome) {
|
|
11209
11324
|
case "downloaded": return {
|
|
11210
11325
|
...scope,
|
|
11211
11326
|
type: "UPDATE_DOWNLOADED",
|
|
11212
|
-
|
|
11327
|
+
toReleaseId: releaseId
|
|
11213
11328
|
};
|
|
11214
11329
|
case "applied": return {
|
|
11215
11330
|
...scope,
|
|
11216
11331
|
type: "UPDATE_APPLIED",
|
|
11217
|
-
|
|
11332
|
+
toReleaseId: releaseId
|
|
11218
11333
|
};
|
|
11219
11334
|
case "recovered": return {
|
|
11220
11335
|
...scope,
|
|
11221
11336
|
type: "RECOVERED",
|
|
11222
|
-
|
|
11337
|
+
fromReleaseId: releaseId
|
|
11223
11338
|
};
|
|
11224
11339
|
case "failed": return {
|
|
11225
11340
|
...scope,
|
|
11226
11341
|
type: "UPDATE_FAILED",
|
|
11227
|
-
|
|
11342
|
+
toReleaseId: releaseId
|
|
11228
11343
|
};
|
|
11229
11344
|
default: throw new InsightsBadRequestError("Invalid Insights outcome.");
|
|
11230
11345
|
}
|
|
@@ -11234,7 +11349,7 @@ const sameFilter = (left, right) => {
|
|
|
11234
11349
|
switch (right.kind) {
|
|
11235
11350
|
case "all": return true;
|
|
11236
11351
|
case "installationMovement": return left.installId === right.installId;
|
|
11237
|
-
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);
|
|
11238
11353
|
}
|
|
11239
11354
|
};
|
|
11240
11355
|
const readEventCursor = (value, filter) => {
|
|
@@ -11271,7 +11386,7 @@ const assertEventRows = (rows, input) => {
|
|
|
11271
11386
|
for (let index = 0; index < rows.length; index += 1) {
|
|
11272
11387
|
const row = rows[index];
|
|
11273
11388
|
const previous = rows[index - 1];
|
|
11274
|
-
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.");
|
|
11275
11390
|
}
|
|
11276
11391
|
};
|
|
11277
11392
|
/** An `UPDATE_FAILED` row's failure, as the event lists show it. */
|
|
@@ -11312,6 +11427,7 @@ const eventDetails = ({ type, metadata }) => ({
|
|
|
11312
11427
|
...metadata.implied_download === true ? { impliedDownload: true } : {}
|
|
11313
11428
|
});
|
|
11314
11429
|
const toEventHistoryRow = (row) => ({
|
|
11430
|
+
...row.from_release_id == null ? {} : { fromReleaseId: row.from_release_id },
|
|
11315
11431
|
...row.to_release_id == null ? {} : { toReleaseId: row.to_release_id },
|
|
11316
11432
|
...row.metadata.sdk_version == null ? {} : { sdkVersion: row.metadata.sdk_version },
|
|
11317
11433
|
...row.metadata.min_bundle_id === void 0 ? {} : { minBundleId: row.metadata.min_bundle_id },
|
|
@@ -11336,6 +11452,7 @@ const toInstallationRow = (row) => ({
|
|
|
11336
11452
|
cohort: row.metadata.cohort,
|
|
11337
11453
|
installId: row.install_id,
|
|
11338
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,
|
|
11339
11456
|
pendingBundleId: row.type === "UPDATE_DOWNLOADED" ? row.to_bundle_id : null,
|
|
11340
11457
|
pendingReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.to_release_id : null,
|
|
11341
11458
|
latestStatus: row.type,
|
|
@@ -11464,46 +11581,33 @@ const createInsightsProvider = (model) => Object.freeze({
|
|
|
11464
11581
|
measuredAtMs: Date.now()
|
|
11465
11582
|
};
|
|
11466
11583
|
};
|
|
11467
|
-
const
|
|
11468
|
-
|
|
11469
|
-
...scope,
|
|
11470
|
-
sinceMs
|
|
11471
|
-
}));
|
|
11472
|
-
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 {
|
|
11473
11586
|
...scope,
|
|
11474
11587
|
window,
|
|
11475
11588
|
sinceMs,
|
|
11476
11589
|
beforeReceivedAtMs,
|
|
11477
|
-
reportingInstallations: await
|
|
11590
|
+
reportingInstallations: await measure(model.countLatestEvents({
|
|
11591
|
+
...scope,
|
|
11592
|
+
sinceMs
|
|
11593
|
+
}))
|
|
11478
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))]);
|
|
11479
11600
|
const countOutcome = (outcome) => measure(model.countEvents({
|
|
11480
11601
|
filter: bundleFilter({
|
|
11481
11602
|
...scope,
|
|
11482
|
-
|
|
11603
|
+
releaseId,
|
|
11483
11604
|
outcome
|
|
11484
11605
|
}),
|
|
11485
11606
|
sinceMs,
|
|
11486
11607
|
beforeReceivedAtMs
|
|
11487
11608
|
}));
|
|
11488
|
-
const [reportingInstallations, bundleInstallations, downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
11489
|
-
|
|
11490
|
-
measure(model.countLatestEvents({
|
|
11491
|
-
...scope,
|
|
11492
|
-
sinceMs,
|
|
11493
|
-
bundle: [{
|
|
11494
|
-
field: "from_bundle_id",
|
|
11495
|
-
value: bundleId,
|
|
11496
|
-
types: ["UPDATE_DOWNLOADED"]
|
|
11497
|
-
}, {
|
|
11498
|
-
field: "to_bundle_id",
|
|
11499
|
-
value: bundleId,
|
|
11500
|
-
types: [
|
|
11501
|
-
"UNCHANGED",
|
|
11502
|
-
"UPDATE_APPLIED",
|
|
11503
|
-
"RECOVERED"
|
|
11504
|
-
]
|
|
11505
|
-
}]
|
|
11506
|
-
})),
|
|
11609
|
+
const [[reportingInstallations, bundleInstallations], downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
11610
|
+
installations,
|
|
11507
11611
|
countOutcome("downloaded"),
|
|
11508
11612
|
countOutcome("applied"),
|
|
11509
11613
|
countOutcome("recovered"),
|
|
@@ -11516,7 +11620,7 @@ const createInsightsProvider = (model) => Object.freeze({
|
|
|
11516
11620
|
beforeReceivedAtMs,
|
|
11517
11621
|
reportingInstallations,
|
|
11518
11622
|
bundle: {
|
|
11519
|
-
|
|
11623
|
+
releaseId,
|
|
11520
11624
|
reportingInstallations: bundleInstallations,
|
|
11521
11625
|
downloadedReports,
|
|
11522
11626
|
appliedReports,
|
|
@@ -11651,17 +11755,10 @@ const gaugeSlot = (head) => ({
|
|
|
11651
11755
|
builtinBundleId: runningBuiltinBundleId(head)
|
|
11652
11756
|
});
|
|
11653
11757
|
/**
|
|
11654
|
-
* The `insights_latest_by_bundle` field of a head's (from, to) pair. A head
|
|
11655
|
-
* matches a `from` and a `to` predicate of one type at once only through its
|
|
11656
|
-
* pair, so this gauge is what a count subtracts to count it once.
|
|
11657
|
-
*/
|
|
11658
|
-
const PAIR_FIELD = "from_to";
|
|
11659
|
-
/** The pair gauge's `bundle_id`: a hash of the two bundle ids, which fit no single 36-character column. */
|
|
11660
|
-
const bundlePairKey = (from, to) => insightsKey(`${from.length}:${from}${to.length}:${to}`);
|
|
11661
|
-
/**
|
|
11662
11758
|
* Moves a head's gauges: the distribution row, and the built-in one when it
|
|
11663
|
-
* runs its build's built-in bundle
|
|
11664
|
-
*
|
|
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.
|
|
11665
11762
|
*/
|
|
11666
11763
|
const countHead = (tx, head, delta) => {
|
|
11667
11764
|
const { bucket, releaseId, builtinBundleId } = gaugeSlot(head);
|
|
@@ -11681,26 +11778,6 @@ const countHead = (tx, head, delta) => {
|
|
|
11681
11778
|
builtin_bundle_id: builtinBundleId,
|
|
11682
11779
|
bucket_start_ms: bucket
|
|
11683
11780
|
}, { latest_installations: delta }, { shardBy });
|
|
11684
|
-
for (const field of ["from_bundle_id", "to_bundle_id"]) {
|
|
11685
|
-
const bundleId = head[field];
|
|
11686
|
-
if (bundleId === null) continue;
|
|
11687
|
-
tx.aggregate("insights_latest_by_bundle", {
|
|
11688
|
-
platform: head.platform,
|
|
11689
|
-
channel: head.channel,
|
|
11690
|
-
bundle_field: field,
|
|
11691
|
-
bundle_id: bundleId,
|
|
11692
|
-
type: head.type,
|
|
11693
|
-
bucket_start_ms: bucket
|
|
11694
|
-
}, { installations: delta }, { shardBy });
|
|
11695
|
-
}
|
|
11696
|
-
if (head.from_bundle_id !== null) tx.aggregate("insights_latest_by_bundle", {
|
|
11697
|
-
platform: head.platform,
|
|
11698
|
-
channel: head.channel,
|
|
11699
|
-
bundle_field: PAIR_FIELD,
|
|
11700
|
-
bundle_id: bundlePairKey(head.from_bundle_id, head.to_bundle_id),
|
|
11701
|
-
type: head.type,
|
|
11702
|
-
bucket_start_ms: bucket
|
|
11703
|
-
}, { installations: delta }, { shardBy });
|
|
11704
11781
|
};
|
|
11705
11782
|
/**
|
|
11706
11783
|
* Where each period's rows go, each with its retention: hours for 90 days,
|
|
@@ -11761,26 +11838,19 @@ const countEvent = (tx, event) => {
|
|
|
11761
11838
|
}
|
|
11762
11839
|
};
|
|
11763
11840
|
/**
|
|
11764
|
-
* A stored event's outcome rows: its bundle filter's hour,
|
|
11765
|
-
*
|
|
11766
|
-
*
|
|
11767
|
-
* hour of that launch or crash, so the download series covers what the
|
|
11768
|
-
* 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.
|
|
11769
11844
|
*/
|
|
11770
11845
|
const countOutcome = (tx, event) => {
|
|
11771
11846
|
const shardBy = event.install_id;
|
|
11772
|
-
const
|
|
11847
|
+
for (const [type, bundleRef] of outcomeRefsOf(event)) tx.aggregate("insights_outcomes", {
|
|
11773
11848
|
platform: event.platform,
|
|
11774
11849
|
channel: event.channel,
|
|
11775
11850
|
type,
|
|
11776
11851
|
bundle_ref: bundleRef,
|
|
11777
11852
|
bucket_start_ms: hourOf(event.received_at_ms)
|
|
11778
11853
|
}, { events: 1 }, { shardBy });
|
|
11779
|
-
for (const bundleRef of bundleRefsOf(event)) hour(event.type, bundleRef);
|
|
11780
|
-
if (event.metadata.implied_download === true) hour("UPDATE_DOWNLOADED", bundleRefOfFilter({
|
|
11781
|
-
type: "UPDATE_DOWNLOADED",
|
|
11782
|
-
toBundleId: event.type === "RECOVERED" ? event.from_bundle_id : event.to_bundle_id
|
|
11783
|
-
}));
|
|
11784
11854
|
tx.aggregate("insights_outcomes", {
|
|
11785
11855
|
...DAILY_EVENTS,
|
|
11786
11856
|
bucket_start_ms: dayOf(event.received_at_ms)
|
|
@@ -12260,31 +12330,48 @@ const countEventSeries = async (db, input) => {
|
|
|
12260
12330
|
events: count
|
|
12261
12331
|
}));
|
|
12262
12332
|
};
|
|
12263
|
-
/**
|
|
12264
|
-
const
|
|
12265
|
-
if (
|
|
12266
|
-
return
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12274
|
-
|
|
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
|
+
}));
|
|
12275
12346
|
};
|
|
12347
|
+
const installations = (count) => Math.max(0, count);
|
|
12276
12348
|
/**
|
|
12277
12349
|
* Latest events at or after `sinceMs`, a UTC day's start: the gauges count
|
|
12278
12350
|
* each installation in the UTC day of its latest event, so they answer whole
|
|
12279
12351
|
* days only, and a later start is rejected rather than rounded.
|
|
12280
12352
|
*/
|
|
12281
|
-
const countLatestEvents = async (db, input) =>
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
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;
|
|
12285
12364
|
let total = 0;
|
|
12286
|
-
|
|
12287
|
-
|
|
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", {
|
|
12288
12375
|
index: "byScope",
|
|
12289
12376
|
where: {
|
|
12290
12377
|
channel,
|
|
@@ -12294,33 +12381,12 @@ const countLatestEvents = async (db, input) => {
|
|
|
12294
12381
|
limit: PAGE,
|
|
12295
12382
|
...page
|
|
12296
12383
|
}));
|
|
12297
|
-
|
|
12298
|
-
} else {
|
|
12299
|
-
const gauge = async (bundleField, bundleId, type) => {
|
|
12300
|
-
return (await drain((page) => db.findAggregates("insights_latest_by_bundle", {
|
|
12301
|
-
index: "byBundle",
|
|
12302
|
-
where: {
|
|
12303
|
-
platform,
|
|
12304
|
-
channel,
|
|
12305
|
-
bundle_field: bundleField,
|
|
12306
|
-
bundle_id: bundleId,
|
|
12307
|
-
type
|
|
12308
|
-
},
|
|
12309
|
-
range: { gte: start },
|
|
12310
|
-
limit: PAGE,
|
|
12311
|
-
...page
|
|
12312
|
-
}))).reduce((sum, row) => sum + row.installations, 0);
|
|
12313
|
-
};
|
|
12314
|
-
for (const { field, value, type } of predicates) total += await gauge(field, value, type);
|
|
12315
|
-
for (const from of predicates) {
|
|
12316
|
-
if (from.field !== "from_bundle_id") continue;
|
|
12317
|
-
for (const to of predicates) {
|
|
12318
|
-
if (to.field !== "to_bundle_id" || to.type !== from.type) continue;
|
|
12319
|
-
total -= await gauge(PAIR_FIELD, bundlePairKey(from.value, to.value), from.type);
|
|
12320
|
-
}
|
|
12321
|
-
}
|
|
12384
|
+
for (const row of builtin) if (row.release_id === "" && row.builtin_bundle_id === releaseId) release += row.latest_installations;
|
|
12322
12385
|
}
|
|
12323
|
-
return
|
|
12386
|
+
return {
|
|
12387
|
+
installations: installations(total),
|
|
12388
|
+
release: installations(release)
|
|
12389
|
+
};
|
|
12324
12390
|
};
|
|
12325
12391
|
/** The oldest whole hour and UTC day that hourly and daily rows still hold. */
|
|
12326
12392
|
const retained = (now, { rawDays, dailyDays }) => ({
|
|
@@ -12790,6 +12856,26 @@ const getUpdateFailures = async (db, input, now, retention) => {
|
|
|
12790
12856
|
};
|
|
12791
12857
|
};
|
|
12792
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
|
|
12793
12879
|
//#region ../insights/dist/server/queryInput.mjs
|
|
12794
12880
|
const MAX_PAGE_LIMIT = 100;
|
|
12795
12881
|
const MAX_IDENTITY_LENGTH = 255;
|
|
@@ -12834,7 +12920,7 @@ const readScope = (url) => {
|
|
|
12834
12920
|
const parseEventPageInput = (request) => {
|
|
12835
12921
|
const url = new URL(request.url);
|
|
12836
12922
|
const bundleFields = [
|
|
12837
|
-
|
|
12923
|
+
RELEASE_ID_PARAM,
|
|
12838
12924
|
"outcome",
|
|
12839
12925
|
"platform",
|
|
12840
12926
|
"channel"
|
|
@@ -12845,7 +12931,7 @@ const parseEventPageInput = (request) => {
|
|
|
12845
12931
|
if (outcome !== "downloaded" && outcome !== "applied" && outcome !== "recovered" && outcome !== "failed") throw new InsightsBadRequestError("Invalid 'outcome' query parameter.");
|
|
12846
12932
|
bundle = {
|
|
12847
12933
|
...readScope(url),
|
|
12848
|
-
|
|
12934
|
+
releaseId: readId(url, RELEASE_ID_PARAM, 1024),
|
|
12849
12935
|
outcome
|
|
12850
12936
|
};
|
|
12851
12937
|
}
|
|
@@ -12871,11 +12957,10 @@ const parseReportingOverviewInput = (request) => {
|
|
|
12871
12957
|
const url = new URL(request.url);
|
|
12872
12958
|
const window = readSingle(url, "window") ?? "30d";
|
|
12873
12959
|
if (window !== "24h" && window !== "7d" && window !== "30d") throw new InsightsBadRequestError("Invalid 'window' query parameter.");
|
|
12874
|
-
const bundleId = readSingle(url, "bundleId");
|
|
12875
12960
|
return {
|
|
12876
12961
|
...readScope(url),
|
|
12877
12962
|
window,
|
|
12878
|
-
...bundleId === void 0 ? {} : {
|
|
12963
|
+
...readSingle(url, "bundleId") === void 0 ? {} : { releaseId: readId(url, RELEASE_ID_PARAM, 1024) }
|
|
12879
12964
|
};
|
|
12880
12965
|
};
|
|
12881
12966
|
//#endregion
|
|
@@ -12956,7 +13041,7 @@ const createInsightsRouteHandlers = (provider) => ({
|
|
|
12956
13041
|
await provider.appendBundleEvent(await parseBundleEventRequest(request));
|
|
12957
13042
|
return new Response(null, { status: 204 });
|
|
12958
13043
|
}),
|
|
12959
|
-
getReportingOverview: (_params, request) => query(() => provider.getReportingOverview(parseReportingOverviewInput(request))),
|
|
13044
|
+
getReportingOverview: (_params, request) => query(async () => toWireOverview(await provider.getReportingOverview(parseReportingOverviewInput(request)))),
|
|
12960
13045
|
getInstallation: (params) => run$1(async () => {
|
|
12961
13046
|
const installation = await provider.getInstallation({ installId: requireParam(params, "installId") });
|
|
12962
13047
|
return installation === null ? json$1({ error: "Installation not found" }, 404) : json$1(installation, 200);
|
|
@@ -12978,12 +13063,20 @@ const createInsightsApi = (db, now, retention) => ({
|
|
|
12978
13063
|
listEvents: (input) => listEvents(db, input),
|
|
12979
13064
|
findLatestEvents: (input) => findLatestEvents(db, input),
|
|
12980
13065
|
countLatestEvents: (input) => countLatestEvents(db, input),
|
|
13066
|
+
countReleaseInstallations: (input) => countReleaseInstallations(db, input),
|
|
12981
13067
|
countEvents: (input) => countEvents(db, input),
|
|
12982
13068
|
countEventSeries: (input) => countEventSeries(db, input),
|
|
12983
13069
|
getReleaseActivity: (input) => getReleaseActivity(db, input, now),
|
|
12984
13070
|
getAppUsage: (input) => getAppUsage(db, input, now, retention),
|
|
12985
13071
|
/** A release's or a channel's update failures, and their breakdown over a time range. */
|
|
12986
|
-
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)
|
|
12987
13080
|
});
|
|
12988
13081
|
/** `GET /failures`'s query: a scope, an optional release, and a time range or none. */
|
|
12989
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/server": "1.2.0-rc.
|
|
44
|
-
"@hot-updater/plugin-core": "1.2.0-rc.
|
|
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",
|