@workleap/logrocket 1.2.1 → 1.2.2

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,14 @@
1
1
  # @workleap/logrocket
2
2
 
3
+ ## 1.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#58](https://github.com/workleap/wl-telemetry/pull/58) [`10d0c3f`](https://github.com/workleap/wl-telemetry/commit/10d0c3fe6e7565a2a95aeed9f3bc83274d90f1ad) Thanks [@patricklafrance](https://github.com/patricklafrance)! - LogRocketLogger object segment type is now unknown.
8
+
9
+ - Updated dependencies [[`10d0c3f`](https://github.com/workleap/wl-telemetry/commit/10d0c3fe6e7565a2a95aeed9f3bc83274d90f1ad)]:
10
+ - @workleap/telemetry@1.1.3
11
+
3
12
  ## 1.2.1
4
13
 
5
14
  ### Patch Changes
@@ -20,7 +20,7 @@ export declare class LogRocketLoggerScope implements LoggerScope {
20
20
  /**
21
21
  * @see {@link https://workleap.github.io/wl-logging}
22
22
  */
23
- withObject(obj?: object): this;
23
+ withObject(obj?: unknown): this;
24
24
  /**
25
25
  * @see {@link https://workleap.github.io/wl-logging}
26
26
  */
@@ -80,7 +80,7 @@ export declare class LogRocketLogger implements Logger {
80
80
  /**
81
81
  * @see {@link https://workleap.github.io/wl-logging}
82
82
  */
83
- withObject(obj?: object): this;
83
+ withObject(obj?: unknown): this;
84
84
  /**
85
85
  * @see {@link https://workleap.github.io/wl-logging}
86
86
  */
@@ -1 +1 @@
1
- {"version":3,"file":"LogRocketLogger.js","sources":["webpack://@workleap/logrocket/./src/LogRocketLogger.ts"],"sourcesContent":["import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel, type LogOptions, type Segment } from \"@workleap/logging\";\nimport LogRocket from \"logrocket\";\n\ntype LogFunction = (...rest: unknown[]) => void;\ntype PendingLog = () => void;\n\nfunction parseSegments(segments: Segment[]) {\n return segments.reduce<unknown[]>((acc, x) => {\n if (x.text) {\n acc.push(x.text);\n } else if (x.obj) {\n acc.push(x.obj);\n } else if (x.error) {\n acc.push(x.error);\n } else if (x.lineChange) {\n acc.push(\"\\r\\n\");\n }\n\n return acc;\n }, []);\n}\n\n/**\n * An scope implementation for the LogRocket logger.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLoggerScope implements LoggerScope {\n readonly #logLevel: LogLevel;\n readonly #label: string;\n\n #segments: Segment[] = [];\n #pendingLogs: PendingLog[] = [];\n #hasEnded: boolean = false;\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(label: string, logLevel: LogLevel) {\n this.#logLevel = logLevel;\n this.#label = label;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n // Required closure to preserved the current log items for when they will be formatted when the scope is ended.\n const segments = this.#segments;\n\n this.#pendingLogs.push(() => {\n const parsedSegments = parseSegments(segments);\n parsedSegments.unshift(`(${this.#label})`);\n\n fct(...parsedSegments);\n });\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options: LogOptions = {}) {\n if (text) {\n this.#segments.push({\n text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: object) {\n if (obj) {\n this.#segments.push({\n obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n lineChange: true\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n end(options: LoggerScopeEndOptions = {}) {\n const {\n dismiss = false\n } = options;\n\n if (!this.#hasEnded) {\n this.#hasEnded = true;\n\n if (!dismiss) {\n if (this.#pendingLogs.length > 0) {\n this.#pendingLogs.forEach(x => {\n x();\n });\n\n this.#pendingLogs = [];\n }\n }\n }\n }\n}\n\n/**\n * A logger implementation for LogRocket.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLogger implements Logger {\n readonly #logLevel: LogLevel;\n #segments: Segment[] = [];\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(options: LoggerOptions = {}) {\n const {\n logLevel = LogLevel.debug\n } = options;\n\n this.#logLevel = logLevel;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n const parsedSegments = parseSegments(this.#segments);\n\n fct(...parsedSegments);\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n getName() {\n return LogRocketLogger.name;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options: LogOptions = {}) {\n if (text) {\n this.#segments.push({\n text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: object) {\n if (obj) {\n this.#segments.push({\n obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n lineChange: true\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * Start a new logging scope. The scope will inherit the LogLevel of the root logger.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n startScope(label: string) {\n return new LogRocketLoggerScope(label, this.#logLevel);\n }\n}\n"],"names":["LogLevel","LogRocket","parseSegments","segments","acc","x","LogRocketLoggerScope","label","logLevel","fct","threshold","parsedSegments","text","options","error","obj","log","dismiss","LogRocketLogger"],"mappings":";;;;;;;;AAA2J;AACzH;AAKlC,SAASE,cAAcC,QAAmB;IACtC,OAAOA,SAAS,MAAM,CAAY,CAACC,KAAKC;QACpC,IAAIA,EAAE,IAAI,EAAE;YACRD,IAAI,IAAI,CAACC,EAAE,IAAI;QACnB,OAAO,IAAIA,EAAE,GAAG,EAAE;YACdD,IAAI,IAAI,CAACC,EAAE,GAAG;QAClB,OAAO,IAAIA,EAAE,KAAK,EAAE;YAChBD,IAAI,IAAI,CAACC,EAAE,KAAK;QACpB,OAAO,IAAIA,EAAE,UAAU,EAAE;YACrBD,IAAI,IAAI,CAAC;QACb;QAEA,OAAOA;IACX,GAAG,EAAE;AACT;AAEA;;;CAGC,GACM,MAAME;IACA,SAAS,CAAW;IACpB,MAAM,CAAS;IAExB,SAAS,GAAc,EAAE,CAAC;IAC1B,YAAY,GAAiB,EAAE,CAAC;IAChC,SAAS,GAAY,MAAM;IAE3B;;KAEC,GACD,YAAYC,KAAa,EAAEC,QAAkB,CAAE;QAC3C,IAAI,CAAC,SAAS,GAAGA;QACjB,IAAI,CAAC,MAAM,GAAGD;IAClB;IAEA,cAAc;QACV,IAAI,C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J;QAEA,IAAI,CAAC,IAAI,CAACZ,aAAa,EAAED,cAAc;IAC3C;IAEA;;;KAGC,GACD,YAAYgB,GAAY,EAAEH,OAAoB,EAAE;QAC5C,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,aAAa,EAAED,oBAAoB;IACjD;IAEA;;;KAGC,GACD,QAAQgB,GAAY,EAAEH,OAAoB,EAAE;QACxC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,cAAc,EAAED,gBAAgB;IAC9C;IAEA;;;KAGC,GACD,MAAMgB,GAAY,EAAEH,OAAoB,EAAE;QACtC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,cAAc;IAC7C;IAEA;;;KAGC,GACD,SAASgB,GAAY,EAAEH,OAAoB,EAAE;QACzC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,iBAAiB;IAChD;IAEA;;;KAGC,GACD,WAAWO,KAAa,EAAE;QACtB,OAAO,IAAID,qBAAqBC,OAAO,IAAI,CAAC,SAAS;IACzD;AACJ"}
1
+ {"version":3,"file":"LogRocketLogger.js","sources":["webpack://@workleap/logrocket/./src/LogRocketLogger.ts"],"sourcesContent":["import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel, type LogOptions, type Segment } from \"@workleap/logging\";\nimport LogRocket from \"logrocket\";\n\ntype LogFunction = (...rest: unknown[]) => void;\ntype PendingLog = () => void;\n\nfunction parseSegments(segments: Segment[]) {\n return segments.reduce<unknown[]>((acc, x) => {\n if (x.text) {\n acc.push(x.text);\n } else if (x.obj) {\n acc.push(x.obj);\n } else if (x.error) {\n acc.push(x.error);\n } else if (x.lineChange) {\n acc.push(\"\\r\\n\");\n }\n\n return acc;\n }, []);\n}\n\n/**\n * An scope implementation for the LogRocket logger.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLoggerScope implements LoggerScope {\n readonly #logLevel: LogLevel;\n readonly #label: string;\n\n #segments: Segment[] = [];\n #pendingLogs: PendingLog[] = [];\n #hasEnded: boolean = false;\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(label: string, logLevel: LogLevel) {\n this.#logLevel = logLevel;\n this.#label = label;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n // Required closure to preserved the current log items for when they will be formatted when the scope is ended.\n const segments = this.#segments;\n\n this.#pendingLogs.push(() => {\n const parsedSegments = parseSegments(segments);\n parsedSegments.unshift(`(${this.#label})`);\n\n fct(...parsedSegments);\n });\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options: LogOptions = {}) {\n if (text) {\n this.#segments.push({\n text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n lineChange: true\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n end(options: LoggerScopeEndOptions = {}) {\n const {\n dismiss = false\n } = options;\n\n if (!this.#hasEnded) {\n this.#hasEnded = true;\n\n if (!dismiss) {\n if (this.#pendingLogs.length > 0) {\n this.#pendingLogs.forEach(x => {\n x();\n });\n\n this.#pendingLogs = [];\n }\n }\n }\n }\n}\n\n/**\n * A logger implementation for LogRocket.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLogger implements Logger {\n readonly #logLevel: LogLevel;\n #segments: Segment[] = [];\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(options: LoggerOptions = {}) {\n const {\n logLevel = LogLevel.debug\n } = options;\n\n this.#logLevel = logLevel;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n const parsedSegments = parseSegments(this.#segments);\n\n fct(...parsedSegments);\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n getName() {\n return LogRocketLogger.name;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options: LogOptions = {}) {\n if (text) {\n this.#segments.push({\n text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n lineChange: true\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * Start a new logging scope. The scope will inherit the LogLevel of the root logger.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n startScope(label: string) {\n return new LogRocketLoggerScope(label, this.#logLevel);\n }\n}\n"],"names":["LogLevel","LogRocket","parseSegments","segments","acc","x","LogRocketLoggerScope","label","logLevel","fct","threshold","parsedSegments","text","options","error","obj","log","dismiss","LogRocketLogger"],"mappings":";;;;;;;;AAA2J;AACzH;AAKlC,SAASE,cAAcC,QAAmB;IACtC,OAAOA,SAAS,MAAM,CAAY,CAACC,KAAKC;QACpC,IAAIA,EAAE,IAAI,EAAE;YACRD,IAAI,IAAI,CAACC,EAAE,IAAI;QACnB,OAAO,IAAIA,EAAE,GAAG,EAAE;YACdD,IAAI,IAAI,CAACC,EAAE,GAAG;QAClB,OAAO,IAAIA,EAAE,KAAK,EAAE;YAChBD,IAAI,IAAI,CAACC,EAAE,KAAK;QACpB,OAAO,IAAIA,EAAE,UAAU,EAAE;YACrBD,IAAI,IAAI,CAAC;QACb;QAEA,OAAOA;IACX,GAAG,EAAE;AACT;AAEA;;;CAGC,GACM,MAAME;IACA,SAAS,CAAW;IACpB,MAAM,CAAS;IAExB,SAAS,GAAc,EAAE,CAAC;IAC1B,YAAY,GAAiB,EAAE,CAAC;IAChC,SAAS,GAAY,MAAM;IAE3B;;KAEC,GACD,YAAYC,KAAa,EAAEC,QAAkB,CAAE;QAC3C,IAAI,CAAC,SAAS,GAAGA;QACjB,IAAI,CAAC,MAAM,G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CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,aAAa,EAAED,cAAc;IAC3C;IAEA;;;KAGC,GACD,YAAYgB,GAAY,EAAEH,OAAoB,EAAE;QAC5C,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,aAAa,EAAED,oBAAoB;IACjD;IAEA;;;KAGC,GACD,QAAQgB,GAAY,EAAEH,OAAoB,EAAE;QACxC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,cAAc,EAAED,gBAAgB;IAC9C;IAEA;;;KAGC,GACD,MAAMgB,GAAY,EAAEH,OAAoB,EAAE;QACtC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,cAAc;IAC7C;IAEA;;;KAGC,GACD,SAASgB,GAAY,EAAEH,OAAoB,EAAE;QACzC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,iBAAiB;IAChD;IAEA;;;KAGC,GACD,WAAWO,KAAa,EAAE;QACtB,OAAO,IAAID,qBAAqBC,OAAO,IAAI,CAAC,SAAS;IACzD;AACJ"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workleap/logrocket",
3
3
  "author": "Workleap",
4
- "version": "1.2.1",
4
+ "version": "1.2.2",
5
5
  "description": "A package containing utilities for LogRocket.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -31,9 +31,9 @@
31
31
  "logrocket": "^10.1.0"
32
32
  },
33
33
  "dependencies": {
34
- "@workleap/logging": "^1.2.1",
34
+ "@workleap/logging": "^1.2.2",
35
35
  "logrocket-fuzzy-search-sanitizer": "0.0.2",
36
- "@workleap/telemetry": "1.1.2"
36
+ "@workleap/telemetry": "1.1.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@rsbuild/core": "1.4.6",
@@ -92,7 +92,7 @@ export class LogRocketLoggerScope implements LoggerScope {
92
92
  /**
93
93
  * @see {@link https://workleap.github.io/wl-logging}
94
94
  */
95
- withObject(obj?: object) {
95
+ withObject(obj?: unknown) {
96
96
  if (obj) {
97
97
  this.#segments.push({
98
98
  obj
@@ -284,7 +284,7 @@ export class LogRocketLogger implements Logger {
284
284
  /**
285
285
  * @see {@link https://workleap.github.io/wl-logging}
286
286
  */
287
- withObject(obj?: object) {
287
+ withObject(obj?: unknown) {
288
288
  if (obj) {
289
289
  this.#segments.push({
290
290
  obj