@hot-updater/cloudflare 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/init/index.cjs +1 -0
- package/dist/init/index.mjs +2 -1
- package/package.json +7 -7
- package/worker/dist/README.md +1 -1
- package/worker/dist/index.js +204 -158
- package/worker/dist/index.js.map +4 -4
package/worker/dist/index.js
CHANGED
|
@@ -539,14 +539,14 @@ function modularInverse(value, modulus) {
|
|
|
539
539
|
return positiveMod(t, modulus);
|
|
540
540
|
}
|
|
541
541
|
__name(modularInverse, "modularInverse");
|
|
542
|
-
function getRolloutShuffleParameters(
|
|
543
|
-
let multiplier = positiveMod(hashString(`${
|
|
542
|
+
function getRolloutShuffleParameters(releaseId) {
|
|
543
|
+
let multiplier = positiveMod(hashString(`${releaseId}:multiplier`), 997);
|
|
544
544
|
if (multiplier === 0) multiplier = 1;
|
|
545
545
|
while (gcd(multiplier, NUMERIC_COHORT_SIZE) !== 1) {
|
|
546
546
|
multiplier = positiveMod(multiplier + 1, NUMERIC_COHORT_SIZE);
|
|
547
547
|
if (multiplier === 0) multiplier = 1;
|
|
548
548
|
}
|
|
549
|
-
const offset = positiveMod(hashString(`${
|
|
549
|
+
const offset = positiveMod(hashString(`${releaseId}:offset`), NUMERIC_COHORT_SIZE);
|
|
550
550
|
return {
|
|
551
551
|
multiplier,
|
|
552
552
|
offset,
|
|
@@ -586,17 +586,17 @@ function isValidCohort(cohort) {
|
|
|
586
586
|
return isNumericCohort(normalized) || isCustomCohort(normalized);
|
|
587
587
|
}
|
|
588
588
|
__name(isValidCohort, "isValidCohort");
|
|
589
|
-
function getNumericCohortRolloutPosition(
|
|
589
|
+
function getNumericCohortRolloutPosition(releaseId, cohortValue) {
|
|
590
590
|
if (cohortValue < 1 || cohortValue > 1e3) throw new Error(`Invalid numeric cohort: ${cohortValue}`);
|
|
591
|
-
const { offset, inverseMultiplier } = getRolloutShuffleParameters(
|
|
591
|
+
const { offset, inverseMultiplier } = getRolloutShuffleParameters(releaseId);
|
|
592
592
|
return positiveMod(inverseMultiplier * (cohortValue - 1 - offset), NUMERIC_COHORT_SIZE);
|
|
593
593
|
}
|
|
594
594
|
__name(getNumericCohortRolloutPosition, "getNumericCohortRolloutPosition");
|
|
595
|
-
function getRolledOutNumericCohorts(
|
|
595
|
+
function getRolledOutNumericCohorts(releaseId, rolloutCohortCount) {
|
|
596
596
|
const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
597
597
|
if (normalizedRolloutCount <= 0) return [];
|
|
598
598
|
if (normalizedRolloutCount >= 1e3) return Array.from({ length: NUMERIC_COHORT_SIZE }, (_, index) => index + 1);
|
|
599
|
-
const { multiplier, offset } = getRolloutShuffleParameters(
|
|
599
|
+
const { multiplier, offset } = getRolloutShuffleParameters(releaseId);
|
|
600
600
|
return Array.from({ length: normalizedRolloutCount }, (_, position) => positiveMod(multiplier * position + offset, NUMERIC_COHORT_SIZE)).map((zeroBasedCohort) => zeroBasedCohort + 1).sort((left, right) => left - right);
|
|
601
601
|
}
|
|
602
602
|
__name(getRolledOutNumericCohorts, "getRolledOutNumericCohorts");
|
|
@@ -5021,7 +5021,7 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
|
|
|
5021
5021
|
}, "createSqlAdapter");
|
|
5022
5022
|
|
|
5023
5023
|
// ../../packages/server/dist/package.mjs
|
|
5024
|
-
var version = "1.2.0-rc.
|
|
5024
|
+
var version = "1.2.0-rc.58";
|
|
5025
5025
|
|
|
5026
5026
|
// ../../packages/server/dist/version.mjs
|
|
5027
5027
|
var HOT_UPDATER_SERVER_VERSION = version;
|
|
@@ -9513,13 +9513,15 @@ var isLaunch = /* @__PURE__ */ __name((row) => {
|
|
|
9513
9513
|
const kinds = metadataOf(row).change?.kinds ?? [];
|
|
9514
9514
|
return kinds.includes("bundle") && !kinds.includes("first_seen") && row.to_release_id !== null;
|
|
9515
9515
|
}, "isLaunch");
|
|
9516
|
-
var
|
|
9516
|
+
var sideRef = /* @__PURE__ */ __name((key, releaseId, bundleId) => key === "release" ? releaseId ?? bundleId : bundleId, "sideRef");
|
|
9517
|
+
var bundleRefsOf = /* @__PURE__ */ __name((row, key = "release") => {
|
|
9517
9518
|
if (isFailedCheck(row) || isLateEvent(row)) return [];
|
|
9518
|
-
if (row.type === "RECOVERED") return [`from:${row.from_bundle_id}`];
|
|
9519
|
-
if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${row.to_bundle_id}`] : [];
|
|
9520
|
-
return [`to:${row.to_bundle_id}`];
|
|
9519
|
+
if (row.type === "RECOVERED") return [`from:${sideRef(key, row.from_release_id, row.from_bundle_id)}`];
|
|
9520
|
+
if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${sideRef(key, row.to_release_id, row.to_bundle_id)}`] : [];
|
|
9521
|
+
return [`to:${sideRef(key, row.to_release_id, row.to_bundle_id)}`];
|
|
9521
9522
|
}, "bundleRefsOf");
|
|
9522
|
-
var
|
|
9523
|
+
var outcomeRefsOf = /* @__PURE__ */ __name((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)}`]] : []], "outcomeRefsOf");
|
|
9524
|
+
var bundleRefOfFilter = /* @__PURE__ */ __name((filter) => filter.type === "RECOVERED" ? `from:${filter.fromReleaseId}` : filter.type === "UNCHANGED" ? `on:${filter.toReleaseId}` : `to:${filter.toReleaseId}`, "bundleRefOfFilter");
|
|
9523
9525
|
var bundleEvents = /* @__PURE__ */ __name((days) => defineTable({
|
|
9524
9526
|
id: {
|
|
9525
9527
|
type: "string",
|
|
@@ -9578,7 +9580,11 @@ var bundleEvents = /* @__PURE__ */ __name((days) => defineTable({
|
|
|
9578
9580
|
type: "string",
|
|
9579
9581
|
compute: /* @__PURE__ */ __name((row) => MOVEMENTS.has(row.type) ? row.install_id : null, "compute")
|
|
9580
9582
|
},
|
|
9581
|
-
/**
|
|
9583
|
+
/**
|
|
9584
|
+
* The bundle a bundle filter matches (`bundleRefsOf`), by release.
|
|
9585
|
+
* Rows a 1.1 server wrote name the artifact until
|
|
9586
|
+
* `backfillReleaseRefs` rewrites them.
|
|
9587
|
+
*/
|
|
9582
9588
|
bundle_ref: {
|
|
9583
9589
|
type: "string",
|
|
9584
9590
|
multi: true,
|
|
@@ -9956,6 +9962,70 @@ var createInsightsSchema = /* @__PURE__ */ __name(({ rawDays, dailyDays } = DEFA
|
|
|
9956
9962
|
}, "createInsightsSchema");
|
|
9957
9963
|
var insightsSchema = createInsightsSchema();
|
|
9958
9964
|
|
|
9965
|
+
// ../insights/dist/server/backfill.mjs
|
|
9966
|
+
var PAGE5 = 500;
|
|
9967
|
+
var BATCH = 25;
|
|
9968
|
+
var sameRefs = /* @__PURE__ */ __name((stored2, refs) => {
|
|
9969
|
+
const values = Array.isArray(stored2) ? stored2 : [];
|
|
9970
|
+
return values.length === refs.length && values.every((value) => refs.includes(value));
|
|
9971
|
+
}, "sameRefs");
|
|
9972
|
+
var namesArtifact = /* @__PURE__ */ __name((row) => {
|
|
9973
|
+
const byKey = /* @__PURE__ */ __name((key) => bundleRefsOf(row, key), "byKey");
|
|
9974
|
+
return sameRefs(row.bundle_ref, byKey("artifact")) && !sameRefs(row.bundle_ref, byKey("release"));
|
|
9975
|
+
}, "namesArtifact");
|
|
9976
|
+
var backfillReleaseRefs = /* @__PURE__ */ __name(async (db, now, { rawDays }, { dryRun: dryRun2 = false } = {}) => {
|
|
9977
|
+
const today = now() - now() % DAY_MS2;
|
|
9978
|
+
let events = 0;
|
|
9979
|
+
const move = /* @__PURE__ */ __name(async (candidates) => {
|
|
9980
|
+
if (dryRun2) {
|
|
9981
|
+
events += candidates.length;
|
|
9982
|
+
return;
|
|
9983
|
+
}
|
|
9984
|
+
const moved = await rewrite3(candidates).catch(async (error) => {
|
|
9985
|
+
if (!(error instanceof DatabaseConstraintError) || error.reason !== "too_large" || candidates.length === 1) throw error;
|
|
9986
|
+
const half = Math.ceil(candidates.length / 2);
|
|
9987
|
+
await move(candidates.slice(0, half));
|
|
9988
|
+
await move(candidates.slice(half));
|
|
9989
|
+
return 0;
|
|
9990
|
+
});
|
|
9991
|
+
events += moved;
|
|
9992
|
+
}, "move");
|
|
9993
|
+
const rewrite3 = /* @__PURE__ */ __name((candidates) => db.transaction(async (tx) => {
|
|
9994
|
+
const rows = await Promise.all(candidates.map(({ id }) => tx.findOne("bundle_events", { id })));
|
|
9995
|
+
let moved = 0;
|
|
9996
|
+
for (const row of rows) {
|
|
9997
|
+
if (row === null || !namesArtifact(row)) continue;
|
|
9998
|
+
tx.update("bundle_events", row, {});
|
|
9999
|
+
const outcome = /* @__PURE__ */ __name((ref, delta) => tx.aggregate("insights_outcomes", {
|
|
10000
|
+
platform: row.platform,
|
|
10001
|
+
channel: row.channel,
|
|
10002
|
+
type: ref[0],
|
|
10003
|
+
bundle_ref: ref[1],
|
|
10004
|
+
bucket_start_ms: row.received_at_ms - row.received_at_ms % HOUR_MS2
|
|
10005
|
+
}, { events: delta }, { shardBy: row.install_id }), "outcome");
|
|
10006
|
+
for (const ref of outcomeRefsOf(row, "artifact")) outcome(ref, -1);
|
|
10007
|
+
for (const ref of outcomeRefsOf(row, "release")) outcome(ref, 1);
|
|
10008
|
+
moved += 1;
|
|
10009
|
+
}
|
|
10010
|
+
return moved;
|
|
10011
|
+
}), "rewrite");
|
|
10012
|
+
for (let day = today - rawDays * DAY_MS2; day <= today; day += DAY_MS2) {
|
|
10013
|
+
let cursor;
|
|
10014
|
+
do {
|
|
10015
|
+
const page2 = await db.findMany("bundle_events", {
|
|
10016
|
+
index: "byDay",
|
|
10017
|
+
where: { day },
|
|
10018
|
+
limit: PAGE5,
|
|
10019
|
+
...cursor === void 0 ? {} : { cursor }
|
|
10020
|
+
});
|
|
10021
|
+
const stale = page2.rows.filter(namesArtifact);
|
|
10022
|
+
for (let start = 0; start < stale.length; start += BATCH) await move(stale.slice(start, start + BATCH));
|
|
10023
|
+
cursor = page2.next;
|
|
10024
|
+
} while (cursor !== void 0);
|
|
10025
|
+
}
|
|
10026
|
+
return { events };
|
|
10027
|
+
}, "backfillReleaseRefs");
|
|
10028
|
+
|
|
9959
10029
|
// ../insights/dist/server/eventRow.mjs
|
|
9960
10030
|
var CHANGE_KINDS = /* @__PURE__ */ new Set([
|
|
9961
10031
|
"first_seen",
|
|
@@ -10033,7 +10103,7 @@ var isBundleFilter = /* @__PURE__ */ __name((value, withKind = false) => {
|
|
|
10033
10103
|
"type",
|
|
10034
10104
|
...withKind ? ["kind"] : []
|
|
10035
10105
|
];
|
|
10036
|
-
return value.type === "RECOVERED" ? isText2(value.
|
|
10106
|
+
return value.type === "RECOVERED" ? isText2(value.fromReleaseId) && hasOnlyKeys(value, [...keys, "fromReleaseId"]) : (value.type === "UPDATE_DOWNLOADED" || value.type === "UPDATE_APPLIED" || value.type === "UPDATE_FAILED" || value.type === "UNCHANGED") && isText2(value.toReleaseId) && hasOnlyKeys(value, [...keys, "toReleaseId"]);
|
|
10037
10107
|
}, "isBundleFilter");
|
|
10038
10108
|
var isEventFilter = /* @__PURE__ */ __name((value) => {
|
|
10039
10109
|
if (!isRecord5(value)) return false;
|
|
@@ -10128,20 +10198,24 @@ var createValidatedInsightsModel = /* @__PURE__ */ __name((model) => ({
|
|
|
10128
10198
|
if (!isRecord5(input) || !hasOnlyKeys(input, [
|
|
10129
10199
|
"platform",
|
|
10130
10200
|
"channel",
|
|
10131
|
-
"sinceMs"
|
|
10132
|
-
|
|
10133
|
-
]) || !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) => !isRecord5(bundle) || !hasOnlyKeys(bundle, [
|
|
10134
|
-
"field",
|
|
10135
|
-
"value",
|
|
10136
|
-
"types"
|
|
10137
|
-
]) || bundle.field !== "from_bundle_id" && bundle.field !== "to_bundle_id" || !isText2(bundle.value) || !Array.isArray(bundle.types) || bundle.types.length === 0 || bundle.types.some((type) => ![
|
|
10138
|
-
"UNCHANGED",
|
|
10139
|
-
"UPDATE_DOWNLOADED",
|
|
10140
|
-
"UPDATE_APPLIED",
|
|
10141
|
-
"RECOVERED"
|
|
10142
|
-
].includes(type))))) invalidQuery();
|
|
10201
|
+
"sinceMs"
|
|
10202
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs)) invalidQuery();
|
|
10143
10203
|
return validateCount(await model.countLatestEvents(input));
|
|
10144
10204
|
},
|
|
10205
|
+
async countReleaseInstallations(input) {
|
|
10206
|
+
if (!isRecord5(input) || !hasOnlyKeys(input, [
|
|
10207
|
+
"platform",
|
|
10208
|
+
"channel",
|
|
10209
|
+
"sinceMs",
|
|
10210
|
+
"releaseId"
|
|
10211
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs) || !isText2(input.releaseId)) invalidQuery();
|
|
10212
|
+
const counts = await model.countReleaseInstallations(input);
|
|
10213
|
+
if (!isRecord5(counts) || !hasOnlyKeys(counts, ["installations", "release"])) invalidResult();
|
|
10214
|
+
return {
|
|
10215
|
+
installations: validateCount(counts.installations),
|
|
10216
|
+
release: validateCount(counts.release)
|
|
10217
|
+
};
|
|
10218
|
+
},
|
|
10145
10219
|
async countEvents(input) {
|
|
10146
10220
|
if (!isRecord5(input) || !hasOnlyKeys(input, [
|
|
10147
10221
|
"filter",
|
|
@@ -10194,6 +10268,7 @@ var createInsightsModel = /* @__PURE__ */ __name((api) => createValidatedInsight
|
|
|
10194
10268
|
listEvents: api.listEvents,
|
|
10195
10269
|
findLatestEvents: api.findLatestEvents,
|
|
10196
10270
|
countLatestEvents: api.countLatestEvents,
|
|
10271
|
+
countReleaseInstallations: api.countReleaseInstallations,
|
|
10197
10272
|
countEvents: api.countEvents,
|
|
10198
10273
|
countEventSeries: api.countEventSeries,
|
|
10199
10274
|
getReleaseActivity: api.getReleaseActivity,
|
|
@@ -10585,31 +10660,31 @@ var readScope = /* @__PURE__ */ __name((input) => {
|
|
|
10585
10660
|
}, "readScope");
|
|
10586
10661
|
var bundleFilter = /* @__PURE__ */ __name((input) => {
|
|
10587
10662
|
const scope = readScope(input);
|
|
10588
|
-
const
|
|
10663
|
+
const releaseId = requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
10589
10664
|
switch (input.outcome) {
|
|
10590
10665
|
case "downloaded":
|
|
10591
10666
|
return {
|
|
10592
10667
|
...scope,
|
|
10593
10668
|
type: "UPDATE_DOWNLOADED",
|
|
10594
|
-
|
|
10669
|
+
toReleaseId: releaseId
|
|
10595
10670
|
};
|
|
10596
10671
|
case "applied":
|
|
10597
10672
|
return {
|
|
10598
10673
|
...scope,
|
|
10599
10674
|
type: "UPDATE_APPLIED",
|
|
10600
|
-
|
|
10675
|
+
toReleaseId: releaseId
|
|
10601
10676
|
};
|
|
10602
10677
|
case "recovered":
|
|
10603
10678
|
return {
|
|
10604
10679
|
...scope,
|
|
10605
10680
|
type: "RECOVERED",
|
|
10606
|
-
|
|
10681
|
+
fromReleaseId: releaseId
|
|
10607
10682
|
};
|
|
10608
10683
|
case "failed":
|
|
10609
10684
|
return {
|
|
10610
10685
|
...scope,
|
|
10611
10686
|
type: "UPDATE_FAILED",
|
|
10612
|
-
|
|
10687
|
+
toReleaseId: releaseId
|
|
10613
10688
|
};
|
|
10614
10689
|
default:
|
|
10615
10690
|
throw new InsightsBadRequestError("Invalid Insights outcome.");
|
|
@@ -10623,7 +10698,7 @@ var sameFilter = /* @__PURE__ */ __name((left, right) => {
|
|
|
10623
10698
|
case "installationMovement":
|
|
10624
10699
|
return left.installId === right.installId;
|
|
10625
10700
|
case "bundle":
|
|
10626
|
-
return left.platform === right.platform && left.channel === right.channel && left.type === right.type && (right.type === "RECOVERED" ? left.
|
|
10701
|
+
return left.platform === right.platform && left.channel === right.channel && left.type === right.type && (right.type === "RECOVERED" ? left.fromReleaseId === right.fromReleaseId : left.toReleaseId === right.toReleaseId);
|
|
10627
10702
|
}
|
|
10628
10703
|
}, "sameFilter");
|
|
10629
10704
|
var readEventCursor = /* @__PURE__ */ __name((value, filter) => {
|
|
@@ -10660,7 +10735,7 @@ var assertEventRows = /* @__PURE__ */ __name((rows, input) => {
|
|
|
10660
10735
|
for (let index = 0; index < rows.length; index += 1) {
|
|
10661
10736
|
const row = rows[index];
|
|
10662
10737
|
const previous = rows[index - 1];
|
|
10663
|
-
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.
|
|
10738
|
+
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.");
|
|
10664
10739
|
}
|
|
10665
10740
|
}, "assertEventRows");
|
|
10666
10741
|
var toFailure = /* @__PURE__ */ __name((failure) => ({
|
|
@@ -10699,6 +10774,7 @@ var eventDetails = /* @__PURE__ */ __name(({ type, metadata }) => ({
|
|
|
10699
10774
|
...metadata.implied_download === true ? { impliedDownload: true } : {}
|
|
10700
10775
|
}), "eventDetails");
|
|
10701
10776
|
var toEventHistoryRow = /* @__PURE__ */ __name((row) => ({
|
|
10777
|
+
...row.from_release_id == null ? {} : { fromReleaseId: row.from_release_id },
|
|
10702
10778
|
...row.to_release_id == null ? {} : { toReleaseId: row.to_release_id },
|
|
10703
10779
|
...row.metadata.sdk_version == null ? {} : { sdkVersion: row.metadata.sdk_version },
|
|
10704
10780
|
...row.metadata.min_bundle_id === void 0 ? {} : { minBundleId: row.metadata.min_bundle_id },
|
|
@@ -10723,6 +10799,7 @@ var toInstallationRow = /* @__PURE__ */ __name((row) => ({
|
|
|
10723
10799
|
cohort: row.metadata.cohort,
|
|
10724
10800
|
installId: row.install_id,
|
|
10725
10801
|
lastKnownBundleId: row.type === "UPDATE_DOWNLOADED" ? row.from_bundle_id : row.to_bundle_id,
|
|
10802
|
+
lastKnownReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.from_release_id : row.to_release_id,
|
|
10726
10803
|
pendingBundleId: row.type === "UPDATE_DOWNLOADED" ? row.to_bundle_id : null,
|
|
10727
10804
|
pendingReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.to_release_id : null,
|
|
10728
10805
|
latestStatus: row.type,
|
|
@@ -10845,46 +10922,33 @@ var createInsightsProvider = /* @__PURE__ */ __name((model) => Object.freeze({
|
|
|
10845
10922
|
measuredAtMs: Date.now()
|
|
10846
10923
|
};
|
|
10847
10924
|
}, "measure");
|
|
10848
|
-
const
|
|
10849
|
-
|
|
10850
|
-
...scope,
|
|
10851
|
-
sinceMs
|
|
10852
|
-
}));
|
|
10853
|
-
if (bundleId === void 0) return {
|
|
10925
|
+
const releaseId = input.releaseId === void 0 ? void 0 : requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
10926
|
+
if (releaseId === void 0) return {
|
|
10854
10927
|
...scope,
|
|
10855
10928
|
window: window2,
|
|
10856
10929
|
sinceMs,
|
|
10857
10930
|
beforeReceivedAtMs,
|
|
10858
|
-
reportingInstallations: await
|
|
10931
|
+
reportingInstallations: await measure(model.countLatestEvents({
|
|
10932
|
+
...scope,
|
|
10933
|
+
sinceMs
|
|
10934
|
+
}))
|
|
10859
10935
|
};
|
|
10936
|
+
const installations2 = model.countReleaseInstallations({
|
|
10937
|
+
...scope,
|
|
10938
|
+
sinceMs,
|
|
10939
|
+
releaseId
|
|
10940
|
+
}).then(async (counts) => [await measure(Promise.resolve(counts.installations)), await measure(Promise.resolve(counts.release))]);
|
|
10860
10941
|
const countOutcome2 = /* @__PURE__ */ __name((outcome) => measure(model.countEvents({
|
|
10861
10942
|
filter: bundleFilter({
|
|
10862
10943
|
...scope,
|
|
10863
|
-
|
|
10944
|
+
releaseId,
|
|
10864
10945
|
outcome
|
|
10865
10946
|
}),
|
|
10866
10947
|
sinceMs,
|
|
10867
10948
|
beforeReceivedAtMs
|
|
10868
10949
|
})), "countOutcome");
|
|
10869
|
-
const [reportingInstallations, bundleInstallations, downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
10870
|
-
|
|
10871
|
-
measure(model.countLatestEvents({
|
|
10872
|
-
...scope,
|
|
10873
|
-
sinceMs,
|
|
10874
|
-
bundle: [{
|
|
10875
|
-
field: "from_bundle_id",
|
|
10876
|
-
value: bundleId,
|
|
10877
|
-
types: ["UPDATE_DOWNLOADED"]
|
|
10878
|
-
}, {
|
|
10879
|
-
field: "to_bundle_id",
|
|
10880
|
-
value: bundleId,
|
|
10881
|
-
types: [
|
|
10882
|
-
"UNCHANGED",
|
|
10883
|
-
"UPDATE_APPLIED",
|
|
10884
|
-
"RECOVERED"
|
|
10885
|
-
]
|
|
10886
|
-
}]
|
|
10887
|
-
})),
|
|
10950
|
+
const [[reportingInstallations, bundleInstallations], downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
10951
|
+
installations2,
|
|
10888
10952
|
countOutcome2("downloaded"),
|
|
10889
10953
|
countOutcome2("applied"),
|
|
10890
10954
|
countOutcome2("recovered"),
|
|
@@ -10897,7 +10961,7 @@ var createInsightsProvider = /* @__PURE__ */ __name((model) => Object.freeze({
|
|
|
10897
10961
|
beforeReceivedAtMs,
|
|
10898
10962
|
reportingInstallations,
|
|
10899
10963
|
bundle: {
|
|
10900
|
-
|
|
10964
|
+
releaseId,
|
|
10901
10965
|
reportingInstallations: bundleInstallations,
|
|
10902
10966
|
downloadedReports,
|
|
10903
10967
|
appliedReports,
|
|
@@ -11022,8 +11086,6 @@ var gaugeSlot = /* @__PURE__ */ __name((head) => ({
|
|
|
11022
11086
|
releaseId: head.type === "UPDATE_DOWNLOADED" ? head.from_release_id : head.to_release_id,
|
|
11023
11087
|
builtinBundleId: runningBuiltinBundleId(head)
|
|
11024
11088
|
}), "gaugeSlot");
|
|
11025
|
-
var PAIR_FIELD = "from_to";
|
|
11026
|
-
var bundlePairKey = /* @__PURE__ */ __name((from, to) => insightsKey(`${from.length}:${from}${to.length}:${to}`), "bundlePairKey");
|
|
11027
11089
|
var countHead = /* @__PURE__ */ __name((tx, head, delta) => {
|
|
11028
11090
|
const { bucket, releaseId, builtinBundleId } = gaugeSlot(head);
|
|
11029
11091
|
const shardBy = head.install_id;
|
|
@@ -11042,26 +11104,6 @@ var countHead = /* @__PURE__ */ __name((tx, head, delta) => {
|
|
|
11042
11104
|
builtin_bundle_id: builtinBundleId,
|
|
11043
11105
|
bucket_start_ms: bucket
|
|
11044
11106
|
}, { latest_installations: delta }, { shardBy });
|
|
11045
|
-
for (const field of ["from_bundle_id", "to_bundle_id"]) {
|
|
11046
|
-
const bundleId = head[field];
|
|
11047
|
-
if (bundleId === null) continue;
|
|
11048
|
-
tx.aggregate("insights_latest_by_bundle", {
|
|
11049
|
-
platform: head.platform,
|
|
11050
|
-
channel: head.channel,
|
|
11051
|
-
bundle_field: field,
|
|
11052
|
-
bundle_id: bundleId,
|
|
11053
|
-
type: head.type,
|
|
11054
|
-
bucket_start_ms: bucket
|
|
11055
|
-
}, { installations: delta }, { shardBy });
|
|
11056
|
-
}
|
|
11057
|
-
if (head.from_bundle_id !== null) tx.aggregate("insights_latest_by_bundle", {
|
|
11058
|
-
platform: head.platform,
|
|
11059
|
-
channel: head.channel,
|
|
11060
|
-
bundle_field: PAIR_FIELD,
|
|
11061
|
-
bundle_id: bundlePairKey(head.from_bundle_id, head.to_bundle_id),
|
|
11062
|
-
type: head.type,
|
|
11063
|
-
bucket_start_ms: bucket
|
|
11064
|
-
}, { installations: delta }, { shardBy });
|
|
11065
11107
|
}, "countHead");
|
|
11066
11108
|
var PERIOD_MODELS = {
|
|
11067
11109
|
hour: {
|
|
@@ -11111,18 +11153,13 @@ var countEvent = /* @__PURE__ */ __name((tx, event) => {
|
|
|
11111
11153
|
}, "countEvent");
|
|
11112
11154
|
var countOutcome = /* @__PURE__ */ __name((tx, event) => {
|
|
11113
11155
|
const shardBy = event.install_id;
|
|
11114
|
-
const
|
|
11156
|
+
for (const [type, bundleRef] of outcomeRefsOf(event)) tx.aggregate("insights_outcomes", {
|
|
11115
11157
|
platform: event.platform,
|
|
11116
11158
|
channel: event.channel,
|
|
11117
11159
|
type,
|
|
11118
11160
|
bundle_ref: bundleRef,
|
|
11119
11161
|
bucket_start_ms: hourOf(event.received_at_ms)
|
|
11120
|
-
}, { events: 1 }, { shardBy })
|
|
11121
|
-
for (const bundleRef of bundleRefsOf(event)) hour2(event.type, bundleRef);
|
|
11122
|
-
if (event.metadata.implied_download === true) hour2("UPDATE_DOWNLOADED", bundleRefOfFilter({
|
|
11123
|
-
type: "UPDATE_DOWNLOADED",
|
|
11124
|
-
toBundleId: event.type === "RECOVERED" ? event.from_bundle_id : event.to_bundle_id
|
|
11125
|
-
}));
|
|
11162
|
+
}, { events: 1 }, { shardBy });
|
|
11126
11163
|
tx.aggregate("insights_outcomes", {
|
|
11127
11164
|
...DAILY_EVENTS,
|
|
11128
11165
|
bucket_start_ms: dayOf(event.received_at_ms)
|
|
@@ -11340,7 +11377,7 @@ var recordEvent = /* @__PURE__ */ __name((db, event) => {
|
|
|
11340
11377
|
}, "recordEvent");
|
|
11341
11378
|
|
|
11342
11379
|
// ../insights/dist/server/reads.mjs
|
|
11343
|
-
var
|
|
11380
|
+
var PAGE6 = 500;
|
|
11344
11381
|
var hourFloor = /* @__PURE__ */ __name((ms) => ms - ms % HOUR_MS2, "hourFloor");
|
|
11345
11382
|
var hourCeil = /* @__PURE__ */ __name((ms) => hourFloor(ms + HOUR_MS2 - 1), "hourCeil");
|
|
11346
11383
|
var dayFloor = /* @__PURE__ */ __name((ms) => ms - ms % DAY_MS2, "dayFloor");
|
|
@@ -11464,7 +11501,7 @@ var countRaw = /* @__PURE__ */ __name(async (db, filter, from, to) => {
|
|
|
11464
11501
|
gte: from,
|
|
11465
11502
|
lt: to
|
|
11466
11503
|
},
|
|
11467
|
-
limit:
|
|
11504
|
+
limit: PAGE6,
|
|
11468
11505
|
...page2
|
|
11469
11506
|
}));
|
|
11470
11507
|
total += rows.length;
|
|
@@ -11483,7 +11520,7 @@ var countEvents = /* @__PURE__ */ __name(async (db, input) => {
|
|
|
11483
11520
|
gte: start,
|
|
11484
11521
|
lt: end
|
|
11485
11522
|
},
|
|
11486
|
-
limit:
|
|
11523
|
+
limit: PAGE6,
|
|
11487
11524
|
...page2
|
|
11488
11525
|
}));
|
|
11489
11526
|
return await countRaw(db, filter, sinceMs, start) + hours.reduce((sum, row) => sum + row.events, 0) + await countRaw(db, filter, end, beforeReceivedAtMs);
|
|
@@ -11499,7 +11536,7 @@ var countEventSeries = /* @__PURE__ */ __name(async (db, input) => {
|
|
|
11499
11536
|
gte: start,
|
|
11500
11537
|
lt: end
|
|
11501
11538
|
},
|
|
11502
|
-
limit:
|
|
11539
|
+
limit: PAGE6,
|
|
11503
11540
|
...page2
|
|
11504
11541
|
}));
|
|
11505
11542
|
for (const row of hours) events[Math.floor((row.bucket_start_ms - start) / intervalMs)] += row.events;
|
|
@@ -11508,62 +11545,50 @@ var countEventSeries = /* @__PURE__ */ __name(async (db, input) => {
|
|
|
11508
11545
|
events: count
|
|
11509
11546
|
}));
|
|
11510
11547
|
}, "countEventSeries");
|
|
11511
|
-
var
|
|
11512
|
-
if (bundle === void 0) return void 0;
|
|
11513
|
-
return [...new Map(bundle.flatMap(({ field, value, types }) => types.map((type) => [JSON.stringify([
|
|
11514
|
-
field,
|
|
11515
|
-
value,
|
|
11516
|
-
type
|
|
11517
|
-
]), {
|
|
11518
|
-
field,
|
|
11519
|
-
value,
|
|
11520
|
-
type
|
|
11521
|
-
}]))).values()];
|
|
11522
|
-
}, "latestPredicates");
|
|
11523
|
-
var countLatestEvents = /* @__PURE__ */ __name(async (db, input) => {
|
|
11524
|
-
const { platform, channel, sinceMs: start } = input;
|
|
11548
|
+
var distributionRows = /* @__PURE__ */ __name((db, { platform, channel, sinceMs: start }) => {
|
|
11525
11549
|
if (start % 864e5 !== 0) throw new DatabaseAdapterInputError("invalid-query");
|
|
11526
|
-
|
|
11550
|
+
return drain2((page2) => db.findAggregates("insights_distribution", {
|
|
11551
|
+
index: "byScope",
|
|
11552
|
+
where: {
|
|
11553
|
+
channel,
|
|
11554
|
+
platform
|
|
11555
|
+
},
|
|
11556
|
+
range: { gte: start },
|
|
11557
|
+
limit: PAGE6,
|
|
11558
|
+
...page2
|
|
11559
|
+
}));
|
|
11560
|
+
}, "distributionRows");
|
|
11561
|
+
var installations = /* @__PURE__ */ __name((count) => Math.max(0, count), "installations");
|
|
11562
|
+
var countLatestEvents = /* @__PURE__ */ __name(async (db, input) => installations((await distributionRows(db, input)).reduce((sum, row) => sum + row.latest_installations, 0)), "countLatestEvents");
|
|
11563
|
+
var countReleaseInstallations = /* @__PURE__ */ __name(async (db, input) => {
|
|
11564
|
+
const { platform, channel, sinceMs: start, releaseId } = input;
|
|
11527
11565
|
let total = 0;
|
|
11528
|
-
|
|
11529
|
-
|
|
11566
|
+
let release = 0;
|
|
11567
|
+
let named = false;
|
|
11568
|
+
for (const row of await distributionRows(db, input)) {
|
|
11569
|
+
total += row.latest_installations;
|
|
11570
|
+
if (row.release_id !== releaseId) continue;
|
|
11571
|
+
named = true;
|
|
11572
|
+
release += row.latest_installations;
|
|
11573
|
+
}
|
|
11574
|
+
if (!named) {
|
|
11575
|
+
const builtin = await drain2((page2) => db.findAggregates("insights_builtin_distribution", {
|
|
11530
11576
|
index: "byScope",
|
|
11531
11577
|
where: {
|
|
11532
11578
|
channel,
|
|
11533
11579
|
platform
|
|
11534
11580
|
},
|
|
11535
11581
|
range: { gte: start },
|
|
11536
|
-
limit:
|
|
11582
|
+
limit: PAGE6,
|
|
11537
11583
|
...page2
|
|
11538
11584
|
}));
|
|
11539
|
-
|
|
11540
|
-
} else {
|
|
11541
|
-
const gauge = /* @__PURE__ */ __name(async (bundleField, bundleId, type) => {
|
|
11542
|
-
return (await drain2((page2) => db.findAggregates("insights_latest_by_bundle", {
|
|
11543
|
-
index: "byBundle",
|
|
11544
|
-
where: {
|
|
11545
|
-
platform,
|
|
11546
|
-
channel,
|
|
11547
|
-
bundle_field: bundleField,
|
|
11548
|
-
bundle_id: bundleId,
|
|
11549
|
-
type
|
|
11550
|
-
},
|
|
11551
|
-
range: { gte: start },
|
|
11552
|
-
limit: PAGE5,
|
|
11553
|
-
...page2
|
|
11554
|
-
}))).reduce((sum, row) => sum + row.installations, 0);
|
|
11555
|
-
}, "gauge");
|
|
11556
|
-
for (const { field, value, type } of predicates) total += await gauge(field, value, type);
|
|
11557
|
-
for (const from of predicates) {
|
|
11558
|
-
if (from.field !== "from_bundle_id") continue;
|
|
11559
|
-
for (const to of predicates) {
|
|
11560
|
-
if (to.field !== "to_bundle_id" || to.type !== from.type) continue;
|
|
11561
|
-
total -= await gauge(PAIR_FIELD, bundlePairKey(from.value, to.value), from.type);
|
|
11562
|
-
}
|
|
11563
|
-
}
|
|
11585
|
+
for (const row of builtin) if (row.release_id === "" && row.builtin_bundle_id === releaseId) release += row.latest_installations;
|
|
11564
11586
|
}
|
|
11565
|
-
return
|
|
11566
|
-
|
|
11587
|
+
return {
|
|
11588
|
+
installations: installations(total),
|
|
11589
|
+
release: installations(release)
|
|
11590
|
+
};
|
|
11591
|
+
}, "countReleaseInstallations");
|
|
11567
11592
|
var retained = /* @__PURE__ */ __name((now, { rawDays, dailyDays }) => ({
|
|
11568
11593
|
hour: hourCeil(now - rawDays * DAY_MS2),
|
|
11569
11594
|
day: dayCeil(now - dailyDays * DAY_MS2)
|
|
@@ -11625,7 +11650,7 @@ var windowRows = /* @__PURE__ */ __name(async (db, models, parts, range, days, h
|
|
|
11625
11650
|
gte: period.start,
|
|
11626
11651
|
lt: period.end
|
|
11627
11652
|
},
|
|
11628
|
-
limit:
|
|
11653
|
+
limit: PAGE6,
|
|
11629
11654
|
...page2
|
|
11630
11655
|
})));
|
|
11631
11656
|
}
|
|
@@ -11654,7 +11679,7 @@ var lifetimeMetrics = /* @__PURE__ */ __name(async (db, release) => {
|
|
|
11654
11679
|
gte: 0,
|
|
11655
11680
|
lte: 0
|
|
11656
11681
|
},
|
|
11657
|
-
limit:
|
|
11682
|
+
limit: PAGE6
|
|
11658
11683
|
})).rows;
|
|
11659
11684
|
return {
|
|
11660
11685
|
downloads: lifetime?.downloads ?? 0,
|
|
@@ -11681,9 +11706,9 @@ var getReleaseActivity = /* @__PURE__ */ __name(async (db, input, now) => {
|
|
|
11681
11706
|
measuredAtMs
|
|
11682
11707
|
};
|
|
11683
11708
|
}, "getReleaseActivity");
|
|
11684
|
-
var byInstallations = /* @__PURE__ */ __name((values) => [...values].flatMap(([name,
|
|
11709
|
+
var byInstallations = /* @__PURE__ */ __name((values) => [...values].flatMap(([name, installations2]) => installations2 > 0 ? [{
|
|
11685
11710
|
name,
|
|
11686
|
-
installations
|
|
11711
|
+
installations: installations2
|
|
11687
11712
|
}] : []).sort((left, right) => right.installations - left.installations || left.name.localeCompare(right.name, "en", { numeric: true })), "byInstallations");
|
|
11688
11713
|
var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
11689
11714
|
const { timeRange, intervalMs } = input;
|
|
@@ -11706,7 +11731,7 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
|
11706
11731
|
platform
|
|
11707
11732
|
},
|
|
11708
11733
|
range,
|
|
11709
|
-
limit:
|
|
11734
|
+
limit: PAGE6,
|
|
11710
11735
|
...page2
|
|
11711
11736
|
}) : db.findAggregates("insights_distribution", {
|
|
11712
11737
|
index: "byVersion",
|
|
@@ -11716,7 +11741,7 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
|
11716
11741
|
app_version: input.appVersion
|
|
11717
11742
|
},
|
|
11718
11743
|
range,
|
|
11719
|
-
limit:
|
|
11744
|
+
limit: PAGE6,
|
|
11720
11745
|
...page2
|
|
11721
11746
|
})));
|
|
11722
11747
|
builtinDistribution.push(...await drain2((page2) => input.appVersion === void 0 ? db.findAggregates("insights_builtin_distribution", {
|
|
@@ -11726,7 +11751,7 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
|
11726
11751
|
platform
|
|
11727
11752
|
},
|
|
11728
11753
|
range,
|
|
11729
|
-
limit:
|
|
11754
|
+
limit: PAGE6,
|
|
11730
11755
|
...page2
|
|
11731
11756
|
}) : db.findAggregates("insights_builtin_distribution", {
|
|
11732
11757
|
index: "byVersion",
|
|
@@ -11736,7 +11761,7 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
|
11736
11761
|
app_version: input.appVersion
|
|
11737
11762
|
},
|
|
11738
11763
|
range,
|
|
11739
|
-
limit:
|
|
11764
|
+
limit: PAGE6,
|
|
11740
11765
|
...page2
|
|
11741
11766
|
})));
|
|
11742
11767
|
}
|
|
@@ -11782,7 +11807,7 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
|
11782
11807
|
appVersions: sortedVersions.map(({ name }) => name),
|
|
11783
11808
|
versions: sortedVersions,
|
|
11784
11809
|
platforms: byInstallations(platforms),
|
|
11785
|
-
bundleDistribution: [...bundles2.values()].filter(({ installations }) =>
|
|
11810
|
+
bundleDistribution: [...bundles2.values()].filter(({ installations: installations2 }) => installations2 > 0),
|
|
11786
11811
|
measuredAtMs: at
|
|
11787
11812
|
};
|
|
11788
11813
|
}, "getAppUsage");
|
|
@@ -11838,7 +11863,7 @@ var breakdownOf = /* @__PURE__ */ __name((rows) => {
|
|
|
11838
11863
|
});
|
|
11839
11864
|
}, "breakdownOf");
|
|
11840
11865
|
var FAILURE_ROWS_PER_HOUR = 20;
|
|
11841
|
-
var FAILURE_QUERY_LIMIT = Math.min(
|
|
11866
|
+
var FAILURE_QUERY_LIMIT = Math.min(PAGE6, 168);
|
|
11842
11867
|
var failureRowsByHour = /* @__PURE__ */ __name(async (db, platform, channel, timeRange) => {
|
|
11843
11868
|
const read = /* @__PURE__ */ __name((end2, cursor2) => db.findAggregates("insights_failures", {
|
|
11844
11869
|
index: "byScope",
|
|
@@ -11914,7 +11939,7 @@ var getUpdateFailures = /* @__PURE__ */ __name(async (db, input, now, retention)
|
|
|
11914
11939
|
gte: 0,
|
|
11915
11940
|
lte: 0
|
|
11916
11941
|
},
|
|
11917
|
-
limit:
|
|
11942
|
+
limit: PAGE6
|
|
11918
11943
|
}), db.findAggregates("insights_sketches_lifetime", {
|
|
11919
11944
|
index: "window",
|
|
11920
11945
|
where: where(failure),
|
|
@@ -11922,7 +11947,7 @@ var getUpdateFailures = /* @__PURE__ */ __name(async (db, input, now, retention)
|
|
|
11922
11947
|
gte: 0,
|
|
11923
11948
|
lte: 0
|
|
11924
11949
|
},
|
|
11925
|
-
limit:
|
|
11950
|
+
limit: PAGE6
|
|
11926
11951
|
})]);
|
|
11927
11952
|
const lifetime = counters3.rows[0];
|
|
11928
11953
|
return {
|
|
@@ -11979,6 +12004,20 @@ var getUpdateFailures = /* @__PURE__ */ __name(async (db, input, now, retention)
|
|
|
11979
12004
|
};
|
|
11980
12005
|
}, "getUpdateFailures");
|
|
11981
12006
|
|
|
12007
|
+
// ../insights/dist/server/wire.mjs
|
|
12008
|
+
var RELEASE_ID_PARAM = "bundleId";
|
|
12009
|
+
var toWireOverview = /* @__PURE__ */ __name(({ bundle, ...overview }) => {
|
|
12010
|
+
if (bundle === void 0) return overview;
|
|
12011
|
+
const { releaseId, ...counts } = bundle;
|
|
12012
|
+
return {
|
|
12013
|
+
...overview,
|
|
12014
|
+
bundle: {
|
|
12015
|
+
...counts,
|
|
12016
|
+
bundleId: releaseId
|
|
12017
|
+
}
|
|
12018
|
+
};
|
|
12019
|
+
}, "toWireOverview");
|
|
12020
|
+
|
|
11982
12021
|
// ../insights/dist/server/queryInput.mjs
|
|
11983
12022
|
var MAX_PAGE_LIMIT2 = 100;
|
|
11984
12023
|
var MAX_IDENTITY_LENGTH3 = 255;
|
|
@@ -12023,7 +12062,7 @@ var readScope2 = /* @__PURE__ */ __name((url) => {
|
|
|
12023
12062
|
var parseEventPageInput = /* @__PURE__ */ __name((request) => {
|
|
12024
12063
|
const url = new URL(request.url);
|
|
12025
12064
|
const bundleFields = [
|
|
12026
|
-
|
|
12065
|
+
RELEASE_ID_PARAM,
|
|
12027
12066
|
"outcome",
|
|
12028
12067
|
"platform",
|
|
12029
12068
|
"channel"
|
|
@@ -12034,7 +12073,7 @@ var parseEventPageInput = /* @__PURE__ */ __name((request) => {
|
|
|
12034
12073
|
if (outcome !== "downloaded" && outcome !== "applied" && outcome !== "recovered" && outcome !== "failed") throw new InsightsBadRequestError("Invalid 'outcome' query parameter.");
|
|
12035
12074
|
bundle = {
|
|
12036
12075
|
...readScope2(url),
|
|
12037
|
-
|
|
12076
|
+
releaseId: readId(url, RELEASE_ID_PARAM, 1024),
|
|
12038
12077
|
outcome
|
|
12039
12078
|
};
|
|
12040
12079
|
}
|
|
@@ -12060,11 +12099,10 @@ var parseReportingOverviewInput = /* @__PURE__ */ __name((request) => {
|
|
|
12060
12099
|
const url = new URL(request.url);
|
|
12061
12100
|
const window2 = readSingle(url, "window") ?? "30d";
|
|
12062
12101
|
if (window2 !== "24h" && window2 !== "7d" && window2 !== "30d") throw new InsightsBadRequestError("Invalid 'window' query parameter.");
|
|
12063
|
-
const bundleId = readSingle(url, "bundleId");
|
|
12064
12102
|
return {
|
|
12065
12103
|
...readScope2(url),
|
|
12066
12104
|
window: window2,
|
|
12067
|
-
...bundleId === void 0 ? {} : {
|
|
12105
|
+
...readSingle(url, "bundleId") === void 0 ? {} : { releaseId: readId(url, RELEASE_ID_PARAM, 1024) }
|
|
12068
12106
|
};
|
|
12069
12107
|
}, "parseReportingOverviewInput");
|
|
12070
12108
|
|
|
@@ -12143,7 +12181,7 @@ var createInsightsRouteHandlers = /* @__PURE__ */ __name((provider) => ({
|
|
|
12143
12181
|
await provider.appendBundleEvent(await parseBundleEventRequest(request));
|
|
12144
12182
|
return new Response(null, { status: 204 });
|
|
12145
12183
|
}), "appendBundleEvent"),
|
|
12146
|
-
getReportingOverview: /* @__PURE__ */ __name((_params, request) => query(() => provider.getReportingOverview(parseReportingOverviewInput(request))), "getReportingOverview"),
|
|
12184
|
+
getReportingOverview: /* @__PURE__ */ __name((_params, request) => query(async () => toWireOverview(await provider.getReportingOverview(parseReportingOverviewInput(request)))), "getReportingOverview"),
|
|
12147
12185
|
getInstallation: /* @__PURE__ */ __name((params) => run(async () => {
|
|
12148
12186
|
const installation = await provider.getInstallation({ installId: requireParam(params, "installId") });
|
|
12149
12187
|
return installation === null ? json2({ error: "Installation not found" }, 404) : json2(installation, 200);
|
|
@@ -12165,12 +12203,20 @@ var createInsightsApi = /* @__PURE__ */ __name((db, now, retention) => ({
|
|
|
12165
12203
|
listEvents: /* @__PURE__ */ __name((input) => listEvents(db, input), "listEvents"),
|
|
12166
12204
|
findLatestEvents: /* @__PURE__ */ __name((input) => findLatestEvents(db, input), "findLatestEvents"),
|
|
12167
12205
|
countLatestEvents: /* @__PURE__ */ __name((input) => countLatestEvents(db, input), "countLatestEvents"),
|
|
12206
|
+
countReleaseInstallations: /* @__PURE__ */ __name((input) => countReleaseInstallations(db, input), "countReleaseInstallations"),
|
|
12168
12207
|
countEvents: /* @__PURE__ */ __name((input) => countEvents(db, input), "countEvents"),
|
|
12169
12208
|
countEventSeries: /* @__PURE__ */ __name((input) => countEventSeries(db, input), "countEventSeries"),
|
|
12170
12209
|
getReleaseActivity: /* @__PURE__ */ __name((input) => getReleaseActivity(db, input, now), "getReleaseActivity"),
|
|
12171
12210
|
getAppUsage: /* @__PURE__ */ __name((input) => getAppUsage(db, input, now, retention), "getAppUsage"),
|
|
12172
12211
|
/** A release's or a channel's update failures, and their breakdown over a time range. */
|
|
12173
|
-
getUpdateFailures: /* @__PURE__ */ __name((input) => getUpdateFailures(db, input, now, retention), "getUpdateFailures")
|
|
12212
|
+
getUpdateFailures: /* @__PURE__ */ __name((input) => getUpdateFailures(db, input, now, retention), "getUpdateFailures"),
|
|
12213
|
+
/**
|
|
12214
|
+
* Moves the stored events a 1.1 server keyed by artifact, and their
|
|
12215
|
+
* outcome counts, to their release, reading every stored event of the
|
|
12216
|
+
* raw period: `hot-updater db migrate` and `hot-updater init` run it once
|
|
12217
|
+
* a database, and an interrupted run can run again.
|
|
12218
|
+
*/
|
|
12219
|
+
backfillReleaseRefs: /* @__PURE__ */ __name((options) => backfillReleaseRefs(db, now, retention, options), "backfillReleaseRefs")
|
|
12174
12220
|
}), "createInsightsApi");
|
|
12175
12221
|
var readFailuresQuery = /* @__PURE__ */ __name((url) => {
|
|
12176
12222
|
const query2 = url.searchParams;
|