@hot-updater/cloudflare 1.2.0-rc.57 → 1.2.0-rc.59
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 +231 -160
- 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");
|
|
@@ -4377,6 +4377,7 @@ var createTransactions = /* @__PURE__ */ __name(({ adapter, schema, reads, retry
|
|
|
4377
4377
|
let negative;
|
|
4378
4378
|
let failures = 0;
|
|
4379
4379
|
let lost;
|
|
4380
|
+
let busy = false;
|
|
4380
4381
|
for (let round = 0; ; round += 1) {
|
|
4381
4382
|
const delay = round && Math.min(maxDelayMs, baseDelayMs * 2 ** (round - 1));
|
|
4382
4383
|
if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay / 2 + Math.random() * (delay / 2)));
|
|
@@ -4387,6 +4388,7 @@ var createTransactions = /* @__PURE__ */ __name(({ adapter, schema, reads, retry
|
|
|
4387
4388
|
if (run3 === void 0) {
|
|
4388
4389
|
onRetry?.("rerun", round + 1);
|
|
4389
4390
|
lost = void 0;
|
|
4391
|
+
busy = false;
|
|
4390
4392
|
if ((failures += 1) >= attempts) break;
|
|
4391
4393
|
continue;
|
|
4392
4394
|
}
|
|
@@ -4397,6 +4399,7 @@ var createTransactions = /* @__PURE__ */ __name(({ adapter, schema, reads, retry
|
|
|
4397
4399
|
if (!(error instanceof NegativeGaugeError)) throw error;
|
|
4398
4400
|
negative = error;
|
|
4399
4401
|
onRetry?.("rerun", round + 1);
|
|
4402
|
+
busy = false;
|
|
4400
4403
|
run3 = void 0;
|
|
4401
4404
|
lost = void 0;
|
|
4402
4405
|
if ((failures += 1) >= attempts) break;
|
|
@@ -4417,6 +4420,7 @@ var createTransactions = /* @__PURE__ */ __name(({ adapter, schema, reads, retry
|
|
|
4417
4420
|
}
|
|
4418
4421
|
if (outcome.ok) return run3.result;
|
|
4419
4422
|
const failed2 = "failedOp" in outcome ? outcome.failedOp : void 0;
|
|
4423
|
+
busy = failed2 === void 0;
|
|
4420
4424
|
if (failed2 === void 0 || failed2 >= run3.ops.length) {
|
|
4421
4425
|
onRetry?.("resend", round + 1);
|
|
4422
4426
|
failures += 1;
|
|
@@ -4430,7 +4434,7 @@ var createTransactions = /* @__PURE__ */ __name(({ adapter, schema, reads, retry
|
|
|
4430
4434
|
run3 = void 0;
|
|
4431
4435
|
if ((failures += 1) >= attempts) break;
|
|
4432
4436
|
}
|
|
4433
|
-
throw negative ?? new DatabaseConflictError(`The transaction conflicted ${attempts} times.`);
|
|
4437
|
+
throw negative ?? new DatabaseConflictError(busy ? `The database stayed busy through ${attempts} attempts of the transaction, as a store does at its throughput limit.` : `The transaction conflicted ${attempts} times.`);
|
|
4434
4438
|
} };
|
|
4435
4439
|
}, "createTransactions");
|
|
4436
4440
|
|
|
@@ -5021,7 +5025,7 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
|
|
|
5021
5025
|
}, "createSqlAdapter");
|
|
5022
5026
|
|
|
5023
5027
|
// ../../packages/server/dist/package.mjs
|
|
5024
|
-
var version = "1.2.0-rc.
|
|
5028
|
+
var version = "1.2.0-rc.59";
|
|
5025
5029
|
|
|
5026
5030
|
// ../../packages/server/dist/version.mjs
|
|
5027
5031
|
var HOT_UPDATER_SERVER_VERSION = version;
|
|
@@ -6491,10 +6495,14 @@ var createLabelAllocator = /* @__PURE__ */ __name((tx, used, caughtUp) => {
|
|
|
6491
6495
|
}, "createLabelAllocator");
|
|
6492
6496
|
var FILL_BATCH = 25;
|
|
6493
6497
|
var PAGE2 = 500;
|
|
6498
|
+
var PAUSE_MS = 1e3;
|
|
6499
|
+
var MAX_PAUSE_MS = 32e3;
|
|
6500
|
+
var sleep2 = /* @__PURE__ */ __name((ms) => new Promise((resolve) => setTimeout(resolve, ms)), "sleep");
|
|
6494
6501
|
var fillLabels = /* @__PURE__ */ __name(async (db, { channelId, platform }, { dryRun: dryRun2 = false } = {}) => {
|
|
6495
6502
|
const id = labelSequenceId(channelId, platform);
|
|
6496
6503
|
let labeled = 0;
|
|
6497
6504
|
let batchSize = FILL_BATCH;
|
|
6505
|
+
let paused = 0;
|
|
6498
6506
|
const label = /* @__PURE__ */ __name(async (ids) => {
|
|
6499
6507
|
for (let at = 0; at < ids.length; ) {
|
|
6500
6508
|
const batch = ids.slice(at, at + batchSize);
|
|
@@ -6519,12 +6527,16 @@ var fillLabels = /* @__PURE__ */ __name(async (db, { channelId, platform }, { dr
|
|
|
6519
6527
|
return count;
|
|
6520
6528
|
});
|
|
6521
6529
|
at += batch.length;
|
|
6530
|
+
paused = 0;
|
|
6522
6531
|
} catch (error) {
|
|
6523
6532
|
if (batchSize > 1 && error instanceof DatabaseConstraintError && error.reason === "too_large") {
|
|
6524
6533
|
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
6525
6534
|
continue;
|
|
6526
6535
|
}
|
|
6527
|
-
throw error;
|
|
6536
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS) throw error;
|
|
6537
|
+
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
6538
|
+
paused = paused === 0 ? PAUSE_MS : paused * 2;
|
|
6539
|
+
await sleep2(paused);
|
|
6528
6540
|
}
|
|
6529
6541
|
}
|
|
6530
6542
|
}, "label");
|
|
@@ -9513,13 +9525,15 @@ var isLaunch = /* @__PURE__ */ __name((row) => {
|
|
|
9513
9525
|
const kinds = metadataOf(row).change?.kinds ?? [];
|
|
9514
9526
|
return kinds.includes("bundle") && !kinds.includes("first_seen") && row.to_release_id !== null;
|
|
9515
9527
|
}, "isLaunch");
|
|
9516
|
-
var
|
|
9528
|
+
var sideRef = /* @__PURE__ */ __name((key, releaseId, bundleId) => key === "release" ? releaseId ?? bundleId : bundleId, "sideRef");
|
|
9529
|
+
var bundleRefsOf = /* @__PURE__ */ __name((row, key = "release") => {
|
|
9517
9530
|
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}`];
|
|
9531
|
+
if (row.type === "RECOVERED") return [`from:${sideRef(key, row.from_release_id, row.from_bundle_id)}`];
|
|
9532
|
+
if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${sideRef(key, row.to_release_id, row.to_bundle_id)}`] : [];
|
|
9533
|
+
return [`to:${sideRef(key, row.to_release_id, row.to_bundle_id)}`];
|
|
9521
9534
|
}, "bundleRefsOf");
|
|
9522
|
-
var
|
|
9535
|
+
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");
|
|
9536
|
+
var bundleRefOfFilter = /* @__PURE__ */ __name((filter) => filter.type === "RECOVERED" ? `from:${filter.fromReleaseId}` : filter.type === "UNCHANGED" ? `on:${filter.toReleaseId}` : `to:${filter.toReleaseId}`, "bundleRefOfFilter");
|
|
9523
9537
|
var bundleEvents = /* @__PURE__ */ __name((days) => defineTable({
|
|
9524
9538
|
id: {
|
|
9525
9539
|
type: "string",
|
|
@@ -9578,7 +9592,11 @@ var bundleEvents = /* @__PURE__ */ __name((days) => defineTable({
|
|
|
9578
9592
|
type: "string",
|
|
9579
9593
|
compute: /* @__PURE__ */ __name((row) => MOVEMENTS.has(row.type) ? row.install_id : null, "compute")
|
|
9580
9594
|
},
|
|
9581
|
-
/**
|
|
9595
|
+
/**
|
|
9596
|
+
* The bundle a bundle filter matches (`bundleRefsOf`), by release.
|
|
9597
|
+
* Rows a 1.1 server wrote name the artifact until
|
|
9598
|
+
* `backfillReleaseRefs` rewrites them.
|
|
9599
|
+
*/
|
|
9582
9600
|
bundle_ref: {
|
|
9583
9601
|
type: "string",
|
|
9584
9602
|
multi: true,
|
|
@@ -9956,6 +9974,83 @@ var createInsightsSchema = /* @__PURE__ */ __name(({ rawDays, dailyDays } = DEFA
|
|
|
9956
9974
|
}, "createInsightsSchema");
|
|
9957
9975
|
var insightsSchema = createInsightsSchema();
|
|
9958
9976
|
|
|
9977
|
+
// ../insights/dist/server/backfill.mjs
|
|
9978
|
+
var PAGE5 = 500;
|
|
9979
|
+
var BATCH = 25;
|
|
9980
|
+
var PAUSE_MS2 = 1e3;
|
|
9981
|
+
var MAX_PAUSE_MS2 = 32e3;
|
|
9982
|
+
var sleep3 = /* @__PURE__ */ __name((ms) => new Promise((resolve) => setTimeout(resolve, ms)), "sleep");
|
|
9983
|
+
var sameRefs = /* @__PURE__ */ __name((stored2, refs) => {
|
|
9984
|
+
const values = Array.isArray(stored2) ? stored2 : [];
|
|
9985
|
+
return values.length === refs.length && values.every((value) => refs.includes(value));
|
|
9986
|
+
}, "sameRefs");
|
|
9987
|
+
var namesArtifact = /* @__PURE__ */ __name((row) => {
|
|
9988
|
+
const byKey = /* @__PURE__ */ __name((key) => bundleRefsOf(row, key), "byKey");
|
|
9989
|
+
return sameRefs(row.bundle_ref, byKey("artifact")) && !sameRefs(row.bundle_ref, byKey("release"));
|
|
9990
|
+
}, "namesArtifact");
|
|
9991
|
+
var backfillReleaseRefs = /* @__PURE__ */ __name(async (db, now, { rawDays }, { dryRun: dryRun2 = false } = {}) => {
|
|
9992
|
+
const today = now() - now() % DAY_MS2;
|
|
9993
|
+
let events = 0;
|
|
9994
|
+
let size = BATCH;
|
|
9995
|
+
let paused = 0;
|
|
9996
|
+
const move = /* @__PURE__ */ __name(async (stale) => {
|
|
9997
|
+
if (dryRun2) {
|
|
9998
|
+
events += stale.length;
|
|
9999
|
+
return;
|
|
10000
|
+
}
|
|
10001
|
+
for (let start = 0; start < stale.length; ) {
|
|
10002
|
+
const candidates = stale.slice(start, start + size);
|
|
10003
|
+
try {
|
|
10004
|
+
events += await rewrite3(candidates);
|
|
10005
|
+
start += candidates.length;
|
|
10006
|
+
paused = 0;
|
|
10007
|
+
} catch (error) {
|
|
10008
|
+
if (error instanceof DatabaseConstraintError && error.reason === "too_large" && candidates.length > 1) {
|
|
10009
|
+
size = Math.ceil(candidates.length / 2);
|
|
10010
|
+
continue;
|
|
10011
|
+
}
|
|
10012
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS2) throw error;
|
|
10013
|
+
size = Math.ceil(candidates.length / 2);
|
|
10014
|
+
paused = paused === 0 ? PAUSE_MS2 : paused * 2;
|
|
10015
|
+
await sleep3(paused);
|
|
10016
|
+
}
|
|
10017
|
+
}
|
|
10018
|
+
}, "move");
|
|
10019
|
+
const rewrite3 = /* @__PURE__ */ __name((candidates) => db.transaction(async (tx) => {
|
|
10020
|
+
const rows = await Promise.all(candidates.map(({ id }) => tx.findOne("bundle_events", { id })));
|
|
10021
|
+
let moved = 0;
|
|
10022
|
+
for (const row of rows) {
|
|
10023
|
+
if (row === null || !namesArtifact(row)) continue;
|
|
10024
|
+
tx.update("bundle_events", row, {});
|
|
10025
|
+
const outcome = /* @__PURE__ */ __name((ref, delta) => tx.aggregate("insights_outcomes", {
|
|
10026
|
+
platform: row.platform,
|
|
10027
|
+
channel: row.channel,
|
|
10028
|
+
type: ref[0],
|
|
10029
|
+
bundle_ref: ref[1],
|
|
10030
|
+
bucket_start_ms: row.received_at_ms - row.received_at_ms % HOUR_MS2
|
|
10031
|
+
}, { events: delta }, { shardBy: row.install_id }), "outcome");
|
|
10032
|
+
for (const ref of outcomeRefsOf(row, "artifact")) outcome(ref, -1);
|
|
10033
|
+
for (const ref of outcomeRefsOf(row, "release")) outcome(ref, 1);
|
|
10034
|
+
moved += 1;
|
|
10035
|
+
}
|
|
10036
|
+
return moved;
|
|
10037
|
+
}), "rewrite");
|
|
10038
|
+
for (let day = today - rawDays * DAY_MS2; day <= today; day += DAY_MS2) {
|
|
10039
|
+
let cursor;
|
|
10040
|
+
do {
|
|
10041
|
+
const page2 = await db.findMany("bundle_events", {
|
|
10042
|
+
index: "byDay",
|
|
10043
|
+
where: { day },
|
|
10044
|
+
limit: PAGE5,
|
|
10045
|
+
...cursor === void 0 ? {} : { cursor }
|
|
10046
|
+
});
|
|
10047
|
+
await move(page2.rows.filter(namesArtifact));
|
|
10048
|
+
cursor = page2.next;
|
|
10049
|
+
} while (cursor !== void 0);
|
|
10050
|
+
}
|
|
10051
|
+
return { events };
|
|
10052
|
+
}, "backfillReleaseRefs");
|
|
10053
|
+
|
|
9959
10054
|
// ../insights/dist/server/eventRow.mjs
|
|
9960
10055
|
var CHANGE_KINDS = /* @__PURE__ */ new Set([
|
|
9961
10056
|
"first_seen",
|
|
@@ -10033,7 +10128,7 @@ var isBundleFilter = /* @__PURE__ */ __name((value, withKind = false) => {
|
|
|
10033
10128
|
"type",
|
|
10034
10129
|
...withKind ? ["kind"] : []
|
|
10035
10130
|
];
|
|
10036
|
-
return value.type === "RECOVERED" ? isText2(value.
|
|
10131
|
+
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
10132
|
}, "isBundleFilter");
|
|
10038
10133
|
var isEventFilter = /* @__PURE__ */ __name((value) => {
|
|
10039
10134
|
if (!isRecord5(value)) return false;
|
|
@@ -10128,20 +10223,24 @@ var createValidatedInsightsModel = /* @__PURE__ */ __name((model) => ({
|
|
|
10128
10223
|
if (!isRecord5(input) || !hasOnlyKeys(input, [
|
|
10129
10224
|
"platform",
|
|
10130
10225
|
"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();
|
|
10226
|
+
"sinceMs"
|
|
10227
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs)) invalidQuery();
|
|
10143
10228
|
return validateCount(await model.countLatestEvents(input));
|
|
10144
10229
|
},
|
|
10230
|
+
async countReleaseInstallations(input) {
|
|
10231
|
+
if (!isRecord5(input) || !hasOnlyKeys(input, [
|
|
10232
|
+
"platform",
|
|
10233
|
+
"channel",
|
|
10234
|
+
"sinceMs",
|
|
10235
|
+
"releaseId"
|
|
10236
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs) || !isText2(input.releaseId)) invalidQuery();
|
|
10237
|
+
const counts = await model.countReleaseInstallations(input);
|
|
10238
|
+
if (!isRecord5(counts) || !hasOnlyKeys(counts, ["installations", "release"])) invalidResult();
|
|
10239
|
+
return {
|
|
10240
|
+
installations: validateCount(counts.installations),
|
|
10241
|
+
release: validateCount(counts.release)
|
|
10242
|
+
};
|
|
10243
|
+
},
|
|
10145
10244
|
async countEvents(input) {
|
|
10146
10245
|
if (!isRecord5(input) || !hasOnlyKeys(input, [
|
|
10147
10246
|
"filter",
|
|
@@ -10194,6 +10293,7 @@ var createInsightsModel = /* @__PURE__ */ __name((api) => createValidatedInsight
|
|
|
10194
10293
|
listEvents: api.listEvents,
|
|
10195
10294
|
findLatestEvents: api.findLatestEvents,
|
|
10196
10295
|
countLatestEvents: api.countLatestEvents,
|
|
10296
|
+
countReleaseInstallations: api.countReleaseInstallations,
|
|
10197
10297
|
countEvents: api.countEvents,
|
|
10198
10298
|
countEventSeries: api.countEventSeries,
|
|
10199
10299
|
getReleaseActivity: api.getReleaseActivity,
|
|
@@ -10585,31 +10685,31 @@ var readScope = /* @__PURE__ */ __name((input) => {
|
|
|
10585
10685
|
}, "readScope");
|
|
10586
10686
|
var bundleFilter = /* @__PURE__ */ __name((input) => {
|
|
10587
10687
|
const scope = readScope(input);
|
|
10588
|
-
const
|
|
10688
|
+
const releaseId = requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
10589
10689
|
switch (input.outcome) {
|
|
10590
10690
|
case "downloaded":
|
|
10591
10691
|
return {
|
|
10592
10692
|
...scope,
|
|
10593
10693
|
type: "UPDATE_DOWNLOADED",
|
|
10594
|
-
|
|
10694
|
+
toReleaseId: releaseId
|
|
10595
10695
|
};
|
|
10596
10696
|
case "applied":
|
|
10597
10697
|
return {
|
|
10598
10698
|
...scope,
|
|
10599
10699
|
type: "UPDATE_APPLIED",
|
|
10600
|
-
|
|
10700
|
+
toReleaseId: releaseId
|
|
10601
10701
|
};
|
|
10602
10702
|
case "recovered":
|
|
10603
10703
|
return {
|
|
10604
10704
|
...scope,
|
|
10605
10705
|
type: "RECOVERED",
|
|
10606
|
-
|
|
10706
|
+
fromReleaseId: releaseId
|
|
10607
10707
|
};
|
|
10608
10708
|
case "failed":
|
|
10609
10709
|
return {
|
|
10610
10710
|
...scope,
|
|
10611
10711
|
type: "UPDATE_FAILED",
|
|
10612
|
-
|
|
10712
|
+
toReleaseId: releaseId
|
|
10613
10713
|
};
|
|
10614
10714
|
default:
|
|
10615
10715
|
throw new InsightsBadRequestError("Invalid Insights outcome.");
|
|
@@ -10623,7 +10723,7 @@ var sameFilter = /* @__PURE__ */ __name((left, right) => {
|
|
|
10623
10723
|
case "installationMovement":
|
|
10624
10724
|
return left.installId === right.installId;
|
|
10625
10725
|
case "bundle":
|
|
10626
|
-
return left.platform === right.platform && left.channel === right.channel && left.type === right.type && (right.type === "RECOVERED" ? left.
|
|
10726
|
+
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
10727
|
}
|
|
10628
10728
|
}, "sameFilter");
|
|
10629
10729
|
var readEventCursor = /* @__PURE__ */ __name((value, filter) => {
|
|
@@ -10660,7 +10760,7 @@ var assertEventRows = /* @__PURE__ */ __name((rows, input) => {
|
|
|
10660
10760
|
for (let index = 0; index < rows.length; index += 1) {
|
|
10661
10761
|
const row = rows[index];
|
|
10662
10762
|
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.
|
|
10763
|
+
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
10764
|
}
|
|
10665
10765
|
}, "assertEventRows");
|
|
10666
10766
|
var toFailure = /* @__PURE__ */ __name((failure) => ({
|
|
@@ -10699,6 +10799,7 @@ var eventDetails = /* @__PURE__ */ __name(({ type, metadata }) => ({
|
|
|
10699
10799
|
...metadata.implied_download === true ? { impliedDownload: true } : {}
|
|
10700
10800
|
}), "eventDetails");
|
|
10701
10801
|
var toEventHistoryRow = /* @__PURE__ */ __name((row) => ({
|
|
10802
|
+
...row.from_release_id == null ? {} : { fromReleaseId: row.from_release_id },
|
|
10702
10803
|
...row.to_release_id == null ? {} : { toReleaseId: row.to_release_id },
|
|
10703
10804
|
...row.metadata.sdk_version == null ? {} : { sdkVersion: row.metadata.sdk_version },
|
|
10704
10805
|
...row.metadata.min_bundle_id === void 0 ? {} : { minBundleId: row.metadata.min_bundle_id },
|
|
@@ -10723,6 +10824,7 @@ var toInstallationRow = /* @__PURE__ */ __name((row) => ({
|
|
|
10723
10824
|
cohort: row.metadata.cohort,
|
|
10724
10825
|
installId: row.install_id,
|
|
10725
10826
|
lastKnownBundleId: row.type === "UPDATE_DOWNLOADED" ? row.from_bundle_id : row.to_bundle_id,
|
|
10827
|
+
lastKnownReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.from_release_id : row.to_release_id,
|
|
10726
10828
|
pendingBundleId: row.type === "UPDATE_DOWNLOADED" ? row.to_bundle_id : null,
|
|
10727
10829
|
pendingReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.to_release_id : null,
|
|
10728
10830
|
latestStatus: row.type,
|
|
@@ -10845,46 +10947,33 @@ var createInsightsProvider = /* @__PURE__ */ __name((model) => Object.freeze({
|
|
|
10845
10947
|
measuredAtMs: Date.now()
|
|
10846
10948
|
};
|
|
10847
10949
|
}, "measure");
|
|
10848
|
-
const
|
|
10849
|
-
|
|
10850
|
-
...scope,
|
|
10851
|
-
sinceMs
|
|
10852
|
-
}));
|
|
10853
|
-
if (bundleId === void 0) return {
|
|
10950
|
+
const releaseId = input.releaseId === void 0 ? void 0 : requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
10951
|
+
if (releaseId === void 0) return {
|
|
10854
10952
|
...scope,
|
|
10855
10953
|
window: window2,
|
|
10856
10954
|
sinceMs,
|
|
10857
10955
|
beforeReceivedAtMs,
|
|
10858
|
-
reportingInstallations: await
|
|
10956
|
+
reportingInstallations: await measure(model.countLatestEvents({
|
|
10957
|
+
...scope,
|
|
10958
|
+
sinceMs
|
|
10959
|
+
}))
|
|
10859
10960
|
};
|
|
10961
|
+
const installations2 = model.countReleaseInstallations({
|
|
10962
|
+
...scope,
|
|
10963
|
+
sinceMs,
|
|
10964
|
+
releaseId
|
|
10965
|
+
}).then(async (counts) => [await measure(Promise.resolve(counts.installations)), await measure(Promise.resolve(counts.release))]);
|
|
10860
10966
|
const countOutcome2 = /* @__PURE__ */ __name((outcome) => measure(model.countEvents({
|
|
10861
10967
|
filter: bundleFilter({
|
|
10862
10968
|
...scope,
|
|
10863
|
-
|
|
10969
|
+
releaseId,
|
|
10864
10970
|
outcome
|
|
10865
10971
|
}),
|
|
10866
10972
|
sinceMs,
|
|
10867
10973
|
beforeReceivedAtMs
|
|
10868
10974
|
})), "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
|
-
})),
|
|
10975
|
+
const [[reportingInstallations, bundleInstallations], downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
10976
|
+
installations2,
|
|
10888
10977
|
countOutcome2("downloaded"),
|
|
10889
10978
|
countOutcome2("applied"),
|
|
10890
10979
|
countOutcome2("recovered"),
|
|
@@ -10897,7 +10986,7 @@ var createInsightsProvider = /* @__PURE__ */ __name((model) => Object.freeze({
|
|
|
10897
10986
|
beforeReceivedAtMs,
|
|
10898
10987
|
reportingInstallations,
|
|
10899
10988
|
bundle: {
|
|
10900
|
-
|
|
10989
|
+
releaseId,
|
|
10901
10990
|
reportingInstallations: bundleInstallations,
|
|
10902
10991
|
downloadedReports,
|
|
10903
10992
|
appliedReports,
|
|
@@ -11022,8 +11111,6 @@ var gaugeSlot = /* @__PURE__ */ __name((head) => ({
|
|
|
11022
11111
|
releaseId: head.type === "UPDATE_DOWNLOADED" ? head.from_release_id : head.to_release_id,
|
|
11023
11112
|
builtinBundleId: runningBuiltinBundleId(head)
|
|
11024
11113
|
}), "gaugeSlot");
|
|
11025
|
-
var PAIR_FIELD = "from_to";
|
|
11026
|
-
var bundlePairKey = /* @__PURE__ */ __name((from, to) => insightsKey(`${from.length}:${from}${to.length}:${to}`), "bundlePairKey");
|
|
11027
11114
|
var countHead = /* @__PURE__ */ __name((tx, head, delta) => {
|
|
11028
11115
|
const { bucket, releaseId, builtinBundleId } = gaugeSlot(head);
|
|
11029
11116
|
const shardBy = head.install_id;
|
|
@@ -11042,26 +11129,6 @@ var countHead = /* @__PURE__ */ __name((tx, head, delta) => {
|
|
|
11042
11129
|
builtin_bundle_id: builtinBundleId,
|
|
11043
11130
|
bucket_start_ms: bucket
|
|
11044
11131
|
}, { 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
11132
|
}, "countHead");
|
|
11066
11133
|
var PERIOD_MODELS = {
|
|
11067
11134
|
hour: {
|
|
@@ -11111,18 +11178,13 @@ var countEvent = /* @__PURE__ */ __name((tx, event) => {
|
|
|
11111
11178
|
}, "countEvent");
|
|
11112
11179
|
var countOutcome = /* @__PURE__ */ __name((tx, event) => {
|
|
11113
11180
|
const shardBy = event.install_id;
|
|
11114
|
-
const
|
|
11181
|
+
for (const [type, bundleRef] of outcomeRefsOf(event)) tx.aggregate("insights_outcomes", {
|
|
11115
11182
|
platform: event.platform,
|
|
11116
11183
|
channel: event.channel,
|
|
11117
11184
|
type,
|
|
11118
11185
|
bundle_ref: bundleRef,
|
|
11119
11186
|
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
|
-
}));
|
|
11187
|
+
}, { events: 1 }, { shardBy });
|
|
11126
11188
|
tx.aggregate("insights_outcomes", {
|
|
11127
11189
|
...DAILY_EVENTS,
|
|
11128
11190
|
bucket_start_ms: dayOf(event.received_at_ms)
|
|
@@ -11340,7 +11402,7 @@ var recordEvent = /* @__PURE__ */ __name((db, event) => {
|
|
|
11340
11402
|
}, "recordEvent");
|
|
11341
11403
|
|
|
11342
11404
|
// ../insights/dist/server/reads.mjs
|
|
11343
|
-
var
|
|
11405
|
+
var PAGE6 = 500;
|
|
11344
11406
|
var hourFloor = /* @__PURE__ */ __name((ms) => ms - ms % HOUR_MS2, "hourFloor");
|
|
11345
11407
|
var hourCeil = /* @__PURE__ */ __name((ms) => hourFloor(ms + HOUR_MS2 - 1), "hourCeil");
|
|
11346
11408
|
var dayFloor = /* @__PURE__ */ __name((ms) => ms - ms % DAY_MS2, "dayFloor");
|
|
@@ -11464,7 +11526,7 @@ var countRaw = /* @__PURE__ */ __name(async (db, filter, from, to) => {
|
|
|
11464
11526
|
gte: from,
|
|
11465
11527
|
lt: to
|
|
11466
11528
|
},
|
|
11467
|
-
limit:
|
|
11529
|
+
limit: PAGE6,
|
|
11468
11530
|
...page2
|
|
11469
11531
|
}));
|
|
11470
11532
|
total += rows.length;
|
|
@@ -11483,7 +11545,7 @@ var countEvents = /* @__PURE__ */ __name(async (db, input) => {
|
|
|
11483
11545
|
gte: start,
|
|
11484
11546
|
lt: end
|
|
11485
11547
|
},
|
|
11486
|
-
limit:
|
|
11548
|
+
limit: PAGE6,
|
|
11487
11549
|
...page2
|
|
11488
11550
|
}));
|
|
11489
11551
|
return await countRaw(db, filter, sinceMs, start) + hours.reduce((sum, row) => sum + row.events, 0) + await countRaw(db, filter, end, beforeReceivedAtMs);
|
|
@@ -11499,7 +11561,7 @@ var countEventSeries = /* @__PURE__ */ __name(async (db, input) => {
|
|
|
11499
11561
|
gte: start,
|
|
11500
11562
|
lt: end
|
|
11501
11563
|
},
|
|
11502
|
-
limit:
|
|
11564
|
+
limit: PAGE6,
|
|
11503
11565
|
...page2
|
|
11504
11566
|
}));
|
|
11505
11567
|
for (const row of hours) events[Math.floor((row.bucket_start_ms - start) / intervalMs)] += row.events;
|
|
@@ -11508,62 +11570,50 @@ var countEventSeries = /* @__PURE__ */ __name(async (db, input) => {
|
|
|
11508
11570
|
events: count
|
|
11509
11571
|
}));
|
|
11510
11572
|
}, "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;
|
|
11573
|
+
var distributionRows = /* @__PURE__ */ __name((db, { platform, channel, sinceMs: start }) => {
|
|
11525
11574
|
if (start % 864e5 !== 0) throw new DatabaseAdapterInputError("invalid-query");
|
|
11526
|
-
|
|
11575
|
+
return drain2((page2) => db.findAggregates("insights_distribution", {
|
|
11576
|
+
index: "byScope",
|
|
11577
|
+
where: {
|
|
11578
|
+
channel,
|
|
11579
|
+
platform
|
|
11580
|
+
},
|
|
11581
|
+
range: { gte: start },
|
|
11582
|
+
limit: PAGE6,
|
|
11583
|
+
...page2
|
|
11584
|
+
}));
|
|
11585
|
+
}, "distributionRows");
|
|
11586
|
+
var installations = /* @__PURE__ */ __name((count) => Math.max(0, count), "installations");
|
|
11587
|
+
var countLatestEvents = /* @__PURE__ */ __name(async (db, input) => installations((await distributionRows(db, input)).reduce((sum, row) => sum + row.latest_installations, 0)), "countLatestEvents");
|
|
11588
|
+
var countReleaseInstallations = /* @__PURE__ */ __name(async (db, input) => {
|
|
11589
|
+
const { platform, channel, sinceMs: start, releaseId } = input;
|
|
11527
11590
|
let total = 0;
|
|
11528
|
-
|
|
11529
|
-
|
|
11591
|
+
let release = 0;
|
|
11592
|
+
let named = false;
|
|
11593
|
+
for (const row of await distributionRows(db, input)) {
|
|
11594
|
+
total += row.latest_installations;
|
|
11595
|
+
if (row.release_id !== releaseId) continue;
|
|
11596
|
+
named = true;
|
|
11597
|
+
release += row.latest_installations;
|
|
11598
|
+
}
|
|
11599
|
+
if (!named) {
|
|
11600
|
+
const builtin = await drain2((page2) => db.findAggregates("insights_builtin_distribution", {
|
|
11530
11601
|
index: "byScope",
|
|
11531
11602
|
where: {
|
|
11532
11603
|
channel,
|
|
11533
11604
|
platform
|
|
11534
11605
|
},
|
|
11535
11606
|
range: { gte: start },
|
|
11536
|
-
limit:
|
|
11607
|
+
limit: PAGE6,
|
|
11537
11608
|
...page2
|
|
11538
11609
|
}));
|
|
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
|
-
}
|
|
11610
|
+
for (const row of builtin) if (row.release_id === "" && row.builtin_bundle_id === releaseId) release += row.latest_installations;
|
|
11564
11611
|
}
|
|
11565
|
-
return
|
|
11566
|
-
|
|
11612
|
+
return {
|
|
11613
|
+
installations: installations(total),
|
|
11614
|
+
release: installations(release)
|
|
11615
|
+
};
|
|
11616
|
+
}, "countReleaseInstallations");
|
|
11567
11617
|
var retained = /* @__PURE__ */ __name((now, { rawDays, dailyDays }) => ({
|
|
11568
11618
|
hour: hourCeil(now - rawDays * DAY_MS2),
|
|
11569
11619
|
day: dayCeil(now - dailyDays * DAY_MS2)
|
|
@@ -11625,7 +11675,7 @@ var windowRows = /* @__PURE__ */ __name(async (db, models, parts, range, days, h
|
|
|
11625
11675
|
gte: period.start,
|
|
11626
11676
|
lt: period.end
|
|
11627
11677
|
},
|
|
11628
|
-
limit:
|
|
11678
|
+
limit: PAGE6,
|
|
11629
11679
|
...page2
|
|
11630
11680
|
})));
|
|
11631
11681
|
}
|
|
@@ -11654,7 +11704,7 @@ var lifetimeMetrics = /* @__PURE__ */ __name(async (db, release) => {
|
|
|
11654
11704
|
gte: 0,
|
|
11655
11705
|
lte: 0
|
|
11656
11706
|
},
|
|
11657
|
-
limit:
|
|
11707
|
+
limit: PAGE6
|
|
11658
11708
|
})).rows;
|
|
11659
11709
|
return {
|
|
11660
11710
|
downloads: lifetime?.downloads ?? 0,
|
|
@@ -11681,9 +11731,9 @@ var getReleaseActivity = /* @__PURE__ */ __name(async (db, input, now) => {
|
|
|
11681
11731
|
measuredAtMs
|
|
11682
11732
|
};
|
|
11683
11733
|
}, "getReleaseActivity");
|
|
11684
|
-
var byInstallations = /* @__PURE__ */ __name((values) => [...values].flatMap(([name,
|
|
11734
|
+
var byInstallations = /* @__PURE__ */ __name((values) => [...values].flatMap(([name, installations2]) => installations2 > 0 ? [{
|
|
11685
11735
|
name,
|
|
11686
|
-
installations
|
|
11736
|
+
installations: installations2
|
|
11687
11737
|
}] : []).sort((left, right) => right.installations - left.installations || left.name.localeCompare(right.name, "en", { numeric: true })), "byInstallations");
|
|
11688
11738
|
var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
11689
11739
|
const { timeRange, intervalMs } = input;
|
|
@@ -11706,7 +11756,7 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
|
11706
11756
|
platform
|
|
11707
11757
|
},
|
|
11708
11758
|
range,
|
|
11709
|
-
limit:
|
|
11759
|
+
limit: PAGE6,
|
|
11710
11760
|
...page2
|
|
11711
11761
|
}) : db.findAggregates("insights_distribution", {
|
|
11712
11762
|
index: "byVersion",
|
|
@@ -11716,7 +11766,7 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
|
11716
11766
|
app_version: input.appVersion
|
|
11717
11767
|
},
|
|
11718
11768
|
range,
|
|
11719
|
-
limit:
|
|
11769
|
+
limit: PAGE6,
|
|
11720
11770
|
...page2
|
|
11721
11771
|
})));
|
|
11722
11772
|
builtinDistribution.push(...await drain2((page2) => input.appVersion === void 0 ? db.findAggregates("insights_builtin_distribution", {
|
|
@@ -11726,7 +11776,7 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
|
11726
11776
|
platform
|
|
11727
11777
|
},
|
|
11728
11778
|
range,
|
|
11729
|
-
limit:
|
|
11779
|
+
limit: PAGE6,
|
|
11730
11780
|
...page2
|
|
11731
11781
|
}) : db.findAggregates("insights_builtin_distribution", {
|
|
11732
11782
|
index: "byVersion",
|
|
@@ -11736,7 +11786,7 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
|
11736
11786
|
app_version: input.appVersion
|
|
11737
11787
|
},
|
|
11738
11788
|
range,
|
|
11739
|
-
limit:
|
|
11789
|
+
limit: PAGE6,
|
|
11740
11790
|
...page2
|
|
11741
11791
|
})));
|
|
11742
11792
|
}
|
|
@@ -11782,7 +11832,7 @@ var getAppUsage = /* @__PURE__ */ __name(async (db, input, now, retention) => {
|
|
|
11782
11832
|
appVersions: sortedVersions.map(({ name }) => name),
|
|
11783
11833
|
versions: sortedVersions,
|
|
11784
11834
|
platforms: byInstallations(platforms),
|
|
11785
|
-
bundleDistribution: [...bundles2.values()].filter(({ installations }) =>
|
|
11835
|
+
bundleDistribution: [...bundles2.values()].filter(({ installations: installations2 }) => installations2 > 0),
|
|
11786
11836
|
measuredAtMs: at
|
|
11787
11837
|
};
|
|
11788
11838
|
}, "getAppUsage");
|
|
@@ -11838,7 +11888,7 @@ var breakdownOf = /* @__PURE__ */ __name((rows) => {
|
|
|
11838
11888
|
});
|
|
11839
11889
|
}, "breakdownOf");
|
|
11840
11890
|
var FAILURE_ROWS_PER_HOUR = 20;
|
|
11841
|
-
var FAILURE_QUERY_LIMIT = Math.min(
|
|
11891
|
+
var FAILURE_QUERY_LIMIT = Math.min(PAGE6, 168);
|
|
11842
11892
|
var failureRowsByHour = /* @__PURE__ */ __name(async (db, platform, channel, timeRange) => {
|
|
11843
11893
|
const read = /* @__PURE__ */ __name((end2, cursor2) => db.findAggregates("insights_failures", {
|
|
11844
11894
|
index: "byScope",
|
|
@@ -11914,7 +11964,7 @@ var getUpdateFailures = /* @__PURE__ */ __name(async (db, input, now, retention)
|
|
|
11914
11964
|
gte: 0,
|
|
11915
11965
|
lte: 0
|
|
11916
11966
|
},
|
|
11917
|
-
limit:
|
|
11967
|
+
limit: PAGE6
|
|
11918
11968
|
}), db.findAggregates("insights_sketches_lifetime", {
|
|
11919
11969
|
index: "window",
|
|
11920
11970
|
where: where(failure),
|
|
@@ -11922,7 +11972,7 @@ var getUpdateFailures = /* @__PURE__ */ __name(async (db, input, now, retention)
|
|
|
11922
11972
|
gte: 0,
|
|
11923
11973
|
lte: 0
|
|
11924
11974
|
},
|
|
11925
|
-
limit:
|
|
11975
|
+
limit: PAGE6
|
|
11926
11976
|
})]);
|
|
11927
11977
|
const lifetime = counters3.rows[0];
|
|
11928
11978
|
return {
|
|
@@ -11979,6 +12029,20 @@ var getUpdateFailures = /* @__PURE__ */ __name(async (db, input, now, retention)
|
|
|
11979
12029
|
};
|
|
11980
12030
|
}, "getUpdateFailures");
|
|
11981
12031
|
|
|
12032
|
+
// ../insights/dist/server/wire.mjs
|
|
12033
|
+
var RELEASE_ID_PARAM = "bundleId";
|
|
12034
|
+
var toWireOverview = /* @__PURE__ */ __name(({ bundle, ...overview }) => {
|
|
12035
|
+
if (bundle === void 0) return overview;
|
|
12036
|
+
const { releaseId, ...counts } = bundle;
|
|
12037
|
+
return {
|
|
12038
|
+
...overview,
|
|
12039
|
+
bundle: {
|
|
12040
|
+
...counts,
|
|
12041
|
+
bundleId: releaseId
|
|
12042
|
+
}
|
|
12043
|
+
};
|
|
12044
|
+
}, "toWireOverview");
|
|
12045
|
+
|
|
11982
12046
|
// ../insights/dist/server/queryInput.mjs
|
|
11983
12047
|
var MAX_PAGE_LIMIT2 = 100;
|
|
11984
12048
|
var MAX_IDENTITY_LENGTH3 = 255;
|
|
@@ -12023,7 +12087,7 @@ var readScope2 = /* @__PURE__ */ __name((url) => {
|
|
|
12023
12087
|
var parseEventPageInput = /* @__PURE__ */ __name((request) => {
|
|
12024
12088
|
const url = new URL(request.url);
|
|
12025
12089
|
const bundleFields = [
|
|
12026
|
-
|
|
12090
|
+
RELEASE_ID_PARAM,
|
|
12027
12091
|
"outcome",
|
|
12028
12092
|
"platform",
|
|
12029
12093
|
"channel"
|
|
@@ -12034,7 +12098,7 @@ var parseEventPageInput = /* @__PURE__ */ __name((request) => {
|
|
|
12034
12098
|
if (outcome !== "downloaded" && outcome !== "applied" && outcome !== "recovered" && outcome !== "failed") throw new InsightsBadRequestError("Invalid 'outcome' query parameter.");
|
|
12035
12099
|
bundle = {
|
|
12036
12100
|
...readScope2(url),
|
|
12037
|
-
|
|
12101
|
+
releaseId: readId(url, RELEASE_ID_PARAM, 1024),
|
|
12038
12102
|
outcome
|
|
12039
12103
|
};
|
|
12040
12104
|
}
|
|
@@ -12060,11 +12124,10 @@ var parseReportingOverviewInput = /* @__PURE__ */ __name((request) => {
|
|
|
12060
12124
|
const url = new URL(request.url);
|
|
12061
12125
|
const window2 = readSingle(url, "window") ?? "30d";
|
|
12062
12126
|
if (window2 !== "24h" && window2 !== "7d" && window2 !== "30d") throw new InsightsBadRequestError("Invalid 'window' query parameter.");
|
|
12063
|
-
const bundleId = readSingle(url, "bundleId");
|
|
12064
12127
|
return {
|
|
12065
12128
|
...readScope2(url),
|
|
12066
12129
|
window: window2,
|
|
12067
|
-
...bundleId === void 0 ? {} : {
|
|
12130
|
+
...readSingle(url, "bundleId") === void 0 ? {} : { releaseId: readId(url, RELEASE_ID_PARAM, 1024) }
|
|
12068
12131
|
};
|
|
12069
12132
|
}, "parseReportingOverviewInput");
|
|
12070
12133
|
|
|
@@ -12143,7 +12206,7 @@ var createInsightsRouteHandlers = /* @__PURE__ */ __name((provider) => ({
|
|
|
12143
12206
|
await provider.appendBundleEvent(await parseBundleEventRequest(request));
|
|
12144
12207
|
return new Response(null, { status: 204 });
|
|
12145
12208
|
}), "appendBundleEvent"),
|
|
12146
|
-
getReportingOverview: /* @__PURE__ */ __name((_params, request) => query(() => provider.getReportingOverview(parseReportingOverviewInput(request))), "getReportingOverview"),
|
|
12209
|
+
getReportingOverview: /* @__PURE__ */ __name((_params, request) => query(async () => toWireOverview(await provider.getReportingOverview(parseReportingOverviewInput(request)))), "getReportingOverview"),
|
|
12147
12210
|
getInstallation: /* @__PURE__ */ __name((params) => run(async () => {
|
|
12148
12211
|
const installation = await provider.getInstallation({ installId: requireParam(params, "installId") });
|
|
12149
12212
|
return installation === null ? json2({ error: "Installation not found" }, 404) : json2(installation, 200);
|
|
@@ -12165,12 +12228,20 @@ var createInsightsApi = /* @__PURE__ */ __name((db, now, retention) => ({
|
|
|
12165
12228
|
listEvents: /* @__PURE__ */ __name((input) => listEvents(db, input), "listEvents"),
|
|
12166
12229
|
findLatestEvents: /* @__PURE__ */ __name((input) => findLatestEvents(db, input), "findLatestEvents"),
|
|
12167
12230
|
countLatestEvents: /* @__PURE__ */ __name((input) => countLatestEvents(db, input), "countLatestEvents"),
|
|
12231
|
+
countReleaseInstallations: /* @__PURE__ */ __name((input) => countReleaseInstallations(db, input), "countReleaseInstallations"),
|
|
12168
12232
|
countEvents: /* @__PURE__ */ __name((input) => countEvents(db, input), "countEvents"),
|
|
12169
12233
|
countEventSeries: /* @__PURE__ */ __name((input) => countEventSeries(db, input), "countEventSeries"),
|
|
12170
12234
|
getReleaseActivity: /* @__PURE__ */ __name((input) => getReleaseActivity(db, input, now), "getReleaseActivity"),
|
|
12171
12235
|
getAppUsage: /* @__PURE__ */ __name((input) => getAppUsage(db, input, now, retention), "getAppUsage"),
|
|
12172
12236
|
/** 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")
|
|
12237
|
+
getUpdateFailures: /* @__PURE__ */ __name((input) => getUpdateFailures(db, input, now, retention), "getUpdateFailures"),
|
|
12238
|
+
/**
|
|
12239
|
+
* Moves the stored events a 1.1 server keyed by artifact, and their
|
|
12240
|
+
* outcome counts, to their release, reading every stored event of the
|
|
12241
|
+
* raw period: `hot-updater db migrate` and `hot-updater init` run it once
|
|
12242
|
+
* a database, and an interrupted run can run again.
|
|
12243
|
+
*/
|
|
12244
|
+
backfillReleaseRefs: /* @__PURE__ */ __name((options) => backfillReleaseRefs(db, now, retention, options), "backfillReleaseRefs")
|
|
12174
12245
|
}), "createInsightsApi");
|
|
12175
12246
|
var readFailuresQuery = /* @__PURE__ */ __name((url) => {
|
|
12176
12247
|
const query2 = url.searchParams;
|