Guarded read-only run of the Play POST read paths: errorIssues:search in UTC, issues failure keeps the vitals, read-only listing / images dry runs

A live run where only the token exchange, edit insert / delete and Reporting :query were let through:
- health / validate: errorIssues:search answered 400 "Unsupported timezone" for America/Los_Angeles (it takes
  hour-aligned UTC only); the failure dropped the crash and ANR rates and the reason was cut off in the query string.
  Issues are asked in UTC; a failing issues search is a vitals-issues warning; Reporting errors leave out the query.
- play listing --dry / play images --dry wrote into the edit (PUT details and listings, image clears and uploads,
  :validate) before discarding it. Now one throwaway edit is read (details, listings, image sha256) and compared
  with the local copy, then deleted.
- play.read(): one helper for read-only edits (status, next-version-code), always deleted, warns if the delete fails;
  next-version-code counts distinct codes.
- tests on sanitized recorded answers (tests/play-post-reads.test.ts)
This commit is contained in:
CRTkafa 2026-10-11 00:41:55 +00:00
parent c2b0a0d8a3
commit 3a755823da
11 changed files with 314 additions and 29 deletions

View file

@ -7,6 +7,8 @@
// https://developers.google.com/play/developer/reporting/reference/rest/v1beta1/vitals.anrrate
// https://developers.google.com/play/developer/reporting/reference/rest/v1beta1/vitals.errors.issues/search
// DAILY timelines only take the America/Los_Angeles time zone, dates without hours; endTime is exclusive.
// errorIssues:search is the other way round: its interval must be hour-aligned and in UTC (America/Los_Angeles
// answers 400 "Unsupported timezone").
// Bad behavior thresholds (user-perceived, 28-day average, checked daily): crash 1.09 %, ANR 0.47 % overall; 8 % on a
// single phone model. https://developer.android.com/topic/performance/vitals and Play Console Help answer 9844486
// https://support.google.com/googleplay/android-developer/answer/9844486
@ -68,14 +70,16 @@ export function parseMetricRows(resp: { rows?: ApiRow[] }): MetricRow[] {
})).sort((a, b) => a.date.localeCompare(b.date));
}
/** errorIssues:search query string: the top issues of a window, most reports first. */
/** errorIssues:search query string: the top issues of a window, most reports first. The interval is UTC midnights
* (the API takes only hour-aligned UTC times here, unlike the DAILY metric timelines). */
export function issuesQuery(end: Ymd, days: number, o: { type?: 'CRASH' | 'ANR'; pageSize?: number } = {}): string {
const start = ymd(new Date(Date.UTC(end.year, end.month - 1, end.day)), days);
const p = new URLSearchParams();
for (const [k, v] of Object.entries({ start, end })) {
const x = v as Ymd;
p.set(`interval.${k}Time.year`, String(x.year)); p.set(`interval.${k}Time.month`, String(x.month)); p.set(`interval.${k}Time.day`, String(x.day));
p.set(`interval.${k}Time.timeZone.id`, LA.id);
p.set(`interval.${k}Time.hours`, '0');
p.set(`interval.${k}Time.timeZone.id`, 'UTC');
}
if (o.type) p.set('filter', `errorIssueType = ${o.type}`);
p.set('orderBy', 'errorReportCount desc');
@ -97,6 +101,8 @@ export interface PlayHealth {
/** Worst device models by user-perceived crash / ANR rate over the window (optional). */
devices?: { model: string; crash?: number; anr?: number; users?: number }[];
issues: Issue[];
/** errorIssues:search failed: the rates above are still valid, only the issue list is missing. */
issuesError?: string;
}
export interface AppleHealth {
@ -193,6 +199,7 @@ export function healthFindings(h: HealthSnapshot, o: { unreadable?: Level } = {}
f.push({ store: 'play', level: levelFor(crash, PLAY_THRESHOLDS.crash), code: 'vitals-crash', msg: `user-perceived crash rate (28 d) ${pct(crash)} (bad behavior threshold ${pct(PLAY_THRESHOLDS.crash)})`, fix });
f.push({ store: 'play', level: levelFor(anr, PLAY_THRESHOLDS.anr), code: 'vitals-anr', msg: `user-perceived ANR rate (28 d) ${pct(anr)} (bad behavior threshold ${pct(PLAY_THRESHOLDS.anr)})`, fix });
}
if (play.issuesError) f.push({ store: 'play', level: 'warn', code: 'vitals-issues', msg: `top crash / ANR issues not read: ${play.issuesError.slice(0, 200)}`, fix: 'Play Console > Android vitals > Crashes and ANRs' });
for (const d of play.devices ?? []) {
const worst = Math.max(d.crash ?? 0, d.anr ?? 0);
const lv = levelFor(worst, PLAY_THRESHOLDS.perDevice);
@ -220,7 +227,7 @@ export function healthTable(h: HealthSnapshot): string {
rows.push(['play', `crash rate (user-perceived, ${p.window.days} d avg)`, pct(weightedAverage(p.crash, 'userPerceivedCrashRate')), '']);
rows.push(['play', 'ANR rate (user-perceived, 28 d)', pct(lastValue(p.anr, 'userPerceivedAnrRate28dUserWeighted')), pct(PLAY_THRESHOLDS.anr)]);
rows.push(['play', `ANR rate (user-perceived, ${p.window.days} d avg)`, pct(weightedAverage(p.anr, 'userPerceivedAnrRate')), '']);
rows.push(['play', 'top issues', p.issues.length, '']);
rows.push(['play', 'top issues', p.issuesError ? 'not read' : p.issues.length, '']);
} else if (h.play) rows.push(['play', 'error', h.play.error.slice(0, 80), '']);
if (h.apple && !('error' in h.apple)) {
for (const m of h.apple.metrics.slice(0, 12)) rows.push(['apple', `${m.metric} (${m.version})`, `${m.value} ${m.unit}`.trim(), m.goal ?? '']);