@leaflink/snitch 0.0.0-PR-55--577cbd7 → 0.0.0-PR-56--4e938e8

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/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
2
- export type LogMessage = string | typeof Error | unknown | object;
3
- export type LogMeta = Record<string, unknown> | typeof Error | unknown | object;
4
- export type LogFunction = (message: LogMessage, meta: LogMeta, level: LogLevel) => void;
2
+ type LogMessage = object | string;
3
+ type LogFunction = (message: LogMessage, meta: Record<string, unknown> | undefined, level: LogLevel) => void;
5
4
  export interface Transport {
6
5
  level: LogLevel;
7
6
  log: LogFunction;
@@ -12,16 +11,16 @@ export declare class Logger {
12
11
  transports: Transport[];
13
12
  });
14
13
  private _log;
15
- debug(message: LogMessage, meta?: LogMeta): void;
16
- info(message: LogMessage, meta?: LogMeta): void;
17
- log(message: LogMessage, meta?: LogMeta): void;
18
- warn(message: LogMessage, meta?: LogMeta): void;
19
- error(message: LogMessage, meta?: LogMeta): void;
14
+ debug(message: LogMessage, meta?: Record<string, unknown>): void;
15
+ info(message: LogMessage, meta?: Record<string, unknown>): void;
16
+ log(message: LogMessage, meta?: Record<string, unknown>): void;
17
+ warn(message: LogMessage, meta?: Record<string, unknown>): void;
18
+ error(message: LogMessage, meta?: Record<string, unknown>): void;
20
19
  addTransport(transport: Transport): void;
21
20
  clearTransports(): void;
22
21
  }
23
22
  declare const logger: Logger;
24
23
  export default logger;
25
24
  export { ConsoleTransport } from './transports/console.js';
26
- export { DatadogTransport, ReactNativeDatadogTransport } from './transports/datadog.js';
25
+ export { DatadogTransport } from './transports/datadog.js';
27
26
  export { SentryTransport } from './transports/sentry.js';
