@alliance-droid/status-feedback-system 4.1.4 → 4.1.5

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,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.1.5
4
+
5
+ ### Fixed
6
+
7
+ - `<DevFeedback>` console-error capture: arguments are now serialized properly before being attached to a bug report. Previously `console.error(obj)` / `console.error('msg', { detail })` were captured via `String()`, which produced `[object Object]` — so the resulting ADO work item listed each console error as `[object Object]`. Errors now serialize to their stack, plain objects/arrays to JSON (with circular-reference safety), and primitives via `String()`. Extracted to `formatConsoleArg` / `formatConsoleArgs` with unit coverage.
8
+
3
9
  ## 4.1.4
4
10
 
5
11
  ### Changed
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { createStatusClient, type StatusClient } from '../api.js';
3
3
  import { FEEDBACK_CATEGORIES } from '../types.js';
4
+ import { formatConsoleArgs } from '../console-format.js';
4
5
  import PasteImageInput from './shared/PasteImageInput.svelte';
5
6
  import {
6
7
  Card,
@@ -209,7 +210,7 @@
209
210
  // Capture recent console errors to attach to bug reports.
210
211
  const originalConsoleError = console.error;
211
212
  console.error = (...args: unknown[]) => {
212
- consoleErrors.push(args.map(String).join(' '));
213
+ consoleErrors.push(formatConsoleArgs(args));
213
214
  if (consoleErrors.length > maxConsoleErrors) consoleErrors.shift();
214
215
  originalConsoleError.apply(console, args);
215
216
  };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Serialize console.error arguments into useful strings for bug-report capture.
3
+ *
4
+ * The naive `args.map(String).join(' ')` turns any object argument into the
5
+ * useless `"[object Object]"` and drops an Error's stack — so a captured
6
+ * `console.error(err)` or `console.error('msg', { detail })` reaches the ADO
7
+ * work item as `[object Object]`. These helpers serialize each argument by shape.
8
+ */
9
+ /** Serialize a single console.error argument to a useful string. */
10
+ export declare function formatConsoleArg(arg: unknown): string;
11
+ /** Serialize a console.error argument list into a single line. */
12
+ export declare function formatConsoleArgs(args: unknown[]): string;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Serialize console.error arguments into useful strings for bug-report capture.
3
+ *
4
+ * The naive `args.map(String).join(' ')` turns any object argument into the
5
+ * useless `"[object Object]"` and drops an Error's stack — so a captured
6
+ * `console.error(err)` or `console.error('msg', { detail })` reaches the ADO
7
+ * work item as `[object Object]`. These helpers serialize each argument by shape.
8
+ */
9
+ /** Serialize a single console.error argument to a useful string. */
10
+ export function formatConsoleArg(arg) {
11
+ if (typeof arg === 'string')
12
+ return arg;
13
+ if (arg instanceof Error)
14
+ return arg.stack || `${arg.name}: ${arg.message}`;
15
+ if (arg === null)
16
+ return 'null';
17
+ if (arg === undefined)
18
+ return 'undefined';
19
+ if (typeof arg === 'object') {
20
+ const seen = new WeakSet();
21
+ try {
22
+ const json = JSON.stringify(arg, (_key, value) => {
23
+ if (value instanceof Error)
24
+ return value.stack || `${value.name}: ${value.message}`;
25
+ if (typeof value === 'object' && value !== null) {
26
+ if (seen.has(value))
27
+ return '[Circular]';
28
+ seen.add(value);
29
+ }
30
+ return value;
31
+ });
32
+ // JSON.stringify returns undefined for unserializable roots and "{}"
33
+ // for objects with no enumerable props — fall back to String() then.
34
+ if (json && json !== '{}')
35
+ return json;
36
+ }
37
+ catch {
38
+ /* fall through to String() */
39
+ }
40
+ }
41
+ return String(arg);
42
+ }
43
+ /** Serialize a console.error argument list into a single line. */
44
+ export function formatConsoleArgs(args) {
45
+ return args.map(formatConsoleArg).join(' ');
46
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alliance-droid/status-feedback-system",
3
- "version": "4.1.4",
3
+ "version": "4.1.5",
4
4
  "type": "module",
5
5
  "description": "Drop-in system status pages and user feedback forms for SvelteKit apps",
6
6
  "svelte": "./dist/index.js",