diff --git a/automation/app-store-discord/README.md b/automation/app-store-discord/README.md index eb47560..d8183ef 100644 --- a/automation/app-store-discord/README.md +++ b/automation/app-store-discord/README.md @@ -15,7 +15,7 @@ GitHub Actions가 App Store Connect의 **기간별 최초 다운로드 수와 ## 집계 기준 -`App Store Downloads Standard` 보고서에서 `Download Type = First-time Download`인 행의 `Counts`를 합산한다. Apple 계정 기준 처음 받기/구입을 누른 횟수이며 재다운로드·업데이트·회원가입 수와 구분한다. +`App Downloads Standard` 보고서에서 `Download Type = First-time Download`인 행의 `Counts`를 합산한다. Apple 계정 기준 처음 받기/구입을 누른 횟수이며 재다운로드·업데이트·회원가입 수와 구분한다. - 모든 세그먼트를 수집한 다음 집계한다. - 동일한 데이터 날짜가 여러 보고서에 있으면 최신 `processingDate` 값으로 교체한다. 과거 값과 더하지 않는다. diff --git a/automation/app-store-discord/src/apple.mjs b/automation/app-store-discord/src/apple.mjs index 70d5e84..a85c87e 100644 --- a/automation/app-store-discord/src/apple.mjs +++ b/automation/app-store-discord/src/apple.mjs @@ -261,8 +261,8 @@ export async function collectDownloads(env, previous = { days: {} }, { fetchImpl if (active.length !== 1) fail('REPORT_REQUEST', 'A single active ONGOING report request is required. Complete the App Store Connect report setup.'); const requestId = active[0].id; const reports = await list(`/v1/analyticsReportRequests/${resourceId(requestId)}/reports?limit=200`); - const standard = reports.filter((item) => item.attributes.name === 'App Store Downloads Standard'); - if (standard.length !== 1) fail('REPORT_NOT_READY', 'The App Store Downloads Standard report is not available yet. Initial generation can take 24–48 hours.'); + const standard = reports.filter((item) => item.attributes.name === 'App Downloads Standard'); + if (standard.length !== 1) fail('REPORT_NOT_READY', 'The App Downloads Standard report is not available yet. Initial generation can take 24–48 hours.'); const reportId = standard[0].id; const instances = await list(`/v1/analyticsReports/${resourceId(reportId)}/instances?filter%5Bgranularity%5D=DAILY&limit=200`); const recent = instances.filter((instance) => { diff --git a/automation/app-store-discord/test/apple.test.mjs b/automation/app-store-discord/test/apple.test.mjs index 8e1a797..6f23903 100644 --- a/automation/app-store-discord/test/apple.test.mjs +++ b/automation/app-store-discord/test/apple.test.mjs @@ -30,7 +30,7 @@ function fixture(instances, override) { return page([metadata('request', { accessType: 'ONGOING', stoppedDueToInactivity: false })]); } if (url.pathname === '/v1/analyticsReportRequests/request/reports') { - return page([metadata('detailed', { name: 'App Store Downloads Detailed' }), metadata('report', { name: 'App Store Downloads Standard' })]); + return page([metadata('detailed', { name: 'App Downloads Detailed' }), metadata('report', { name: 'App Downloads Standard' })]); } if (url.pathname === '/v1/analyticsReports/report/instances') { return page(instances.map((item) => metadata(item.id, { granularity: 'DAILY', processingDate: item.processingDate }))); @@ -172,3 +172,25 @@ test('lifetime history survives retention and accepts corrections to an old date assert.equal(result.days['2026-02-01'].count, 22); assert.equal(previous.days['2026-01-01'].count, 11); }); + + +test('selects the real App Downloads Standard report instead of Detailed', async () => { + const { fetchImpl, calls } = fixture([ + { id: 'daily', processingDate: '2026-11-18', segments: [row('2026-11-16', 7)] }, + ]); + const result = await collectDownloads(ENV, undefined, { fetchImpl, now: NOW }); + assert.equal(result.reportId, 'report'); + assert.equal(result.days['2026-11-16'].count, 7); + assert.ok(calls.some(call => call.url.pathname === '/v1/analyticsReports/report/instances')); + assert.ok(calls.every(call => !call.url.pathname.includes('/analyticsReports/detailed/'))); +}); + +test('a Detailed-only report list still reports Standard as unavailable', async () => { + const { fetchImpl, calls } = fixture([], url => { + if (url.pathname.endsWith('/request/reports')) { + return page([metadata('detailed', { name: 'App Downloads Detailed' })]); + } + }); + await assert.rejects(collectDownloads(ENV, undefined, { fetchImpl, now: NOW }), { code: 'REPORT_NOT_READY' }); + assert.ok(calls.every(call => !call.url.pathname.includes('/instances'))); +});