package/dist/index.js CHANGED
@@ -41,6 +41,6 @@ export class Logger {
41
41
  const logger = new Logger();
42
42
  export default logger;
43
43
  export { ConsoleTransport } from './transports/console.js';
44
- export { DatadogTransport, ReactNativeDatadogTransport } from './transports/datadog.js';
44
+ export { DatadogTransport } from './transports/datadog.js';
45
45
  export { SentryTransport } from './transports/sentry.js';
46
46
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACT,CAAC;AAcF,MAAM,OAAO,MAAM;IACjB,UAAU,CAAc;IAExB,YAAY,IAAkC;QAC5C,IAAI,CAAC,UAAU,GAAG,IAAI,EAAE,UAAU,IAAI,EAAE,CAAC;IAC3C,CAAC;IAEO,IAAI,CAAC,KAAe,EAAE,OAAmB,EAAE,IAAc;QAC/D,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;YACvC,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;gBAC5C,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;aACrC;SACF;IACH,CAAC;IAED,KAAK,CAAC,OAAmB,EAAE,IAAc;QACvC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,OAAmB,EAAE,IAAc;QACtC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,OAAmB,EAAE,IAAc;QACrC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,CAAC,OAAmB,EAAE,IAAc;QACtC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CA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OAAO,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,OAAmB,EAAE,IAA8B;QACtD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,OAAmB,EAAE,IAA8B;QACrD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,CAAC,OAAmB,EAAE,IAA8B;QACtD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,OAAmB,EAAE,IAA8B;QACvD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,YAAY,CAAC,SAAoB;QAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAED,eAAe;QACb,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;CACF;AAED,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;AAC5B,eAAe,MAAM,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export type LogLevel = 'error' | 'warn' | 'info' | 'debug';\nconst levels = {\n error: 0,\n warn: 1,\n info: 2,\n debug: 3,\n};\n\ntype LogMessage = object | string;\ntype LogFunction = (message: LogMessage, meta: Record<string, unknown> | undefined, level: LogLevel) => void;\n\nexport interface Transport {\n level: LogLevel;\n log: LogFunction;\n}\n\nexport class Logger {\n transports: Transport[];\n\n constructor(opts?: { transports: Transport[] }) {\n this.transports = opts?.transports || [];\n }\n\n private _log(level: LogLevel, message: LogMessage, meta?: Record<string, unknown>) {\n for (const transport of this.transports) {\n if (levels[transport.level] >= levels[level]) {\n transport.log(message, meta, level);\n }\n }\n }\n\n debug(message: LogMessage, meta?: Record<string, unknown>) {\n this._log('debug', message, meta);\n }\n\n info(message: LogMessage, meta?: Record<string, unknown>) {\n this._log('info', message, meta);\n }\n\n log(message: LogMessage, meta?: Record<string, unknown>) {\n this.info(message, meta);\n }\n\n warn(message: LogMessage, meta?: Record<string, unknown>) {\n this._log('warn', message, meta);\n }\n\n error(message: LogMessage, meta?: Record<string, unknown>) {\n this._log('error', message, meta);\n }\n\n addTransport(transport: Transport) {\n this.transports.push(transport);\n }\n\n clearTransports() {\n this.transports = [];\n }\n}\n\nconst logger = new Logger();\nexport default logger;\n\nexport { ConsoleTransport } from './transports/console.js';\nexport { DatadogTransport } from './transports/datadog.js';\nexport { SentryTransport } from './transports/sentry.js';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../src/index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,MAAM,EAAY,MAAM,YAAY,CAAC;AAEtD,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;AAE1C,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,sCAAsC,EAAE,CAAC,KAAK,EAAE,EAAE;IAC5F,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEzC,MAAM,CAAC,YAAY,CAAC;QAClB,KAAK,EAAE,KAAiB;QACxB,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;KAClC,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;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,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC","sourcesContent":["import logger, { Logger, LogLevel } from './index.js';\n\nafterEach(() => logger.clearTransports());\n\nit.each(['debug', 'info', 'warn', 'error'])('can register a logger to a log level', (level) => {\n expect(logger.transports.length).toBe(0);\n\n logger.addTransport({\n level: level as LogLevel,\n log: () => console.log('logged!'),\n });\n\n expect(logger.transports.length).toBe(1);\n expect(logger.transports[0].level).toBe(level);\n});\n\nit(\"calls a transport when the log level is at or below the transport's level\", () => {\n const errorSpy = vi.fn();\n const warnSpy = vi.fn();\n const infoSpy = vi.fn();\n const debugSpy = vi.fn();\n\n logger.addTransport({\n level: 'error',\n log: errorSpy,\n });\n\n logger.addTransport({\n level: 'warn',\n log: warnSpy,\n });\n\n logger.addTransport({\n level: 'info',\n log: infoSpy,\n });\n\n logger.addTransport({\n level: 'debug',\n log: debugSpy,\n });\n\n // eslint-disable-next-line testing-library/no-debugging-utils\n logger.debug('debug message', {});\n expect(errorSpy).not.toHaveBeenCalled();\n expect(warnSpy).not.toHaveBeenCalled();\n expect(infoSpy).not.toHaveBeenCalled();\n expect(debugSpy).toHaveBeenCalledWith('debug message', {}, 'debug');\n\n logger.info('info message', {});\n expect(errorSpy).not.toHaveBeenCalled();\n expect(warnSpy).not.toHaveBeenCalled();\n expect(infoSpy).toHaveBeenCalledWith('info message', {}, 'info');\n expect(debugSpy).toHaveBeenCalledWith('info message', {}, 'info');\n\n logger.warn('warn message', {});\n expect(errorSpy).not.toHaveBeenCalled();\n expect(warnSpy).toHaveBeenCalledWith('warn message', {}, 'warn');\n expect(infoSpy).toHaveBeenCalledWith('warn message', {}, 'warn');\n expect(debugSpy).toHaveBeenCalledWith('warn message', {}, 'warn');\n\n logger.error('error message', {});\n expect(errorSpy).toHaveBeenCalledWith('error message', {}, 'error');\n expect(warnSpy).toHaveBeenCalledWith('error message', {}, 'error');\n expect(infoSpy).toHaveBeenCalledWith('error message', {}, 'error');\n expect(debugSpy).toHaveBeenCalledWith('error message', {}, 'error');\n});\n\nit('can create a logger with transports set in the constructor', () => {\n const customLogger = new Logger({\n transports: [\n {\n level: 'info',\n log: vi.fn(),\n },\n {\n level: 'warn',\n log: vi.fn(),\n },\n ],\n });\n\n expect(customLogger.transports.length).toBe(2);\n});\n"]}
@@ -1,9 +1,9 @@
1
- import { LogLevel, LogMessage, LogMeta, Transport } from '../index.js';
1
+ import { LogLevel, Transport } from '../index.js';
2
2
  export interface ConsoleTransportOptions {
3
3
  level?: LogLevel;
4
4
  }
5
5
  export declare class ConsoleTransport implements Transport {
6
6
  level: LogLevel;
7
- log: (message: LogMessage, meta: LogMeta, level: LogLevel) => void;
7
+ log: (message: string | object, meta: Record<string, unknown> | undefined, level: LogLevel) => void;
8
8
  constructor(opts?: ConsoleTransportOptions);
9
9
  }
