Play Developer Reporting API v1beta1 (crashRateMetricSet / anrRateMetricSet DAILY queries in America/Los_Angeles, user-perceived 28-day rates, worst device models, errorIssues:search) and App Store Connect perfPowerMetrics, diagnostic signatures and TestFlight crash submissions. Thresholds 1.09 % crash / 0.47 % ANR / 8 % per device (developer.android.com/topic/performance/vitals): over = blocker, from 80 % = warn, in validate too (--no-health). Weekly Markdown report with week-over-week change in .storebound/health/. MCP: health (read-only), health_report.
137 lines
9.3 KiB
TypeScript
137 lines
9.3 KiB
TypeScript
// Store readiness report (read-only on both stores): what still blocks a submission, in the order to fix it.
|
|
// storebound validate [--apple] [--play] [--json] [--src store/renders] [--no-local] [--no-health]
|
|
// Without --apple / --play: every store the config has. Exit code 1 when there is at least one blocker.
|
|
// Reads only: GETs on App Store Connect, a Play edit that is opened, read and deleted (never committed), and plain GETs
|
|
// of the public privacy policy and app-ads.txt URLs. Also checks the local renders folder (if there is one) with the
|
|
// `shots check` rules: wrong pixel size, alpha, too few / many images, Play 8 MB and feature graphic format are
|
|
// blockers (the upload would fail), text overflow flags from the last render are warnings. --no-local skips it.
|
|
// Live apps: crash / ANR vitals (Play Reporting API) and App Store diagnostics, as in `storebound health`: over a Play
|
|
// bad behavior threshold is a blocker, near it a warning; a store without vitals access is only noted. --no-health skips.
|
|
import { ascClient, type J } from './apple/asc';
|
|
import { requiredDisplayTypes } from './apple/screenshots';
|
|
import { playCodes } from './lib/config';
|
|
import type { Ctx } from './lib/ctx';
|
|
import { checkUrl } from './lib/http';
|
|
import { collectHealth } from './health';
|
|
import { healthFindings } from './lib/health';
|
|
import { log, warn } from './lib/log';
|
|
import { type AppleSnapshot, appleRules, type Finding, formatFindings, PLAY_REQUIRED_IMAGES, type PlaySnapshot, playRules, rendersFindings, sortFindings } from './lib/validate-rules';
|
|
import { rendersCheck } from './shots/check';
|
|
import { playClient } from './play/client';
|
|
import { listOneTimeProducts } from './play/products';
|
|
|
|
export async function collectApple(ctx: Ctx): Promise<AppleSnapshot> {
|
|
const { config, root } = ctx.loaded;
|
|
const c = await ascClient(root, config.apple!.bundleId, config.apple?.appId);
|
|
const appId = await c.app();
|
|
log('validate', 'apple: reading version, build, localizations');
|
|
const versions = await c.all(`/v1/apps/${appId}/appStoreVersions?filter[platform]=IOS&limit=10`);
|
|
const v: J = (await c.editableVersion()) ?? versions[0] ?? null;
|
|
let build: AppleSnapshot['build'] = null;
|
|
const locales: AppleSnapshot['locales'] = [];
|
|
let reviewDetail: AppleSnapshot['reviewDetail'] = null;
|
|
if (v) {
|
|
const b = (await c.maybe(`/v1/appStoreVersions/${v.id}/build`))?.data;
|
|
if (b) {
|
|
const decl = (await c.maybe(`/v1/builds/${b.id}/appEncryptionDeclaration`))?.data;
|
|
build = { number: b.attributes.version, processingState: b.attributes.processingState, usesNonExemptEncryption: b.attributes.usesNonExemptEncryption ?? null,
|
|
declarationState: decl?.attributes?.appEncryptionDeclarationState ?? null };
|
|
}
|
|
const info = await c.editableAppInfo();
|
|
const infoLocs = new Map((await c.all(`/v1/appInfos/${info.id}/appInfoLocalizations?limit=50`)).map((l: J) => [l.attributes.locale, l.attributes] as const));
|
|
for (const l of await c.all(`/v1/appStoreVersions/${v.id}/appStoreVersionLocalizations?limit=50`)) {
|
|
const sets = await c.all(`/v1/appStoreVersionLocalizations/${l.id}/appScreenshotSets?limit=50`);
|
|
const screenshots: Record<string, number> = {};
|
|
for (const s of sets) screenshots[s.attributes.screenshotDisplayType] = (await c.all(`/v1/appScreenshotSets/${s.id}/appScreenshots?limit=50`)).length;
|
|
const ia = infoLocs.get(l.attributes.locale) ?? {};
|
|
locales.push({ locale: l.attributes.locale, name: ia.name, subtitle: ia.subtitle, description: l.attributes.description, keywords: l.attributes.keywords, screenshots });
|
|
}
|
|
reviewDetail = (await c.maybe(`/v1/appStoreVersions/${v.id}/appStoreReviewDetail`))?.data?.attributes ?? null;
|
|
}
|
|
log('validate', 'apple: age rating, price, availability, in-app purchases');
|
|
const info = await c.editableAppInfo();
|
|
const ageRating = (await c.maybe(`/v1/appInfos/${info.id}/ageRatingDeclaration`))?.data?.attributes ?? null;
|
|
const sched = await c.maybe(`/v1/apps/${appId}/appPriceSchedule?include=manualPrices`);
|
|
const avail = await c.maybe(`/v1/apps/${appId}/appAvailabilityV2`);
|
|
const iaps: AppleSnapshot['iaps'] = [];
|
|
for (const p of await c.all(`/v1/apps/${appId}/inAppPurchasesV2?limit=200`)) {
|
|
const shot = (await c.maybe(`/v2/inAppPurchases/${p.id}/appStoreReviewScreenshot`))?.data;
|
|
iaps.push({ productId: p.attributes.productId, state: p.attributes.state, reviewScreenshot: !!shot });
|
|
}
|
|
return {
|
|
version: v ? { versionString: v.attributes.versionString, state: v.attributes.appVersionState ?? v.attributes.appStoreState } : null,
|
|
build, locales, reviewDetail, ageRating,
|
|
expectedLocales: config.languages.map(l => l.apple).filter((x): x is string => !!x),
|
|
requiredDisplayTypes: requiredDisplayTypes(config.apple),
|
|
priceSchedule: !!sched?.included?.some((x: J) => x.type === 'appPrices'),
|
|
availability: !!avail?.data,
|
|
iaps, expectedProducts: (config.products ?? []).map(p => p.id),
|
|
privacyUrl: await checkUrl(config.app.privacyPolicyUrl),
|
|
};
|
|
}
|
|
|
|
export async function collectPlay(ctx: Ctx): Promise<PlaySnapshot> {
|
|
const { config, root } = ctx.loaded;
|
|
const play = await playClient(root, config.play!.packageName);
|
|
const e = await play.call<{ id: string }>('POST', `${play.API}/edits`, {});
|
|
log('validate', `play: read-only edit ${e.id} (deleted afterwards)`);
|
|
try {
|
|
const details = await play.call<{ defaultLanguage?: string; contactWebsite?: string }>('GET', `${play.API}/edits/${e.id}/details`);
|
|
const raw = (await play.call<{ listings?: { language: string; title?: string; shortDescription?: string; fullDescription?: string }[] }>('GET', `${play.API}/edits/${e.id}/listings`)).listings ?? [];
|
|
const listings: PlaySnapshot['listings'] = [];
|
|
for (const l of raw) {
|
|
const images: Record<string, number> = {};
|
|
for (const type of Object.keys(PLAY_REQUIRED_IMAGES))
|
|
images[type] = ((await play.call<{ images?: unknown[] }>('GET', `${play.API}/edits/${e.id}/listings/${l.language}/${type}`)).images ?? []).length;
|
|
listings.push({ ...l, images });
|
|
}
|
|
const tracks = ((await play.call<{ tracks?: { track: string; releases?: { status: string; versionCodes?: string[]; userFraction?: number }[] }[] }>('GET', `${play.API}/edits/${e.id}/tracks`)).tracks ?? [])
|
|
.map(t => ({ track: t.track, releases: (t.releases ?? []).map(r => ({ status: r.status, versionCodes: r.versionCodes ?? [], userFraction: r.userFraction })) }));
|
|
const products = (await listOneTimeProducts(play)).map(p => ({ productId: p.productId, states: (p.purchaseOptions ?? []).map(o => o.state ?? '') }));
|
|
const website = details.contactWebsite ?? null;
|
|
const appAdsLines = config.ads?.appAdsTxt ?? [];
|
|
const adsLikely = !!config.ads || Object.values(config.dataSafety?.data ?? {}).some(u => u.collect.includes('advertising'));
|
|
let appAds = null;
|
|
if (website && (appAdsLines.length || adsLikely)) {
|
|
try { appAds = await checkUrl(new URL('/app-ads.txt', website).href, { body: true }); } catch { appAds = { url: website, status: null, error: 'bad website URL' }; }
|
|
}
|
|
return {
|
|
defaultLanguage: details.defaultLanguage ?? config.play?.defaultLanguage ?? 'en-US',
|
|
expectedLanguages: config.languages.flatMap(playCodes), listings, tracks, products,
|
|
expectedProducts: (config.products ?? []).map(p => p.id),
|
|
privacyUrl: await checkUrl(config.app.privacyPolicyUrl), website, appAds, appAdsLines, adsLikely,
|
|
};
|
|
} finally {
|
|
await play.call('DELETE', `${play.API}/edits/${e.id}`).catch(() => {});
|
|
}
|
|
}
|
|
|
|
export async function run(ctx: Ctx): Promise<void> {
|
|
const { config } = ctx.loaded;
|
|
const a = ctx.args;
|
|
const both = !a.has('apple') && !a.has('play');
|
|
const findings: Finding[] = [];
|
|
const dir = ctx.loaded.resolve(a.get('src') ?? config.renders ?? config.shots?.out ?? 'store/renders');
|
|
const local = a.has('no-local') ? null : rendersCheck(config, dir);
|
|
if (local) log('validate', `local renders: ${dir}`);
|
|
if ((both || a.has('apple')) && config.apple) {
|
|
try { findings.push(...appleRules({ ...(await collectApple(ctx)), renders: local?.apple })); }
|
|
catch (e) { findings.push({ store: 'apple', level: 'blocker', code: 'api', msg: (e as Error).message.slice(0, 400) }, ...rendersFindings('apple', local?.apple)); }
|
|
} else if (a.has('apple')) warn('validate', 'no apple section in the config');
|
|
if ((both || a.has('play')) && config.play) {
|
|
try { findings.push(...playRules({ ...(await collectPlay(ctx)), renders: local?.play })); }
|
|
catch (e) { findings.push({ store: 'play', level: 'blocker', code: 'api', msg: (e as Error).message.slice(0, 400) }, ...rendersFindings('play', local?.play)); }
|
|
} else if (a.has('play')) warn('validate', 'no play section in the config');
|
|
if (!a.has('no-health') && (config.apple || config.play)) {
|
|
log('validate', 'vitals and diagnostics (last 7 days)');
|
|
const h = await collectHealth(ctx, { apple: (both || a.has('apple')) && !!config.apple, play: (both || a.has('play')) && !!config.play, days: 7 });
|
|
findings.push(...sortFindings(healthFindings(h, { unreadable: 'ok' })));
|
|
}
|
|
const blockers = findings.filter(f => f.level === 'blocker').length;
|
|
if (a.has('json')) console.log(JSON.stringify({ blockers, findings }, null, 2));
|
|
else {
|
|
console.log(formatFindings(findings));
|
|
log('validate', blockers ? `${blockers} blocker(s)` : 'no blockers (UI-only steps are not visible to the API: App Privacy, Play App content)');
|
|
}
|
|
if (blockers) process.exitCode = 1;
|
|
}
|