@adobe/spacecat-shared-utils 1.84.0 → 1.85.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-utils-v1.85.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.85.0...@adobe/spacecat-shared-utils-v1.85.1) (2025-12-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Structured (JSON) for Logging should be JSON string ([#1237](https://github.com/adobe/spacecat-shared/issues/1237)) ([cfcee6e](https://github.com/adobe/spacecat-shared/commit/cfcee6e4315aa518c52e4ca50b99b0cb762f5a61))
7
+
8
+ # [@adobe/spacecat-shared-utils-v1.85.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.84.0...@adobe/spacecat-shared-utils-v1.85.0) (2025-12-11)
9
+
10
+
11
+ ### Features
12
+
13
+ * add WIKIPEDIA_ANALYSIS audit type and opportunity type ([#1222](https://github.com/adobe/spacecat-shared/issues/1222)) ([5a1b113](https://github.com/adobe/spacecat-shared/commit/5a1b113ff343a930e80bb5aafedbe2b8c5423534))
14
+
1
15
  # [@adobe/spacecat-shared-utils-v1.84.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.83.0...@adobe/spacecat-shared-utils-v1.84.0) (2025-12-10)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-utils",
3
- "version": "1.84.0",
3
+ "version": "1.85.1",
4
4
  "description": "Shared modules of the Spacecat Services - utils",
5
5
  "type": "module",
6
6
  "exports": {
package/src/constants.js CHANGED
@@ -64,4 +64,7 @@ export const OPPORTUNITY_TYPES = /** @type {const} */ ({
64
64
 
65
65
  // Paid Cookie Consent
66
66
  PAID_COOKIE_CONSENT: 'paid-cookie-consent',
67
+
68
+ // Wikipedia Analysis (LLMO)
69
+ WIKIPEDIA_ANALYSIS: 'wikipedia-analysis',
67
70
  });
@@ -27,11 +27,13 @@ function isPlainObject(value) {
27
27
 
28
28
  /**
29
29
  * A higher-order function that wraps a given function and enhances logging by converting
30
- * all logs to JSON format and appending `jobId` and `traceId` to log messages when available.
30
+ * all logs to JSON format and appending `severity`, `jobId`and `traceId`
31
+ * to log messages when available.
31
32
  *
32
33
  * All log messages are automatically converted to structured JSON format:
33
- * - String messages become: { message: "...", jobId: "...", traceId: "..." }
34
- * - Object messages are merged with: { ...yourObject, jobId: "...", traceId: "..." }
34
+ * - String messages become: { severity: "info", message: "...", jobId: "...", traceId: "..." }
35
+ * - Object messages are merged with:
36
+ * { severity: "info", ...yourObject, jobId: "...", traceId: "..." }
35
37
  *
36
38
  * @param {function} fn - The original function to be wrapped
37
39
  * @returns {function(object, object): Promise<Response>} - A wrapped function with JSON logging
@@ -63,12 +65,13 @@ export function logWrapper(fn) {
63
65
  accumulator[level] = (...args) => {
64
66
  // If first argument is a plain object, merge with markers
65
67
  if (args.length > 0 && isPlainObject(args[0])) {
66
- return log[level]({ ...markers, ...args[0] });
68
+ return log[level](JSON.stringify({ severity: level, ...markers, ...args[0] }));
67
69
  }
68
70
 
69
71
  // If first argument is a string, convert to structured format
70
72
  if (args.length > 0 && typeof args[0] === 'string') {
71
73
  const logObject = {
74
+ severity: level,
72
75
  ...markers,
73
76
  message: args[0],
74
77
  };
@@ -87,11 +90,11 @@ export function logWrapper(fn) {
87
90
  logObject.data = args.slice(1);
88
91
  }
89
92
 
90
- return log[level](logObject);
93
+ return log[level](JSON.stringify(logObject));
91
94
  }
92
95
 
93
96
  // For other types (arrays, primitives, Error objects), wrap in object
94
- return log[level]({ ...markers, data: args });
97
+ return log[level](JSON.stringify({ severity: level, ...markers, data: args }));
95
98
  };
96
99
  }
97
100
  return accumulator;