@adobe/spacecat-shared-athena-client 1.7.6 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-athena-client-v1.8.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-athena-client-v1.8.0...@adobe/spacecat-shared-athena-client-v1.8.1) (2025-12-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* expose traffic_loss in result mapper for consent-banner ([#1208](https://github.com/adobe/spacecat-shared/issues/1208)) ([2b89f67](https://github.com/adobe/spacecat-shared/commit/2b89f6754ebc9766b8853ece11fa99dbb2c6a1c5))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-athena-client-v1.8.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-athena-client-v1.7.6...@adobe/spacecat-shared-athena-client-v1.8.0) (2025-12-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* added query for PTRv2 ([#1205](https://github.com/adobe/spacecat-shared/issues/1205)) ([e291c2d](https://github.com/adobe/spacecat-shared/commit/e291c2d028bf20cc5851116d201a2d6c7c925d65))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-athena-client-v1.7.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-athena-client-v1.7.5...@adobe/spacecat-shared-athena-client-v1.7.6) (2025-11-28)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -261,6 +261,7 @@ export {
|
|
|
261
261
|
getTrafficAnalysisQueryPlaceholders,
|
|
262
262
|
buildPageTypeCase,
|
|
263
263
|
getTrafficAnalysisQueryPlaceholdersFilled,
|
|
264
|
+
getTop3PagesWithTrafficLostTemplate,
|
|
264
265
|
} from './traffic-analysis/queries.js';
|
|
265
266
|
export { TrafficDataResponseDto } from './traffic-analysis/traffic-data-base-response.js';
|
|
266
267
|
export { TrafficDataWithCWVDto } from './traffic-analysis/traffic-data-with-cwv.js';
|
|
@@ -142,3 +142,103 @@ export function getTrafficAnalysisQueryPlaceholdersFilled({
|
|
|
142
142
|
pageViewThreshold,
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Generates the top 3 pages with traffic lost SQL query with consent and referrer parameters.
|
|
148
|
+
* @param {Object} params - Template parameters
|
|
149
|
+
* @param {string} params.siteId - Site ID
|
|
150
|
+
* @param {string} params.tableName - Table name
|
|
151
|
+
* @param {string} params.temporalCondition - Temporal condition
|
|
152
|
+
* @param {string} params.dimensionColumns - Dimension columns
|
|
153
|
+
* @param {string} params.groupBy - Group by clause
|
|
154
|
+
* @param {string} params.dimensionColumnsPrefixed - Prefixed dimension columns
|
|
155
|
+
* @param {number} params.pageViewThreshold - Minimum total pageviews for path to include
|
|
156
|
+
* @param {number} params.limit - Limit the number of results
|
|
157
|
+
* @returns {string} The SQL query string
|
|
158
|
+
*/
|
|
159
|
+
export function getTop3PagesWithTrafficLostTemplate({
|
|
160
|
+
siteId,
|
|
161
|
+
tableName,
|
|
162
|
+
temporalCondition,
|
|
163
|
+
dimensionColumns,
|
|
164
|
+
groupBy,
|
|
165
|
+
dimensionColumnsPrefixed,
|
|
166
|
+
pageViewThreshold,
|
|
167
|
+
limit,
|
|
168
|
+
}) {
|
|
169
|
+
return `
|
|
170
|
+
WITH min_totals AS (
|
|
171
|
+
SELECT
|
|
172
|
+
path AS min_key,
|
|
173
|
+
CAST(SUM(pageviews) AS BIGINT) AS total_pageviews
|
|
174
|
+
FROM ${tableName}
|
|
175
|
+
WHERE siteid = '${siteId}' AND consent='show'
|
|
176
|
+
AND (${temporalCondition})
|
|
177
|
+
GROUP BY path
|
|
178
|
+
HAVING SUM(pageviews) >= ${pageViewThreshold}
|
|
179
|
+
),
|
|
180
|
+
raw AS (
|
|
181
|
+
SELECT
|
|
182
|
+
week,
|
|
183
|
+
month,
|
|
184
|
+
path,
|
|
185
|
+
trf_type,
|
|
186
|
+
trf_channel,
|
|
187
|
+
trf_platform,
|
|
188
|
+
device,
|
|
189
|
+
utm_source,
|
|
190
|
+
utm_medium,
|
|
191
|
+
utm_campaign,
|
|
192
|
+
referrer,
|
|
193
|
+
consent,
|
|
194
|
+
notfound,
|
|
195
|
+
pageviews,
|
|
196
|
+
clicked,
|
|
197
|
+
engaged,
|
|
198
|
+
latest_scroll,
|
|
199
|
+
CASE WHEN latest_scroll >= 10000 THEN 1 ELSE 0 END AS engaged_scroll,
|
|
200
|
+
lcp,
|
|
201
|
+
cls,
|
|
202
|
+
inp
|
|
203
|
+
FROM ${tableName} m
|
|
204
|
+
JOIN min_totals t ON m.path = t.min_key
|
|
205
|
+
WHERE m.siteid = '${siteId}' AND consent='show'
|
|
206
|
+
AND (${temporalCondition})
|
|
207
|
+
),
|
|
208
|
+
agg AS (
|
|
209
|
+
SELECT
|
|
210
|
+
${dimensionColumns},
|
|
211
|
+
COUNT(*) AS row_count,
|
|
212
|
+
CAST(SUM(pageviews) AS BIGINT) AS pageviews,
|
|
213
|
+
CAST(SUM(clicked) AS BIGINT) AS clicks,
|
|
214
|
+
CAST(SUM(engaged) AS BIGINT) AS engagements,
|
|
215
|
+
CAST(SUM(engaged_scroll) AS BIGINT) AS engaged_scroll,
|
|
216
|
+
approx_percentile(latest_scroll, 0.70) AS p70_scroll,
|
|
217
|
+
approx_percentile(lcp, 0.70) AS p70_lcp,
|
|
218
|
+
approx_percentile(cls, 0.70) AS p70_cls,
|
|
219
|
+
approx_percentile(inp, 0.70) AS p70_inp
|
|
220
|
+
FROM raw
|
|
221
|
+
GROUP BY ${groupBy}
|
|
222
|
+
),
|
|
223
|
+
grand_total AS (
|
|
224
|
+
SELECT CAST(SUM(pageviews) AS BIGINT) AS total_pv FROM agg
|
|
225
|
+
)
|
|
226
|
+
SELECT
|
|
227
|
+
${dimensionColumnsPrefixed},
|
|
228
|
+
CAST(a.pageviews AS DOUBLE) * (1 - CAST(a.engagements AS DOUBLE) / NULLIF(a.row_count, 0)) AS traffic_loss,
|
|
229
|
+
1 - CAST(a.engagements AS DOUBLE) / NULLIF(a.row_count, 0) AS bounce_rate,
|
|
230
|
+
a.pageviews,
|
|
231
|
+
CAST(a.pageviews AS DOUBLE) / NULLIF(t.total_pv, 0) AS pct_pageviews,
|
|
232
|
+
CAST(a.clicks AS DOUBLE) / NULLIF(a.row_count, 0) AS click_rate,
|
|
233
|
+
CAST(a.engagements AS DOUBLE) / NULLIF(a.row_count, 0) AS engagement_rate,
|
|
234
|
+
CAST(a.engaged_scroll AS DOUBLE) / NULLIF(a.row_count, 0) AS engaged_scroll_rate,
|
|
235
|
+
a.p70_scroll,
|
|
236
|
+
a.p70_lcp,
|
|
237
|
+
a.p70_cls,
|
|
238
|
+
a.p70_inp
|
|
239
|
+
FROM agg a
|
|
240
|
+
CROSS JOIN grand_total t
|
|
241
|
+
ORDER BY traffic_loss DESC
|
|
242
|
+
${limit ? `LIMIT ${limit}` : ''}
|
|
243
|
+
`.trim();
|
|
244
|
+
}
|
|
@@ -58,6 +58,11 @@ export const TrafficDataWithCWVDto = {
|
|
|
58
58
|
* inp_score: string,
|
|
59
59
|
* cls_score: string,
|
|
60
60
|
* overall_cwv_score: string,
|
|
61
|
+
* traffic_loss: number,
|
|
62
|
+
* url: string,
|
|
63
|
+
* path: string,
|
|
64
|
+
* page_type: string,
|
|
65
|
+
* device: string,
|
|
61
66
|
* }} JSON object.
|
|
62
67
|
*/
|
|
63
68
|
toJSON: (data, thresholdConfig, baseUrl) => {
|
|
@@ -85,6 +90,7 @@ export const TrafficDataWithCWVDto = {
|
|
|
85
90
|
path: data.path,
|
|
86
91
|
page_type: data.page_type,
|
|
87
92
|
device: data.device,
|
|
93
|
+
traffic_loss: data.traffic_loss,
|
|
88
94
|
p70_lcp: lcp,
|
|
89
95
|
p70_cls: cls,
|
|
90
96
|
p70_inp: inp,
|