nuxt-error-tracker 0.1.5 → 0.1.6

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-error-tracker",
3
3
  "configKey": "errorTracker",
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, extendViteConfig, createResolver, addPlugin } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addPlugin } from '@nuxt/kit';
2
2
 
3
3
  function posInt(value, fallback) {
4
4
  const n = Number(value);
@@ -37,13 +37,6 @@ const module = defineNuxtModule({
37
37
  // Server DTO caps at 50 breadcrumbs — stay at or below.
38
38
  maxBreadcrumbs: Math.min(posInt(options.maxBreadcrumbs, 30), 50)
39
39
  };
40
- extendViteConfig((config) => {
41
- config.optimizeDeps ||= {};
42
- config.optimizeDeps.include ||= [];
43
- if (!config.optimizeDeps.include.includes("protobufjs")) {
44
- config.optimizeDeps.include.push("protobufjs");
45
- }
46
- });
47
40
  const resolver = createResolver(import.meta.url);
48
41
  addPlugin({
49
42
  src: resolver.resolve("./runtime/plugin.server"),
@@ -1,37 +1,24 @@
1
- import protobuf from "protobufjs";
2
- const INGEST_PROTO = `
3
- syntax = "proto3";
4
- message Breadcrumb {
5
- string type = 1;
6
- string category = 2;
7
- string message = 3;
8
- string level = 4;
9
- string timestamp = 5;
10
- string data = 6;
11
- }
12
- message Error {
13
- string message = 1;
14
- string stack = 2;
15
- string source = 3;
16
- string url = 4;
17
- string route = 5;
18
- string userId = 6;
19
- string appVersion = 7;
20
- string device = 8;
21
- string occurredAt = 9;
22
- repeated Breadcrumb breadcrumbs = 10;
1
+ const textEncoder = new TextEncoder();
2
+ function pushVarint(out, value) {
3
+ let v = value >>> 0;
4
+ while (v > 127) {
5
+ out.push(v & 127 | 128);
6
+ v >>>= 7;
7
+ }
8
+ out.push(v);
23
9
  }
24
- message Meta {
25
- string device = 1;
26
- string userId = 2;
27
- string appVersion = 3;
10
+ function pushLenField(out, fieldNo, bytes) {
11
+ pushVarint(out, fieldNo << 3 | 2);
12
+ pushVarint(out, bytes.length);
13
+ for (let i = 0; i < bytes.length; i++) out.push(bytes[i]);
28
14
  }
29
- message Batch {
30
- Meta meta = 1;
31
- repeated Error errors = 2;
15
+ function pushString(out, fieldNo, value) {
16
+ if (!value) return;
17
+ const encoded = textEncoder.encode(value);
18
+ pushVarint(out, fieldNo << 3 | 2);
19
+ pushVarint(out, encoded.length);
20
+ for (let i = 0; i < encoded.length; i++) out.push(encoded[i]);
32
21
  }
33
- `;
34
- const Batch = protobuf.parse(INGEST_PROTO).root.lookupType("Batch");
35
22
  function jsonStr(v) {
36
23
  if (v === void 0 || v === null) return "";
37
24
  try {
@@ -40,31 +27,38 @@ function jsonStr(v) {
40
27
  return "";
41
28
  }
42
29
  }
30
+ function encodeBreadcrumb(c) {
31
+ const out = [];
32
+ pushString(out, 1, c.type ?? "");
33
+ pushString(out, 2, c.category ?? "");
34
+ pushString(out, 3, c.message ?? "");
35
+ pushString(out, 4, c.level ?? "");
36
+ pushString(out, 5, c.timestamp ?? "");
37
+ pushString(out, 6, jsonStr(c.data));
38
+ return out;
39
+ }
40
+ function encodeError(e) {
41
+ const out = [];
42
+ pushString(out, 1, e.message);
43
+ pushString(out, 2, e.stack);
44
+ pushString(out, 3, e.source);
45
+ pushString(out, 4, e.url);
46
+ pushString(out, 5, e.route);
47
+ pushString(out, 9, e.occurredAt);
48
+ for (const c of e.breadcrumbs ?? []) {
49
+ pushLenField(out, 10, encodeBreadcrumb(c));
50
+ }
51
+ return out;
52
+ }
43
53
  export function encodeBatch(body) {
44
- const message = {
45
- meta: {
46
- device: jsonStr(body.meta.device),
47
- userId: body.meta.userId ?? "",
48
- appVersion: body.meta.appVersion ?? ""
49
- },
50
- errors: body.errors.map((e) => ({
51
- message: e.message,
52
- stack: e.stack,
53
- source: e.source,
54
- url: e.url,
55
- route: e.route,
56
- appVersion: "",
57
- device: "",
58
- occurredAt: e.occurredAt,
59
- breadcrumbs: (e.breadcrumbs ?? []).map((c) => ({
60
- type: c.type ?? "",
61
- category: c.category ?? "",
62
- message: c.message ?? "",
63
- level: c.level ?? "",
64
- timestamp: c.timestamp ?? "",
65
- data: jsonStr(c.data)
66
- }))
67
- }))
68
- };
69
- return Batch.encode(Batch.fromObject(message)).finish();
54
+ const out = [];
55
+ const meta = [];
56
+ pushString(meta, 1, jsonStr(body.meta.device));
57
+ pushString(meta, 2, body.meta.userId ?? "");
58
+ pushString(meta, 3, body.meta.appVersion ?? "");
59
+ pushLenField(out, 1, meta);
60
+ for (const e of body.errors) {
61
+ pushLenField(out, 2, encodeError(e));
62
+ }
63
+ return new Uint8Array(out);
70
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-error-tracker",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -19,9 +19,6 @@
19
19
  "build": "nuxt-module-build build",
20
20
  "prepublishOnly": "nuxt-module-build build"
21
21
  },
22
- "dependencies": {
23
- "protobufjs": "^8.6.6"
24
- },
25
22
  "peerDependencies": {
26
23
  "@nuxt/kit": "^3.14.0 || ^4.0.0"
27
24
  },