@leaflink/snitch 1.2.1 → 1.3.0
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.
|
@@ -6,16 +6,16 @@ export class ConsoleTransport {
|
|
|
6
6
|
this.log = (message, meta, level) => {
|
|
7
7
|
switch (level) {
|
|
8
8
|
case 'error':
|
|
9
|
-
console.error(message, meta);
|
|
9
|
+
console.error(message, meta ?? '');
|
|
10
10
|
break;
|
|
11
11
|
case 'warn':
|
|
12
|
-
console.warn(message, meta);
|
|
12
|
+
console.warn(message, meta ?? '');
|
|
13
13
|
break;
|
|
14
14
|
case 'debug':
|
|
15
|
-
console.debug(message, meta);
|
|
15
|
+
console.debug(message, meta ?? '');
|
|
16
16
|
break;
|
|
17
17
|
default:
|
|
18
|
-
console.log(message, meta);
|
|
18
|
+
console.log(message, meta ?? '');
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/transports/console.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,gBAAgB;IAC3B,KAAK,CAAW;IAChB,GAAG,CAAiG;IAEpG,YAAY,IAA8B;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,OAAO,CAAC;QACpC,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAClC,QAAQ,KAAK,EAAE;gBACb,KAAK,OAAO;oBACV,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/transports/console.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,gBAAgB;IAC3B,KAAK,CAAW;IAChB,GAAG,CAAiG;IAEpG,YAAY,IAA8B;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,OAAO,CAAC;QACpC,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAClC,QAAQ,KAAK,EAAE;gBACb,KAAK,OAAO;oBACV,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;oBACnC,MAAM;gBACR,KAAK,MAAM;oBACT,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;oBAClC,MAAM;gBACR,KAAK,OAAO;oBACV,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;oBACnC,MAAM;gBACR;oBACE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;aACpC;QACH,CAAC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -10,9 +10,23 @@ export class SentryTransport {
|
|
|
10
10
|
constructor(opts) {
|
|
11
11
|
this.level = opts.level || 'error';
|
|
12
12
|
this.log = (message, meta, level) => {
|
|
13
|
+
// There's a handful of well defined context properties in sentry:
|
|
14
|
+
// https://docs.sentry.io/platforms/javascript/enriching-events/context/#passing-context-directly
|
|
15
|
+
// If the metadata you pass is not one of these, we will automatically put it into extra for
|
|
16
|
+
// you, which is just a dumping ground for contextual metadata that sentry normalizes for you.
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
|
+
const { tags, extra, contexts, user, level: metaLevel, fingerprint, ...customMeta } = meta || {};
|
|
19
|
+
const extraSentry = {
|
|
20
|
+
...(extra && typeof extra === 'object' ? extra : {}),
|
|
21
|
+
...(customMeta && typeof customMeta === 'object' ? customMeta : {}),
|
|
22
|
+
};
|
|
13
23
|
const sentryMeta = {
|
|
14
24
|
level: SentryErrorLevelMap[level],
|
|
15
|
-
|
|
25
|
+
extra: extraSentry,
|
|
26
|
+
tags,
|
|
27
|
+
contexts,
|
|
28
|
+
user,
|
|
29
|
+
fingerprint,
|
|
16
30
|
};
|
|
17
31
|
if (typeof message === 'string') {
|
|
18
32
|
opts.sentryInstance.captureMessage(message, sentryMeta);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry.js","sourceRoot":"","sources":["../../src/transports/sentry.ts"],"names":[],"mappings":"AAEA,MAAM,mBAAmB,GAAG;IAC1B,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,OAAO;CACf,CAAC;AAUF,MAAM,OAAO,eAAe;IAC1B,KAAK,CAAW;IAChB,GAAG,CAAiG;IAEpG,YAAY,IAA4B;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC;QACnC,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAClC,MAAM,UAAU,GAAG;gBACjB,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC;gBACjC,
|
|
1
|
+
{"version":3,"file":"sentry.js","sourceRoot":"","sources":["../../src/transports/sentry.ts"],"names":[],"mappings":"AAEA,MAAM,mBAAmB,GAAG;IAC1B,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,OAAO;CACf,CAAC;AAUF,MAAM,OAAO,eAAe;IAC1B,KAAK,CAAW;IAChB,GAAG,CAAiG;IAEpG,YAAY,IAA4B;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC;QACnC,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAClC,kEAAkE;YAClE,iGAAiG;YACjG,4FAA4F;YAC5F,8FAA8F;YAC9F,6DAA6D;YAC7D,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;YACjG,MAAM,WAAW,GAAG;gBAClB,GAAG,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpD,GAAG,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;aACpE,CAAC;YACF,MAAM,UAAU,GAAG;gBACjB,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC;gBACjC,KAAK,EAAE,WAAW;gBAClB,IAAI;gBACJ,QAAQ;gBACR,IAAI;gBACJ,WAAW;aACZ,CAAC;YAEF,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;gBAC/B,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;aACzD;iBAAM;gBACL,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;aAC3D;QACH,CAAC,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leaflink/snitch",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Front end logging inspired by winston.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"default": "./dist/transports/datadog.js"
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
28
30
|
"engines": {
|
|
29
31
|
"node": ">=16",
|
|
30
32
|
"npm": ">=8"
|
|
@@ -32,7 +34,6 @@
|
|
|
32
34
|
"files": [
|
|
33
35
|
"dist"
|
|
34
36
|
],
|
|
35
|
-
"types": "./dist/index.d.ts",
|
|
36
37
|
"publishConfig": {
|
|
37
38
|
"access": "public"
|
|
38
39
|
},
|