@logtape/sentry 2.2.1-dev.775 → 2.2.1-dev.777
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/mod.cjs +2 -10
- package/dist/mod.d.cts.map +1 -1
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +1 -9
- package/dist/mod.js.map +1 -1
- package/dist/util.cjs +9 -0
- package/dist/util.d.cts +12 -0
- package/dist/util.d.cts.map +1 -0
- package/dist/util.d.ts +12 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.deno.cjs +16 -0
- package/dist/util.deno.d.cts +12 -0
- package/dist/util.deno.d.cts.map +1 -0
- package/dist/util.deno.d.ts +12 -0
- package/dist/util.deno.d.ts.map +1 -0
- package/dist/util.deno.js +16 -0
- package/dist/util.deno.js.map +1 -0
- package/dist/util.js +9 -0
- package/dist/util.js.map +1 -0
- package/dist/util.node.cjs +10 -0
- package/dist/util.node.d.cts +12 -0
- package/dist/util.node.d.cts.map +1 -0
- package/dist/util.node.d.ts +12 -0
- package/dist/util.node.d.ts.map +1 -0
- package/dist/util.node.js +10 -0
- package/dist/util.node.js.map +1 -0
- package/package.json +31 -3
package/dist/mod.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const __logtape_logtape = require_rolldown_runtime.__toESM(require("@logtape/logtape"));
|
|
3
3
|
const __sentry_core = require_rolldown_runtime.__toESM(require("@sentry/core"));
|
|
4
|
+
const __util = require_rolldown_runtime.__toESM(require("#util"));
|
|
4
5
|
|
|
5
6
|
//#region src/mod.ts
|
|
6
7
|
/**
|
|
@@ -20,7 +21,7 @@ function getParameterizedString(record) {
|
|
|
20
21
|
result += record.message[i];
|
|
21
22
|
tplString += String(record.message[i]).replaceAll("%", "%%");
|
|
22
23
|
} else {
|
|
23
|
-
const value = inspect(record.message[i]);
|
|
24
|
+
const value = (0, __util.inspect)(record.message[i]);
|
|
24
25
|
result += value;
|
|
25
26
|
tplString += `%s`;
|
|
26
27
|
tplValues.push(value);
|
|
@@ -30,15 +31,6 @@ function getParameterizedString(record) {
|
|
|
30
31
|
paramStr.__sentry_template_values__ = tplValues;
|
|
31
32
|
return paramStr;
|
|
32
33
|
}
|
|
33
|
-
/**
|
|
34
|
-
* A platform-specific inspect function. In Deno, this is {@link Deno.inspect},
|
|
35
|
-
* and in Node.js/Bun it is {@link util.inspect}. If neither is available, it
|
|
36
|
-
* falls back to {@link JSON.stringify}.
|
|
37
|
-
*
|
|
38
|
-
* @param value The value to inspect.
|
|
39
|
-
* @returns The string representation of the value.
|
|
40
|
-
*/
|
|
41
|
-
const inspect = "Deno" in globalThis && "inspect" in globalThis.Deno && typeof globalThis.Deno.inspect === "function" ? globalThis.Deno.inspect : "util" in globalThis && "inspect" in globalThis.util && typeof globalThis.util.inspect === "function" ? globalThis.util.inspect : JSON.stringify;
|
|
42
34
|
function mapLevelForEvents(level) {
|
|
43
35
|
switch (level) {
|
|
44
36
|
case "trace": return "debug";
|
package/dist/mod.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;;;AAyFA;AAiBA;;;;;;;;;;AA2DW,UA5EM,cAAA,CA4EN;EAAO,cAAA,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,cAAA,CAAA,EAzEG,aAyEH,GAAA,OAAA,EAAA,GAAA,MAAA;EAeD,gBAAA,EAAA,CAAA,SAAiB,EAAA,OAAA,EAAA,IAAA,CAAA,EAAA,OAAA,EAAA,GAAA,MAAA;;;;;AAuCa;AA4F/C;;;;;AAEO,UA/MU,eAAA,CA+MV;;;;0BA1MM,sCACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA0CN;;;YAGD;;;;;;WAQH,QACP,OACE,4BAEW,iCACG;;;;;;UAUH,iBAAA;;;;;;;;;;;;;;;;;;;WAmBN;;;;;;;;;;;;;;;;;;wBAoBa,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4FtB,aAAA,mBACI,oBAAoB,iBACrC"}
|
package/dist/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;;;AAyFA;AAiBA;;;;;;;;;;AA2DW,UA5EM,cAAA,CA4EN;EAAO,cAAA,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,cAAA,CAAA,EAzEG,aAyEH,GAAA,OAAA,EAAA,GAAA,MAAA;EAeD,gBAAA,EAAA,CAAA,SAAiB,EAAA,OAAA,EAAA,IAAA,CAAA,EAAA,OAAA,EAAA,GAAA,MAAA;;;;;AAuCa;AA4F/C;;;;;AAEO,UA/MU,eAAA,CA+MV;;;;0BA1MM,sCACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA0CN;;;YAGD;;;;;;WAQH,QACP,OACE,4BAEW,iCACG;;;;;;UAUH,iBAAA;;;;;;;;;;;;;;;;;;;WAmBN;;;;;;;;;;;;;;;;;;wBAoBa,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4FtB,aAAA,mBACI,oBAAoB,iBACrC"}
|
package/dist/mod.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { compareLogLevel, getLogger } from "@logtape/logtape";
|
|
2
2
|
import * as SentryCore from "@sentry/core";
|
|
3
|
+
import { inspect } from "#util";
|
|
3
4
|
|
|
4
5
|
//#region src/mod.ts
|
|
5
6
|
/**
|
|
@@ -29,15 +30,6 @@ function getParameterizedString(record) {
|
|
|
29
30
|
paramStr.__sentry_template_values__ = tplValues;
|
|
30
31
|
return paramStr;
|
|
31
32
|
}
|
|
32
|
-
/**
|
|
33
|
-
* A platform-specific inspect function. In Deno, this is {@link Deno.inspect},
|
|
34
|
-
* and in Node.js/Bun it is {@link util.inspect}. If neither is available, it
|
|
35
|
-
* falls back to {@link JSON.stringify}.
|
|
36
|
-
*
|
|
37
|
-
* @param value The value to inspect.
|
|
38
|
-
* @returns The string representation of the value.
|
|
39
|
-
*/
|
|
40
|
-
const inspect = "Deno" in globalThis && "inspect" in globalThis.Deno && typeof globalThis.Deno.inspect === "function" ? globalThis.Deno.inspect : "util" in globalThis && "inspect" in globalThis.util && typeof globalThis.util.inspect === "function" ? globalThis.util.inspect : JSON.stringify;
|
|
41
33
|
function mapLevelForEvents(level) {
|
|
42
34
|
switch (level) {
|
|
43
35
|
case "trace": return "debug";
|
package/dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","names":["record: LogRecord","tplValues: string[]","inspect: (value: unknown) => string","level: LogLevel","optionsOrClient?: SentrySinkOptions | SentryInstance","legacyClient: SentryInstance | undefined","options: SentrySinkOptions","msg: ParameterizedString","ctx?: unknown","exception: unknown","hint?: unknown"],"sources":["../src/mod.ts"],"sourcesContent":["import {\n compareLogLevel,\n getLogger,\n type LogLevel,\n type LogRecord,\n type Sink,\n} from \"@logtape/logtape\";\nimport type {\n LogSeverityLevel,\n ParameterizedString,\n SeverityLevel,\n} from \"@sentry/core\";\n// Import namespace to safely check for public logger API (added in v9.41.0)\nimport * as SentryCore from \"@sentry/core\";\n\n/**\n * Converts a LogTape {@link LogRecord} into a Sentry {@link ParameterizedString}.\n *\n * This preserves the template structure for better message grouping in Sentry,\n * allowing similar messages with different values to be grouped together.\n *\n * @param record The log record to convert.\n * @returns A parameterized string with template and values.\n */\nfunction getParameterizedString(record: LogRecord): ParameterizedString {\n let result = \"\";\n let tplString = \"\";\n const tplValues: string[] = [];\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n result += record.message[i];\n tplString += String(record.message[i]).replaceAll(\"%\", \"%%\");\n } else {\n const value = inspect(record.message[i]);\n result += value;\n tplString += `%s`;\n tplValues.push(value);\n }\n }\n const paramStr = new String(result) as ParameterizedString;\n paramStr.__sentry_template_string__ = tplString;\n paramStr.__sentry_template_values__ = tplValues;\n return paramStr;\n}\n\n/**\n * A platform-specific inspect function. In Deno, this is {@link Deno.inspect},\n * and in Node.js/Bun it is {@link util.inspect}. If neither is available, it\n * falls back to {@link JSON.stringify}.\n *\n * @param value The value to inspect.\n * @returns The string representation of the value.\n */\nconst inspect: (value: unknown) => string =\n // @ts-ignore: Deno global\n \"Deno\" in globalThis && \"inspect\" in globalThis.Deno &&\n // @ts-ignore: Deno global\n typeof globalThis.Deno.inspect === \"function\"\n // @ts-ignore: Deno global\n ? globalThis.Deno.inspect\n // @ts-ignore: Node.js global\n : \"util\" in globalThis && \"inspect\" in globalThis.util &&\n // @ts-ignore: Node.js global\n typeof globalThis.util.inspect === \"function\"\n // @ts-ignore: Node.js global\n ? globalThis.util.inspect\n : JSON.stringify;\n\n// Level normalization helpers\n\nfunction mapLevelForEvents(level: LogLevel): SeverityLevel {\n switch (level) {\n case \"trace\":\n return \"debug\";\n default:\n return level as SeverityLevel; // debug | info | error | fatal\n }\n}\n\nfunction mapLevelForLogs(level: LogLevel): LogSeverityLevel {\n switch (level) {\n case \"trace\":\n return \"debug\";\n case \"warning\":\n return \"warn\";\n case \"debug\":\n case \"info\":\n case \"error\":\n case \"fatal\":\n return level;\n default:\n return \"info\"; // fallback\n }\n}\n\n/**\n * A Sentry client instance type (used for v1.1.x backward compatibility).\n *\n * Client instances only support `captureMessage` and `captureException`.\n * For scope operations (breadcrumbs, user context, traces), the sink always\n * uses global functions from `@sentry/core`.\n *\n * @deprecated This is only used for backward compatibility with v1.1.x.\n * New code should use `getSentrySink()` without parameters, which automatically\n * uses Sentry's global functions.\n *\n * @since 1.3.0\n */\nexport interface SentryInstance {\n captureMessage: (\n message: string,\n captureContext?: SeverityLevel | unknown,\n ) => string;\n captureException: (exception: unknown, hint?: unknown) => string;\n}\n\n/**\n * A Sentry SDK namespace object.\n *\n * Pass the namespace imported by your application when *@logtape/sentry* should\n * use the same Sentry module instance that initialized your app, for example\n * `import * as Sentry from \"@sentry/node\"`.\n *\n * @since 2.2.0\n */\nexport interface SentryNamespace {\n /**\n * Captures a message event and sends it to Sentry.\n */\n captureMessage(\n message: ParameterizedString,\n captureContext?: SeverityLevel | unknown,\n ): string;\n\n /**\n * Captures an exception event and sends it to Sentry.\n */\n captureException(exception: unknown, hint?: unknown): string;\n\n /**\n * Gets the currently active span, if any.\n */\n getActiveSpan():\n | {\n spanContext: () => {\n traceId: string;\n spanId: string;\n parentSpanId?: string;\n };\n }\n | undefined;\n\n /**\n * Gets the currently active Sentry client, if any.\n */\n getClient():\n | {\n getOptions: () => {\n enableLogs?: boolean;\n _experiments?: {\n enableLogs?: boolean;\n };\n };\n }\n | undefined;\n\n /**\n * Gets the current isolation scope.\n */\n getIsolationScope():\n | {\n addBreadcrumb: (breadcrumb: {\n category: string;\n level: SeverityLevel;\n message: string;\n timestamp: number;\n data: Record<string, unknown>;\n }) => void;\n }\n | undefined;\n\n /**\n * Sentry's structured logging API, available in Sentry SDK 9.41.0+.\n */\n logger?: Partial<\n Record<\n LogSeverityLevel,\n (\n message: ParameterizedString,\n attributes: Record<string, unknown>,\n ) => void\n >\n >;\n}\n\n/**\n * Options for configuring the Sentry sink.\n * @since 1.3.0\n */\nexport interface SentrySinkOptions {\n /**\n * Sentry SDK namespace to use for capture, scope, span, and structured log\n * APIs.\n *\n * This is useful when your application initializes Sentry through a framework\n * SDK such as `@sentry/nextjs` or `@sentry/react-native`, and\n * *@logtape/sentry* resolves a different `@sentry/core` module instance.\n *\n * @example\n * ```typescript\n * import * as Sentry from \"@sentry/node\";\n *\n * getSentrySink({ sentry: Sentry });\n * ```\n *\n * @default `@sentry/core`\n * @since 2.2.0\n */\n sentry?: SentryNamespace;\n\n /**\n * Enable automatic breadcrumb creation for log events.\n *\n * When enabled, all logs become breadcrumbs in Sentry's isolation scope,\n * providing a complete context trail when errors occur. Breadcrumbs are\n * lightweight and only appear in error reports for debugging.\n *\n * @default false\n * @since 1.3.0\n */\n enableBreadcrumbs?: boolean;\n\n /**\n * Optional hook to transform or filter records before sending to Sentry.\n * Return `null` to drop the record.\n *\n * @since 1.3.0\n */\n beforeSend?: (record: LogRecord) => LogRecord | null;\n}\n\n/**\n * Gets a LogTape sink that sends logs to Sentry.\n *\n * This sink uses Sentry's global capture functions from `@sentry/core` by\n * default, following Sentry v8+ best practices. Simply call `Sentry.init()`\n * before creating the sink, and it will automatically use your initialized\n * client when both packages resolve the same Sentry module instance.\n *\n * @param optionsOrClient Optional configuration. Can be:\n * - Omitted: Uses global Sentry functions (recommended)\n * - Object with options: Configure sink behavior\n * - Object with `sentry`: Use an application-provided Sentry SDK namespace\n * - Sentry client instance: Backward compatibility (deprecated)\n * @returns A LogTape sink that sends logs to Sentry.\n *\n * @example Recommended usage - no parameters\n * ```typescript\n * import { configure } from \"@logtape/logtape\";\n * import { getSentrySink } from \"@logtape/sentry\";\n * import * as Sentry from \"@sentry/node\";\n *\n * Sentry.init({ dsn: process.env.SENTRY_DSN });\n *\n * await configure({\n * sinks: {\n * sentry: getSentrySink(), // That's it!\n * },\n * loggers: [\n * { category: [], sinks: [\"sentry\"], lowestLevel: \"error\" },\n * ],\n * });\n * ```\n *\n * @example With an application-provided Sentry namespace\n * ```typescript\n * import { configure } from \"@logtape/logtape\";\n * import { getSentrySink } from \"@logtape/sentry\";\n * import * as Sentry from \"@sentry/nextjs\";\n *\n * Sentry.init({ dsn: process.env.SENTRY_DSN });\n *\n * await configure({\n * sinks: {\n * sentry: getSentrySink({ sentry: Sentry }),\n * },\n * loggers: [\n * { category: [], sinks: [\"sentry\"], lowestLevel: \"error\" },\n * ],\n * });\n * ```\n *\n * @example With options\n * ```typescript\n * import * as Sentry from \"@sentry/node\";\n * Sentry.init({ dsn: process.env.SENTRY_DSN });\n *\n * await configure({\n * sinks: {\n * sentry: getSentrySink({\n * enableBreadcrumbs: true,\n * }),\n * },\n * loggers: [\n * { category: [], sinks: [\"sentry\"], lowestLevel: \"info\" },\n * ],\n * });\n * ```\n *\n * @example Edge functions - must flush before termination\n * ```typescript\n * // Cloudflare Workers\n * export default {\n * async fetch(request, env, ctx) {\n * logger.error(\"Something happened\");\n * ctx.waitUntil(Sentry.flush(2000)); // Don't block response\n * return new Response(\"OK\");\n * }\n * };\n * ```\n *\n * @example Legacy usage (v1.1.x - deprecated)\n * ```typescript\n * import { getClient } from \"@sentry/node\";\n * const client = getClient();\n * getSentrySink(client); // Still works but shows deprecation warning\n * ```\n *\n * @since 1.0.0\n */\nexport function getSentrySink(\n optionsOrClient?: SentrySinkOptions | SentryInstance,\n): Sink {\n let legacyClient: SentryInstance | undefined;\n let options: SentrySinkOptions = {};\n\n // Detect which API pattern is being used\n if (optionsOrClient == null) {\n // Pattern: getSentrySink() - no params (RECOMMENDED)\n // Use global functions\n } else if (\n typeof optionsOrClient === \"object\" &&\n \"captureMessage\" in optionsOrClient &&\n typeof optionsOrClient.captureMessage === \"function\"\n ) {\n // Pattern: getSentrySink(client) - DEPRECATED (v1.1.x backward compatibility)\n getLogger([\"logtape\", \"meta\", \"sentry\"]).warn(\n \"Passing a client directly is deprecated. \" +\n \"Use getSentrySink({ sentry: Sentry }) instead.\",\n );\n legacyClient = optionsOrClient as SentryInstance;\n } else if (typeof optionsOrClient === \"object\") {\n // Pattern: getSentrySink({ options }) - options object\n options = optionsOrClient as SentrySinkOptions;\n } else {\n throw new Error(\n `[@logtape/sentry] Invalid parameter (type: ${typeof optionsOrClient}).\\n\\n` +\n \"Expected one of:\\n\" +\n \" getSentrySink() // Recommended\\n\" +\n \" getSentrySink({ options }) // With options\\n\" +\n \" getSentrySink({ sentry }) // With a Sentry SDK namespace\\n\" +\n \" getSentrySink(client) // Deprecated (v1.1.x compat)\\n\",\n );\n }\n\n const sentry = options.sentry ?? SentryCore;\n\n // Choose which Sentry functions to use:\n // - For capture functions: use client if provided (v1.1.x compat),\n // otherwise the configured SDK namespace.\n // - For scope operations: use the configured SDK namespace because clients\n // don't expose current scope/span APIs.\n const captureMessage = legacyClient\n ? (msg: ParameterizedString, ctx?: unknown) =>\n legacyClient.captureMessage(String(msg), ctx)\n : sentry.captureMessage;\n const captureException = legacyClient\n ? (exception: unknown, hint?: unknown) =>\n legacyClient.captureException(exception, hint)\n : sentry.captureException;\n\n return (record: LogRecord) => {\n try {\n // Skip meta logger records to prevent infinite recursion\n const { category } = record;\n if (\n category[0] === \"logtape\" && category[1] === \"meta\" &&\n category[2] === \"sentry\"\n ) {\n return;\n }\n\n // Optional transformation/filtering\n const transformed = options.beforeSend\n ? options.beforeSend(record)\n : record;\n if (transformed == null) return;\n\n // Parameterized message for structured logging and events\n const paramMessage = getParameterizedString(transformed);\n const message = paramMessage.toString();\n\n // Level mapping\n const eventLevel = mapLevelForEvents(transformed.level);\n\n // Enriched structured attributes\n const attributes = {\n ...transformed.properties,\n \"sentry.origin\": \"auto.logging.logtape\",\n category: transformed.category.join(\".\"),\n timestamp: transformed.timestamp,\n } as Record<string, unknown>;\n\n // After enriched attributes\n const activeSpan = sentry.getActiveSpan();\n if (activeSpan) {\n const spanCtx = activeSpan.spanContext();\n attributes.trace_id = spanCtx.traceId;\n attributes.span_id = spanCtx.spanId;\n if (\"parentSpanId\" in spanCtx) {\n attributes.parent_span_id = spanCtx.parentSpanId; // Optional\n }\n }\n\n // Send structured log if Sentry logging is enabled (v9.41.0+)\n // Uses public logger API when available (SDK 9.41.0+)\n const client = sentry.getClient();\n if (client) {\n const { enableLogs, _experiments } = client.getOptions();\n const loggingEnabled = enableLogs ?? _experiments?.enableLogs;\n\n const sentryLogger = sentry.logger as SentryNamespace[\"logger\"];\n if (loggingEnabled && sentryLogger != null) {\n const logLevel = mapLevelForLogs(transformed.level);\n const logFn = sentryLogger[logLevel];\n if (typeof logFn === \"function\") {\n logFn(paramMessage, attributes);\n }\n }\n }\n\n // Capture as Sentry event (Issue) based on level and error presence\n // Use compareLogLevel() to handle future severity level additions\n const isErrorLevel = compareLogLevel(transformed.level, \"error\") >= 0;\n\n if (isErrorLevel && transformed.properties.error instanceof Error) {\n // Error instance at error/fatal level -> captureException for stack trace\n const { error, ...rest } = attributes;\n captureException(error as Error, {\n level: eventLevel,\n extra: { message, ...rest },\n });\n } else if (isErrorLevel) {\n // Error/fatal level without Error instance -> captureMessage as Issue\n captureMessage(paramMessage, {\n level: eventLevel,\n extra: attributes,\n });\n } else if (options.enableBreadcrumbs) {\n // Non-error levels -> breadcrumbs only (if enabled)\n const isolationScope = sentry.getIsolationScope();\n isolationScope?.addBreadcrumb({\n category: transformed.category.join(\".\"),\n level: eventLevel,\n message,\n timestamp: transformed.timestamp / 1000,\n data: attributes,\n });\n }\n } catch (error) {\n getLogger([\"logtape\", \"meta\", \"sentry\"]).error(\n \"Failed to send log events to Sentry\",\n { error },\n );\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,SAAS,uBAAuBA,QAAwC;CACtE,IAAI,SAAS;CACb,IAAI,YAAY;CAChB,MAAMC,YAAsB,CAAE;AAC9B,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,QAAQ,IACzC,KAAI,IAAI,MAAM,GAAG;AACf,YAAU,OAAO,QAAQ;AACzB,eAAa,OAAO,OAAO,QAAQ,GAAG,CAAC,WAAW,KAAK,KAAK;CAC7D,OAAM;EACL,MAAM,QAAQ,QAAQ,OAAO,QAAQ,GAAG;AACxC,YAAU;AACV,gBAAc;AACd,YAAU,KAAK,MAAM;CACtB;CAEH,MAAM,WA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,UAAU,YAAY,SAAS,KAAK,IAAI;KACxC,OAAO;KACP;KACA,WAAW,YAAY,YAAY;KACnC,MAAM;IACP,EAAC;GACH;EACF,SAAQ,OAAO;AACd,aAAU;IAAC;IAAW;IAAQ;GAAS,EAAC,CAAC,MACvC,uCACA,EAAE,MAAO,EACV;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"mod.js","names":["record: LogRecord","tplValues: string[]","level: LogLevel","optionsOrClient?: SentrySinkOptions | SentryInstance","legacyClient: SentryInstance | undefined","options: SentrySinkOptions","msg: ParameterizedString","ctx?: unknown","exception: unknown","hint?: unknown"],"sources":["../src/mod.ts"],"sourcesContent":["import {\n compareLogLevel,\n getLogger,\n type LogLevel,\n type LogRecord,\n type Sink,\n} from \"@logtape/logtape\";\nimport type {\n LogSeverityLevel,\n ParameterizedString,\n SeverityLevel,\n} from \"@sentry/core\";\n// Import namespace to safely check for public logger API (added in v9.41.0)\nimport * as SentryCore from \"@sentry/core\";\n// Cross-runtime inspect: Deno.inspect / util.inspect (handles circular\n// references); falls back to JSON.stringify in browsers. Resolved via the\n// `#util` import map per runtime.\nimport { inspect } from \"#util\";\n\n/**\n * Converts a LogTape {@link LogRecord} into a Sentry {@link ParameterizedString}.\n *\n * This preserves the template structure for better message grouping in Sentry,\n * allowing similar messages with different values to be grouped together.\n *\n * @param record The log record to convert.\n * @returns A parameterized string with template and values.\n */\nfunction getParameterizedString(record: LogRecord): ParameterizedString {\n let result = \"\";\n let tplString = \"\";\n const tplValues: string[] = [];\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n result += record.message[i];\n tplString += String(record.message[i]).replaceAll(\"%\", \"%%\");\n } else {\n const value = inspect(record.message[i]);\n result += value;\n tplString += `%s`;\n tplValues.push(value);\n }\n }\n const paramStr = new String(result) as ParameterizedString;\n paramStr.__sentry_template_string__ = tplString;\n paramStr.__sentry_template_values__ = tplValues;\n return paramStr;\n}\n\n// Level normalization helpers\n\nfunction mapLevelForEvents(level: LogLevel): SeverityLevel {\n switch (level) {\n case \"trace\":\n return \"debug\";\n default:\n return level as SeverityLevel; // debug | info | error | fatal\n }\n}\n\nfunction mapLevelForLogs(level: LogLevel): LogSeverityLevel {\n switch (level) {\n case \"trace\":\n return \"debug\";\n case \"warning\":\n return \"warn\";\n case \"debug\":\n case \"info\":\n case \"error\":\n case \"fatal\":\n return level;\n default:\n return \"info\"; // fallback\n }\n}\n\n/**\n * A Sentry client instance type (used for v1.1.x backward compatibility).\n *\n * Client instances only support `captureMessage` and `captureException`.\n * For scope operations (breadcrumbs, user context, traces), the sink always\n * uses global functions from `@sentry/core`.\n *\n * @deprecated This is only used for backward compatibility with v1.1.x.\n * New code should use `getSentrySink()` without parameters, which automatically\n * uses Sentry's global functions.\n *\n * @since 1.3.0\n */\nexport interface SentryInstance {\n captureMessage: (\n message: string,\n captureContext?: SeverityLevel | unknown,\n ) => string;\n captureException: (exception: unknown, hint?: unknown) => string;\n}\n\n/**\n * A Sentry SDK namespace object.\n *\n * Pass the namespace imported by your application when *@logtape/sentry* should\n * use the same Sentry module instance that initialized your app, for example\n * `import * as Sentry from \"@sentry/node\"`.\n *\n * @since 2.2.0\n */\nexport interface SentryNamespace {\n /**\n * Captures a message event and sends it to Sentry.\n */\n captureMessage(\n message: ParameterizedString,\n captureContext?: SeverityLevel | unknown,\n ): string;\n\n /**\n * Captures an exception event and sends it to Sentry.\n */\n captureException(exception: unknown, hint?: unknown): string;\n\n /**\n * Gets the currently active span, if any.\n */\n getActiveSpan():\n | {\n spanContext: () => {\n traceId: string;\n spanId: string;\n parentSpanId?: string;\n };\n }\n | undefined;\n\n /**\n * Gets the currently active Sentry client, if any.\n */\n getClient():\n | {\n getOptions: () => {\n enableLogs?: boolean;\n _experiments?: {\n enableLogs?: boolean;\n };\n };\n }\n | undefined;\n\n /**\n * Gets the current isolation scope.\n */\n getIsolationScope():\n | {\n addBreadcrumb: (breadcrumb: {\n category: string;\n level: SeverityLevel;\n message: string;\n timestamp: number;\n data: Record<string, unknown>;\n }) => void;\n }\n | undefined;\n\n /**\n * Sentry's structured logging API, available in Sentry SDK 9.41.0+.\n */\n logger?: Partial<\n Record<\n LogSeverityLevel,\n (\n message: ParameterizedString,\n attributes: Record<string, unknown>,\n ) => void\n >\n >;\n}\n\n/**\n * Options for configuring the Sentry sink.\n * @since 1.3.0\n */\nexport interface SentrySinkOptions {\n /**\n * Sentry SDK namespace to use for capture, scope, span, and structured log\n * APIs.\n *\n * This is useful when your application initializes Sentry through a framework\n * SDK such as `@sentry/nextjs` or `@sentry/react-native`, and\n * *@logtape/sentry* resolves a different `@sentry/core` module instance.\n *\n * @example\n * ```typescript\n * import * as Sentry from \"@sentry/node\";\n *\n * getSentrySink({ sentry: Sentry });\n * ```\n *\n * @default `@sentry/core`\n * @since 2.2.0\n */\n sentry?: SentryNamespace;\n\n /**\n * Enable automatic breadcrumb creation for log events.\n *\n * When enabled, all logs become breadcrumbs in Sentry's isolation scope,\n * providing a complete context trail when errors occur. Breadcrumbs are\n * lightweight and only appear in error reports for debugging.\n *\n * @default false\n * @since 1.3.0\n */\n enableBreadcrumbs?: boolean;\n\n /**\n * Optional hook to transform or filter records before sending to Sentry.\n * Return `null` to drop the record.\n *\n * @since 1.3.0\n */\n beforeSend?: (record: LogRecord) => LogRecord | null;\n}\n\n/**\n * Gets a LogTape sink that sends logs to Sentry.\n *\n * This sink uses Sentry's global capture functions from `@sentry/core` by\n * default, following Sentry v8+ best practices. Simply call `Sentry.init()`\n * before creating the sink, and it will automatically use your initialized\n * client when both packages resolve the same Sentry module instance.\n *\n * @param optionsOrClient Optional configuration. Can be:\n * - Omitted: Uses global Sentry functions (recommended)\n * - Object with options: Configure sink behavior\n * - Object with `sentry`: Use an application-provided Sentry SDK namespace\n * - Sentry client instance: Backward compatibility (deprecated)\n * @returns A LogTape sink that sends logs to Sentry.\n *\n * @example Recommended usage - no parameters\n * ```typescript\n * import { configure } from \"@logtape/logtape\";\n * import { getSentrySink } from \"@logtape/sentry\";\n * import * as Sentry from \"@sentry/node\";\n *\n * Sentry.init({ dsn: process.env.SENTRY_DSN });\n *\n * await configure({\n * sinks: {\n * sentry: getSentrySink(), // That's it!\n * },\n * loggers: [\n * { category: [], sinks: [\"sentry\"], lowestLevel: \"error\" },\n * ],\n * });\n * ```\n *\n * @example With an application-provided Sentry namespace\n * ```typescript\n * import { configure } from \"@logtape/logtape\";\n * import { getSentrySink } from \"@logtape/sentry\";\n * import * as Sentry from \"@sentry/nextjs\";\n *\n * Sentry.init({ dsn: process.env.SENTRY_DSN });\n *\n * await configure({\n * sinks: {\n * sentry: getSentrySink({ sentry: Sentry }),\n * },\n * loggers: [\n * { category: [], sinks: [\"sentry\"], lowestLevel: \"error\" },\n * ],\n * });\n * ```\n *\n * @example With options\n * ```typescript\n * import * as Sentry from \"@sentry/node\";\n * Sentry.init({ dsn: process.env.SENTRY_DSN });\n *\n * await configure({\n * sinks: {\n * sentry: getSentrySink({\n * enableBreadcrumbs: true,\n * }),\n * },\n * loggers: [\n * { category: [], sinks: [\"sentry\"], lowestLevel: \"info\" },\n * ],\n * });\n * ```\n *\n * @example Edge functions - must flush before termination\n * ```typescript\n * // Cloudflare Workers\n * export default {\n * async fetch(request, env, ctx) {\n * logger.error(\"Something happened\");\n * ctx.waitUntil(Sentry.flush(2000)); // Don't block response\n * return new Response(\"OK\");\n * }\n * };\n * ```\n *\n * @example Legacy usage (v1.1.x - deprecated)\n * ```typescript\n * import { getClient } from \"@sentry/node\";\n * const client = getClient();\n * getSentrySink(client); // Still works but shows deprecation warning\n * ```\n *\n * @since 1.0.0\n */\nexport function getSentrySink(\n optionsOrClient?: SentrySinkOptions | SentryInstance,\n): Sink {\n let legacyClient: SentryInstance | undefined;\n let options: SentrySinkOptions = {};\n\n // Detect which API pattern is being used\n if (optionsOrClient == null) {\n // Pattern: getSentrySink() - no params (RECOMMENDED)\n // Use global functions\n } else if (\n typeof optionsOrClient === \"object\" &&\n \"captureMessage\" in optionsOrClient &&\n typeof optionsOrClient.captureMessage === \"function\"\n ) {\n // Pattern: getSentrySink(client) - DEPRECATED (v1.1.x backward compatibility)\n getLogger([\"logtape\", \"meta\", \"sentry\"]).warn(\n \"Passing a client directly is deprecated. \" +\n \"Use getSentrySink({ sentry: Sentry }) instead.\",\n );\n legacyClient = optionsOrClient as SentryInstance;\n } else if (typeof optionsOrClient === \"object\") {\n // Pattern: getSentrySink({ options }) - options object\n options = optionsOrClient as SentrySinkOptions;\n } else {\n throw new Error(\n `[@logtape/sentry] Invalid parameter (type: ${typeof optionsOrClient}).\\n\\n` +\n \"Expected one of:\\n\" +\n \" getSentrySink() // Recommended\\n\" +\n \" getSentrySink({ options }) // With options\\n\" +\n \" getSentrySink({ sentry }) // With a Sentry SDK namespace\\n\" +\n \" getSentrySink(client) // Deprecated (v1.1.x compat)\\n\",\n );\n }\n\n const sentry = options.sentry ?? SentryCore;\n\n // Choose which Sentry functions to use:\n // - For capture functions: use client if provided (v1.1.x compat),\n // otherwise the configured SDK namespace.\n // - For scope operations: use the configured SDK namespace because clients\n // don't expose current scope/span APIs.\n const captureMessage = legacyClient\n ? (msg: ParameterizedString, ctx?: unknown) =>\n legacyClient.captureMessage(String(msg), ctx)\n : sentry.captureMessage;\n const captureException = legacyClient\n ? (exception: unknown, hint?: unknown) =>\n legacyClient.captureException(exception, hint)\n : sentry.captureException;\n\n return (record: LogRecord) => {\n try {\n // Skip meta logger records to prevent infinite recursion\n const { category } = record;\n if (\n category[0] === \"logtape\" && category[1] === \"meta\" &&\n category[2] === \"sentry\"\n ) {\n return;\n }\n\n // Optional transformation/filtering\n const transformed = options.beforeSend\n ? options.beforeSend(record)\n : record;\n if (transformed == null) return;\n\n // Parameterized message for structured logging and events\n const paramMessage = getParameterizedString(transformed);\n const message = paramMessage.toString();\n\n // Level mapping\n const eventLevel = mapLevelForEvents(transformed.level);\n\n // Enriched structured attributes\n const attributes = {\n ...transformed.properties,\n \"sentry.origin\": \"auto.logging.logtape\",\n category: transformed.category.join(\".\"),\n timestamp: transformed.timestamp,\n } as Record<string, unknown>;\n\n // After enriched attributes\n const activeSpan = sentry.getActiveSpan();\n if (activeSpan) {\n const spanCtx = activeSpan.spanContext();\n attributes.trace_id = spanCtx.traceId;\n attributes.span_id = spanCtx.spanId;\n if (\"parentSpanId\" in spanCtx) {\n attributes.parent_span_id = spanCtx.parentSpanId; // Optional\n }\n }\n\n // Send structured log if Sentry logging is enabled (v9.41.0+)\n // Uses public logger API when available (SDK 9.41.0+)\n const client = sentry.getClient();\n if (client) {\n const { enableLogs, _experiments } = client.getOptions();\n const loggingEnabled = enableLogs ?? _experiments?.enableLogs;\n\n const sentryLogger = sentry.logger as SentryNamespace[\"logger\"];\n if (loggingEnabled && sentryLogger != null) {\n const logLevel = mapLevelForLogs(transformed.level);\n const logFn = sentryLogger[logLevel];\n if (typeof logFn === \"function\") {\n logFn(paramMessage, attributes);\n }\n }\n }\n\n // Capture as Sentry event (Issue) based on level and error presence\n // Use compareLogLevel() to handle future severity level additions\n const isErrorLevel = compareLogLevel(transformed.level, \"error\") >= 0;\n\n if (isErrorLevel && transformed.properties.error instanceof Error) {\n // Error instance at error/fatal level -> captureException for stack trace\n const { error, ...rest } = attributes;\n captureException(error as Error, {\n level: eventLevel,\n extra: { message, ...rest },\n });\n } else if (isErrorLevel) {\n // Error/fatal level without Error instance -> captureMessage as Issue\n captureMessage(paramMessage, {\n level: eventLevel,\n extra: attributes,\n });\n } else if (options.enableBreadcrumbs) {\n // Non-error levels -> breadcrumbs only (if enabled)\n const isolationScope = sentry.getIsolationScope();\n isolationScope?.addBreadcrumb({\n category: transformed.category.join(\".\"),\n level: eventLevel,\n message,\n timestamp: transformed.timestamp / 1000,\n data: attributes,\n });\n }\n } catch (error) {\n getLogger([\"logtape\", \"meta\", \"sentry\"]).error(\n \"Failed to send log events to Sentry\",\n { error },\n );\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,SAAS,uBAAuBA,QAAwC;CACtE,IAAI,SAAS;CACb,IAAI,Y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,WAAU,aAET,gBAAe,cAAc;IAC3B,OAAO;IACP,OAAO;GACR,EAAC;YACO,QAAQ,mBAAmB;IAEpC,MAAM,iBAAiB,OAAO,mBAAmB;AACjD,oBAAgB,cAAc;KAC5B,UAAU,YAAY,SAAS,KAAK,IAAI;KACxC,OAAO;KACP;KACA,WAAW,YAAY,YAAY;KACnC,MAAM;IACP,EAAC;GACH;EACF,SAAQ,OAAO;AACd,aAAU;IAAC;IAAW;IAAQ;GAAS,EAAC,CAAC,MACvC,uCACA,EAAE,MAAO,EACV;EACF;CACF;AACF"}
|
package/dist/util.cjs
ADDED
package/dist/util.d.cts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/util.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.cts","names":[],"sources":["../src/util.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/util.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","names":[],"sources":["../src/util.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/util.deno.ts
|
|
3
|
+
function inspect(obj, options) {
|
|
4
|
+
if ("Deno" in globalThis) return Deno.inspect(obj, {
|
|
5
|
+
colors: options?.colors,
|
|
6
|
+
depth: options?.depth ?? void 0,
|
|
7
|
+
compact: options?.compact ?? true
|
|
8
|
+
});
|
|
9
|
+
else {
|
|
10
|
+
const indent = options?.compact === true ? void 0 : 2;
|
|
11
|
+
return JSON.stringify(obj, null, indent);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.inspect = inspect;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/util.deno.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.deno.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.deno.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.deno.d.cts","names":[],"sources":["../src/util.deno.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/util.deno.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.deno.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.deno.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.deno.d.ts","names":[],"sources":["../src/util.deno.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/util.deno.ts
|
|
2
|
+
function inspect(obj, options) {
|
|
3
|
+
if ("Deno" in globalThis) return Deno.inspect(obj, {
|
|
4
|
+
colors: options?.colors,
|
|
5
|
+
depth: options?.depth ?? void 0,
|
|
6
|
+
compact: options?.compact ?? true
|
|
7
|
+
});
|
|
8
|
+
else {
|
|
9
|
+
const indent = options?.compact === true ? void 0 : 2;
|
|
10
|
+
return JSON.stringify(obj, null, indent);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { inspect };
|
|
16
|
+
//# sourceMappingURL=util.deno.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.deno.js","names":["obj: unknown","options?: InspectOptions"],"sources":["../src/util.deno.ts"],"sourcesContent":["export interface InspectOptions {\n colors?: boolean;\n depth?: number | null;\n compact?: boolean;\n [key: string]: unknown;\n}\n\nexport function inspect(obj: unknown, options?: InspectOptions): string {\n if (\"Deno\" in globalThis) {\n return Deno.inspect(obj, {\n colors: options?.colors,\n depth: options?.depth ?? undefined,\n compact: options?.compact ?? true,\n });\n } else {\n const indent = options?.compact === true ? undefined : 2;\n return JSON.stringify(obj, null, indent);\n }\n}\n"],"mappings":";AAOA,SAAgB,QAAQA,KAAcC,SAAkC;AACtE,KAAI,UAAU,WACZ,QAAO,KAAK,QAAQ,KAAK;EACvB,QAAQ,SAAS;EACjB,OAAO,SAAS;EAChB,SAAS,SAAS,WAAW;CAC9B,EAAC;MACG;EACL,MAAM,SAAS,SAAS,YAAY,gBAAmB;AACvD,SAAO,KAAK,UAAU,KAAK,MAAM,OAAO;CACzC;AACF"}
|
package/dist/util.js
ADDED
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","names":["obj: unknown","options?: InspectOptions"],"sources":["../src/util.ts"],"sourcesContent":["export interface InspectOptions {\n colors?: boolean;\n depth?: number | null;\n compact?: boolean;\n [key: string]: unknown;\n}\n\nexport function inspect(obj: unknown, options?: InspectOptions): string {\n const indent = options?.compact === true ? undefined : 2;\n return JSON.stringify(obj, null, indent);\n}\n"],"mappings":";AAOA,SAAgB,QAAQA,KAAcC,SAAkC;CACtE,MAAM,SAAS,SAAS,YAAY,gBAAmB;AACvD,QAAO,KAAK,UAAU,KAAK,MAAM,OAAO;AACzC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const node_util = require_rolldown_runtime.__toESM(require("node:util"));
|
|
3
|
+
|
|
4
|
+
//#region src/util.node.ts
|
|
5
|
+
function inspect(obj, options) {
|
|
6
|
+
return node_util.default.inspect(obj, options);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.inspect = inspect;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/util.node.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.node.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.node.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.node.d.cts","names":[],"sources":["../src/util.node.ts"],"sourcesContent":[],"mappings":";UAEiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/util.node.d.ts
|
|
2
|
+
interface InspectOptions {
|
|
3
|
+
colors?: boolean;
|
|
4
|
+
depth?: number | null;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function inspect(obj: unknown, options?: InspectOptions): string;
|
|
9
|
+
//# sourceMappingURL=util.node.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InspectOptions, inspect };
|
|
12
|
+
//# sourceMappingURL=util.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.node.d.ts","names":[],"sources":["../src/util.node.ts"],"sourcesContent":[],"mappings":";UAEiB,cAAA;EAAA,MAAA,CAAA,EAAA,OAAA;EAOD,KAAA,CAAA,EAAA,MAAO,GAAA,IAAyB;;;;iBAAhC,OAAA,yBAAgC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.node.js","names":["obj: unknown","options?: InspectOptions"],"sources":["../src/util.node.ts"],"sourcesContent":["import util from \"node:util\";\n\nexport interface InspectOptions {\n colors?: boolean;\n depth?: number | null;\n compact?: boolean;\n [key: string]: unknown;\n}\n\nexport function inspect(obj: unknown, options?: InspectOptions): string {\n return util.inspect(obj, options);\n}\n"],"mappings":";;;AASA,SAAgB,QAAQA,KAAcC,SAAkC;AACtE,QAAO,KAAK,QAAQ,KAAK,QAAQ;AAClC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logtape/sentry",
|
|
3
|
-
"version": "2.2.1-dev.
|
|
3
|
+
"version": "2.2.1-dev.777+88214474",
|
|
4
4
|
"description": "LogTape Sentry sink",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"LogTape",
|
|
@@ -40,12 +40,36 @@
|
|
|
40
40
|
"./package.json": "./package.json"
|
|
41
41
|
},
|
|
42
42
|
"sideEffects": false,
|
|
43
|
+
"imports": {
|
|
44
|
+
"#util": {
|
|
45
|
+
"types": {
|
|
46
|
+
"import": "./dist/util.d.ts",
|
|
47
|
+
"require": "./dist/util.d.cts"
|
|
48
|
+
},
|
|
49
|
+
"browser": {
|
|
50
|
+
"import": "./dist/util.js",
|
|
51
|
+
"require": "./dist/util.cjs"
|
|
52
|
+
},
|
|
53
|
+
"node": {
|
|
54
|
+
"import": "./dist/util.node.js",
|
|
55
|
+
"require": "./dist/util.node.cjs"
|
|
56
|
+
},
|
|
57
|
+
"bun": {
|
|
58
|
+
"import": "./dist/util.node.js",
|
|
59
|
+
"require": "./dist/util.node.cjs"
|
|
60
|
+
},
|
|
61
|
+
"deno": "./dist/util.deno.js",
|
|
62
|
+
"import": "./dist/util.js",
|
|
63
|
+
"require": "./dist/util.cjs",
|
|
64
|
+
"default": "./dist/util.js"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
43
67
|
"files": [
|
|
44
68
|
"dist/"
|
|
45
69
|
],
|
|
46
70
|
"peerDependencies": {
|
|
47
71
|
"@sentry/core": ">=8.0.0",
|
|
48
|
-
"@logtape/logtape": "^2.2.1-dev.
|
|
72
|
+
"@logtape/logtape": "^2.2.1-dev.777+88214474"
|
|
49
73
|
},
|
|
50
74
|
"devDependencies": {
|
|
51
75
|
"@sentry/core": "^9.41.0",
|
|
@@ -55,6 +79,10 @@
|
|
|
55
79
|
},
|
|
56
80
|
"scripts": {
|
|
57
81
|
"build": "tsdown",
|
|
58
|
-
"prepublish": "tsdown"
|
|
82
|
+
"prepublish": "tsdown",
|
|
83
|
+
"test": "tsdown && node --experimental-transform-types --test",
|
|
84
|
+
"test:bun": "tsdown && bun test",
|
|
85
|
+
"test:deno": "deno test",
|
|
86
|
+
"test-all": "tsdown && node --experimental-transform-types --test && bun test && deno test"
|
|
59
87
|
}
|
|
60
88
|
}
|