@@ -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,CAAgE;IAEnE,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"}
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;oBAC7B,MAAM;gBACR,KAAK,MAAM;oBACT,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;oBAC5B,MAAM;gBACR,KAAK,OAAO;oBACV,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;oBAC7B,MAAM;gBACR;oBACE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;aAC9B;QACH,CAAC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { LogLevel, Transport } from '../index.js';\n\nexport interface ConsoleTransportOptions {\n level?: LogLevel;\n}\n\nexport class ConsoleTransport implements Transport {\n level: LogLevel;\n log: (message: string | object, meta: Record<string, unknown> | undefined, level: LogLevel) => void;\n\n constructor(opts?: ConsoleTransportOptions) {\n this.level = opts?.level || 'debug';\n this.log = (message, meta, level) => {\n switch (level) {\n case 'error':\n console.error(message, meta);\n break;\n case 'warn':\n console.warn(message, meta);\n break;\n case 'debug':\n console.debug(message, meta);\n break;\n default:\n console.log(message, meta);\n }\n };\n }\n}\n"]}
@@ -1,20 +1,11 @@
1
1
  import type { datadogLogs } from '@datadog/browser-logs';
2
- import type { DdLogs } from '@datadog/mobile-react-native';
3
- import { LogFunction, LogLevel, Transport } from '../index.js';
2
+ import { LogLevel, Transport } from '../index.js';
4
3
  export interface DatadogTransportOptions {
5
4
  level?: LogLevel;
6
5
  datadogLogsInstance: typeof datadogLogs;
7
6
  }
8
- export interface ReactNativeDatadogTransportOptions extends Omit<DatadogTransportOptions, 'datadogLogsInstance'> {
9
- datadogLogsInstance: typeof DdLogs;
10
- }
11
7
  export declare class DatadogTransport implements Transport {
12
8
  level: LogLevel;
13
- log: LogFunction;
9
+ log: (message: string | object, meta: Record<string, unknown> | undefined, level: LogLevel) => void;
14
10
  constructor(opts: DatadogTransportOptions);
15
11
  }
