@adobe/spacecat-shared-athena-client 1.2.2 → 1.2.3

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,10 @@
1
+ # [@adobe/spacecat-shared-athena-client-v1.2.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-athena-client-v1.2.2...@adobe/spacecat-shared-athena-client-v1.2.3) (2025-07-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * introduce filter on traffic type ([#882](https://github.com/adobe/spacecat-shared/issues/882)) ([df08c60](https://github.com/adobe/spacecat-shared/commit/df08c6066206ba43582104b6be6a6622259cbafc))
7
+
1
8
  # [@adobe/spacecat-shared-athena-client-v1.2.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-athena-client-v1.2.1...@adobe/spacecat-shared-athena-client-v1.2.2) (2025-07-25)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-athena-client",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Shared modules of the Spacecat Services - AWS Athena Client",
5
5
  "type": "module",
6
6
  "engines": {
@@ -36,6 +36,7 @@ export function getTrafficAnalysisQueryPlaceholders() {
36
36
  'siteId',
37
37
  'tableName',
38
38
  'temporalCondition',
39
+ 'trfTypeCondition',
39
40
  ];
40
41
  }
41
42
 
@@ -71,7 +72,8 @@ export function buildPageTypeCase(pageTypes, column) {
71
72
  * @param {string} params.tableName - The name of the source table.
72
73
  * @param {string} params.pageTypeMatchColumn - The pageTypeMatchColumn of the source table.
73
74
  * @param {Object|null} [params.pageTypes=null] - Optional pageType rules for CASE generation.
74
- *
75
+ * @param {string[]|null} [params.trfTypes] - Traffic type to filter by before
76
+ * grouping (e.g ['paid']).
75
77
  * @returns {Object} Template values for SQL generation.
76
78
  */
77
79
  export function getTrafficAnalysisQueryPlaceholdersFilled({
@@ -82,6 +84,7 @@ export function getTrafficAnalysisQueryPlaceholdersFilled({
82
84
  tableName,
83
85
  pageTypes = null,
84
86
  pageTypeMatchColumn = 'path',
87
+ trfTypes = null,
85
88
  }) {
86
89
  if (!week || !year || !siteId || !tableName) {
87
90
  throw new Error('Missing required parameters: week, year, siteId, or tableName');
@@ -104,6 +107,12 @@ export function getTrafficAnalysisQueryPlaceholdersFilled({
104
107
  pageTypeCase = buildPageTypeCase(pageTypes, pageTypeMatchColumn);
105
108
  }
106
109
 
110
+ let trfTypeCondition = 'TRUE';
111
+ if (trfTypes && trfTypes.length > 0) {
112
+ const quotedTypes = trfTypes.map((type) => `'${type}'`).join(', ');
113
+ trfTypeCondition = `trf_type IN (${quotedTypes})`;
114
+ }
115
+
107
116
  return {
108
117
  siteId,
109
118
  groupBy: dimensionColumns,
@@ -112,5 +121,6 @@ export function getTrafficAnalysisQueryPlaceholdersFilled({
112
121
  tableName,
113
122
  temporalCondition,
114
123
  pageTypeCase,
124
+ trfTypeCondition,
115
125
  };
116
126
  }
@@ -26,6 +26,7 @@ export function getTrafficAnalysisTemplate({
26
26
  siteId,
27
27
  tableName,
28
28
  temporalCondition,
29
+ trfTypeCondition,
29
30
  dimensionColumns,
30
31
  groupBy,
31
32
  dimensionColumnsPrefixed,
@@ -57,6 +58,7 @@ WITH raw AS (
57
58
  FROM ${tableName}
58
59
  WHERE siteid = '${siteId}'
59
60
  AND (${temporalCondition})
61
+ AND ${trfTypeCondition}
60
62
  ),
61
63
  agg AS (
62
64
  SELECT