Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion automation/app-store-discord/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 값으로 교체한다. 과거 값과 더하지 않는다.
Expand Down
4 changes: 2 additions & 2 deletions automation/app-store-discord/src/apple.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
24 changes: 23 additions & 1 deletion automation/app-store-discord/test/apple.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })));
Expand Down Expand Up @@ -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')));
});