diff --git a/packages/spacecat-shared-rum-api-client/src/functions/total-metrics.js b/packages/spacecat-shared-rum-api-client/src/functions/total-metrics.js index 04428313..7f3ab52a 100644 --- a/packages/spacecat-shared-rum-api-client/src/functions/total-metrics.js +++ b/packages/spacecat-shared-rum-api-client/src/functions/total-metrics.js @@ -17,16 +17,17 @@ function handler(bundles) { const dataChunks = new DataChunks(); loadBundles(bundles, dataChunks); dataChunks.addSeries('traffic_domain', series.pageViews); - dataChunks.addSeries('ctr', (bundle) => (bundle.events.some((e) => e.checkpoint === 'click') + dataChunks.addSeries('clicks', (bundle) => (bundle.events.some((e) => e.checkpoint === 'click') ? bundle.weight : 0)); const totalPageViews = dataChunks?.totals?.traffic_domain?.weight; - const sum = dataChunks?.totals?.ctr?.sum ?? 0; - const weight = dataChunks?.totals?.ctr?.weight ?? 0; + const sum = dataChunks?.totals?.clicks?.sum ?? 0; + const weight = dataChunks?.totals?.clicks?.weight ?? 0; const totalCTR = weight !== 0 ? sum / weight : 0; return { totalPageViews, totalCTR, + totalClicks: sum, }; } diff --git a/packages/spacecat-shared-rum-api-client/test/total-metrics.test.js b/packages/spacecat-shared-rum-api-client/test/total-metrics.test.js index 35e69e38..631a0bec 100644 --- a/packages/spacecat-shared-rum-api-client/test/total-metrics.test.js +++ b/packages/spacecat-shared-rum-api-client/test/total-metrics.test.js @@ -19,6 +19,7 @@ describe('Total Metrics Queries', () => { const result = totalMetrics.handler(bundlesForUrls.rumBundles); expect(result).to.deep.equal({ totalCTR: 0.2027468663384768, + totalClicks: 4901, totalPageViews: 24173, }); });