runtime-reporter 0.4.3 → 0.4.4

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.
Files changed (2) hide show
  1. package/README.md +15 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -60,10 +60,10 @@ Inject runtime data into your messages via message templates and tokenized varia
60
60
 
61
61
  ```ts
62
62
  const reporter = createReporter({
63
- ERR01: "{{ componentName }} failed at {{ phase }}",
63
+ ERR01: "{{ componentName }} failed to mount",
64
64
  });
65
65
 
66
- reporter.error("ERR01", { componentName: "MyComponent", phase: "mount" });
66
+ reporter.error("ERR01", { componentName: "MyComponent" });
67
67
  ```
68
68
 
69
69
  ### Type safety
@@ -168,7 +168,7 @@ import { reporter } from "./runtime-reporter";
168
168
 
169
169
  export function MyComponent() {
170
170
  useEffect(() => {
171
- reporter.error("ERR01", { componentName: "MyComponent", phase: "mount" });
171
+ reporter.error("ERR01", { componentName: "MyComponent" });
172
172
  }, []);
173
173
 
174
174
  return <div>My Component</div>;
@@ -228,7 +228,7 @@ const reporter = createReporter(
228
228
  process.env.NODE_ENV === "production" ? ({} as typeof messages) : messages
229
229
  );
230
230
 
231
- reporter.fail("ERR01", { componentName: "Router", phase: "mount" });
231
+ reporter.fail("ERR01", { componentName: "Router" });
232
232
  // throws: "An error occurred (ERR01)"
233
233
  ```
234
234
 
@@ -243,7 +243,7 @@ it("should log error if component fails to mount", () => {
243
243
  render(<MyComponent />);
244
244
 
245
245
  expect(console.error).toHaveBeenCalledWith(
246
- reporter.message("ERR01", { componentName: "MyComponent", phase: "mount" })
246
+ reporter.message("ERR01", { componentName: "MyComponent" })
247
247
  );
248
248
  });
249
249
  ```
@@ -256,16 +256,21 @@ You can still get the same benefits as TypeScript by using JSDoc-style type anno
256
256
  /**
257
257
  * @type {import("runtime-reporter").RuntimeReporterMessages<{
258
258
  * code: "ERR01";
259
- * template: "{{ componentName }} failed at {{ phase }}";
260
- * tokens: "componentName" | "phase";
259
+ * template: "{{ componentName }} failed to mount";
260
+ * tokens: "componentName";
261
261
  * } | {
262
- * code: "INFO01";
263
- * template: "Ready";
262
+ * code: "ERR02";
263
+ * template: "Failed to load configuration";
264
+ * } | {
265
+ * code: "ERR03";
266
+ * template: "Failed to fetch {{ resource }} from {{ url }}";
267
+ * tokens: "resource" | "url";
264
268
  * }>}
265
269
  */
266
270
  const messages = {
267
271
  ERR01: "{{ componentName }} failed at {{ phase }}",
268
- INFO01: "Ready",
272
+ ERR02: "Failed to load configuration",
273
+ ERR03: "Failed to fetch {{ resource }} from {{ url }}",
269
274
  };
270
275
  ```
271
276
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runtime-reporter",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Structured runtime reporting that is type-safe, centralized, and production-ready.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",