16
- export declare class ReactNativeDatadogTransport implements Transport {
17
- level: LogLevel;
18
- log: LogFunction;
19
- constructor(opts: ReactNativeDatadogTransportOptions);
20
- }
@@ -1,24 +1,3 @@
1
- function isEmpty(obj) {
2
- if (obj === null || obj === undefined || !obj) {
3
- return true;
4
- }
5
- for (const prop in obj) {
6
- if (Object.hasOwn(obj, prop)) {
7
- return false;
8
- }
9
- }
10
- return true;
11
- }
12
- /**
13
- * Wraps the meta object to avoid our custom meta properties mixing with datadog's built-in properties.
14
- *
15
- * @param meta - The meta object to wrap.
16
- * @returns The wrapped meta object.
17
- */
18
- function wrapMeta(meta) {
19
- // using `extra` just to match what Sentry does
20
- return isEmpty(meta) ? {} : { extra: meta };
21
- }
22
1
  export class DatadogTransport {
23
2
  level;
24
3
  log;
@@ -28,72 +7,15 @@ export class DatadogTransport {
28
7
  // LogLevel maps directly to datadogLogsInstance logger methods
29
8
  if (message instanceof Error) {
30
9
  // Datadog logger has an optional third error param for exception handling
31
- opts.datadogLogsInstance.logger[level](message.message, wrapMeta(meta), message);
32
- }
33
- else if (typeof message === 'string' && meta instanceof Error) {
34
- opts.datadogLogsInstance.logger[level](message, {}, meta);
10
+ opts.datadogLogsInstance.logger[level](message.message, meta, message);
35
11
  }
36
12
  else if (typeof message === 'string') {
37
- opts.datadogLogsInstance.logger[level](message, wrapMeta(meta));
13
+ opts.datadogLogsInstance.logger[level](message, meta);
38
14
  }
39
15
  else {
40
16
  // Datadog requires a string for the message param. Our downstream usage currently provides
41
17
  // either a string or an Error, but for future-proofing this just stringify the unknown object as message.
42
- opts.datadogLogsInstance.logger[level](JSON.stringify(message), wrapMeta(meta));
43
- }
44
- };
45
- }
46
- }
47
- /**
48
- * Helper function to help call the datadog logger methods directly instead of dynamically calling
49
- * them with the `level` param. This is a workaround to avoid the following error:
50
- *
51
- * ```
52
- * Error: JS Functions are not convertible to dynamic
53
- * ```
54
- *
55
- * @param level - The log level to call the datadog logger method with.
56
- * @param args - The arguments to pass to the datadog logger method.
57
- */
58
- function callRnDatadogLogger(instance, level, args) {
59
- if (level === 'debug') {
60
- instance.debug(...args);
61
- }
62
- else if (level === 'info') {
63
- instance.info(...args);
64
- }
65
- else if (level === 'warn') {
66
- instance.warn(...args);
67
- }
68
- else if (level === 'error') {
69
- instance.error(...args);
70
- }
71
- }
72
- export class ReactNativeDatadogTransport {
73
- level;
74
- log;
75
- constructor(opts) {
76
- this.level = opts.level || 'info';
77
- this.log = (message, meta = {}, level) => {
78
- if (message instanceof Error) {
79
- callRnDatadogLogger(opts.datadogLogsInstance, level, [
80
- message.message,
81
- message.name,
82
- message.message,
83
- message.stack,
84
- wrapMeta(meta),
85
- ]);
86
- }
87
- else if (typeof message === 'string') {
88
- if (meta instanceof Error) {
89
- callRnDatadogLogger(opts.datadogLogsInstance, level, [message, meta.name, meta.message, meta.stack]);
90
- }
91
- else {
92
- callRnDatadogLogger(opts.datadogLogsInstance, level, [message, wrapMeta(meta)]);
93
- }
94
- }
95
- else {
96
- callRnDatadogLogger(opts.datadogLogsInstance, level, [JSON.stringify(message), wrapMeta(meta)]);
18
+ opts.datadogLogsInstance.logger[level](JSON.stringify(message), meta);
97
19
  }
98
20
  };
99
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"datadog.js","sourceRoot":"","sources":["../../src/transports/datadog.ts"],"names":[],"mappings":"AAKA,SAAS,OAAO,CAAC,GAAW;IAC1B,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,GAAG,EAAE;QAC7C,OAAO,IAAI,CAAC;KACb;IAED,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE;QACtB,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE;YAC5B,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,IAAa;IAC7B,+CAA+C;IAC/C,OAAO,OAAO,CAAC,IAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACxD,CAAC;AAWD,MAAM,OAAO,gBAAgB;IAC3B,KAAK,CAAW;IAChB,GAAG,CAAc;IAEjB,YAAY,IAA6B;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE;YACvC,+DAA+D;YAC/D,IAAI,OAAO,YAAY,KAAK,EAAE;gBAC5B,0EAA0E;gBAC1E,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,Q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GAAG,EAAE,EAAE,KAAK,EAAE,EAAE;YACvC,+DAA+D;YAC/D,IAAI,OAAO,YAAY,KAAK,EAAE;gBAC5B,0EAA0E;gBAC1E,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;aACxE;iBAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;gBACtC,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;aACvD;iBAAM;gBACL,2FAA2F;gBAC3F,0GAA0G;gBAC1G,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;aACvE;QACH,CAAC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { datadogLogs } from '@datadog/browser-logs';\n\nimport { LogLevel, Transport } from '../index.js';\n\nexport interface DatadogTransportOptions {\n level?: LogLevel;\n datadogLogsInstance: typeof datadogLogs;\n}\n\nexport class DatadogTransport implements Transport {\n level: LogLevel;\n log: (message: string | object, meta: Record<string, unknown> | undefined, level: LogLevel) => void;\n\n constructor(opts: DatadogTransportOptions) {\n this.level = opts.level || 'info';\n this.log = (message, meta = {}, level) => {\n // LogLevel maps directly to datadogLogsInstance logger methods\n if (message instanceof Error) {\n // Datadog logger has an optional third error param for exception handling\n opts.datadogLogsInstance.logger[level](message.message, meta, message);\n } else if (typeof message === 'string') {\n opts.datadogLogsInstance.logger[level](message, meta);\n } else {\n // Datadog requires a string for the message param. Our downstream usage currently provides\n // either a string or an Error, but for future-proofing this just stringify the unknown object as message.\n opts.datadogLogsInstance.logger[level](JSON.stringify(message), meta);\n }\n };\n }\n}\n"]}
@@ -1,21 +1,13 @@
1
- import { LogFunction, LogLevel, LogMeta, Transport } from '../index.js';
1
+ import { LogLevel, Transport } from '../index.js';
2
2
  export interface SentryTransportOptions {
3
3
  level?: LogLevel;
4
4
  sentryInstance: {
5
- captureMessage: (message: string, sentryMeta: Record<string, unknown> | unknown | undefined) => void;
6
- captureException: (message: object, sentryMeta: Record<string, unknown> | unknown | undefined) => void;
5
+ captureMessage: (message: string, sentryMeta: Record<string, unknown> | undefined) => void;
6
+ captureException: (message: object, sentryMeta: Record<string, unknown> | undefined) => void;
7
7
  };
8
8
  }
9
- export type SentryMeta = LogMeta & {
10
- level?: string;
11
- extra?: Record<string, unknown>;
12
- tags?: Record<string, unknown>;
13
- contexts?: Record<string, unknown>;
14
- user?: Record<string, unknown>;
15
- fingerprint?: string[];
16
- };
17
9
  export declare class SentryTransport implements Transport {
18
10
  level: LogLevel;
19
- log: LogFunction;
11
+ log: (message: string | object, meta: Record<string, unknown> | undefined, level: LogLevel) => void;
20
12
  constructor(opts: SentryTransportOptions);
21
13
  }
