feat(performance): 메타 광고 상세보기 [합계 | 계정별] 탭
- 가져올 때 그날 메타 행 metrics 에 계정별 값(_accounts: 이름·광고비·ROAS·항목, insights account_name)을 함께 저장 — 새 마이그레이션 없음. "_" 키는 일자별 표 열·합계·화면 값에서 제외. - ad_spend.detail_tabs: 합계 탭 + 계정 탭(그 계정이 광고 낸 날만, 광고비 큰 계정부터), 계정별 값 없는 날 수 안내. - 상세보기 창: 탭(주황 강조, 계정 ID 말풍선), 계정 탭은 1원 반올림 차이 안내. 네이버·구글은 그대로 표 하나. - 테스트: 계정별 변환·탭 순서/이름/가중 ROAS·옛 자료 안내·API 응답, jsdom 탭 전환. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -75,6 +75,9 @@ a.perf-tab.is-active:link, a.perf-tab.is-active:visited { color: #fff; }
|
||||
.perf-detail-btn .material-symbols-outlined { font-size: 16px; }
|
||||
.perf-detail-btn:hover { background: #fff1ea; text-decoration: underline; }
|
||||
.perf-detail-table th, .perf-detail-table td { white-space: nowrap; }
|
||||
/* 상세보기 [합계 | 계정…] 탭(메타 — 여러 광고 계정) */
|
||||
.perf-detail-tabs { flex-wrap: wrap; margin-bottom: 10px; }
|
||||
.perf-detail-tabs .perf-seg.is-active { background: var(--perf-ad); }
|
||||
.perf-ad-upload-btn { margin-left: auto; }
|
||||
.perf-kpi-pct { font-size: 26px; font-weight: 700; }
|
||||
|
||||
|
||||
+39
-10
@@ -403,7 +403,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 광고 보고서 일자별 상세(네이버·구글 머리글) — 지금 보는 기간의 날마다 광고비·ROAS·보고서 항목, 맨 아래 합계.
|
||||
// 광고 보고서 일자별 상세(네이버·구글·메타 머리글) — 지금 보는 기간의 날마다 광고비·ROAS·보고서 항목, 맨 아래 합계.
|
||||
root.addEventListener("click", async function (e) {
|
||||
const btn = e.target.closest("[data-detail-channel]");
|
||||
if (!btn) return;
|
||||
@@ -425,15 +425,44 @@
|
||||
const d = new Date(iso + "T00:00:00");
|
||||
return iso.slice(5, 7) + "/" + iso.slice(8, 10) + "(" + WD[d.getDay()] + ")";
|
||||
};
|
||||
m.body.innerHTML = '<div class="perf-ev-wrap"><table class="perf-table perf-detail-table"><thead><tr><th class="perf-th-label">날짜</th>' +
|
||||
cols.map(function (c) { return "<th>" + esc(c) + "</th>"; }).join("") + "</tr></thead><tbody>" +
|
||||
res.rows.map(function (r) {
|
||||
return '<tr><th class="perf-td-label" scope="row">' + esc(day(r.date)) + "</th>" +
|
||||
cols.map(function (c) { return '<td class="perf-num">' + cell((r.values || {})[c]) + "</td>"; }).join("") + "</tr>";
|
||||
}).join("") + '</tbody><tfoot><tr class="perf-row-total"><th class="perf-td-label" scope="row">합계</th>' +
|
||||
cols.map(function (c) { return '<td class="perf-num">' + cell((res.total || {})[c]) + "</td>"; }).join("") +
|
||||
"</tr></tfoot></table></div>" +
|
||||
'<p class="perf-muted">합계: 숫자 항목은 더한 값, 클릭률 = 클릭수 ÷ 노출수, 광고수익률·ROAS = 날짜별 값을 광고비로 가중 평균.</p>';
|
||||
const table = function (t) {
|
||||
const tcols = t.columns || cols;
|
||||
return '<div class="perf-ev-wrap"><table class="perf-table perf-detail-table"><thead><tr><th class="perf-th-label">날짜</th>' +
|
||||
tcols.map(function (c) { return "<th>" + esc(c) + "</th>"; }).join("") + "</tr></thead><tbody>" +
|
||||
(t.rows || []).map(function (r) {
|
||||
return '<tr><th class="perf-td-label" scope="row">' + esc(day(r.date)) + "</th>" +
|
||||
tcols.map(function (c) { return '<td class="perf-num">' + cell((r.values || {})[c]) + "</td>"; }).join("") + "</tr>";
|
||||
}).join("") + '</tbody><tfoot><tr class="perf-row-total"><th class="perf-td-label" scope="row">합계</th>' +
|
||||
tcols.map(function (c) { return '<td class="perf-num">' + cell((t.total || {})[c]) + "</td>"; }).join("") +
|
||||
"</tr></tfoot></table></div>";
|
||||
};
|
||||
const foot = '<p class="perf-muted">합계: 숫자 항목은 더한 값, 클릭률 = 클릭수 ÷ 노출수, 광고수익률·ROAS = 날짜별 값을 광고비로 가중 평균.</p>';
|
||||
const tabs = res.tabs || [];
|
||||
if (tabs.length < 2) { m.body.innerHTML = table(res) + foot; return; }
|
||||
// 여러 광고 계정을 합치는 채널(메타) — [합계 | 계정…] 탭. 계정 탭 = 그 계정이 광고를 낸 날만.
|
||||
const missing = res.accounts_missing
|
||||
? '<p class="perf-notice">' + fmt(res.accounts_missing) + "일은 계정별 자료가 없어 합계 탭에만 있습니다 — [" + esc(name) +
|
||||
" 광고 불러오기]로 그 기간을 다시 가져오면 계정별로 나뉩니다.</p>"
|
||||
: "";
|
||||
m.body.innerHTML = '<div class="perf-quick perf-detail-tabs" role="tablist" aria-label="계정">' +
|
||||
tabs.map(function (t, i) {
|
||||
return '<button type="button" class="perf-seg' + (i ? "" : " is-active") + '" role="tab" aria-selected="' + (i ? "false" : "true") +
|
||||
'" data-tab="' + i + '"' + (t.account_id ? ' title="act_' + esc(t.account_id) + '"' : "") + ">" + esc(t.label) + "</button>";
|
||||
}).join("") + '</div><div class="perf-detail-tab-body"></div>' + missing + foot;
|
||||
const bodyEl = m.body.querySelector(".perf-detail-tab-body");
|
||||
const show = function (i) {
|
||||
m.body.querySelectorAll(".perf-detail-tabs [data-tab]").forEach(function (b) {
|
||||
const on = Number(b.dataset.tab) === i;
|
||||
b.classList.toggle("is-active", on);
|
||||
b.setAttribute("aria-selected", on ? "true" : "false");
|
||||
});
|
||||
bodyEl.innerHTML = table(tabs[i]) + (i ? '<p class="perf-muted">계정마다 따로 반올림해 계정 광고비의 합이 합계 탭과 1원 다를 수 있습니다.</p>' : "");
|
||||
};
|
||||
m.body.querySelector(".perf-detail-tabs").addEventListener("click", function (ev) {
|
||||
const b = ev.target.closest("[data-tab]");
|
||||
if (b) show(Number(b.dataset.tab));
|
||||
});
|
||||
show(0);
|
||||
} catch (err) {
|
||||
m.body.innerHTML = '<p class="perf-notice is-warn">' + esc(err.message) + "</p>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user