@adobe/spacecat-shared-rum-api-client 2.38.1 → 2.38.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 +14 -0
- package/package.json +2 -2
- package/src/common/traffic.js +38 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-rum-api-client-v2.38.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.38.2...@adobe/spacecat-shared-rum-api-client-v2.38.3) (2025-10-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/rum-distiller to v1.20.8 ([#1033](https://github.com/adobe/spacecat-shared/issues/1033)) ([e3a0b99](https://github.com/adobe/spacecat-shared/commit/e3a0b99c9464d542631e6dd744a2d9c214eda314))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-rum-api-client-v2.38.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.38.1...@adobe/spacecat-shared-rum-api-client-v2.38.2) (2025-10-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **traffic-attribution:** enforce earned-llm for llm providers ([#1028](https://github.com/adobe/spacecat-shared/issues/1028)) ([550c411](https://github.com/adobe/spacecat-shared/commit/550c411220ffc50a0d8ee6eb954f3e439efc5b0e))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-rum-api-client-v2.38.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.38.0...@adobe/spacecat-shared-rum-api-client-v2.38.1) (2025-10-09)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/spacecat-shared-rum-api-client",
|
|
3
|
-
"version": "2.38.
|
|
3
|
+
"version": "2.38.3",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - Rum API client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@adobe/fetch": "4.2.3",
|
|
39
39
|
"@adobe/helix-shared-wrap": "2.0.2",
|
|
40
40
|
"@adobe/helix-universal": "5.2.3",
|
|
41
|
-
"@adobe/rum-distiller": "1.20.
|
|
41
|
+
"@adobe/rum-distiller": "1.20.8",
|
|
42
42
|
"@adobe/spacecat-shared-utils": "1.48.0",
|
|
43
43
|
"aws4": "1.13.2",
|
|
44
44
|
"urijs": "1.19.11"
|
package/src/common/traffic.js
CHANGED
|
@@ -138,6 +138,29 @@ const not = (truth) => (text) => {
|
|
|
138
138
|
|
|
139
139
|
const notEmpty = (text) => hasText(text);
|
|
140
140
|
|
|
141
|
+
/*
|
|
142
|
+
* --------- ENFORCEMENTS ----------------
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
const ENFORCEMENTS = [
|
|
146
|
+
// vendors 'openai', 'claude', and 'perplexity' can only be earned/llm
|
|
147
|
+
{
|
|
148
|
+
when: (state) => state.vendor === 'openai' || state.vendor === 'claude' || state.vendor === 'perplexity',
|
|
149
|
+
enforce: (state) => ({ ...state, type: 'earned', category: 'llm' }),
|
|
150
|
+
},
|
|
151
|
+
// if utm_source=chatgpt.com, force earned/llm and vendor=openai
|
|
152
|
+
{
|
|
153
|
+
when: (state, ctx) => (ctx.utmSourceRaw || '').toLowerCase() === 'chatgpt.com',
|
|
154
|
+
enforce: (state) => ({ ...state, type: 'earned', category: 'llm', vendor: 'openai' }),
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
function applyEnforcements(initialState, context) {
|
|
159
|
+
return ENFORCEMENTS
|
|
160
|
+
.reduce((acc, rule) => (
|
|
161
|
+
rule.when(acc, context) ? rule.enforce(acc, context) : acc), initialState);
|
|
162
|
+
}
|
|
163
|
+
|
|
141
164
|
/*
|
|
142
165
|
* --------- RULES ----------------
|
|
143
166
|
*/
|
|
@@ -246,18 +269,29 @@ export function classifyTrafficSource(url, referrer, utmSource, utmMedium, track
|
|
|
246
269
|
|
|
247
270
|
const sanitize = (str) => (str || '').toLowerCase().replace(/[^a-zA-Z0-9]/, '');
|
|
248
271
|
|
|
249
|
-
const
|
|
272
|
+
const match = rules.find((rule) => (
|
|
250
273
|
rule.referrer(referrerDomain)
|
|
251
274
|
&& rule.utmSource(sanitize(utmSource))
|
|
252
275
|
&& rule.utmMedium(sanitize(utmMedium))
|
|
253
276
|
&& rule.tracking(trackingParams)
|
|
254
277
|
));
|
|
278
|
+
const { type, category } = match;
|
|
255
279
|
const vendor = classifyVendor(referrerDomain, utmSource, utmMedium);
|
|
256
280
|
|
|
281
|
+
const enforced = applyEnforcements(
|
|
282
|
+
{ type, category, vendor },
|
|
283
|
+
{
|
|
284
|
+
utmSourceRaw: utmSource,
|
|
285
|
+
utmSource: sanitize(utmSource),
|
|
286
|
+
utmMedium: sanitize(utmMedium),
|
|
287
|
+
referrerDomain,
|
|
288
|
+
},
|
|
289
|
+
);
|
|
290
|
+
|
|
257
291
|
return {
|
|
258
|
-
type,
|
|
259
|
-
category,
|
|
260
|
-
vendor,
|
|
292
|
+
type: enforced.type,
|
|
293
|
+
category: enforced.category,
|
|
294
|
+
vendor: enforced.vendor,
|
|
261
295
|
};
|
|
262
296
|
}
|
|
263
297
|
|