@@ -9,55 +9,16 @@ export class SentryTransport {
9
9
  log;
10
10
  constructor(opts) {
11
11
  this.level = opts.level || 'error';
12
- this.log = (message, meta, logLevel) => {
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
- if (meta &&
18
- typeof meta === 'object' &&
19
- !Array.isArray(meta) &&
20
- Object.getPrototypeOf(meta) === Object.prototype) {
21
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
- const { tags, extra, contexts, user, level, fingerprint, ...customMeta } = meta || {};
23
- const extraSentry = {
24
- ...(extra && typeof extra === 'object' ? extra : {}),
25
- ...(customMeta && typeof customMeta === 'object' ? customMeta : {}),
26
- };
27
- const sentryMeta = {
28
- level: SentryErrorLevelMap[logLevel],
29
- extra: extraSentry,
30
- tags,
31
- contexts,
32
- user,
33
- fingerprint,
34
- };
35
- if (typeof message === 'string') {
36
- opts.sentryInstance.captureMessage(message, sentryMeta);
37
- }
38
- else if (message instanceof Error) {
39
- opts.sentryInstance.captureException(message, sentryMeta);
40
- }
41
- return;
42
- }
12
+ this.log = (message, meta, level) => {
13
+ const sentryMeta = {
14
+ level: SentryErrorLevelMap[level],
15
+ ...meta,
16
+ };
43
17
  if (typeof message === 'string') {
44
- if (meta instanceof Error) {
45
- const originalMessage = meta.message;
46
- meta.message = message;
47
- opts.sentryInstance.captureException(meta, { extra: { originalMessage } });
48
- }
49
- else {
50
- opts.sentryInstance.captureMessage(message, meta);
51
- }
52
- }
53
- else if (message instanceof Error) {
54
- opts.sentryInstance.captureException(message, meta);
55
- }
56
- else if (meta instanceof Error) {
57
- opts.sentryInstance.captureException(meta, meta);
18
+ opts.sentryInstance.captureMessage(message, sentryMeta);
58
19
  }
59
20
  else {
60
- opts.sentryInstance.captureMessage(JSON.stringify(message), meta);
21
+ opts.sentryInstance.captureException(message, sentryMeta);
61
22
  }
62
23
  };
63
24
  }
@@ -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;AAmBF,MAAM,OAAO,eAAe;IAC1B,KAAK,CAAW;IAChB,GAAG,CAAc;IAEjB,YAAY,IAA4B;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC;QACnC,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YACrC,kEAAkE;YAClE,iGAAiG;YACjG,4FAA4F;YAC5F,8FAA8F;YAC9F,IACE,IAAI;gBACJ,OAAO,IAAI,KAAK,QAAQ;gBACxB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBACpB,MAAM,CAAC,cAAc,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AC,OAAO,EAAE,IAAI,CAAC,CAAC;iBACnD;aACF;iBAAM,IAAI,OAAO,YAAY,KAAK,EAAE;gBACnC,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;aACrD;iBAAM,IAAI,IAAI,YAAY,KAAK,EAAE;gBAChC,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aAClD;iBAAM;gBACL,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;aACnE;QACH,CAAC,CAAC;IACJ,CAAC;CACF"}
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,GAAG,IAAI;aACR,CAAC;YACF,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","sourcesContent":["import { LogLevel, Transport } from '../index.js';\n\nconst SentryErrorLevelMap = {\n debug: 'debug',\n info: 'info',\n warn: 'warning',\n error: 'error',\n};\n\nexport interface SentryTransportOptions {\n level?: LogLevel;\n sentryInstance: {\n captureMessage: (message: string, sentryMeta: Record<string, unknown> | undefined) => void;\n captureException: (message: object, sentryMeta: Record<string, unknown> | undefined) => void;\n };\n}\n\nexport class SentryTransport implements Transport {\n level: LogLevel;\n log: (message: string | object, meta: Record<string, unknown> | undefined, level: LogLevel) => void;\n\n constructor(opts: SentryTransportOptions) {\n this.level = opts.level || 'error';\n this.log = (message, meta, level) => {\n const sentryMeta = {\n level: SentryErrorLevelMap[level],\n ...meta,\n };\n if (typeof message === 'string') {\n opts.sentryInstance.captureMessage(message, sentryMeta);\n } else {\n opts.sentryInstance.captureException(message, sentryMeta);\n }\n };\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflink/snitch",
3
- "version": "0.0.0-PR-55--577cbd7",
3
+ "version": "0.0.0-PR-56--4e938e8",
4
4
  "description": "Front end logging inspired by winston.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -25,8 +25,6 @@
25
25
  "default": "./dist/transports/datadog.js"
26
26
  }
27
27
  },
28
- "main": "./dist/index.js",
29
- "types": "./dist/index.d.ts",
30
28
  "engines": {
31
29
  "node": ">=16",
32
30
  "npm": ">=8"
@@ -34,6 +32,7 @@
34
32
  "files": [
35
33
  "dist"
36
34
  ],
35
+ "types": "./dist/index.d.ts",
37
36
  "publishConfig": {
38
37
  "access": "public"
39
38
  },
@@ -58,7 +57,6 @@
58
57
  "@commitlint/cli": "^17.4.4",
59
58
  "@commitlint/config-conventional": "^17.4.4",
60
59
  "@datadog/browser-logs": "^4.39.0",
61
- "@datadog/mobile-react-native": "^2.6.3",
62
60
  "@vitest/coverage-c8": "^0.29.2",
63
61
  "eslint": "^8.41.0",
64
62
  "eslint-config-leaflink": "^1.3.1",
@@ -1 +0,0 @@
1
- export {};
@@ -1,50 +0,0 @@
1
- import logger, { ConsoleTransport } from '../index.js';
2
- describe('console transport', () => {
3
- beforeAll(() => {
4
- logger.addTransport(new ConsoleTransport());
5
- });
6
- afterAll(() => {
7
- logger.clearTransports();
8
- });
9
- it('should log error to console', () => {
10
- const customErr = 'custom error';
11
- const errorSpy = vi.spyOn(console, 'error');
12
- logger.error(customErr);
13
- expect(errorSpy).toHaveBeenCalledWith(customErr, '');
14
- errorSpy.mockClear();
15
- const customMeta = { meta: { extra: 'something' } };
16
- logger.error(customErr, customMeta);
17
- expect(errorSpy).toHaveBeenCalledWith(customErr, customMeta);
18
- });
19
- it('should log debug to console', () => {
20
- const customMsg = 'custom debug';
21
- const debugSpy = vi.spyOn(console, 'debug');
22
- logger['debug'](customMsg);
23
- expect(debugSpy).toHaveBeenCalledWith(customMsg, '');
24
- debugSpy.mockClear();
25
- const customMeta = { meta: { extra: 'something' } };
26
- logger['debug'](customMsg, customMeta);
27
- expect(debugSpy).toHaveBeenCalledWith(customMsg, customMeta);
28
- });
29
- it('should log warn to console', () => {
30
- const customWarn = 'custom warn';
31
- const debugSpy = vi.spyOn(console, 'warn');
32
- logger.warn(customWarn);
33
- expect(debugSpy).toHaveBeenCalledWith(customWarn, '');
34
- debugSpy.mockClear();
35
- const customMeta = { meta: { extra: 'something' } };
36
- logger.warn(customWarn, customMeta);
37
- expect(debugSpy).toHaveBeenCalledWith(customWarn, customMeta);
38
- });
39
- it('should log to console', () => {
40
- const customMsg = 'custom log';
41
- const logSpy = vi.spyOn(console, 'log');
42
- logger.log(customMsg);
43
- expect(logSpy).toHaveBeenCalledWith(customMsg, '');
44
- logSpy.mockClear();
45
- const customMeta = { meta: { extra: 'something' } };
46
- logger.log(customMsg, customMeta);
47
- expect(logSpy).toHaveBeenCalledWith(customMsg, customMeta);
48
- });
49
- });
50
- //# sourceMappingURL=console.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"console.spec.js","sourceRoot":"","sources":["../../src/transports/console.spec.ts"],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AE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC;QAEpD,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAElC,MAAM,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,103 +0,0 @@
1
- import logger, { DatadogTransport, ReactNativeDatadogTransport } from '../index.js';
2
- const DdInstance = {
3
- logger: {
4
- error: vi.fn(),
5
- warn: vi.fn(),
6
- info: vi.fn(),
7
- debug: vi.fn(),
8
- },
9
- };
10
- describe('datadog web transport', () => {
11
- beforeAll(() => {
12
- logger.addTransport(new DatadogTransport({ datadogLogsInstance: DdInstance, level: 'debug' }));
13
- });
14
- afterEach(() => {
15
- Object.values(DdInstance.logger).forEach((level) => level.mockClear());
16
- });
17
- afterAll(() => {
18
- logger.clearTransports();
19
- });
20
- it.each(['info', 'warn', 'debug', 'error'])('should log %s to dd', (level) => {
21
- const customErr = 'custom error';
22
- logger[level](customErr);
23
- expect(DdInstance.logger[level]).toHaveBeenCalledWith(customErr, {});
24
- });
25
- it('should log error instance correctly as first arg', () => {
26
- const customErr = Error('ERR');
27
- logger.error(customErr);
28
- expect(DdInstance.logger.error).toHaveBeenCalledWith(customErr.message, {}, customErr);
29
- });
30
- it('should log error instance correctly as first arg with meta', () => {
31
- const customErr = Error('ERR');
32
- const customMeta = { foo: 'bar' };
33
- logger.error(customErr, customMeta);
34
- expect(DdInstance.logger.error).toHaveBeenCalledWith(customErr.message, { extra: customMeta }, customErr);
35
- });
36
- it('should log correctly with string as first arg and error isntance as second', () => {
37
- const customMsg = 'message';
38
- const customErr = Error('ERR');
39
- logger.error(customMsg, customErr);
40
- expect(DdInstance.logger.error).toHaveBeenCalledWith(customMsg, {}, customErr);
41
- });
42
- it('should log correctly when first arg is a string and no second arg is passed', () => {
43
- const customMsg = 'message';
44
- logger.error(customMsg);
45
- expect(DdInstance.logger.error).toHaveBeenCalledWith(customMsg, {});
46
- });
47
- it('should log correctly when first arg is not a string', () => {
48
- const customArg = [1, 2, 3];
49
- logger.error(customArg);
50
- expect(DdInstance.logger.error).toHaveBeenCalledWith('[' + customArg.join(',') + ']', {});
51
- });
52
- });
53
- const rnDdInstance = {
54
- error: vi.fn(),
55
- info: vi.fn(),
56
- debug: vi.fn(),
57
- warn: vi.fn(),
58
- };
59
- describe('datadog react native transport', () => {
60
- beforeAll(() => {
61
- logger.addTransport(new ReactNativeDatadogTransport({ datadogLogsInstance: rnDdInstance, level: 'debug' }));
62
- });
63
- afterEach(() => {
64
- Object.values(rnDdInstance).forEach((level) => level.mockClear());
65
- });
66
- afterAll(() => {
67
- logger.clearTransports();
68
- });
69
- it.each `
70
- meta | expected
71
- ${undefined} | ${{}}
72
- `('should log error correctly if first argument is an Error', ({ meta, expected }) => {
73
- const customError = Error('custom err');
74
- logger.error(customError, meta);
75
- expect(rnDdInstance.error).toHaveBeenCalledWith(customError.message, customError.name, customError.message, customError.stack, expected);
76
- });
77
- it('should log error correctly if first argument is not an Error nor string', () => {
78
- const customMeta = 'string meta';
79
- logger.error([1, 2], 'string meta');
80
- expect(rnDdInstance.error).toHaveBeenCalledWith('[1,2]', { extra: customMeta });
81
- });
82
- describe('when message is a string', () => {
83
- it('should log an error correctly when meta is an Error', () => {
84
- const customMessage = 'my message';
85
- const customError = Error('custom error');
86
- logger.error(customMessage, customError);
87
- expect(rnDdInstance.error).toHaveBeenCalledWith(customMessage, customError.name, customError.message, customError.stack);
88
- });
89
- it('should log an error message correctly when meta is an object', () => {
90
- const customMessage = 'custom msg';
91
- const customMeta = { foo: 'bar' };
92
- logger.error(customMessage, customMeta);
93
- expect(rnDdInstance.error).toHaveBeenCalledWith(customMessage, { extra: customMeta });
94
- });
95
- it('should log a message correctly when meta is not an object', () => {
96
- const customMessage = 'custom msg';
97
- const customMeta = 'string';
98
- logger.error(customMessage, customMeta);
99
- expect(rnDdInstance.error).toHaveBeenCalledWith(customMessage, { extra: customMeta });
100
- });
101
- });
102
- });
103
- //# sourceMappingURL=datadog.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"datadog.spec.js","sourceRoot":"","sources":["../../src/transports/datadog.spec.ts"],"names":[],"mappings":"AAGA,OAAO,MAAM,EAAE,EAAE,gBAAgB,EAAY,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE9F,MAAM,UAAU,GAAG;IACjB,MAAM,EAAE;QACN,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;QACd,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;QACb,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;QACb,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;KACf;CAC+B,CAAC;AAEnC,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,YAAY,CAAC,IAAI,gBAAgB,CAAC,EAAE,mBAAmB,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACjG,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,EAAE;QACZ,MAAM,CAAC,eAAe,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,qBAAqB,EAAE,CAAC,KAAc,EAAE,EAAE;QACpF,MAAM,SAAS,GAAG,cAAc,CAAC;QAEjC,MAAM,CAAC,KAAiB,CAAC,CAAC,SAAS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AC;QAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;YACtE,MAAM,aAAa,GAAG,YAAY,CAAC;YACnC,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;YAElC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;YAExC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QACxF,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;YACnE,MAAM,aAAa,GAAG,YAAY,CAAC;YACnC,MAAM,UAAU,GAAG,QAAQ,CAAC;YAE5B,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;YAExC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QACxF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,73 +0,0 @@
1
- import logger, { SentryTransport } from '../index.js';
2
- const sentryInstance = {
3
- captureMessage: vi.fn(),
4
- captureException: vi.fn(),
5
- };
6
- describe('sentry transport', () => {
7
- beforeAll(() => {
8
- logger.addTransport(new SentryTransport({ sentryInstance }));
9
- });
10
- afterEach(() => {
11
- Object.values(sentryInstance).forEach((val) => val.mockClear());
12
- });
13
- afterAll(() => {
14
- logger.clearTransports();
15
- });
16
- it.each([undefined, 'meta'])('should capture message when first arg is a string', (meta) => {
17
- const customMsg = 'message';
18
- logger.error(customMsg, meta);
19
- expect(sentryInstance.captureMessage).toHaveBeenCalledWith(customMsg, meta);
20
- expect(sentryInstance.captureException).not.toHaveBeenCalled();
21
- });
22
- it.each([undefined, 'meta'])('should capture exception when first arg is an Error', (meta) => {
23
- const customMsg = 'msg';
24
- const customErr = Error(customMsg);
25
- logger.error(customErr, meta);
26
- expect(sentryInstance.captureException).toHaveBeenCalledWith(customErr, meta);
27
- expect(sentryInstance.captureMessage).not.toHaveBeenCalled();
28
- });
29
- it.each([null, [], () => { }])('should capture exception when second arg is an Error', (message) => {
30
- const customErr = Error('err');
31
- logger.error(message, customErr);
32
- expect(sentryInstance.captureException).toHaveBeenCalledWith(customErr, customErr);
33
- expect(sentryInstance.captureMessage).not.toHaveBeenCalled();
34
- });
35
- it('should capture message when args fall into catch all', () => {
36
- logger.error([], []);
37
- expect(sentryInstance.captureMessage).toHaveBeenCalledWith('[]', []);
38
- expect(sentryInstance.captureException).not.toHaveBeenCalled();
39
- });
40
- it('should capture message when first arg is string and second arg is properly filled', () => {
41
- const customMessage = 'Something happened';
42
- const customMeta = {
43
- tags: { type: 'buyer' },
44
- extra: { filters: { id: 1 } },
45
- contexts: { order: { id: 2 } },
46
- };
47
- logger.error(customMessage, customMeta);
48
- expect(sentryInstance.captureMessage).toHaveBeenCalledWith(customMessage, expect.objectContaining(customMeta));
49
- expect(sentryInstance.captureException).not.toHaveBeenCalled();
50
- });
51
- it('should capture exception when first arg is an Error and second arg is properly filled', () => {
52
- const customErr = Error('Something happened');
53
- const customMeta = {
54
- tags: { type: 'buyer' },
55
- extra: { filters: { id: 1 } },
56
- contexts: { order: { id: 2 } },
57
- };
58
- logger.error(customErr, customMeta);
59
- expect(sentryInstance.captureException).toHaveBeenCalledWith(customErr, expect.objectContaining(customMeta));
60
- expect(sentryInstance.captureMessage).not.toHaveBeenCalled();
61
- });
62
- it('should capture an exception with custom message when first arg is a string but second is an Error', () => {
63
- const customMessage = 'My custom message';
64
- const customErrorMessage = 'My custom error';
65
- const customError = Error(customErrorMessage);
66
- expect(customError.message).toBe(customErrorMessage);
67
- logger.error(customMessage, customError);
68
- expect(customError.message).toBe(customMessage);
69
- expect(sentryInstance.captureException).toHaveBeenCalledWith(customError, expect.objectContaining({ extra: { originalMessage: customErrorMessage } }));
70
- expect(sentryInstance.captureMessage).not.toHaveBeenCalled();
71
- });
72
- });
73
- //# sourceMappingURL=sentry.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentry.spec.js","sourceRoot":"","sources":["../../src/transports/sentry.spec.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,cAAc,GAAG;IACrB,cAAc,EAAE,EAAE,CAAC,EAAE,EAAE;IACvB,gBAAgB,EAAE,EAAE,CAAC,EAAE,EAAE;CAC1B,CAAC;AAEF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,YAAY,CAAC,IAAI,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,EAAE;QACZ,MAAM,CAAC,eAAe,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,mDAAmD,EAAE,CAAC,IAAI,EAAE,EAAE;QACzF,MAAM,SAAS,GAAG,SAAS,CAAC;QAE5B,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE9B,MAAM,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,oBAAoB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC5E,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IACjE,C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