@adobe/spacecat-shared-rum-api-client 2.38.1 → 2.38.2

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-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)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **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))
7
+
1
8
  # [@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
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-rum-api-client",
3
- "version": "2.38.1",
3
+ "version": "2.38.2",
4
4
  "description": "Shared modules of the Spacecat Services - Rum API client",
5
5
  "type": "module",
6
6
  "engines": {
@@ -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 { type, category } = rules.find((rule) => (
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