New:Socket for Asana Is Now Available.Learn more
Get Started

@sentry/core

Package Overview
Dependencies
Maintainers
1
Versions
726
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/core - npm Package Compare versions

Comparing version
10.70.0
to
10.71.0
+1
-1
build/cjs/client.js

@@ -119,3 +119,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

}
this._options.enableLogs = this._options.enableLogs ?? this._options._experiments?.enableLogs;
this._options.enableLogs = this._options.enableLogs ?? this._options._experiments?.enableLogs ?? true;
if (this._options.enableLogs) {

@@ -122,0 +122,0 @@ setupWeightBasedFlushing(this, "afterCaptureLog", "flushLogs", estimateLogSizeInBytes, internal._INTERNAL_flushLogsBuffer);

@@ -1,1 +0,1 @@

{"version":3,"file":"consola.js","sources":["../../../src/integrations/consola.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { getClient } from '../currentScopes';\nimport { _INTERNAL_captureLog } from '../logs/internal';\nimport { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions } from '../logs/utils';\nimport type { LogSeverityLevel } from '../types/log';\nimport { isPlainObject } from '../utils/is';\nimport { normalize } from '../utils/normalize';\n\n/**\n * Result of extracting structured attributes from console arguments.\n */\ninterface ExtractAttributesResult {\n /**\n * The log message to use for the log entry, typically constructed from the console arguments.\n */\n message?: string;\n\n /**\n * The parameterized template string which is added as `sentry.message.template` attribute if applicable.\n */\n messageTemplate?: string;\n\n /**\n * Remaining arguments to process as attributes with keys like `sentry.message.parameter.0`, `sentry.message.parameter.1`, etc.\n */\n messageParameters?: unknown[];\n\n /**\n * Additional attributes to add to the log.\n */\n attributes?: Record<string, unknown>;\n}\n\n/**\n * Options for the Sentry Consola reporter.\n */\ninterface ConsolaReporterOptions {\n /**\n * Use this option to filter which levels should be captured. By default, all levels are captured.\n *\n * @example\n * ```ts\n * const sentryReporter = Sentry.createConsolaReporter({\n * // Only capture error and warn logs\n * levels: ['error', 'warn'],\n * });\n * consola.addReporter(sentryReporter);\n * ```\n */\n levels?: Array<LogSeverityLevel>;\n\n /**\n * Optionally provide a specific Sentry client instance to use for capturing logs.\n * If not provided, the current client will be retrieved using `getClient()`.\n *\n * This is useful when you want to use specific client options for log normalization\n * or when working with multiple client instances.\n *\n * @example\n * ```ts\n * const sentryReporter = Sentry.createConsolaReporter({\n * client: myCustomClient,\n * });\n * ```\n */\n client?: Client;\n}\n\nexport interface ConsolaReporter {\n log: (logObj: ConsolaLogObject) => void;\n}\n\n/**\n * Represents a log object that Consola reporters receive.\n *\n * This interface matches the structure of log objects passed to Consola reporters.\n * See: https://github.com/unjs/consola#custom-reporters\n *\n * @example\n * ```ts\n * const reporter = {\n * log(logObj: ConsolaLogObject) {\n * console.log(`[${logObj.type}] ${logObj.message || logObj.args?.join(' ')}`);\n * }\n * };\n * consola.addReporter(reporter);\n * ```\n */\nexport interface ConsolaLogObject {\n /**\n * Allows additional custom properties to be set on the log object. These properties will be captured as log attributes.\n *\n * Additional properties are set when passing a single object with a `message` (`consola.[type]({ message: '', ... })`) or if the reporter is called directly\n *\n * @example\n * ```ts\n * const reporter = Sentry.createConsolaReporter();\n * reporter.log({\n * type: 'info',\n * message: 'User action',\n * userId: 123,\n * sessionId: 'abc-123'\n * });\n * // Will create attributes: `userId` and `sessionId`\n * ```\n */\n [key: string]: unknown;\n\n /**\n * The numeric log level (0-5) or null.\n *\n * Consola log levels:\n * - 0: Fatal and Error\n * - 1: Warnings\n * - 2: Normal logs\n * - 3: Informational logs, success, fail, ready, start, box, ...\n * - 4: Debug logs\n * - 5: Trace logs\n * - null: Some special types like 'verbose'\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#log-level\n */\n level?: number | null;\n\n /**\n * The log type/method name (e.g., 'error', 'warn', 'info', 'debug', 'trace', 'success', 'fail', etc.).\n *\n * Consola built-in types include:\n * - Standard: silent, fatal, error, warn, log, info, success, fail, ready, start, box, debug, trace, verbose\n * - Custom types can also be defined\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#log-types\n */\n type?: string;\n\n /**\n * An optional tag/scope for the log entry.\n *\n * Tags are created using `consola.withTag('scope')` and help categorize logs.\n *\n * @example\n * ```ts\n * const scopedLogger = consola.withTag('auth');\n * scopedLogger.info('User logged in'); // tag will be 'auth'\n * ```\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#withtagtag\n */\n tag?: string;\n\n /**\n * The raw arguments passed to the log method.\n *\n * These args are typically formatted into the final `message`. In Consola reporters, `message` is not provided. See: https://github.com/unjs/consola/issues/406#issuecomment-3684792551\n *\n * @example\n * ```ts\n * consola.info('Hello', 'world', { user: 'john' });\n * // args = ['Hello', 'world', { user: 'john' }]\n * ```\n *\n * @example\n * ```ts\n * // `message` is a reserved property in Consola\n * consola.log({ message: 'Hello' });\n * // args = ['Hello']\n * ```\n */\n args?: unknown[];\n\n /**\n * The timestamp when the log was created.\n *\n * This is automatically set by Consola when the log is created.\n */\n date?: Date;\n\n /**\n * The formatted log message.\n *\n * When provided, this is the final formatted message. When not provided,\n * the message should be constructed from the `args` array.\n *\n * Note: In reporters, `message` is typically undefined. It is primarily for\n * `consola.[type]({ message: 'xxx' })` usage and is normalized into `args` before\n * reporters receive the log object. See: https://github.com/unjs/consola/issues/406#issuecomment-3684792551\n */\n message?: string;\n}\n\nconst DEFAULT_CAPTURED_LEVELS: Array<LogSeverityLevel> = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];\n\n/**\n * Creates a new Sentry reporter for Consola that forwards logs to Sentry. Requires the `enableLogs` option to be enabled.\n *\n * **Note: This integration supports Consola v3.x only.** The reporter interface and log object structure\n * may differ in other versions of Consola.\n *\n * @param options - Configuration options for the reporter.\n * @returns A Consola reporter that can be added to consola instances.\n *\n * @example\n * ```ts\n * import * as Sentry from '@sentry/node';\n * import { consola } from 'consola';\n *\n * Sentry.init({\n * enableLogs: true,\n * });\n *\n * const sentryReporter = Sentry.createConsolaReporter({\n * // Optional: filter levels to capture\n * levels: ['error', 'warn', 'info'],\n * });\n *\n * consola.addReporter(sentryReporter);\n *\n * // Now consola logs will be captured by Sentry\n * consola.info('This will be sent to Sentry');\n * consola.error('This error will also be sent to Sentry');\n * ```\n */\nexport function createConsolaReporter(options: ConsolaReporterOptions = {}): ConsolaReporter {\n const levels = new Set(options.levels ?? DEFAULT_CAPTURED_LEVELS);\n const providedClient = options.client;\n\n return {\n log(logObj: ConsolaLogObject) {\n // We need to exclude certain known properties from being added as additional attributes\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { type, level, message: consolaMessage, args, tag, date: _date, ...rest } = logObj;\n\n // Get client - use provided client or current client\n const client = providedClient || getClient();\n if (!client) {\n return;\n }\n\n // Determine the log severity level\n const logSeverityLevel = getLogSeverityLevel(type, level);\n\n // Early exit if this level should not be captured\n if (!levels.has(logSeverityLevel)) {\n return;\n }\n\n const { normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();\n\n const attributes: Record<string, unknown> = {};\n\n // Build attributes\n for (const [key, value] of Object.entries(rest)) {\n attributes[key] = normalize(value, normalizeDepth, normalizeMaxBreadth);\n }\n\n attributes['sentry.origin'] = 'auto.log.consola';\n\n if (tag) {\n attributes['consola.tag'] = tag;\n }\n\n if (type) {\n attributes['consola.type'] = type;\n }\n\n // Only add level if it's a valid number (not null/undefined)\n if (level != null && typeof level === 'number') {\n attributes['consola.level'] = level;\n }\n\n const extractionResult = processExtractedAttributes(\n defaultExtractAttributes(args, normalizeDepth, normalizeMaxBreadth),\n normalizeDepth,\n normalizeMaxBreadth,\n );\n\n if (extractionResult?.attributes) {\n Object.assign(attributes, extractionResult.attributes);\n }\n\n _INTERNAL_captureLog({\n level: logSeverityLevel,\n message:\n extractionResult?.message ||\n consolaMessage ||\n (args && formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth)) ||\n '',\n attributes,\n });\n },\n };\n}\n\n// Mapping from consola log types to Sentry log severity levels\nconst CONSOLA_TYPE_TO_LOG_SEVERITY_LEVEL_MAP: Record<string, LogSeverityLevel> = {\n // Consola built-in types\n silent: 'trace',\n fatal: 'fatal',\n error: 'error',\n warn: 'warn',\n log: 'info',\n info: 'info',\n success: 'info',\n fail: 'error',\n ready: 'info',\n start: 'info',\n box: 'info',\n debug: 'debug',\n trace: 'trace',\n verbose: 'debug',\n // Custom types that might exist\n critical: 'fatal',\n notice: 'info',\n};\n\n// Mapping from consola log levels (numbers) to Sentry log severity levels\nconst CONSOLA_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP: Record<number, LogSeverityLevel> = {\n 0: 'fatal', // Fatal and Error\n 1: 'warn', // Warnings\n 2: 'info', // Normal logs\n 3: 'info', // Informational logs, success, fail, ready, start, ...\n 4: 'debug', // Debug logs\n 5: 'trace', // Trace logs\n};\n\n/**\n * Determines the log severity level from Consola type and level.\n *\n * @param type - The Consola log type (e.g., 'error', 'warn', 'info')\n * @param level - The Consola numeric log level (0-5) or null for some types like 'verbose'\n * @returns The corresponding Sentry log severity level\n */\nfunction getLogSeverityLevel(type?: string, level?: number | null): LogSeverityLevel {\n // Handle special case for verbose logs (level can be null with infinite level in Consola)\n if (type === 'verbose') {\n return 'debug';\n }\n\n // Handle silent logs - these should be at trace level\n if (type === 'silent') {\n return 'trace';\n }\n\n // First try to map by type (more specific)\n if (type) {\n const mappedLevel = CONSOLA_TYPE_TO_LOG_SEVERITY_LEVEL_MAP[type];\n if (mappedLevel) {\n return mappedLevel;\n }\n }\n\n // Fallback to level mapping (handle null level)\n if (typeof level === 'number') {\n const mappedLevel = CONSOLA_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP[level];\n if (mappedLevel) {\n return mappedLevel;\n }\n }\n\n // Default fallback\n return 'info';\n}\n\n/**\n * Extracts structured attributes from console arguments. If the first argument is a plain object, its properties are extracted as attributes.\n */\nfunction defaultExtractAttributes(\n args: unknown[] | undefined,\n normalizeDepth: number,\n normalizeMaxBreadth: number,\n): ExtractAttributesResult {\n if (!args?.length) {\n return { message: '' };\n }\n\n // Message looks like how consola logs the message to the console (all args stringified and joined)\n const message = formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth);\n\n const firstArg = args[0];\n\n if (isPlainObject(firstArg)) {\n // Remaining args start from index 2 i f we used second arg as message, otherwise from index 1\n const remainingArgsStartIndex = typeof args[1] === 'string' ? 2 : 1;\n const remainingArgs = args.slice(remainingArgsStartIndex);\n\n return {\n message,\n // Object content from first arg is added as attributes\n attributes: firstArg,\n // Add remaining args as message parameters\n messageParameters: remainingArgs,\n };\n } else {\n const followingArgs = args.slice(1);\n\n const shouldAddTemplateAttr =\n followingArgs.length > 0 && typeof firstArg === 'string' && !hasConsoleSubstitutions(firstArg);\n\n return {\n message,\n messageTemplate: shouldAddTemplateAttr ? firstArg : undefined,\n messageParameters: shouldAddTemplateAttr ? followingArgs : undefined,\n };\n }\n}\n\n/**\n * Processes extracted attributes by normalizing them and preparing message parameter attributes if a template is present.\n */\nfunction processExtractedAttributes(\n extractionResult: ExtractAttributesResult,\n normalizeDepth: number,\n normalizeMaxBreadth: number,\n): { message: string | undefined; attributes: Record<string, unknown> } {\n const { message, attributes, messageTemplate, messageParameters } = extractionResult;\n\n const messageParamAttributes: Record<string, unknown> = {};\n\n if (messageTemplate && messageParameters) {\n const templateAttrs = createConsoleTemplateAttributes(messageTemplate, messageParameters);\n\n for (const [key, value] of Object.entries(templateAttrs)) {\n messageParamAttributes[key] = key.startsWith('sentry.message.parameter.')\n ? normalize(value, normalizeDepth, normalizeMaxBreadth)\n : value;\n }\n } else if (messageParameters && messageParameters.length > 0) {\n messageParameters.forEach((arg, index) => {\n messageParamAttributes[`sentry.message.parameter.${index}`] = normalize(arg, normalizeDepth, normalizeMaxBreadth);\n });\n }\n\n return {\n message: message,\n attributes: {\n ...normalize(attributes, normalizeDepth, normalizeMaxBreadth),\n ...messageParamAttributes,\n },\n };\n}\n"],"names":["getClient","normalize","_INTERNAL_captureLog","formatConsoleArgs","isPlainObject","hasConsoleSubstitutions","createConsoleTemplateAttributes"],"mappings":";;;;;;;;AA8LA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EAAK,KAAA,KAAU;AACxC,MAAA,sBAAA,CAAuB,4BAA4B,KAAK,CAAA,CAAE,IAAIA,mBAAA,CAAU,GAAA,EAAK,gBAAgB,mBAAmB,CAAA;AAAA,IAClH,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,UAAA,EAAY;AAAA,MACV,GAAGA,mBAAA,CAAU,UAAA,EAAY,cAAA,EAAgB,mBAAmB,CAAA;AAAA,MAC5D,GAAG;AAAA;AACL,GACF;AACF;;;;"}
{"version":3,"file":"consola.js","sources":["../../../src/integrations/consola.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { getClient } from '../currentScopes';\nimport { _INTERNAL_captureLog } from '../logs/internal';\nimport { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions } from '../logs/utils';\nimport type { LogSeverityLevel } from '../types/log';\nimport { isPlainObject } from '../utils/is';\nimport { normalize } from '../utils/normalize';\n\n/**\n * Result of extracting structured attributes from console arguments.\n */\ninterface ExtractAttributesResult {\n /**\n * The log message to use for the log entry, typically constructed from the console arguments.\n */\n message?: string;\n\n /**\n * The parameterized template string which is added as `sentry.message.template` attribute if applicable.\n */\n messageTemplate?: string;\n\n /**\n * Remaining arguments to process as attributes with keys like `sentry.message.parameter.0`, `sentry.message.parameter.1`, etc.\n */\n messageParameters?: unknown[];\n\n /**\n * Additional attributes to add to the log.\n */\n attributes?: Record<string, unknown>;\n}\n\n/**\n * Options for the Sentry Consola reporter.\n */\ninterface ConsolaReporterOptions {\n /**\n * Use this option to filter which levels should be captured. By default, all levels are captured.\n *\n * @example\n * ```ts\n * const sentryReporter = Sentry.createConsolaReporter({\n * // Only capture error and warn logs\n * levels: ['error', 'warn'],\n * });\n * consola.addReporter(sentryReporter);\n * ```\n */\n levels?: Array<LogSeverityLevel>;\n\n /**\n * Optionally provide a specific Sentry client instance to use for capturing logs.\n * If not provided, the current client will be retrieved using `getClient()`.\n *\n * This is useful when you want to use specific client options for log normalization\n * or when working with multiple client instances.\n *\n * @example\n * ```ts\n * const sentryReporter = Sentry.createConsolaReporter({\n * client: myCustomClient,\n * });\n * ```\n */\n client?: Client;\n}\n\nexport interface ConsolaReporter {\n log: (logObj: ConsolaLogObject) => void;\n}\n\n/**\n * Represents a log object that Consola reporters receive.\n *\n * This interface matches the structure of log objects passed to Consola reporters.\n * See: https://github.com/unjs/consola#custom-reporters\n *\n * @example\n * ```ts\n * const reporter = {\n * log(logObj: ConsolaLogObject) {\n * console.log(`[${logObj.type}] ${logObj.message || logObj.args?.join(' ')}`);\n * }\n * };\n * consola.addReporter(reporter);\n * ```\n */\nexport interface ConsolaLogObject {\n /**\n * Allows additional custom properties to be set on the log object. These properties will be captured as log attributes.\n *\n * Additional properties are set when passing a single object with a `message` (`consola.[type]({ message: '', ... })`) or if the reporter is called directly\n *\n * @example\n * ```ts\n * const reporter = Sentry.createConsolaReporter();\n * reporter.log({\n * type: 'info',\n * message: 'User action',\n * userId: 123,\n * sessionId: 'abc-123'\n * });\n * // Will create attributes: `userId` and `sessionId`\n * ```\n */\n [key: string]: unknown;\n\n /**\n * The numeric log level (0-5) or null.\n *\n * Consola log levels:\n * - 0: Fatal and Error\n * - 1: Warnings\n * - 2: Normal logs\n * - 3: Informational logs, success, fail, ready, start, box, ...\n * - 4: Debug logs\n * - 5: Trace logs\n * - null: Some special types like 'verbose'\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#log-level\n */\n level?: number | null;\n\n /**\n * The log type/method name (e.g., 'error', 'warn', 'info', 'debug', 'trace', 'success', 'fail', etc.).\n *\n * Consola built-in types include:\n * - Standard: silent, fatal, error, warn, log, info, success, fail, ready, start, box, debug, trace, verbose\n * - Custom types can also be defined\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#log-types\n */\n type?: string;\n\n /**\n * An optional tag/scope for the log entry.\n *\n * Tags are created using `consola.withTag('scope')` and help categorize logs.\n *\n * @example\n * ```ts\n * const scopedLogger = consola.withTag('auth');\n * scopedLogger.info('User logged in'); // tag will be 'auth'\n * ```\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#withtagtag\n */\n tag?: string;\n\n /**\n * The raw arguments passed to the log method.\n *\n * These args are typically formatted into the final `message`. In Consola reporters, `message` is not provided. See: https://github.com/unjs/consola/issues/406#issuecomment-3684792551\n *\n * @example\n * ```ts\n * consola.info('Hello', 'world', { user: 'john' });\n * // args = ['Hello', 'world', { user: 'john' }]\n * ```\n *\n * @example\n * ```ts\n * // `message` is a reserved property in Consola\n * consola.log({ message: 'Hello' });\n * // args = ['Hello']\n * ```\n */\n args?: unknown[];\n\n /**\n * The timestamp when the log was created.\n *\n * This is automatically set by Consola when the log is created.\n */\n date?: Date;\n\n /**\n * The formatted log message.\n *\n * When provided, this is the final formatted message. When not provided,\n * the message should be constructed from the `args` array.\n *\n * Note: In reporters, `message` is typically undefined. It is primarily for\n * `consola.[type]({ message: 'xxx' })` usage and is normalized into `args` before\n * reporters receive the log object. See: https://github.com/unjs/consola/issues/406#issuecomment-3684792551\n */\n message?: string;\n}\n\nconst DEFAULT_CAPTURED_LEVELS: Array<LogSeverityLevel> = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];\n\n/**\n * Creates a new Sentry reporter for Consola that forwards logs to Sentry.\n *\n * **Note: This integration supports Consola v3.x only.** The reporter interface and log object structure\n * may differ in other versions of Consola.\n *\n * @param options - Configuration options for the reporter.\n * @returns A Consola reporter that can be added to consola instances.\n *\n * @example\n * ```ts\n * import * as Sentry from '@sentry/node';\n * import { consola } from 'consola';\n *\n * Sentry.init({\n * dsn: '__DSN__',\n * });\n *\n * const sentryReporter = Sentry.createConsolaReporter({\n * // Optional: filter levels to capture\n * levels: ['error', 'warn', 'info'],\n * });\n *\n * consola.addReporter(sentryReporter);\n *\n * // Now consola logs will be captured by Sentry\n * consola.info('This will be sent to Sentry');\n * consola.error('This error will also be sent to Sentry');\n * ```\n */\nexport function createConsolaReporter(options: ConsolaReporterOptions = {}): ConsolaReporter {\n const levels = new Set(options.levels ?? DEFAULT_CAPTURED_LEVELS);\n const providedClient = options.client;\n\n return {\n log(logObj: ConsolaLogObject) {\n // We need to exclude certain known properties from being added as additional attributes\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { type, level, message: consolaMessage, args, tag, date: _date, ...rest } = logObj;\n\n // Get client - use provided client or current client\n const client = providedClient || getClient();\n if (!client) {\n return;\n }\n\n // Determine the log severity level\n const logSeverityLevel = getLogSeverityLevel(type, level);\n\n // Early exit if this level should not be captured\n if (!levels.has(logSeverityLevel)) {\n return;\n }\n\n const { normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();\n\n const attributes: Record<string, unknown> = {};\n\n // Build attributes\n for (const [key, value] of Object.entries(rest)) {\n attributes[key] = normalize(value, normalizeDepth, normalizeMaxBreadth);\n }\n\n attributes['sentry.origin'] = 'auto.log.consola';\n\n if (tag) {\n attributes['consola.tag'] = tag;\n }\n\n if (type) {\n attributes['consola.type'] = type;\n }\n\n // Only add level if it's a valid number (not null/undefined)\n if (level != null && typeof level === 'number') {\n attributes['consola.level'] = level;\n }\n\n const extractionResult = processExtractedAttributes(\n defaultExtractAttributes(args, normalizeDepth, normalizeMaxBreadth),\n normalizeDepth,\n normalizeMaxBreadth,\n );\n\n if (extractionResult?.attributes) {\n Object.assign(attributes, extractionResult.attributes);\n }\n\n _INTERNAL_captureLog({\n level: logSeverityLevel,\n message:\n extractionResult?.message ||\n consolaMessage ||\n (args && formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth)) ||\n '',\n attributes,\n });\n },\n };\n}\n\n// Mapping from consola log types to Sentry log severity levels\nconst CONSOLA_TYPE_TO_LOG_SEVERITY_LEVEL_MAP: Record<string, LogSeverityLevel> = {\n // Consola built-in types\n silent: 'trace',\n fatal: 'fatal',\n error: 'error',\n warn: 'warn',\n log: 'info',\n info: 'info',\n success: 'info',\n fail: 'error',\n ready: 'info',\n start: 'info',\n box: 'info',\n debug: 'debug',\n trace: 'trace',\n verbose: 'debug',\n // Custom types that might exist\n critical: 'fatal',\n notice: 'info',\n};\n\n// Mapping from consola log levels (numbers) to Sentry log severity levels\nconst CONSOLA_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP: Record<number, LogSeverityLevel> = {\n 0: 'fatal', // Fatal and Error\n 1: 'warn', // Warnings\n 2: 'info', // Normal logs\n 3: 'info', // Informational logs, success, fail, ready, start, ...\n 4: 'debug', // Debug logs\n 5: 'trace', // Trace logs\n};\n\n/**\n * Determines the log severity level from Consola type and level.\n *\n * @param type - The Consola log type (e.g., 'error', 'warn', 'info')\n * @param level - The Consola numeric log level (0-5) or null for some types like 'verbose'\n * @returns The corresponding Sentry log severity level\n */\nfunction getLogSeverityLevel(type?: string, level?: number | null): LogSeverityLevel {\n // Handle special case for verbose logs (level can be null with infinite level in Consola)\n if (type === 'verbose') {\n return 'debug';\n }\n\n // Handle silent logs - these should be at trace level\n if (type === 'silent') {\n return 'trace';\n }\n\n // First try to map by type (more specific)\n if (type) {\n const mappedLevel = CONSOLA_TYPE_TO_LOG_SEVERITY_LEVEL_MAP[type];\n if (mappedLevel) {\n return mappedLevel;\n }\n }\n\n // Fallback to level mapping (handle null level)\n if (typeof level === 'number') {\n const mappedLevel = CONSOLA_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP[level];\n if (mappedLevel) {\n return mappedLevel;\n }\n }\n\n // Default fallback\n return 'info';\n}\n\n/**\n * Extracts structured attributes from console arguments. If the first argument is a plain object, its properties are extracted as attributes.\n */\nfunction defaultExtractAttributes(\n args: unknown[] | undefined,\n normalizeDepth: number,\n normalizeMaxBreadth: number,\n): ExtractAttributesResult {\n if (!args?.length) {\n return { message: '' };\n }\n\n // Message looks like how consola logs the message to the console (all args stringified and joined)\n const message = formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth);\n\n const firstArg = args[0];\n\n if (isPlainObject(firstArg)) {\n // Remaining args start from index 2 i f we used second arg as message, otherwise from index 1\n const remainingArgsStartIndex = typeof args[1] === 'string' ? 2 : 1;\n const remainingArgs = args.slice(remainingArgsStartIndex);\n\n return {\n message,\n // Object content from first arg is added as attributes\n attributes: firstArg,\n // Add remaining args as message parameters\n messageParameters: remainingArgs,\n };\n } else {\n const followingArgs = args.slice(1);\n\n const shouldAddTemplateAttr =\n followingArgs.length > 0 && typeof firstArg === 'string' && !hasConsoleSubstitutions(firstArg);\n\n return {\n message,\n messageTemplate: shouldAddTemplateAttr ? firstArg : undefined,\n messageParameters: shouldAddTemplateAttr ? followingArgs : undefined,\n };\n }\n}\n\n/**\n * Processes extracted attributes by normalizing them and preparing message parameter attributes if a template is present.\n */\nfunction processExtractedAttributes(\n extractionResult: ExtractAttributesResult,\n normalizeDepth: number,\n normalizeMaxBreadth: number,\n): { message: string | undefined; attributes: Record<string, unknown> } {\n const { message, attributes, messageTemplate, messageParameters } = extractionResult;\n\n const messageParamAttributes: Record<string, unknown> = {};\n\n if (messageTemplate && messageParameters) {\n const templateAttrs = createConsoleTemplateAttributes(messageTemplate, messageParameters);\n\n for (const [key, value] of Object.entries(templateAttrs)) {\n messageParamAttributes[key] = key.startsWith('sentry.message.parameter.')\n ? normalize(value, normalizeDepth, normalizeMaxBreadth)\n : value;\n }\n } else if (messageParameters && messageParameters.length > 0) {\n messageParameters.forEach((arg, index) => {\n messageParamAttributes[`sentry.message.parameter.${index}`] = normalize(arg, normalizeDepth, normalizeMaxBreadth);\n });\n }\n\n return {\n message: message,\n attributes: {\n ...normalize(attributes, normalizeDepth, normalizeMaxBreadth),\n ...messageParamAttributes,\n },\n };\n}\n"],"names":["getClient","normalize","_INTERNAL_captureLog","formatConsoleArgs","isPlainObject","hasConsoleSubstitutions","createConsoleTemplateAttributes"],"mappings":";;;;;;;;AA8LA,MAAM,0BAAmD,CAAC,OAAA,EAAS,SAAS,MAAA,EAAQ,MAAA,EAAQ,SAAS,OAAO,CAAA;AAgCrG,SAAS,qBAAA,CAAsB,OAAA,GAAkC,EAAC,EAAoB;AAC3F,EAAA,MAAM,MAAA,GAAS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AA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,UAAA,EAAY;AAAA,MACV,GAAGA,mBAAA,CAAU,UAAA,EAAY,cAAA,EAAgB,mBAAmB,CAAA;AAAA,MAC5D,GAAG;AAAA;AACL,GACF;AACF;;;;"}

@@ -90,2 +90,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

}
function getHeader(headers, name) {
if (!headers) {
return void 0;
}
if (typeof headers.get === "function") {
return headers.get(name) ?? void 0;
}
const plainHeaders = headers;
const lowerCaseName = name.toLowerCase();
const key = Object.keys(plainHeaders).find((headerName) => headerName.toLowerCase() === lowerCaseName);
return key !== void 0 ? plainHeaders[key] : void 0;
}
function extractOperation(method, headers = {}) {

@@ -97,3 +109,3 @@ switch (method) {

case "POST": {
if (headers["Prefer"]?.includes("resolution=")) {
if (getHeader(headers, "Prefer")?.includes("resolution=")) {
return "upsert";

@@ -266,3 +278,3 @@ } else {

"db.url": typedThis.url.origin,
"db.sdk": typedThis.headers["X-Client-Info"],
"db.sdk": getHeader(typedThis.headers, "X-Client-Info"),
"db.system": "postgresql",

@@ -398,2 +410,3 @@ "db.operation": operation,

exports.extractOperation = extractOperation;
exports.getHeader = getHeader;
exports.instrumentSupabaseClient = instrumentSupabaseClient;

@@ -400,0 +413,0 @@ exports.supabaseIntegration = supabaseIntegration;

@@ -1,1 +0,1 @@

{"version":3,"file":"supabase.js","sources":["../../../src/integrations/supabase.ts"],"sourcesContent":["// Based on Kamil Ogórek's work on:\n// https://github.com/supabase-community/sentry-integration-js\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable max-lines */\nimport { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { captureException } from '../exports';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport { setHttpStatus, SPAN_STATUS_ERROR, SPAN_STATUS_OK, startSpan } from '../tracing';\nimport type { IntegrationFn } from '../types/integration';\nimport { debug } from '../utils/debug-logger';\nimport { isObjectLike, isPlainObject } from '../utils/is';\nimport { addExceptionMechanism } from '../utils/misc';\n\nconst AUTH_OPERATIONS_TO_INSTRUMENT = [\n 'reauthenticate',\n 'signInAnonymously',\n 'signInWithOAuth',\n 'signInWithIdToken',\n 'signInWithOtp',\n 'signInWithPassword',\n 'signInWithSSO',\n 'signOut',\n 'signUp',\n 'verifyOtp',\n];\n\nconst AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT = [\n 'createUser',\n 'deleteUser',\n 'listUsers',\n 'getUserById',\n 'updateUserById',\n 'inviteUserByEmail',\n];\n\nexport const FILTER_MAPPINGS = {\n eq: 'eq',\n neq: 'neq',\n gt: 'gt',\n gte: 'gte',\n lt: 'lt',\n lte: 'lte',\n like: 'like',\n 'like(all)': 'likeAllOf',\n 'like(any)': 'likeAnyOf',\n ilike: 'ilike',\n 'ilike(all)': 'ilikeAllOf',\n 'ilike(any)': 'ilikeAnyOf',\n is: 'is',\n in: 'in',\n cs: 'contains',\n cd: 'containedBy',\n sr: 'rangeGt',\n nxl: 'rangeGte',\n sl: 'rangeLt',\n nxr: 'rangeLte',\n adj: 'rangeAdjacent',\n ov: 'overlaps',\n fts: '',\n plfts: 'plain',\n phfts: 'phrase',\n wfts: 'websearch',\n not: 'not',\n};\n\nexport const DB_OPERATIONS_TO_INSTRUMENT = ['select', 'insert', 'upsert', 'update', 'delete'];\n\ntype AuthOperationFn = (...args: unknown[]) => Promise<unknown>;\ntype AuthOperationName = (typeof AUTH_OPERATIONS_TO_INSTRUMENT)[number];\ntype AuthAdminOperationName = (typeof AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT)[number];\ntype PostgRESTQueryOperationFn = (...args: unknown[]) => PostgRESTFilterBuilder;\n\nexport interface SupabaseClientInstance {\n auth: {\n admin: Record<AuthAdminOperationName, AuthOperationFn>;\n } & Record<AuthOperationName, AuthOperationFn>;\n}\n\nexport interface PostgRESTQueryBuilder {\n [key: string]: PostgRESTQueryOperationFn;\n}\n\nexport interface PostgRESTFilterBuilder {\n method: string;\n headers: Record<string, string>;\n url: URL;\n schema: string;\n body: any;\n}\n\nexport interface SupabaseResponse {\n status?: number;\n error?: {\n message: string;\n code?: string;\n details?: unknown;\n };\n}\n\nexport interface SupabaseError extends Error {\n code?: string;\n details?: unknown;\n}\n\nexport interface SupabaseBreadcrumb {\n type: string;\n category: string;\n message: string;\n data?: {\n query?: string[];\n body?: Record<string, unknown>;\n };\n}\n\nexport interface SupabaseClientConstructor {\n prototype: {\n from: (table: string) => PostgRESTQueryBuilder;\n };\n}\n\nexport interface PostgRESTProtoThenable {\n then: <T>(\n onfulfilled?: ((value: T) => T | PromiseLike<T>) | null,\n onrejected?: ((reason: any) => T | PromiseLike<T>) | null,\n ) => Promise<T>;\n}\n\ntype SentryInstrumented<T> = T & {\n __SENTRY_INSTRUMENTED__?: boolean;\n};\n\nfunction markAsInstrumented<T>(fn: T): void {\n try {\n (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__ = true;\n } catch {\n // ignore errors here\n }\n}\n\nfunction isInstrumented<T>(fn: T): boolean | undefined {\n try {\n return (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__;\n } catch {\n return false;\n }\n}\n\n/**\n * Plain-object bodies are copied into `plainBody`; array inserts (and other non-plain shapes) stay only on `rawBody`.\n * Returns a payload suitable for span attributes / breadcrumbs when operation data collection is enabled.\n */\nfunction getMutationBodyPayloadForTelemetry(rawBody: unknown, plainBody: Record<string, unknown>): unknown | undefined {\n if (Object.keys(plainBody).length > 0) {\n return plainBody;\n }\n if (Array.isArray(rawBody) && rawBody.length > 0) {\n return rawBody;\n }\n return undefined;\n}\n\n/** True when the PostgREST builder carries a mutation body (for `insert(...)`, etc. in span descriptions). */\nfunction hasMutationBodyForDescription(rawBody: unknown, plainBody: Record<string, unknown>): boolean {\n return getMutationBodyPayloadForTelemetry(rawBody, plainBody) !== undefined;\n}\n\n/**\n * Extracts the database operation type from the HTTP method and headers\n * @param method - The HTTP method of the request\n * @param headers - The request headers\n * @returns The database operation type ('select', 'insert', 'upsert', 'update', or 'delete')\n */\nexport function extractOperation(method: string, headers: Record<string, string> = {}): string {\n switch (method) {\n case 'GET': {\n return 'select';\n }\n case 'POST': {\n if (headers['Prefer']?.includes('resolution=')) {\n return 'upsert';\n } else {\n return 'insert';\n }\n }\n case 'PATCH': {\n return 'update';\n }\n case 'DELETE': {\n return 'delete';\n }\n default: {\n return '<unknown-op>';\n }\n }\n}\n\n/**\n * Translates Supabase filter parameters into readable method names for tracing\n * @param key - The filter key from the URL search parameters\n * @param query - The filter value from the URL search parameters\n * @returns A string representation of the filter as a method call\n */\nexport function translateFiltersIntoMethods(key: string, query: string): string {\n if (query === '' || query === '*') {\n return 'select(*)';\n }\n\n if (key === 'select') {\n return `select(${query})`;\n }\n\n if (key === 'or' || key.endsWith('.or')) {\n return `${key}${query}`;\n }\n\n const [filter, ...value] = query.split('.');\n\n let method;\n // Handle optional `configPart` of the filter\n if (filter?.startsWith('fts')) {\n method = 'textSearch';\n } else if (filter?.startsWith('plfts')) {\n method = 'textSearch[plain]';\n } else if (filter?.startsWith('phfts')) {\n method = 'textSearch[phrase]';\n } else if (filter?.startsWith('wfts')) {\n method = 'textSearch[websearch]';\n } else {\n method = (filter && FILTER_MAPPINGS[filter as keyof typeof FILTER_MAPPINGS]) || 'filter';\n }\n\n return `${method}(${key}, ${value.join('.')})`;\n}\n\nfunction instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): AuthOperationFn {\n return new Proxy(operation, {\n apply(target, thisArg, argumentsList) {\n return startSpan(\n {\n name: `auth ${isAdmin ? '(admin) ' : ''}${operation.name}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n 'db.system': 'postgresql',\n 'db.operation': `auth.${isAdmin ? 'admin.' : ''}${operation.name}`,\n },\n },\n span => {\n return Reflect.apply(target, thisArg, argumentsList)\n .then((res: unknown) => {\n if (isObjectLike(res) && 'error' in res && res.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n\n captureException(res.error, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n } else {\n span.setStatus({ code: SPAN_STATUS_OK });\n }\n\n span.end();\n return res;\n })\n .catch((err: unknown) => {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n span.end();\n\n captureException(err, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n\n throw err;\n })\n .then(...argumentsList);\n },\n );\n },\n });\n}\n\nfunction instrumentSupabaseAuthClient(supabaseClientInstance: SupabaseClientInstance): void {\n const auth = supabaseClientInstance.auth;\n\n if (!auth || isInstrumented(supabaseClientInstance.auth)) {\n return;\n }\n\n for (const operation of AUTH_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth[operation] === 'function') {\n supabaseClientInstance.auth[operation] = instrumentAuthOperation(authOperation);\n }\n }\n\n for (const operation of AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth.admin[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth.admin[operation] === 'function') {\n supabaseClientInstance.auth.admin[operation] = instrumentAuthOperation(authOperation, true);\n }\n }\n\n markAsInstrumented(supabaseClientInstance.auth);\n}\n\nfunction instrumentSupabaseClientConstructor(SupabaseClient: unknown, _options: { sendOperationData?: boolean }): void {\n if (isInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from)) {\n return;\n }\n\n (SupabaseClient as SupabaseClientConstructor).prototype.from = new Proxy(\n (SupabaseClient as SupabaseClientConstructor).prototype.from,\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTQueryBuilder = (rv as PostgRESTQueryBuilder).constructor;\n\n instrumentPostgRESTQueryBuilder(PostgRESTQueryBuilder as unknown as new () => PostgRESTQueryBuilder, _options);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from);\n}\n\nfunction instrumentPostgRESTFilterBuilder(\n PostgRESTFilterBuilder: PostgRESTFilterBuilder['constructor'],\n _options: { sendOperationData?: boolean },\n): void {\n if (isInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then)) {\n return;\n }\n\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then = new Proxy(\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then,\n {\n apply(target, thisArg, argumentsList) {\n const operations = DB_OPERATIONS_TO_INSTRUMENT;\n const typedThis = thisArg as PostgRESTFilterBuilder;\n const operation = extractOperation(typedThis.method, typedThis.headers);\n\n if (!operations.includes(operation)) {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n if (!typedThis?.url?.pathname || typeof typedThis.url.pathname !== 'string') {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n const pathParts = typedThis.url.pathname.split('/');\n const table = pathParts.length > 0 ? pathParts[pathParts.length - 1] : '';\n\n const queryItems: string[] = [];\n for (const [key, value] of typedThis.url.searchParams.entries()) {\n // It's possible to have multiple entries for the same key, eg. `id=eq.7&id=eq.3`,\n // so we need to use array instead of object to collect them.\n queryItems.push(translateFiltersIntoMethods(key, value));\n }\n const body: Record<string, unknown> = Object.create(null);\n if (isPlainObject(typedThis.body)) {\n for (const [key, value] of Object.entries(typedThis.body)) {\n body[key] = value;\n }\n }\n\n const client = getClient();\n const shouldSendData =\n _options.sendOperationData ?? client?.getDataCollectionOptions().databaseQueryData === true;\n const bodyPayload = getMutationBodyPayloadForTelemetry(typedThis.body, body);\n\n // Adding operation to the beginning of the description if it's not a `select` operation\n // For example, it can be an `insert` or `update` operation but the query can be `select(...)`\n // For `select` operations, we don't need repeat it in the description\n const mutationPart =\n operation === 'select'\n ? ''\n : `${operation}${hasMutationBodyForDescription(typedThis.body, body) ? '(...) ' : ''}`;\n const queryPart = shouldSendData ? queryItems.join(' ') : queryItems.length > 0 ? '[redacted]' : '';\n const descriptionMiddle = [mutationPart.trimEnd(), queryPart].filter(Boolean).join(' ');\n const description = descriptionMiddle ? `${descriptionMiddle} from(${table})` : `from(${table})`;\n\n const attributes: Record<string, any> = {\n 'db.table': table,\n 'db.schema': typedThis.schema,\n 'db.url': typedThis.url.origin,\n 'db.sdk': typedThis.headers['X-Client-Info'],\n 'db.system': 'postgresql',\n 'db.operation': operation,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n };\n\n if (queryItems.length && shouldSendData) {\n attributes['db.query'] = queryItems;\n }\n\n if (bodyPayload !== undefined && shouldSendData) {\n attributes['db.body'] = bodyPayload;\n }\n\n return startSpan(\n {\n name: description,\n attributes,\n },\n span => {\n return (Reflect.apply(target, thisArg, []) as Promise<SupabaseResponse>)\n .then(\n (res: SupabaseResponse) => {\n if (span) {\n if (res && typeof res === 'object' && 'status' in res) {\n setHttpStatus(span, res.status || 500);\n }\n span.end();\n }\n\n if (res?.error) {\n const err = new Error(res.error.message) as SupabaseError;\n if (res.error.code) {\n err.code = res.error.code;\n }\n if (res.error.details) {\n err.details = res.error.details;\n }\n\n const supabaseContext: Record<string, any> = {};\n if (queryItems.length && shouldSendData) {\n supabaseContext.query = queryItems;\n }\n if (bodyPayload !== undefined && shouldSendData) {\n supabaseContext.body = bodyPayload;\n }\n\n captureException(err, scope => {\n scope.addEventProcessor(e => {\n addExceptionMechanism(e, {\n handled: false,\n type: 'auto.db.supabase.postgres',\n });\n\n return e;\n });\n\n scope.setContext('supabase', supabaseContext);\n\n return scope;\n });\n }\n\n const breadcrumb: SupabaseBreadcrumb = {\n type: 'supabase',\n category: `db.${operation}`,\n message: description,\n };\n\n const data: Record<string, unknown> = {};\n\n if (queryItems.length && shouldSendData) {\n data.query = queryItems;\n }\n\n if (bodyPayload !== undefined && shouldSendData) {\n data.body = bodyPayload;\n }\n\n if (Object.keys(data).length) {\n breadcrumb.data = data;\n }\n\n addBreadcrumb(breadcrumb);\n\n return res;\n },\n (err: Error) => {\n // TODO: shouldn't we capture this error?\n if (span) {\n setHttpStatus(span, 500);\n span.end();\n }\n throw err;\n },\n )\n .then(...argumentsList);\n },\n );\n },\n },\n );\n\n markAsInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then);\n}\n\nfunction instrumentPostgRESTQueryBuilder(\n PostgRESTQueryBuilder: new () => PostgRESTQueryBuilder,\n _options: { sendOperationData?: boolean },\n): void {\n // We need to wrap _all_ operations despite them sharing the same `PostgRESTFilterBuilder`\n // constructor, as we don't know which method will be called first, and we don't want to miss any calls.\n for (const operation of DB_OPERATIONS_TO_INSTRUMENT) {\n if (isInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation])) {\n continue;\n }\n\n type PostgRESTOperation = keyof Pick<PostgRESTQueryBuilder, 'select' | 'insert' | 'upsert' | 'update' | 'delete'>;\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation] = new Proxy(\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation],\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTFilterBuilder = (rv as PostgRESTFilterBuilder).constructor;\n\n DEBUG_BUILD && debug.log(`Instrumenting ${operation} operation's PostgRESTFilterBuilder`);\n\n instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder, _options);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation]);\n }\n}\n\nexport const instrumentSupabaseClient = (\n supabaseClient: unknown,\n options: { sendOperationData?: boolean } = {},\n): void => {\n if (!supabaseClient) {\n DEBUG_BUILD && debug.warn('Supabase integration was not installed because no Supabase client was provided.');\n return;\n }\n const SupabaseClientConstructor =\n supabaseClient.constructor === Function ? supabaseClient : supabaseClient.constructor;\n\n instrumentSupabaseClientConstructor(SupabaseClientConstructor, options);\n instrumentSupabaseAuthClient(supabaseClient as SupabaseClientInstance);\n};\n\ninterface SupabaseIntegrationOptions {\n supabaseClient: any;\n /**\n * Whether to attach PostgREST query filters and mutation body payloads\n * to Sentry telemetry.\n *\n * Falls back to `dataCollection.databaseQueryData` when not set.\n * @default undefined\n */\n sendOperationData?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Supabase' as const;\n\nconst _supabaseIntegration = ((supabaseClient: unknown, options: { sendOperationData?: boolean }) => {\n return {\n setupOnce() {\n instrumentSupabaseClient(supabaseClient, options);\n },\n name: INTEGRATION_NAME,\n };\n}) satisfies IntegrationFn;\n\nexport const supabaseIntegration = defineIntegration((options: SupabaseIntegrationOptions) => {\n return _supabaseIntegration(options.supabaseClient, { sendOperationData: options.sendOperationData });\n}) satisfies IntegrationFn;\n"],"names":["startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","isObjectLike","SPAN_STATUS_ERROR","captureException","SPAN_STATUS_OK","isPlainObject","getClient","setHttpStatus","addExceptionMechanism","addBreadcrumb","DEBUG_BUILD","debug","defineIntegration"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAM,6BAAA,GAAgC;AAAA,EACpC,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,iBAAA;AAAA,EACA,mBAAA;AAAA,EACA,eAAA;AAAA,EACA,oBAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA;AAEA,MAAM,mCAAA,GAAsC;AAAA,EAC1C,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA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ase.js","sources":["../../../src/integrations/supabase.ts"],"sourcesContent":["// Based on Kamil Ogórek's work on:\n// https://github.com/supabase-community/sentry-integration-js\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable max-lines */\nimport { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { captureException } from '../exports';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport { setHttpStatus, SPAN_STATUS_ERROR, SPAN_STATUS_OK, startSpan } from '../tracing';\nimport type { IntegrationFn } from '../types/integration';\nimport type { WebFetchHeaders } from '../types/webfetchapi';\nimport { debug } from '../utils/debug-logger';\nimport { isObjectLike, isPlainObject } from '../utils/is';\nimport { addExceptionMechanism } from '../utils/misc';\n\nconst AUTH_OPERATIONS_TO_INSTRUMENT = [\n 'reauthenticate',\n 'signInAnonymously',\n 'signInWithOAuth',\n 'signInWithIdToken',\n 'signInWithOtp',\n 'signInWithPassword',\n 'signInWithSSO',\n 'signOut',\n 'signUp',\n 'verifyOtp',\n];\n\nconst AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT = [\n 'createUser',\n 'deleteUser',\n 'listUsers',\n 'getUserById',\n 'updateUserById',\n 'inviteUserByEmail',\n];\n\nexport const FILTER_MAPPINGS = {\n eq: 'eq',\n neq: 'neq',\n gt: 'gt',\n gte: 'gte',\n lt: 'lt',\n lte: 'lte',\n like: 'like',\n 'like(all)': 'likeAllOf',\n 'like(any)': 'likeAnyOf',\n ilike: 'ilike',\n 'ilike(all)': 'ilikeAllOf',\n 'ilike(any)': 'ilikeAnyOf',\n is: 'is',\n in: 'in',\n cs: 'contains',\n cd: 'containedBy',\n sr: 'rangeGt',\n nxl: 'rangeGte',\n sl: 'rangeLt',\n nxr: 'rangeLte',\n adj: 'rangeAdjacent',\n ov: 'overlaps',\n fts: '',\n plfts: 'plain',\n phfts: 'phrase',\n wfts: 'websearch',\n not: 'not',\n};\n\nexport const DB_OPERATIONS_TO_INSTRUMENT = ['select', 'insert', 'upsert', 'update', 'delete'];\n\ntype AuthOperationFn = (...args: unknown[]) => Promise<unknown>;\ntype AuthOperationName = (typeof AUTH_OPERATIONS_TO_INSTRUMENT)[number];\ntype AuthAdminOperationName = (typeof AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT)[number];\ntype PostgRESTQueryOperationFn = (...args: unknown[]) => PostgRESTFilterBuilder;\n\nexport interface SupabaseClientInstance {\n auth: {\n admin: Record<AuthAdminOperationName, AuthOperationFn>;\n } & Record<AuthOperationName, AuthOperationFn>;\n}\n\nexport interface PostgRESTQueryBuilder {\n [key: string]: PostgRESTQueryOperationFn;\n}\n\n/**\n * `postgrest-js` stores the request headers as a plain object up to v1.19.x and as a `Headers`\n * instance from v2.74.0 on (shipped with `supabase-js` 2.74.0), so we have to handle both shapes.\n */\nexport type PostgRESTHeaders = Record<string, string> | WebFetchHeaders;\n\nexport interface PostgRESTFilterBuilder {\n method: string;\n headers: PostgRESTHeaders;\n url: URL;\n schema: string;\n body: any;\n}\n\nexport interface SupabaseResponse {\n status?: number;\n error?: {\n message: string;\n code?: string;\n details?: unknown;\n };\n}\n\nexport interface SupabaseError extends Error {\n code?: string;\n details?: unknown;\n}\n\nexport interface SupabaseBreadcrumb {\n type: string;\n category: string;\n message: string;\n data?: {\n query?: string[];\n body?: Record<string, unknown>;\n };\n}\n\nexport interface SupabaseClientConstructor {\n prototype: {\n from: (table: string) => PostgRESTQueryBuilder;\n };\n}\n\nexport interface PostgRESTProtoThenable {\n then: <T>(\n onfulfilled?: ((value: T) => T | PromiseLike<T>) | null,\n onrejected?: ((reason: any) => T | PromiseLike<T>) | null,\n ) => Promise<T>;\n}\n\ntype SentryInstrumented<T> = T & {\n __SENTRY_INSTRUMENTED__?: boolean;\n};\n\nfunction markAsInstrumented<T>(fn: T): void {\n try {\n (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__ = true;\n } catch {\n // ignore errors here\n }\n}\n\nfunction isInstrumented<T>(fn: T): boolean | undefined {\n try {\n return (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__;\n } catch {\n return false;\n }\n}\n\n/**\n * Plain-object bodies are copied into `plainBody`; array inserts (and other non-plain shapes) stay only on `rawBody`.\n * Returns a payload suitable for span attributes / breadcrumbs when operation data collection is enabled.\n */\nfunction getMutationBodyPayloadForTelemetry(rawBody: unknown, plainBody: Record<string, unknown>): unknown | undefined {\n if (Object.keys(plainBody).length > 0) {\n return plainBody;\n }\n if (Array.isArray(rawBody) && rawBody.length > 0) {\n return rawBody;\n }\n return undefined;\n}\n\n/** True when the PostgREST builder carries a mutation body (for `insert(...)`, etc. in span descriptions). */\nfunction hasMutationBodyForDescription(rawBody: unknown, plainBody: Record<string, unknown>): boolean {\n return getMutationBodyPayloadForTelemetry(rawBody, plainBody) !== undefined;\n}\n\n/**\n * Reads a header off a PostgREST builder, regardless of whether it holds a plain object or a\n * `Headers` instance. Lookup is case-insensitive because `Headers` lower-cases all of its keys.\n * @param headers - The request headers\n * @param name - The header name to look up\n * @returns The header value, or `undefined` if it is not set\n */\nexport function getHeader(headers: PostgRESTHeaders | undefined, name: string): string | undefined {\n if (!headers) {\n return undefined;\n }\n\n if (typeof (headers as WebFetchHeaders).get === 'function') {\n return (headers as WebFetchHeaders).get(name) ?? undefined;\n }\n\n const plainHeaders = headers as Record<string, string>;\n const lowerCaseName = name.toLowerCase();\n const key = Object.keys(plainHeaders).find(headerName => headerName.toLowerCase() === lowerCaseName);\n\n return key !== undefined ? plainHeaders[key] : undefined;\n}\n\n/**\n * Extracts the database operation type from the HTTP method and headers\n * @param method - The HTTP method of the request\n * @param headers - The request headers\n * @returns The database operation type ('select', 'insert', 'upsert', 'update', or 'delete')\n */\nexport function extractOperation(method: string, headers: PostgRESTHeaders = {}): string {\n switch (method) {\n case 'GET': {\n return 'select';\n }\n case 'POST': {\n if (getHeader(headers, 'Prefer')?.includes('resolution=')) {\n return 'upsert';\n } else {\n return 'insert';\n }\n }\n case 'PATCH': {\n return 'update';\n }\n case 'DELETE': {\n return 'delete';\n }\n default: {\n return '<unknown-op>';\n }\n }\n}\n\n/**\n * Translates Supabase filter parameters into readable method names for tracing\n * @param key - The filter key from the URL search parameters\n * @param query - The filter value from the URL search parameters\n * @returns A string representation of the filter as a method call\n */\nexport function translateFiltersIntoMethods(key: string, query: string): string {\n if (query === '' || query === '*') {\n return 'select(*)';\n }\n\n if (key === 'select') {\n return `select(${query})`;\n }\n\n if (key === 'or' || key.endsWith('.or')) {\n return `${key}${query}`;\n }\n\n const [filter, ...value] = query.split('.');\n\n let method;\n // Handle optional `configPart` of the filter\n if (filter?.startsWith('fts')) {\n method = 'textSearch';\n } else if (filter?.startsWith('plfts')) {\n method = 'textSearch[plain]';\n } else if (filter?.startsWith('phfts')) {\n method = 'textSearch[phrase]';\n } else if (filter?.startsWith('wfts')) {\n method = 'textSearch[websearch]';\n } else {\n method = (filter && FILTER_MAPPINGS[filter as keyof typeof FILTER_MAPPINGS]) || 'filter';\n }\n\n return `${method}(${key}, ${value.join('.')})`;\n}\n\nfunction instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): AuthOperationFn {\n return new Proxy(operation, {\n apply(target, thisArg, argumentsList) {\n return startSpan(\n {\n name: `auth ${isAdmin ? '(admin) ' : ''}${operation.name}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n 'db.system': 'postgresql',\n 'db.operation': `auth.${isAdmin ? 'admin.' : ''}${operation.name}`,\n },\n },\n span => {\n return Reflect.apply(target, thisArg, argumentsList)\n .then((res: unknown) => {\n if (isObjectLike(res) && 'error' in res && res.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n\n captureException(res.error, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n } else {\n span.setStatus({ code: SPAN_STATUS_OK });\n }\n\n span.end();\n return res;\n })\n .catch((err: unknown) => {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n span.end();\n\n captureException(err, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n\n throw err;\n })\n .then(...argumentsList);\n },\n );\n },\n });\n}\n\nfunction instrumentSupabaseAuthClient(supabaseClientInstance: SupabaseClientInstance): void {\n const auth = supabaseClientInstance.auth;\n\n if (!auth || isInstrumented(supabaseClientInstance.auth)) {\n return;\n }\n\n for (const operation of AUTH_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth[operation] === 'function') {\n supabaseClientInstance.auth[operation] = instrumentAuthOperation(authOperation);\n }\n }\n\n for (const operation of AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth.admin[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth.admin[operation] === 'function') {\n supabaseClientInstance.auth.admin[operation] = instrumentAuthOperation(authOperation, true);\n }\n }\n\n markAsInstrumented(supabaseClientInstance.auth);\n}\n\nfunction instrumentSupabaseClientConstructor(SupabaseClient: unknown, _options: { sendOperationData?: boolean }): void {\n if (isInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from)) {\n return;\n }\n\n (SupabaseClient as SupabaseClientConstructor).prototype.from = new Proxy(\n (SupabaseClient as SupabaseClientConstructor).prototype.from,\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTQueryBuilder = (rv as PostgRESTQueryBuilder).constructor;\n\n instrumentPostgRESTQueryBuilder(PostgRESTQueryBuilder as unknown as new () => PostgRESTQueryBuilder, _options);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from);\n}\n\nfunction instrumentPostgRESTFilterBuilder(\n PostgRESTFilterBuilder: PostgRESTFilterBuilder['constructor'],\n _options: { sendOperationData?: boolean },\n): void {\n if (isInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then)) {\n return;\n }\n\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then = new Proxy(\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then,\n {\n apply(target, thisArg, argumentsList) {\n const operations = DB_OPERATIONS_TO_INSTRUMENT;\n const typedThis = thisArg as PostgRESTFilterBuilder;\n const operation = extractOperation(typedThis.method, typedThis.headers);\n\n if (!operations.includes(operation)) {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n if (!typedThis?.url?.pathname || typeof typedThis.url.pathname !== 'string') {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n const pathParts = typedThis.url.pathname.split('/');\n const table = pathParts.length > 0 ? pathParts[pathParts.length - 1] : '';\n\n const queryItems: string[] = [];\n for (const [key, value] of typedThis.url.searchParams.entries()) {\n // It's possible to have multiple entries for the same key, eg. `id=eq.7&id=eq.3`,\n // so we need to use array instead of object to collect them.\n queryItems.push(translateFiltersIntoMethods(key, value));\n }\n const body: Record<string, unknown> = Object.create(null);\n if (isPlainObject(typedThis.body)) {\n for (const [key, value] of Object.entries(typedThis.body)) {\n body[key] = value;\n }\n }\n\n const client = getClient();\n const shouldSendData =\n _options.sendOperationData ?? client?.getDataCollectionOptions().databaseQueryData === true;\n const bodyPayload = getMutationBodyPayloadForTelemetry(typedThis.body, body);\n\n // Adding operation to the beginning of the description if it's not a `select` operation\n // For example, it can be an `insert` or `update` operation but the query can be `select(...)`\n // For `select` operations, we don't need repeat it in the description\n const mutationPart =\n operation === 'select'\n ? ''\n : `${operation}${hasMutationBodyForDescription(typedThis.body, body) ? '(...) ' : ''}`;\n const queryPart = shouldSendData ? queryItems.join(' ') : queryItems.length > 0 ? '[redacted]' : '';\n const descriptionMiddle = [mutationPart.trimEnd(), queryPart].filter(Boolean).join(' ');\n const description = descriptionMiddle ? `${descriptionMiddle} from(${table})` : `from(${table})`;\n\n const attributes: Record<string, any> = {\n 'db.table': table,\n 'db.schema': typedThis.schema,\n 'db.url': typedThis.url.origin,\n 'db.sdk': getHeader(typedThis.headers, 'X-Client-Info'),\n 'db.system': 'postgresql',\n 'db.operation': operation,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n };\n\n if (queryItems.length && shouldSendData) {\n attributes['db.query'] = queryItems;\n }\n\n if (bodyPayload !== undefined && shouldSendData) {\n attributes['db.body'] = bodyPayload;\n }\n\n return startSpan(\n {\n name: description,\n attributes,\n },\n span => {\n return (Reflect.apply(target, thisArg, []) as Promise<SupabaseResponse>)\n .then(\n (res: SupabaseResponse) => {\n if (span) {\n if (res && typeof res === 'object' && 'status' in res) {\n setHttpStatus(span, res.status || 500);\n }\n span.end();\n }\n\n if (res?.error) {\n const err = new Error(res.error.message) as SupabaseError;\n if (res.error.code) {\n err.code = res.error.code;\n }\n if (res.error.details) {\n err.details = res.error.details;\n }\n\n const supabaseContext: Record<string, any> = {};\n if (queryItems.length && shouldSendData) {\n supabaseContext.query = queryItems;\n }\n if (bodyPayload !== undefined && shouldSendData) {\n supabaseContext.body = bodyPayload;\n }\n\n captureException(err, scope => {\n scope.addEventProcessor(e => {\n addExceptionMechanism(e, {\n handled: false,\n type: 'auto.db.supabase.postgres',\n });\n\n return e;\n });\n\n scope.setContext('supabase', supabaseContext);\n\n return scope;\n });\n }\n\n const breadcrumb: SupabaseBreadcrumb = {\n type: 'supabase',\n category: `db.${operation}`,\n message: description,\n };\n\n const data: Record<string, unknown> = {};\n\n if (queryItems.length && shouldSendData) {\n data.query = queryItems;\n }\n\n if (bodyPayload !== undefined && shouldSendData) {\n data.body = bodyPayload;\n }\n\n if (Object.keys(data).length) {\n breadcrumb.data = data;\n }\n\n addBreadcrumb(breadcrumb);\n\n return res;\n },\n (err: Error) => {\n // TODO: shouldn't we capture this error?\n if (span) {\n setHttpStatus(span, 500);\n span.end();\n }\n throw err;\n },\n )\n .then(...argumentsList);\n },\n );\n },\n },\n );\n\n markAsInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then);\n}\n\nfunction instrumentPostgRESTQueryBuilder(\n PostgRESTQueryBuilder: new () => PostgRESTQueryBuilder,\n _options: { sendOperationData?: boolean },\n): void {\n // We need to wrap _all_ operations despite them sharing the same `PostgRESTFilterBuilder`\n // constructor, as we don't know which method will be called first, and we don't want to miss any calls.\n for (const operation of DB_OPERATIONS_TO_INSTRUMENT) {\n if (isInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation])) {\n continue;\n }\n\n type PostgRESTOperation = keyof Pick<PostgRESTQueryBuilder, 'select' | 'insert' | 'upsert' | 'update' | 'delete'>;\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation] = new Proxy(\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation],\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTFilterBuilder = (rv as PostgRESTFilterBuilder).constructor;\n\n DEBUG_BUILD && debug.log(`Instrumenting ${operation} operation's PostgRESTFilterBuilder`);\n\n instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder, _options);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation]);\n }\n}\n\nexport const instrumentSupabaseClient = (\n supabaseClient: unknown,\n options: { sendOperationData?: boolean } = {},\n): void => {\n if (!supabaseClient) {\n DEBUG_BUILD && debug.warn('Supabase integration was not installed because no Supabase client was provided.');\n return;\n }\n const SupabaseClientConstructor =\n supabaseClient.constructor === Function ? supabaseClient : supabaseClient.constructor;\n\n instrumentSupabaseClientConstructor(SupabaseClientConstructor, options);\n instrumentSupabaseAuthClient(supabaseClient as SupabaseClientInstance);\n};\n\ninterface SupabaseIntegrationOptions {\n supabaseClient: any;\n /**\n * Whether to attach PostgREST query filters and mutation body payloads\n * to Sentry telemetry.\n *\n * Falls back to `dataCollection.databaseQueryData` when not set.\n * @default undefined\n */\n sendOperationData?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Supabase' as const;\n\nconst _supabaseIntegration = ((supabaseClient: unknown, options: { sendOperationData?: boolean }) => {\n return {\n setupOnce() {\n instrumentSupabaseClient(supabaseClient, options);\n },\n name: INTEGRATION_NAME,\n };\n}) satisfies IntegrationFn;\n\nexport const supabaseIntegration = defineIntegration((options: SupabaseIntegrationOptions) => {\n return _supabaseIntegration(options.supabaseClient, { sendOperationData: options.sendOperationData });\n}) satisfies IntegrationFn;\n"],"names":["startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","isObjectLike","SPAN_STATUS_ERROR","captureException","SPAN_STATUS_OK","isPlainObject","getClient","setHttpStatus","addExceptionMechanism","addBreadcrumb","DEBUG_BUILD","debug","defineIntegration"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,6BAAA,GAAgC;AAAA,EACpC,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,iBAAA;AAAA,EACA,mBAAA;AAAA,EACA,eAAA;AAAA,EACA,oBAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA;AAEA,MAAM,mCAAA,GAAsC;AAAA,EAC1C,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF,CAAA;AAEO,MAAM,eAAA,GAAkB;AAAA,EAC7B,EAAA,EAAI,IAAA;AAAA,EACJ,GAAA,EAAK,KAAA;AAAA,EACL,EAAA,EAAI,IAAA;AAAA,EACJ,GAAA,EAAK,KAAA;AAAA,EACL,EAAA,EAAI,IAAA;AAAA,EACJ,GAAA,EAAK,KAAA;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KAA6C;AACnG,EAAA,OAAO;AAAA,IACL,SAAA,GAAY;AACV,MAAA,wBAAA,CAAyB,gBAAgB,OAAO,CAAA;AAAA,IAClD,CAAA;AAAA,IACA,IAAA,EAAM;AAAA,GACR;AACF,CAAA,CAAA;AAEO,MAAM,mBAAA,GAAsBC,6BAAA,CAAkB,CAAC,OAAA,KAAwC;AAC5F,EAAA,OAAO,qBAAqB,OAAA,CAAQ,cAAA,EAAgB,EAAE,iBAAA,EAAmB,OAAA,CAAQ,mBAAmB,CAAA;AACtG,CAAC;;;;;;;;;;"}

@@ -1,1 +0,1 @@

{"version":3,"file":"console-integration.js","sources":["../../../src/logs/console-integration.ts"],"sourcesContent":["import { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport type { ConsoleLevel } from '../types/instrument';\nimport type { IntegrationFn } from '../types/integration';\nimport { CONSOLE_LEVELS, debug } from '../utils/debug-logger';\nimport { isPlainObject } from '../utils/is';\nimport { normalize } from '../utils/normalize';\nimport { _INTERNAL_captureLog } from './internal';\nimport { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions } from './utils';\n\ninterface CaptureConsoleOptions {\n levels: ConsoleLevel[];\n}\n\nconst INTEGRATION_NAME = 'ConsoleLogs' as const;\n\nconst DEFAULT_ATTRIBUTES = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.log.console',\n};\n\nconst _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {}) => {\n const levels = options.levels || CONSOLE_LEVELS;\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const { enableLogs, normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('`enableLogs` is not enabled, ConsoleLogs integration disabled');\n return;\n }\n\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.includes(level)) {\n return;\n }\n\n const firstArg = args[0];\n const followingArgs = args.slice(1);\n\n if (level === 'assert') {\n if (!firstArg) {\n const assertionMessage =\n followingArgs.length > 0\n ? `Assertion failed: ${formatConsoleArgs(followingArgs, normalizeDepth, normalizeMaxBreadth)}`\n : 'Assertion failed';\n _INTERNAL_captureLog({ level: 'error', message: assertionMessage, attributes: DEFAULT_ATTRIBUTES });\n }\n return;\n }\n\n const isLevelLog = level === 'log';\n\n const attributes: Record<string, unknown> = { ...DEFAULT_ATTRIBUTES };\n\n if (isPlainObject(firstArg)) {\n // Object-first: extract object keys as attributes, remaining args as parameters\n Object.assign(attributes, normalize(firstArg, normalizeDepth, normalizeMaxBreadth));\n\n const remainingArgsStartIndex = typeof args[1] === 'string' ? 2 : 1;\n const remainingArgs = args.slice(remainingArgsStartIndex);\n\n remainingArgs.forEach((arg, index) => {\n attributes[`sentry.message.parameter.${index}`] = normalize(arg, normalizeDepth, normalizeMaxBreadth);\n });\n } else {\n // Fallback: template + parameters when first arg is a string without substitutions\n const shouldGenerateTemplate =\n followingArgs.length > 0 && typeof firstArg === 'string' && !hasConsoleSubstitutions(firstArg);\n\n if (shouldGenerateTemplate) {\n const templateAttrs = createConsoleTemplateAttributes(firstArg, followingArgs);\n for (const [key, value] of Object.entries(templateAttrs)) {\n attributes[key] = key.startsWith('sentry.message.parameter.')\n ? normalize(value, normalizeDepth, normalizeMaxBreadth)\n : value;\n }\n }\n }\n\n _INTERNAL_captureLog({\n level: isLevelLog ? 'info' : level,\n message: formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth),\n severityNumber: isLevelLog ? 10 : undefined,\n attributes,\n });\n });\n\n client.registerCleanup(unsubscribe);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Captures calls to the `console` API as logs in Sentry. Requires the `enableLogs` option to be enabled.\n *\n * @experimental This feature is experimental and may be changed or removed in future versions.\n *\n * By default the integration instruments `console.debug`, `console.info`, `console.warn`, `console.error`,\n * `console.log`, `console.trace`, and `console.assert`. You can use the `levels` option to customize which\n * levels are captured.\n *\n * @example\n *\n * ```ts\n * import * as Sentry from '@sentry/browser';\n *\n * Sentry.init({\n * enableLogs: true,\n * integrations: [Sentry.consoleLoggingIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleLoggingIntegration = defineIntegration(_consoleLoggingIntegration);\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","CONSOLE_LEVELS","DEBUG_BUILD","debug","addConsoleInstrumentationHandler","getClient","formatConsoleArgs","_INTERNAL_captureLog","isPlainObject","normalize","hasConsoleSubstitutions","createConsoleTemplateAttributes","defineIntegration"],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,gBAAA,GAAmB,aAAA;AAEzB,MAAM,kBAAA,GAAqB;AAAA,EACzB,CAACA,mDAAgC,GAAG;AACtC,CAAA;AAEA,MAAM,0BAAA,IAA8B,CAAC,OAAA,GAA0C,EAAC,KAAM;AACpF,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAUC,0BAAA;AAEjC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AACZ,MAAA,MAAM,EAAE,YAAY,cAAA,GAAiB,CAAA,EAAG,sBAAsB,GAAA,EAAM,GAAI,OAAO,UAAA,EAAW;AAC1F,MAAA,IAAI,CAAC,UAAA,EAAY;AACf,QAAAC,sBAAA,IAAeC,iBAAA,CAAM,KAAK,+DAA+D,CAAA;AACzF,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,cAAcC,wCAAA,CAAiC,CAAC,EAAE,IAAA,EAAM,OAAM,KAAM;AACxE,QAAA,IAAIC,yBAAU,KAAM,MAAA,IAAU,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AACrD,UAAA;AAAA,QACF;AAEA,QAAA,MAAM,QAAA,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AA,IAAI,sBAAA,EAAwB;AAC1B,YAAA,MAAM,aAAA,GAAgBC,qCAAA,CAAgC,QAAA,EAAU,aAAa,CAAA;AAC7E,YAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,aAAa,CAAA,EAAG;AACxD,cAAA,UAAA,CAAW,GAAG,CAAA,GAAI,GAAA,CAAI,UAAA,CAAW,2BAA2B,IACxDF,mBAAA,CAAU,KAAA,EAAO,cAAA,EAAgB,mBAAmB,CAAA,GACpD,KAAA;AAAA,YACN;AAAA,UACF;AAAA,QACF;AAEA,QAAAF,6BAAA,CAAqB;AAAA,UACnB,KAAA,EAAO,aAAa,MAAA,GAAS,KAAA;AAAA,UAC7B,OAAA,EAASD,uBAAA,CAAkB,IAAA,EAAM,cAAA,EAAgB,mBAAmB,CAAA;AAAA,UACpE,cAAA,EAAgB,aAAa,EAAA,GAAK,MAAA;AAAA,UAClC;AAAA,SACD,CAAA;AAAA,MACH,CAAC,CAAA;AAED,MAAA,MAAA,CAAO,gBAAgB,WAAW,CAAA;AAAA,IACpC;AAAA,GACF;AACF,CAAA,CAAA;AAsBO,MAAM,yBAAA,GAA4BM,8BAAkB,0BAA0B;;;;"}
{"version":3,"file":"console-integration.js","sources":["../../../src/logs/console-integration.ts"],"sourcesContent":["import { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport type { ConsoleLevel } from '../types/instrument';\nimport type { IntegrationFn } from '../types/integration';\nimport { CONSOLE_LEVELS, debug } from '../utils/debug-logger';\nimport { isPlainObject } from '../utils/is';\nimport { normalize } from '../utils/normalize';\nimport { _INTERNAL_captureLog } from './internal';\nimport { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions } from './utils';\n\ninterface CaptureConsoleOptions {\n levels: ConsoleLevel[];\n}\n\nconst INTEGRATION_NAME = 'ConsoleLogs' as const;\n\nconst DEFAULT_ATTRIBUTES = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.log.console',\n};\n\nconst _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {}) => {\n const levels = options.levels || CONSOLE_LEVELS;\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const { enableLogs, normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('`enableLogs` is not enabled, ConsoleLogs integration disabled');\n return;\n }\n\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.includes(level)) {\n return;\n }\n\n const firstArg = args[0];\n const followingArgs = args.slice(1);\n\n if (level === 'assert') {\n if (!firstArg) {\n const assertionMessage =\n followingArgs.length > 0\n ? `Assertion failed: ${formatConsoleArgs(followingArgs, normalizeDepth, normalizeMaxBreadth)}`\n : 'Assertion failed';\n _INTERNAL_captureLog({ level: 'error', message: assertionMessage, attributes: DEFAULT_ATTRIBUTES });\n }\n return;\n }\n\n const isLevelLog = level === 'log';\n\n const attributes: Record<string, unknown> = { ...DEFAULT_ATTRIBUTES };\n\n if (isPlainObject(firstArg)) {\n // Object-first: extract object keys as attributes, remaining args as parameters\n Object.assign(attributes, normalize(firstArg, normalizeDepth, normalizeMaxBreadth));\n\n const remainingArgsStartIndex = typeof args[1] === 'string' ? 2 : 1;\n const remainingArgs = args.slice(remainingArgsStartIndex);\n\n remainingArgs.forEach((arg, index) => {\n attributes[`sentry.message.parameter.${index}`] = normalize(arg, normalizeDepth, normalizeMaxBreadth);\n });\n } else {\n // Fallback: template + parameters when first arg is a string without substitutions\n const shouldGenerateTemplate =\n followingArgs.length > 0 && typeof firstArg === 'string' && !hasConsoleSubstitutions(firstArg);\n\n if (shouldGenerateTemplate) {\n const templateAttrs = createConsoleTemplateAttributes(firstArg, followingArgs);\n for (const [key, value] of Object.entries(templateAttrs)) {\n attributes[key] = key.startsWith('sentry.message.parameter.')\n ? normalize(value, normalizeDepth, normalizeMaxBreadth)\n : value;\n }\n }\n }\n\n _INTERNAL_captureLog({\n level: isLevelLog ? 'info' : level,\n message: formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth),\n severityNumber: isLevelLog ? 10 : undefined,\n attributes,\n });\n });\n\n client.registerCleanup(unsubscribe);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Captures calls to the `console` API as logs in Sentry.\n *\n * @experimental This feature is experimental and may be changed or removed in future versions.\n *\n * By default the integration instruments `console.debug`, `console.info`, `console.warn`, `console.error`,\n * `console.log`, `console.trace`, and `console.assert`. You can use the `levels` option to customize which\n * levels are captured.\n *\n * @example\n *\n * ```ts\n * import * as Sentry from '@sentry/browser';\n *\n * Sentry.init({\n * integrations: [Sentry.consoleLoggingIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleLoggingIntegration = defineIntegration(_consoleLoggingIntegration);\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","CONSOLE_LEVELS","DEBUG_BUILD","debug","addConsoleInstrumentationHandler","getClient","formatConsoleArgs","_INTERNAL_captureLog","isPlainObject","normalize","hasConsoleSubstitutions","createConsoleTemplateAttributes","defineIntegration"],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,gBAAA,GAAmB,aAAA;AAEzB,MAAM,kBAAA,GAAqB;AAAA,EACzB,CAACA,mDAAgC,GAAG;AACtC,CAAA;AAEA,MAAM,0BAAA,IAA8B,CAAC,OAAA,GAA0C,EAAC,KAAM;AACpF,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAUC,0BAAA;AAEjC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AACZ,MAAA,MAAM,EAAE,YAAY,cAAA,GAAiB,CAAA,EAAG,sBAAsB,GAAA,EAAM,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AAA;AAExD,UAAA,aAAA,CAAc,OAAA,CAAQ,CAAC,GAAA,EAAK,KAAA,KAAU;AACpC,YAAA,UAAA,CAAW,4BAA4B,KAAK,CAAA,CAAE,IAAIA,mBAAA,CAAU,GAAA,EAAK,gBAAgB,mBAAmB,CAAA;AAAA,UACtG,CAAC,CAAA;AAAA,QACH,CAAA,MAAO;AAEL,UAAA,MAAM,sBAAA,GACJ,cAAc,MAAA,GAAS,CAAA,IAAK,OAAO,QAAA,KAAa,QAAA,IAAY,CAACC,6BAAA,CAAwB,QAAQ,CAAA;AAE/F,UAAA,IAAI,sBAAA,EAAwB;AAC1B,YAAA,MAAM,aAAA,GAAgBC,qCAAA,CAAgC,QAAA,EAAU,aAAa,CAAA;AAC7E,YAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,aAAa,CAAA,EAAG;AACxD,cAAA,UAAA,CAAW,GAAG,CAAA,GAAI,GAAA,CAAI,UAAA,CAAW,2BAA2B,IACxDF,mBAAA,CAAU,KAAA,EAAO,cAAA,EAAgB,mBAAmB,CAAA,GACpD,KAAA;AAAA,YACN;AAAA,UACF;AAAA,QACF;AAEA,QAAAF,6BAAA,CAAqB;AAAA,UACnB,KAAA,EAAO,aAAa,MAAA,GAAS,KAAA;AAAA,UAC7B,OAAA,EAASD,uBAAA,CAAkB,IAAA,EAAM,cAAA,EAAgB,mBAAmB,CAAA;AAAA,UACpE,cAAA,EAAgB,aAAa,EAAA,GAAK,MAAA;AAAA,UAClC;AAAA,SACD,CAAA;AAAA,MACH,CAAC,CAAA;AAED,MAAA,MAAA,CAAO,gBAAgB,WAAW,CAAA;AAAA,IACpC;AAAA,GACF;AACF,CAAA,CAAA;AAqBO,MAAM,yBAAA,GAA4BM,8BAAkB,0BAA0B;;;;"}

@@ -43,3 +43,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

}
const { release, environment, enableLogs = false, beforeSendLog } = client.getOptions();
const { release, environment, enableLogs = true, beforeSendLog } = client.getOptions();
if (!enableLogs) {

@@ -46,0 +46,0 @@ debugBuild.DEBUG_BUILD && debugLogger.debug.warn("logging option not enabled, log will not be captured.");

@@ -1,1 +0,1 @@

{"version":3,"file":"internal.js","sources":["../../../src/logs/internal.ts"],"sourcesContent":["import type { Attributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getGlobalSingleton } from '../carrier';\nimport type { Client } from '../client';\nimport { getClient, getCurrentScope, getIsolationScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Integration } from '../types/integration';\nimport type { Log, SerializedLog } from '../types/log';\nimport { consoleSandbox, debug } from '../utils/debug-logger';\nimport { isParameterizedString } from '../utils/is';\nimport { getCombinedScopeData } from '../utils/scopeData';\nimport { _getSpanForScope } from '../utils/spanOnScope';\nimport { timestampInSeconds } from '../utils/time';\nimport { getSequenceAttribute } from '../utils/timestampSequence';\nimport { _getTraceInfoFromScope } from '../utils/trace-info';\nimport { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';\nimport { createLogEnvelope } from './envelope';\n\nconst MAX_LOG_BUFFER_SIZE = 100;\n\n/**\n * Sets a log attribute if the value exists and the attribute key is not already present.\n *\n * @param logAttributes - The log attributes object to modify.\n * @param key - The attribute key to set.\n * @param value - The value to set (only sets if truthy and key not present).\n * @param setEvenIfPresent - Whether to set the attribute if it is present. Defaults to true.\n */\nfunction setLogAttribute(\n logAttributes: Record<string, unknown>,\n key: string,\n value: unknown,\n setEvenIfPresent = true,\n): void {\n if (value && (!logAttributes[key] || setEvenIfPresent)) {\n logAttributes[key] = value;\n }\n}\n\n/**\n * Captures a serialized log event and adds it to the log buffer for the given client.\n *\n * @param client - A client. Uses the current client if not provided.\n * @param serializedLog - The serialized log event to capture.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureSerializedLog(client: Client, serializedLog: SerializedLog): void {\n const bufferMap = _getBufferMap();\n const logBuffer = _INTERNAL_getLogBuffer(client);\n\n if (logBuffer === undefined) {\n bufferMap.set(client, [serializedLog]);\n } else {\n if (logBuffer.length >= MAX_LOG_BUFFER_SIZE) {\n _INTERNAL_flushLogsBuffer(client, logBuffer);\n bufferMap.set(client, [serializedLog]);\n } else {\n bufferMap.set(client, [...logBuffer, serializedLog]);\n }\n }\n}\n\n/**\n * Captures a log event and sends it to Sentry.\n *\n * @param log - The log event to capture.\n * @param scope - A scope. Uses the current scope if not provided.\n * @param client - A client. Uses the current client if not provided.\n * @param captureSerializedLog - A function to capture the serialized log.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureLog(\n beforeLog: Log,\n currentScope = getCurrentScope(),\n captureSerializedLog: (client: Client, log: SerializedLog) => void = _INTERNAL_captureSerializedLog,\n): void {\n const client = currentScope?.getClient() ?? getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No client available to capture log.');\n return;\n }\n\n const { release, environment, enableLogs = false, beforeSendLog } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('logging option not enabled, log will not be captured.');\n return;\n }\n\n const [, traceContext] = _getTraceInfoFromScope(client, currentScope);\n\n const processedLogAttributes = {\n ...beforeLog.attributes,\n };\n\n const {\n user: { id, email, username },\n attributes: scopeAttributes = {},\n } = getCombinedScopeData(getIsolationScope(), currentScope);\n\n setLogAttribute(processedLogAttributes, 'user.id', id, false);\n setLogAttribute(processedLogAttributes, 'user.email', email, false);\n setLogAttribute(processedLogAttributes, 'user.name', username, false);\n\n setLogAttribute(processedLogAttributes, 'sentry.release', release);\n setLogAttribute(processedLogAttributes, 'sentry.environment', environment);\n\n const { name, version } = client.getSdkMetadata()?.sdk ?? {};\n setLogAttribute(processedLogAttributes, 'sentry.sdk.name', name);\n setLogAttribute(processedLogAttributes, 'sentry.sdk.version', version);\n\n const replay = client.getIntegrationByName<\n Integration & {\n getReplayId: (onlyIfSampled?: boolean) => string;\n getRecordingMode: () => 'session' | 'buffer' | undefined;\n }\n >('Replay');\n\n const replayId = replay?.getReplayId(true);\n setLogAttribute(processedLogAttributes, 'sentry.replay_id', replayId);\n\n if (replayId && replay?.getRecordingMode() === 'buffer') {\n // We send this so we can identify cases where the replayId is attached but the replay itself might not have been sent to Sentry\n setLogAttribute(processedLogAttributes, 'sentry._internal.replay_is_buffering', true);\n }\n\n const beforeLogMessage = beforeLog.message;\n if (isParameterizedString(beforeLogMessage)) {\n const { __sentry_template_string__, __sentry_template_values__ = [] } = beforeLogMessage;\n if (__sentry_template_values__?.length) {\n processedLogAttributes['sentry.message.template'] = __sentry_template_string__;\n }\n __sentry_template_values__.forEach((param, index) => {\n processedLogAttributes[`sentry.message.parameter.${index}`] = param;\n });\n }\n\n const span = _getSpanForScope(currentScope);\n // Add the parent span ID to the log attributes for trace context\n setLogAttribute(processedLogAttributes, 'sentry.trace.parent_span_id', span?.spanContext().spanId);\n\n const processedLog = { ...beforeLog, attributes: processedLogAttributes };\n\n client.emit('beforeCaptureLog', processedLog);\n\n // We need to wrap this in `consoleSandbox` to avoid recursive calls to `beforeSendLog`\n const log = beforeSendLog ? consoleSandbox(() => beforeSendLog(processedLog)) : processedLog;\n if (!log) {\n client.recordDroppedEvent('before_send', 'log_item', 1);\n DEBUG_BUILD && debug.warn('beforeSendLog returned null, log will not be captured.');\n return;\n }\n\n const { level, message, attributes: logAttributes = {}, severityNumber } = log;\n\n const timestamp = timestampInSeconds();\n const sequenceAttr = getSequenceAttribute(timestamp);\n\n const serializedLog: SerializedLog = {\n timestamp,\n level,\n body: _removeLoneSurrogates(String(message)),\n trace_id: traceContext?.trace_id,\n severity_number: severityNumber ?? SEVERITY_TEXT_TO_SEVERITY_NUMBER[level],\n attributes: sanitizeLogAttributes({\n ...serializeAttributes(scopeAttributes),\n ...serializeAttributes(logAttributes, true),\n [sequenceAttr.key]: sequenceAttr.value,\n }),\n };\n\n captureSerializedLog(client, serializedLog);\n\n client.emit('afterCaptureLog', log);\n}\n\n/**\n * Flushes the logs buffer to Sentry.\n *\n * @param client - A client.\n * @param maybeLogBuffer - A log buffer. Uses the log buffer for the given client if not provided.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_flushLogsBuffer(client: Client, maybeLogBuffer?: Array<SerializedLog>): void {\n const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];\n if (logBuffer.length === 0) {\n return;\n }\n\n const clientOptions = client.getOptions();\n const envelope = createLogEnvelope(\n logBuffer,\n clientOptions._metadata,\n clientOptions.tunnel,\n client.getDsn(),\n client.getDataCollectionOptions().userInfo,\n );\n\n // Clear the log buffer after envelopes have been constructed.\n _getBufferMap().set(client, []);\n\n client.emit('flushLogs');\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n\n/**\n * Returns the log buffer for a given client.\n *\n * Exported for testing purposes.\n *\n * @param client - The client to get the log buffer for.\n * @returns The log buffer for the given client.\n */\nexport function _INTERNAL_getLogBuffer(client: Client): Array<SerializedLog> | undefined {\n return _getBufferMap().get(client);\n}\n\nfunction _getBufferMap(): WeakMap<Client, Array<SerializedLog>> {\n // The reference to the Client <> LogBuffer map is stored on the carrier to ensure it's always the same\n return getGlobalSingleton('clientToLogBufferMap', () => new WeakMap<Client, Array<SerializedLog>>());\n}\n\n/**\n * Sanitizes serialized log attributes by replacing lone surrogates in both\n * keys and string values with U+FFFD.\n */\nfunction sanitizeLogAttributes(attributes: Attributes): Attributes {\n const sanitized: Attributes = {};\n for (const [key, attr] of Object.entries(attributes)) {\n const sanitizedKey = _removeLoneSurrogates(key);\n if (attr.type === 'string') {\n sanitized[sanitizedKey] = { ...attr, value: _removeLoneSurrogates(attr.value) };\n } else {\n sanitized[sanitizedKey] = attr;\n }\n }\n return sanitized;\n}\n\n/**\n * Replaces unpaired UTF-16 surrogates with U+FFFD (replacement character).\n *\n * Lone surrogates (U+D800–U+DFFF not part of a valid pair) cause `serde_json`\n * on the server to reject the entire log batch when they appear in\n * JSON-escaped form (e.g. `\\uD800`). Replacing them at the SDK level ensures\n * only the offending characters are lost instead of the whole payload.\n *\n * Uses the native `String.prototype.toWellFormed()` when available\n * (Node 20+, Chrome 111+, Safari 15.4+, Firefox 119+, Hermes).\n * On older runtimes without native support, returns the string as-is.\n *\n * Exported for testing\n */\nexport function _removeLoneSurrogates(str: string): string {\n // isWellFormed/toWellFormed are ES2024 (not in our TS lib target), so we feature-detect via Object().\n const strObj: Record<string, Function> = Object(str);\n const isWellFormed = strObj['isWellFormed'];\n const toWellFormed = strObj['toWellFormed'];\n if (typeof isWellFormed === 'function' && typeof toWellFormed === 'function') {\n return isWellFormed.call(str) ? str : toWellFormed.call(str);\n }\n return str;\n}\n"],"names":["getCurrentScope","getClient","DEBUG_BUILD","debug","_getTraceInfoFromScope","getCombinedScopeData","getIsolationScope","isParameterizedString","_getSpanForScope","consoleSandbox","timestampInSeconds","getSequenceAttribute","SEVERITY_TEXT_TO_SEVERITY_NUMBER","serializeAttributes","envelope","createLogEnvelope","getGlobalSingleton"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,mBAAA,GAAsB,GAAA;AAU5B,SAAS,eAAA,CACP,aAAA,EACA,GAAA,EACA,KAAA,EACA,mBAAmB,IAAA,EACb;AACN,EAAA,IAAI,KAAA,KAAU,CAAC,aAAA,CAAc,GAAG,KAAK,gBAAA,CAAA,EAAmB;AACtD,IAAA,aAAA,CAAc,GAAG,CAAA,GAAI,KAAA;AAAA,EACvB;AACF;AAWO,SAAS,8BAAA,CAA+B,QAAgB,aAAA,EAAoC;AACjG,EAAA,MAAM,YAAY,aAAA,EAAc;AAChC,EAAA,MAAM,SAAA,GAAY,uBAAuB,MAAM,CAAA;AAE/C,EAAA,IAAI,cAAc,MAAA,EAAW;AAC3B,IAAA,SAAA,CAAU,GAAA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AA,IAAI,IAAA,CAAK,SAAS,QAAA,EAAU;AAC1B,MAAA,SAAA,CAAU,YAAY,IAAI,EAAE,GAAG,MAAM,KAAA,EAAO,qBAAA,CAAsB,IAAA,CAAK,KAAK,CAAA,EAAE;AAAA,IAChF,CAAA,MAAO;AACL,MAAA,SAAA,CAAU,YAAY,CAAA,GAAI,IAAA;AAAA,IAC5B;AAAA,EACF;AACA,EAAA,OAAO,SAAA;AACT;AAgBO,SAAS,sBAAsB,GAAA,EAAqB;AAEzD,EAAA,MAAM,MAAA,GAAmC,OAAO,GAAG,CAAA;AACnD,EAAA,MAAM,YAAA,GAAe,OAAO,cAAc,CAAA;AAC1C,EAAA,MAAM,YAAA,GAAe,OAAO,cAAc,CAAA;AAC1C,EAAA,IAAI,OAAO,YAAA,KAAiB,UAAA,IAAc,OAAO,iBAAiB,UAAA,EAAY;AAC5E,IAAA,OAAO,aAAa,IAAA,CAAK,GAAG,IAAI,GAAA,GAAM,YAAA,CAAa,KAAK,GAAG,CAAA;AAAA,EAC7D;AACA,EAAA,OAAO,GAAA;AACT;;;;;;;;"}
{"version":3,"file":"internal.js","sources":["../../../src/logs/internal.ts"],"sourcesContent":["import type { Attributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getGlobalSingleton } from '../carrier';\nimport type { Client } from '../client';\nimport { getClient, getCurrentScope, getIsolationScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Integration } from '../types/integration';\nimport type { Log, SerializedLog } from '../types/log';\nimport { consoleSandbox, debug } from '../utils/debug-logger';\nimport { isParameterizedString } from '../utils/is';\nimport { getCombinedScopeData } from '../utils/scopeData';\nimport { _getSpanForScope } from '../utils/spanOnScope';\nimport { timestampInSeconds } from '../utils/time';\nimport { getSequenceAttribute } from '../utils/timestampSequence';\nimport { _getTraceInfoFromScope } from '../utils/trace-info';\nimport { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';\nimport { createLogEnvelope } from './envelope';\n\nconst MAX_LOG_BUFFER_SIZE = 100;\n\n/**\n * Sets a log attribute if the value exists and the attribute key is not already present.\n *\n * @param logAttributes - The log attributes object to modify.\n * @param key - The attribute key to set.\n * @param value - The value to set (only sets if truthy and key not present).\n * @param setEvenIfPresent - Whether to set the attribute if it is present. Defaults to true.\n */\nfunction setLogAttribute(\n logAttributes: Record<string, unknown>,\n key: string,\n value: unknown,\n setEvenIfPresent = true,\n): void {\n if (value && (!logAttributes[key] || setEvenIfPresent)) {\n logAttributes[key] = value;\n }\n}\n\n/**\n * Captures a serialized log event and adds it to the log buffer for the given client.\n *\n * @param client - A client. Uses the current client if not provided.\n * @param serializedLog - The serialized log event to capture.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureSerializedLog(client: Client, serializedLog: SerializedLog): void {\n const bufferMap = _getBufferMap();\n const logBuffer = _INTERNAL_getLogBuffer(client);\n\n if (logBuffer === undefined) {\n bufferMap.set(client, [serializedLog]);\n } else {\n if (logBuffer.length >= MAX_LOG_BUFFER_SIZE) {\n _INTERNAL_flushLogsBuffer(client, logBuffer);\n bufferMap.set(client, [serializedLog]);\n } else {\n bufferMap.set(client, [...logBuffer, serializedLog]);\n }\n }\n}\n\n/**\n * Captures a log event and sends it to Sentry.\n *\n * @param log - The log event to capture.\n * @param scope - A scope. Uses the current scope if not provided.\n * @param client - A client. Uses the current client if not provided.\n * @param captureSerializedLog - A function to capture the serialized log.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureLog(\n beforeLog: Log,\n currentScope = getCurrentScope(),\n captureSerializedLog: (client: Client, log: SerializedLog) => void = _INTERNAL_captureSerializedLog,\n): void {\n const client = currentScope?.getClient() ?? getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No client available to capture log.');\n return;\n }\n\n const { release, environment, enableLogs = true, beforeSendLog } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('logging option not enabled, log will not be captured.');\n return;\n }\n\n const [, traceContext] = _getTraceInfoFromScope(client, currentScope);\n\n const processedLogAttributes = {\n ...beforeLog.attributes,\n };\n\n const {\n user: { id, email, username },\n attributes: scopeAttributes = {},\n } = getCombinedScopeData(getIsolationScope(), currentScope);\n\n setLogAttribute(processedLogAttributes, 'user.id', id, false);\n setLogAttribute(processedLogAttributes, 'user.email', email, false);\n setLogAttribute(processedLogAttributes, 'user.name', username, false);\n\n setLogAttribute(processedLogAttributes, 'sentry.release', release);\n setLogAttribute(processedLogAttributes, 'sentry.environment', environment);\n\n const { name, version } = client.getSdkMetadata()?.sdk ?? {};\n setLogAttribute(processedLogAttributes, 'sentry.sdk.name', name);\n setLogAttribute(processedLogAttributes, 'sentry.sdk.version', version);\n\n const replay = client.getIntegrationByName<\n Integration & {\n getReplayId: (onlyIfSampled?: boolean) => string;\n getRecordingMode: () => 'session' | 'buffer' | undefined;\n }\n >('Replay');\n\n const replayId = replay?.getReplayId(true);\n setLogAttribute(processedLogAttributes, 'sentry.replay_id', replayId);\n\n if (replayId && replay?.getRecordingMode() === 'buffer') {\n // We send this so we can identify cases where the replayId is attached but the replay itself might not have been sent to Sentry\n setLogAttribute(processedLogAttributes, 'sentry._internal.replay_is_buffering', true);\n }\n\n const beforeLogMessage = beforeLog.message;\n if (isParameterizedString(beforeLogMessage)) {\n const { __sentry_template_string__, __sentry_template_values__ = [] } = beforeLogMessage;\n if (__sentry_template_values__?.length) {\n processedLogAttributes['sentry.message.template'] = __sentry_template_string__;\n }\n __sentry_template_values__.forEach((param, index) => {\n processedLogAttributes[`sentry.message.parameter.${index}`] = param;\n });\n }\n\n const span = _getSpanForScope(currentScope);\n // Add the parent span ID to the log attributes for trace context\n setLogAttribute(processedLogAttributes, 'sentry.trace.parent_span_id', span?.spanContext().spanId);\n\n const processedLog = { ...beforeLog, attributes: processedLogAttributes };\n\n client.emit('beforeCaptureLog', processedLog);\n\n // We need to wrap this in `consoleSandbox` to avoid recursive calls to `beforeSendLog`\n const log = beforeSendLog ? consoleSandbox(() => beforeSendLog(processedLog)) : processedLog;\n if (!log) {\n client.recordDroppedEvent('before_send', 'log_item', 1);\n DEBUG_BUILD && debug.warn('beforeSendLog returned null, log will not be captured.');\n return;\n }\n\n const { level, message, attributes: logAttributes = {}, severityNumber } = log;\n\n const timestamp = timestampInSeconds();\n const sequenceAttr = getSequenceAttribute(timestamp);\n\n const serializedLog: SerializedLog = {\n timestamp,\n level,\n body: _removeLoneSurrogates(String(message)),\n trace_id: traceContext?.trace_id,\n severity_number: severityNumber ?? SEVERITY_TEXT_TO_SEVERITY_NUMBER[level],\n attributes: sanitizeLogAttributes({\n ...serializeAttributes(scopeAttributes),\n ...serializeAttributes(logAttributes, true),\n [sequenceAttr.key]: sequenceAttr.value,\n }),\n };\n\n captureSerializedLog(client, serializedLog);\n\n client.emit('afterCaptureLog', log);\n}\n\n/**\n * Flushes the logs buffer to Sentry.\n *\n * @param client - A client.\n * @param maybeLogBuffer - A log buffer. Uses the log buffer for the given client if not provided.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_flushLogsBuffer(client: Client, maybeLogBuffer?: Array<SerializedLog>): void {\n const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];\n if (logBuffer.length === 0) {\n return;\n }\n\n const clientOptions = client.getOptions();\n const envelope = createLogEnvelope(\n logBuffer,\n clientOptions._metadata,\n clientOptions.tunnel,\n client.getDsn(),\n client.getDataCollectionOptions().userInfo,\n );\n\n // Clear the log buffer after envelopes have been constructed.\n _getBufferMap().set(client, []);\n\n client.emit('flushLogs');\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n\n/**\n * Returns the log buffer for a given client.\n *\n * Exported for testing purposes.\n *\n * @param client - The client to get the log buffer for.\n * @returns The log buffer for the given client.\n */\nexport function _INTERNAL_getLogBuffer(client: Client): Array<SerializedLog> | undefined {\n return _getBufferMap().get(client);\n}\n\nfunction _getBufferMap(): WeakMap<Client, Array<SerializedLog>> {\n // The reference to the Client <> LogBuffer map is stored on the carrier to ensure it's always the same\n return getGlobalSingleton('clientToLogBufferMap', () => new WeakMap<Client, Array<SerializedLog>>());\n}\n\n/**\n * Sanitizes serialized log attributes by replacing lone surrogates in both\n * keys and string values with U+FFFD.\n */\nfunction sanitizeLogAttributes(attributes: Attributes): Attributes {\n const sanitized: Attributes = {};\n for (const [key, attr] of Object.entries(attributes)) {\n const sanitizedKey = _removeLoneSurrogates(key);\n if (attr.type === 'string') {\n sanitized[sanitizedKey] = { ...attr, value: _removeLoneSurrogates(attr.value) };\n } else {\n sanitized[sanitizedKey] = attr;\n }\n }\n return sanitized;\n}\n\n/**\n * Replaces unpaired UTF-16 surrogates with U+FFFD (replacement character).\n *\n * Lone surrogates (U+D800–U+DFFF not part of a valid pair) cause `serde_json`\n * on the server to reject the entire log batch when they appear in\n * JSON-escaped form (e.g. `\\uD800`). Replacing them at the SDK level ensures\n * only the offending characters are lost instead of the whole payload.\n *\n * Uses the native `String.prototype.toWellFormed()` when available\n * (Node 20+, Chrome 111+, Safari 15.4+, Firefox 119+, Hermes).\n * On older runtimes without native support, returns the string as-is.\n *\n * Exported for testing\n */\nexport function _removeLoneSurrogates(str: string): string {\n // isWellFormed/toWellFormed are ES2024 (not in our TS lib target), so we feature-detect via Object().\n const strObj: Record<string, Function> = Object(str);\n const isWellFormed = strObj['isWellFormed'];\n const toWellFormed = strObj['toWellFormed'];\n if (typeof isWellFormed === 'function' && typeof toWellFormed === 'function') {\n return isWellFormed.call(str) ? str : toWellFormed.call(str);\n }\n return str;\n}\n"],"names":["getCurrentScope","getClient","DEBUG_BUILD","debug","_getTraceInfoFromScope","getCombinedScopeData","getIsolationScope","isParameterizedString","_getSpanForScope","consoleSandbox","timestampInSeconds","getSequenceAttribute","SEVERITY_TEXT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 @@

{"version":3,"file":"public-api.js","sources":["../../../src/logs/public-api.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Log, LogSeverityLevel } from '../types/log';\nimport type { ParameterizedString } from '../types/parameterize';\nimport { _INTERNAL_captureLog } from './internal';\n\n/**\n * Capture a log with the given level.\n *\n * @param level - The level of the log.\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.\n * @param scope - The scope to capture the log with.\n * @param severityNumber - The severity number of the log.\n */\nfunction captureLog(\n level: LogSeverityLevel,\n message: ParameterizedString,\n attributes?: Log['attributes'],\n scope?: Scope,\n severityNumber?: Log['severityNumber'],\n): void {\n _INTERNAL_captureLog({ level, message, attributes, severityNumber }, scope);\n}\n\n/**\n * Additional metadata to capture the log with.\n */\ninterface CaptureLogMetadata {\n scope?: Scope;\n}\n\n/**\n * @summary Capture a log with the `trace` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { userId: 100, route: '/dashboard' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.trace('User clicked submit button', {\n * buttonId: 'submit-form',\n * formId: 'user-profile',\n * timestamp: Date.now()\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.trace(Sentry.logger.fmt`User ${user} navigated to ${page}`, {\n * userId: '123',\n * sessionId: 'abc-xyz'\n * });\n * ```\n */\nexport function trace(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('trace', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `debug` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { component: 'Header', state: 'loading' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.debug('Component mounted', {\n * component: 'UserProfile',\n * props: { userId: 123 },\n * renderTime: 150\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.debug(Sentry.logger.fmt`API request to ${endpoint} failed`, {\n * statusCode: 404,\n * requestId: 'req-123',\n * duration: 250\n * });\n * ```\n */\nexport function debug(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('debug', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `info` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { feature: 'checkout', status: 'completed' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.info('User completed checkout', {\n * orderId: 'order-123',\n * amount: 99.99,\n * paymentMethod: 'credit_card'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.info(Sentry.logger.fmt`User ${user} updated profile picture`, {\n * userId: 'user-123',\n * imageSize: '2.5MB',\n * timestamp: Date.now()\n * });\n * ```\n */\nexport function info(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('info', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `warn` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { browser: 'Chrome', version: '91.0' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.warn('Browser compatibility issue detected', {\n * browser: 'Safari',\n * version: '14.0',\n * feature: 'WebRTC',\n * fallback: 'enabled'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.warn(Sentry.logger.fmt`API endpoint ${endpoint} is deprecated`, {\n * recommendedEndpoint: '/api/v2/users',\n * sunsetDate: '2024-12-31',\n * clientVersion: '1.2.3'\n * });\n * ```\n */\nexport function warn(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('warn', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `error` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { error: 'NetworkError', url: '/api/data' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.error('Failed to load user data', {\n * error: 'NetworkError',\n * url: '/api/users/123',\n * statusCode: 500,\n * retryCount: 3\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.error(Sentry.logger.fmt`Payment processing failed for order ${orderId}`, {\n * error: 'InsufficientFunds',\n * amount: 100.00,\n * currency: 'USD',\n * userId: 'user-456'\n * });\n * ```\n */\nexport function error(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('error', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `fatal` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { appState: 'corrupted', sessionId: 'abc-123' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.fatal('Application state corrupted', {\n * lastKnownState: 'authenticated',\n * sessionId: 'session-123',\n * timestamp: Date.now(),\n * recoveryAttempted: true\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.fatal(Sentry.logger.fmt`Critical system failure in ${service}`, {\n * service: 'payment-processor',\n * errorCode: 'CRITICAL_FAILURE',\n * affectedUsers: 150,\n * timestamp: Date.now()\n * });\n * ```\n */\nexport function fatal(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('fatal', message, attributes, scope);\n}\n\nexport { fmt } from '../utils/parameterize';\n"],"names":["_INTERNAL_captureLog"],"mappings":";;;;;AAcA,SAAS,UAAA,CACP,KAAA,EACA,OAAA,EACA,UAAA,EACA,OACA,cAAA,EACM;AACN,EAAAA,6BAAA,CAAqB,EAAE,KAAA,EAAO,OAAA,EAAS,UAAA,EAAY,cAAA,IAAkB,KAAK,CAAA;AAC5E;AAmCO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA6BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA6BO,SAAS,KACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,MAAA,EAAQ,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAC/C;AA8BO,SAAS,KACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,MAAA,EAAQ,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAC/C;AA+BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA+BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;;;;;;;;;;"}
{"version":3,"file":"public-api.js","sources":["../../../src/logs/public-api.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Log, LogSeverityLevel } from '../types/log';\nimport type { ParameterizedString } from '../types/parameterize';\nimport { _INTERNAL_captureLog } from './internal';\n\n/**\n * Capture a log with the given level.\n *\n * @param level - The level of the log.\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.\n * @param scope - The scope to capture the log with.\n * @param severityNumber - The severity number of the log.\n */\nfunction captureLog(\n level: LogSeverityLevel,\n message: ParameterizedString,\n attributes?: Log['attributes'],\n scope?: Scope,\n severityNumber?: Log['severityNumber'],\n): void {\n _INTERNAL_captureLog({ level, message, attributes, severityNumber }, scope);\n}\n\n/**\n * Additional metadata to capture the log with.\n */\ninterface CaptureLogMetadata {\n scope?: Scope;\n}\n\n/**\n * @summary Capture a log with the `trace` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { userId: 100, route: '/dashboard' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.trace('User clicked submit button', {\n * buttonId: 'submit-form',\n * formId: 'user-profile',\n * timestamp: Date.now()\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.trace(Sentry.logger.fmt`User ${user} navigated to ${page}`, {\n * userId: '123',\n * sessionId: 'abc-xyz'\n * });\n * ```\n */\nexport function trace(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('trace', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `debug` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { component: 'Header', state: 'loading' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.debug('Component mounted', {\n * component: 'UserProfile',\n * props: { userId: 123 },\n * renderTime: 150\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.debug(Sentry.logger.fmt`API request to ${endpoint} failed`, {\n * statusCode: 404,\n * requestId: 'req-123',\n * duration: 250\n * });\n * ```\n */\nexport function debug(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('debug', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `info` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { feature: 'checkout', status: 'completed' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.info('User completed checkout', {\n * orderId: 'order-123',\n * amount: 99.99,\n * paymentMethod: 'credit_card'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.info(Sentry.logger.fmt`User ${user} updated profile picture`, {\n * userId: 'user-123',\n * imageSize: '2.5MB',\n * timestamp: Date.now()\n * });\n * ```\n */\nexport function info(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('info', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `warn` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { browser: 'Chrome', version: '91.0' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.warn('Browser compatibility issue detected', {\n * browser: 'Safari',\n * version: '14.0',\n * feature: 'WebRTC',\n * fallback: 'enabled'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.warn(Sentry.logger.fmt`API endpoint ${endpoint} is deprecated`, {\n * recommendedEndpoint: '/api/v2/users',\n * sunsetDate: '2024-12-31',\n * clientVersion: '1.2.3'\n * });\n * ```\n */\nexport function warn(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('warn', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `error` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { error: 'NetworkError', url: '/api/data' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.error('Failed to load user data', {\n * error: 'NetworkError',\n * url: '/api/users/123',\n * statusCode: 500,\n * retryCount: 3\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.error(Sentry.logger.fmt`Payment processing failed for order ${orderId}`, {\n * error: 'InsufficientFunds',\n * amount: 100.00,\n * currency: 'USD',\n * userId: 'user-456'\n * });\n * ```\n */\nexport function error(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('error', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `fatal` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { appState: 'corrupted', sessionId: 'abc-123' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.fatal('Application state corrupted', {\n * lastKnownState: 'authenticated',\n * sessionId: 'session-123',\n * timestamp: Date.now(),\n * recoveryAttempted: true\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.fatal(Sentry.logger.fmt`Critical system failure in ${service}`, {\n * service: 'payment-processor',\n * errorCode: 'CRITICAL_FAILURE',\n * affectedUsers: 150,\n * timestamp: Date.now()\n * });\n * ```\n */\nexport function fatal(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('fatal', message, attributes, scope);\n}\n\nexport { fmt } from '../utils/parameterize';\n"],"names":["_INTERNAL_captureLog"],"mappings":";;;;;AAcA,SAAS,UAAA,CACP,KAAA,EACA,OAAA,EACA,UAAA,EACA,OACA,cAAA,EACM;AACN,EAAAA,6BAAA,CAAqB,EAAE,KAAA,EAAO,OAAA,EAAS,UAAA,EAAY,cAAA,IAAkB,KAAK,CAAA;AAC5E;AAmCO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA6BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA6BO,SAAS,KACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,MAAA,EAAQ,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAC/C;AA8BO,SAAS,KACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,MAAA,EAAQ,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAC/C;AA+BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA+BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;;;;;;;;;;"}

@@ -351,2 +351,5 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

* Note: The client will not be cleared.
*
* @deprecated This method will be removed in v11. To reset scope state, re-initialize the SDK or run
* your code in a fresh scope via `withScope` instead.
*/

@@ -353,0 +356,0 @@ clear() {

@@ -1,1 +0,1 @@

{"version":3,"file":"scope.js","sources":["../../src/scope.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { AttributeObject, RawAttribute, RawAttributes } from './attributes';\nimport type { Client } from './client';\nimport { DEBUG_BUILD } from './debug-build';\nimport { updateSession } from './session';\nimport type { Attachment } from './types/attachment';\nimport type { Breadcrumb } from './types/breadcrumb';\nimport type { Context, Contexts } from './types/context';\nimport type { DynamicSamplingContext } from './types/envelope';\nimport type { Event, EventHint } from './types/event';\nimport type { EventProcessor } from './types/eventprocessor';\nimport type { Extra, Extras } from './types/extra';\nimport type { Primitive } from './types/misc';\nimport type { RequestEventData } from './types/request';\nimport type { Session } from './types/session';\nimport type { SeverityLevel } from './types/severity';\nimport type { Span } from './types/span';\nimport type { PropagationContext } from './types/tracing';\nimport type { User } from './types/user';\nimport { debug } from './utils/debug-logger';\nimport { isPlainObject } from './utils/is';\nimport { merge } from './utils/merge';\nimport { uuid4 } from './utils/misc';\nimport { generateTraceId } from './utils/propagationContext';\nimport { safeMathRandom } from './utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from './utils/spanOnScope';\nimport { truncate } from './utils/string';\nimport { dateTimestampInSeconds } from './utils/time';\n\n/**\n * Default value for maximum number of breadcrumbs added to an event.\n */\nconst DEFAULT_MAX_BREADCRUMBS = 100;\n\n/**\n * A context to be used for capturing an event.\n * This can either be a Scope, or a partial ScopeContext,\n * or a callback that receives the current scope and returns a new scope to use.\n */\nexport type CaptureContext = Scope | Partial<ScopeContext> | ((scope: Scope) => Scope);\n\n/**\n * Data that can be converted to a Scope.\n */\nexport interface ScopeContext {\n user: User;\n level: SeverityLevel;\n extra: Extras;\n contexts: Contexts;\n tags: { [key: string]: Primitive };\n attributes?: RawAttributes<Record<string, unknown>>;\n fingerprint: string[];\n propagationContext: PropagationContext;\n conversationId?: string;\n}\n\nexport interface SdkProcessingMetadata {\n [key: string]: unknown;\n requestSession?: {\n status: 'ok' | 'errored' | 'crashed';\n };\n normalizedRequest?: RequestEventData;\n dynamicSamplingContext?: Partial<DynamicSamplingContext>;\n capturedSpanScope?: Scope;\n capturedSpanIsolationScope?: Scope;\n spanCountBeforeProcessing?: number;\n ipAddress?: string;\n}\n\n/**\n * Normalized data of the Scope, ready to be used.\n */\nexport interface ScopeData {\n eventProcessors: EventProcessor[];\n breadcrumbs: Breadcrumb[];\n user: User;\n tags: { [key: string]: Primitive };\n // TODO(v11): Make this a required field (could be subtly breaking if we did it today)\n attributes?: RawAttributes<Record<string, unknown>>;\n extra: Extras;\n contexts: Contexts;\n attachments: Attachment[];\n propagationContext: PropagationContext;\n sdkProcessingMetadata: SdkProcessingMetadata;\n fingerprint: string[];\n level?: SeverityLevel;\n transactionName?: string;\n span?: Span;\n conversationId?: string;\n}\n\n/**\n * Holds additional event information.\n */\nexport class Scope {\n /** Flag if notifying is happening. */\n protected _notifyingListeners: boolean;\n\n /** Callback for client to receive scope changes. */\n protected _scopeListeners: Array<(scope: Scope) => void>;\n\n /** Callback list that will be called during event processing. */\n protected _eventProcessors: EventProcessor[];\n\n /** Array of breadcrumbs. */\n protected _breadcrumbs: Breadcrumb[];\n\n /** User */\n protected _user: User;\n\n /** Tags */\n protected _tags: { [key: string]: Primitive };\n\n /** Attributes */\n protected _attributes: RawAttributes<Record<string, unknown>>;\n\n /** Extra */\n protected _extra: Extras;\n\n /** Contexts */\n protected _contexts: Contexts;\n\n /** Attachments */\n protected _attachments: Attachment[];\n\n /** Propagation Context for distributed tracing */\n protected _propagationContext: PropagationContext;\n\n /**\n * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get\n * sent to Sentry\n */\n protected _sdkProcessingMetadata: SdkProcessingMetadata;\n\n /** Fingerprint */\n protected _fingerprint?: string[];\n\n /** Severity */\n protected _level?: SeverityLevel;\n\n /**\n * Transaction Name\n *\n * IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects.\n * It's purpose is to assign a transaction to the scope that's added to non-transaction events.\n */\n protected _transactionName?: string;\n\n /** Session */\n protected _session?: Session;\n\n /** The client on this scope */\n protected _client?: Client;\n\n /** Contains the last event id of a captured event. */\n protected _lastEventId?: string;\n\n /** Conversation ID */\n protected _conversationId?: string;\n\n // NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.\n\n public constructor() {\n this._notifyingListeners = false;\n this._scopeListeners = [];\n this._eventProcessors = [];\n this._breadcrumbs = [];\n this._attachments = [];\n this._user = {};\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._contexts = {};\n this._sdkProcessingMetadata = {};\n this._propagationContext = {\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n };\n }\n\n /**\n * Clone all data from this scope into a new scope.\n */\n public clone(): Scope {\n const newScope = new Scope();\n newScope._breadcrumbs = [...this._breadcrumbs];\n newScope._tags = { ...this._tags };\n newScope._attributes = { ...this._attributes };\n newScope._extra = { ...this._extra };\n newScope._contexts = { ...this._contexts };\n if (this._contexts.flags) {\n // We need to copy the `values` array so insertions on a cloned scope\n // won't affect the original array.\n newScope._contexts.flags = {\n values: [...this._contexts.flags.values],\n };\n }\n\n newScope._user = this._user;\n newScope._level = this._level;\n newScope._session = this._session;\n newScope._transactionName = this._transactionName;\n newScope._fingerprint = this._fingerprint;\n newScope._eventProcessors = [...this._eventProcessors];\n newScope._attachments = [...this._attachments];\n newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };\n newScope._propagationContext = { ...this._propagationContext };\n newScope._client = this._client;\n newScope._lastEventId = this._lastEventId;\n newScope._conversationId = this._conversationId;\n\n _setSpanForScope(newScope, _getSpanForScope(this));\n\n return newScope;\n }\n\n /**\n * Update the client assigned to this scope.\n * Note that not every scope will have a client assigned - isolation scopes & the global scope will generally not have a client,\n * as well as manually created scopes.\n */\n public setClient(client: Client | undefined): void {\n this._client = client;\n }\n\n /**\n * Set the ID of the last captured error event.\n * This is generally only captured on the isolation scope.\n */\n public setLastEventId(lastEventId: string | undefined): void {\n this._lastEventId = lastEventId;\n }\n\n /**\n * Get the client assigned to this scope.\n */\n public getClient<C extends Client>(): C | undefined {\n return this._client as C | undefined;\n }\n\n /**\n * Get the ID of the last captured error event.\n * This is generally only available on the isolation scope.\n */\n public lastEventId(): string | undefined {\n return this._lastEventId;\n }\n\n /**\n * @inheritDoc\n */\n public addScopeListener(callback: (scope: Scope) => void): void {\n this._scopeListeners.push(callback);\n }\n\n /**\n * Add an event processor that will be called before an event is sent.\n */\n public addEventProcessor(callback: EventProcessor): this {\n this._eventProcessors.push(callback);\n return this;\n }\n\n /**\n * Set the user for this scope.\n * Set to `null` to unset the user.\n */\n public setUser(user: User | null): this {\n // If null is passed we want to unset everything, but still define keys,\n // so that later down in the pipeline any existing values are cleared.\n this._user = user || {\n email: undefined,\n id: undefined,\n ip_address: undefined,\n username: undefined,\n };\n\n if (this._session) {\n updateSession(this._session, { user });\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the user from this scope.\n */\n public getUser(): User | undefined {\n return this._user;\n }\n\n /**\n * Set the conversation ID for this scope.\n * Set to `null` to unset the conversation ID.\n */\n public setConversationId(conversationId: string | null | undefined): this {\n this._conversationId = conversationId || undefined;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set an object that will be merged into existing tags on the scope,\n * and will be sent as tags data with the event.\n */\n public setTags(tags: { [key: string]: Primitive }): this {\n this._tags = {\n ...this._tags,\n ...tags,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single tag that will be sent as tags data with the event.\n */\n public setTag(key: string, value: Primitive): this {\n return this.setTags({ [key]: value });\n }\n\n /**\n * Sets attributes onto the scope.\n *\n * These attributes are applied to logs, metrics and streamed spans.\n *\n * Supported attribute value types are `string`, `number`, `boolean`, `string[]`, `number[]` and `boolean[]`.\n *\n * @param newAttributes - The attributes to set on the scope, as key-value pairs.\n *\n * @example\n * ```typescript\n * scope.setAttributes({\n * is_admin: true,\n * payment_selection: 'credit_card',\n * render_duration: 150,\n * });\n * ```\n */\n public setAttributes<T extends Record<string, unknown>>(newAttributes: RawAttributes<T>): this {\n this._attributes = {\n ...this._attributes,\n ...newAttributes,\n };\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets an attribute onto the scope.\n *\n * These attributes are applied to logs, metrics and streamed spans.\n *\n * Supported attribute value types are `string`, `number`, `boolean`, `string[]`, `number[]` and `boolean[]`.\n *\n * @param key - The attribute key.\n * @param value - The attribute value.\n *\n * @example\n * ```typescript\n * scope.setAttribute('is_admin', true);\n * scope.setAttribute('render_duration', 150);\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public setAttribute<T extends RawAttribute<T> extends { value: any } | { unit: any } ? AttributeObject : unknown>(\n key: string,\n value: RawAttribute<T>,\n ): this {\n return this.setAttributes({ [key]: value });\n }\n\n /**\n * Removes the attribute with the given key from the scope.\n *\n * @param key - The attribute key.\n *\n * @example\n * ```typescript\n * scope.removeAttribute('is_admin');\n * ```\n */\n public removeAttribute(key: string): this {\n if (key in this._attributes) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n this._notifyScopeListeners();\n }\n return this;\n }\n\n /**\n * Set an object that will be merged into existing extra on the scope,\n * and will be sent as extra data with the event.\n */\n public setExtras(extras: Extras): this {\n this._extra = {\n ...this._extra,\n ...extras,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single key:value extra entry that will be sent as extra data with the event.\n */\n public setExtra(key: string, extra: Extra): this {\n this._extra = { ...this._extra, [key]: extra };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the fingerprint on the scope to send with the events.\n * @param {string[]} fingerprint Fingerprint to group events in Sentry.\n */\n public setFingerprint(fingerprint: string[]): this {\n this._fingerprint = fingerprint;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the level on the scope for future events.\n */\n public setLevel(level: SeverityLevel): this {\n this._level = level;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the transaction name on the scope so that the name of e.g. taken server route or\n * the page location is attached to future events.\n *\n * IMPORTANT: Calling this function does NOT change the name of the currently active\n * root span. If you want to change the name of the active root span, use\n * `Sentry.updateSpanName(rootSpan, 'new name')` instead.\n *\n * By default, the SDK updates the scope's transaction name automatically on sensible\n * occasions, such as a page navigation or when handling a new request on the server.\n */\n public setTransactionName(name?: string): this {\n this._transactionName = name;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets context data with the given name.\n * Data passed as context will be normalized. You can also pass `null` to unset the context.\n * Note that context data will not be merged - calling `setContext` will overwrite an existing context with the same key.\n */\n public setContext(key: string, context: Context | null): this {\n if (context === null) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._contexts[key];\n } else {\n this._contexts[key] = context;\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set the session for the scope.\n */\n public setSession(session?: Session): this {\n if (!session) {\n delete this._session;\n } else {\n this._session = session;\n }\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the session from the scope.\n */\n public getSession(): Session | undefined {\n return this._session;\n }\n\n /**\n * Updates the scope with provided data. Can work in three variations:\n * - plain object containing updatable attributes\n * - Scope instance that'll extract the attributes from\n * - callback function that'll receive the current scope as an argument and allow for modifications\n */\n public update(captureContext?: CaptureContext): this {\n if (!captureContext) {\n return this;\n }\n\n const scopeToMerge = typeof captureContext === 'function' ? captureContext(this) : captureContext;\n\n const scopeInstance =\n scopeToMerge instanceof Scope\n ? scopeToMerge.getScopeData()\n : isPlainObject(scopeToMerge)\n ? (captureContext as ScopeContext)\n : undefined;\n\n const {\n tags,\n attributes,\n extra,\n user,\n contexts,\n level,\n fingerprint = [],\n propagationContext,\n conversationId,\n } = scopeInstance || {};\n\n this._tags = { ...this._tags, ...tags };\n this._attributes = { ...this._attributes, ...attributes };\n this._extra = { ...this._extra, ...extra };\n this._contexts = { ...this._contexts, ...contexts };\n\n if (user && Object.keys(user).length) {\n this._user = user;\n }\n\n if (level) {\n this._level = level;\n }\n\n if (fingerprint.length) {\n this._fingerprint = fingerprint;\n }\n\n if (propagationContext) {\n this._propagationContext = propagationContext;\n }\n\n if (conversationId) {\n this._conversationId = conversationId;\n }\n\n return this;\n }\n\n /**\n * Clears the current scope and resets its properties.\n * Note: The client will not be cleared.\n */\n public clear(): this {\n // client is not cleared here on purpose!\n this._breadcrumbs = [];\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._user = {};\n this._contexts = {};\n this._level = undefined;\n this._transactionName = undefined;\n this._fingerprint = undefined;\n this._session = undefined;\n this._conversationId = undefined;\n _setSpanForScope(this, undefined);\n this._attachments = [];\n this.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Adds a breadcrumb to the scope.\n * By default, the last 100 breadcrumbs are kept.\n */\n public addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this {\n const maxCrumbs = typeof maxBreadcrumbs === 'number' ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;\n\n // No data has been changed, so don't notify scope listeners\n if (maxCrumbs <= 0) {\n return this;\n }\n\n const mergedBreadcrumb: Breadcrumb = {\n timestamp: dateTimestampInSeconds(),\n ...breadcrumb,\n // Breadcrumb messages can theoretically be infinitely large and they're held in memory so we truncate them not to leak (too much) memory\n message: breadcrumb.message ? truncate(breadcrumb.message, 2048) : breadcrumb.message,\n };\n\n this._breadcrumbs.push(mergedBreadcrumb);\n if (this._breadcrumbs.length > maxCrumbs) {\n this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);\n this._client?.recordDroppedEvent('buffer_overflow', 'log_item');\n }\n\n this._notifyScopeListeners();\n\n return this;\n }\n\n /**\n * Get the last breadcrumb of the scope.\n */\n public getLastBreadcrumb(): Breadcrumb | undefined {\n return this._breadcrumbs[this._breadcrumbs.length - 1];\n }\n\n /**\n * Clear all breadcrumbs from the scope.\n */\n public clearBreadcrumbs(): this {\n this._breadcrumbs = [];\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Add an attachment to the scope.\n */\n public addAttachment(attachment: Attachment): this {\n this._attachments.push(attachment);\n return this;\n }\n\n /**\n * Clear all attachments from the scope.\n */\n public clearAttachments(): this {\n this._attachments = [];\n return this;\n }\n\n /**\n * Get the data of this scope, which should be applied to an event during processing.\n */\n public getScopeData(): ScopeData {\n return {\n breadcrumbs: this._breadcrumbs,\n attachments: this._attachments,\n contexts: this._contexts,\n tags: this._tags,\n attributes: this._attributes,\n extra: this._extra,\n user: this._user,\n level: this._level,\n fingerprint: this._fingerprint || [],\n eventProcessors: this._eventProcessors,\n propagationContext: this._propagationContext,\n sdkProcessingMetadata: this._sdkProcessingMetadata,\n transactionName: this._transactionName,\n span: _getSpanForScope(this),\n conversationId: this._conversationId,\n };\n }\n\n /**\n * Add data which will be accessible during event processing but won't get sent to Sentry.\n */\n public setSDKProcessingMetadata(newData: SdkProcessingMetadata): this {\n this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2);\n return this;\n }\n\n /**\n * Add propagation context to the scope, used for distributed tracing\n */\n public setPropagationContext(context: PropagationContext): this {\n this._propagationContext = context;\n return this;\n }\n\n /**\n * Get propagation context from the scope, used for distributed tracing\n */\n public getPropagationContext(): PropagationContext {\n return this._propagationContext;\n }\n\n /**\n * Capture an exception for this scope.\n *\n * @returns {string} The id of the captured Sentry event.\n */\n public captureException(exception: unknown, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture exception!');\n return eventId;\n }\n\n const syntheticException = new Error('Sentry syntheticException');\n\n this._client.captureException(\n exception,\n {\n originalException: exception,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a message for this scope.\n *\n * @returns {string} The id of the captured message.\n */\n public captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture message!');\n return eventId;\n }\n\n const syntheticException = hint?.syntheticException ?? new Error(message);\n\n this._client.captureMessage(\n message,\n level,\n {\n originalException: message,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a Sentry event for this scope.\n *\n * @returns {string} The id of the captured event.\n */\n public captureEvent(event: Event, hint?: EventHint): string {\n const eventId = event.event_id || hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture event!');\n return eventId;\n }\n\n this._client.captureEvent(event, { ...hint, event_id: eventId }, this);\n\n return eventId;\n }\n\n /**\n * This will be called on every set call.\n */\n protected _notifyScopeListeners(): void {\n // We need this check for this._notifyingListeners to be able to work on scope during updates\n // If this check is not here we'll produce endless recursion when something is done with the scope\n // during the callback.\n if (!this._notifyingListeners) {\n this._notifyingListeners = true;\n this._scopeListeners.forEach(callback => {\n callback(this);\n });\n this._notifyingListeners = false;\n }\n }\n}\n"],"names":["generateTraceId","safeMathRandom","_setSpanForScope","_getSpanForScope","updateSession","isPlainObject","dateTimestampInSeconds","truncate","merge","uuid4","DEBUG_BUILD","debug"],"mappings":";;;;;;;;;;;;;;AAgCA,MAAM,uBAAA,GAA0B,GAAA;AA8DzB,MAAM,KAAA,CAAM;AAAA;AAAA,EAoEV,WAAA,GAAc;AACnB,IAAA,IAAA,CAAK,mBAAA,GAAsB,KAAA;AAC3B,IAAA,IAAA,CAAK,kBAAkB,EAAC;AACxB,IAAA,IAAA,CAAK,mBAAmB,EAAC;AACzB,IAAA,IAAA,CAAK,eAAe,EAAC;AACrB,IAAA,IAAA,CAAK,eAAe,EAAC;AACrB,IAAA,IAAA,CAAK,QAAQ,EAAC;AACd,IAAA,IAAA,CAAK,QAAQ,EAAC;AACd,IAAA,IAAA,CAAK,cAAc,EAAC;AACpB,IAAA,IAAA,CAAK,SAAS,EAAC;AACf,IAAA,IAAA,CAAK,YAAY,EAAC;AAClB,IAAA,IAAA,CAAK,yBAAyB,EAAC;AAC/B,IAAA,IAAA,CAAK,mBAAA,GAAsB;AAAA,MACzB,SAASA,kCAAA,EAAgB;AAAA,MACzB,YAAYC,gCAAA;AAAe,KAC7B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKO,KAAA,GAAe;AACpB,IAAA,MAAM,QAAA,GAAW,IAAI,KAAA,EAAM;AAC3B,IAAA,QAAA,CAAS,YAAA,GAAe,CAAC,GAA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,IACT;AAEA,IAAA,MAAM,kBAAA,GAAqB,IAAA,EAAM,kBAAA,IAAsB,IAAI,MAAM,OAAO,CAAA;AAExE,IAAA,IAAA,CAAK,OAAA,CAAQ,cAAA;AAAA,MACX,OAAA;AAAA,MACA,KAAA;AAAA,MACA;AAAA,QACE,iBAAA,EAAmB,OAAA;AAAA,QACnB,kBAAA;AAAA,QACA,GAAG,IAAA;AAAA,QACH,QAAA,EAAU;AAAA,OACZ;AAAA,MACA;AAAA,KACF;AAEA,IAAA,OAAO,OAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,YAAA,CAAa,OAAc,IAAA,EAA0B;AAC1D,IAAA,MAAM,OAAA,GAAU,KAAA,CAAM,QAAA,IAAY,IAAA,EAAM,YAAYF,UAAA,EAAM;AAE1D,IAAA,IAAI,CAAC,KAAK,OAAA,EAAS;AACjB,MAAAC,sBAAA,IAAeC,iBAAA,CAAM,KAAK,yDAAyD,CAAA;AACnF,MAAA,OAAO,OAAA;AAAA,IACT;AAEA,IAAA,IAAA,CAAK,OAAA,CAAQ,aAAa,KAAA,EAAO,EAAE,GAAG,IAAA,EAAM,QAAA,EAAU,OAAA,EAAQ,EAAG,IAAI,CAAA;AAErE,IAAA,OAAO,OAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKU,qBAAA,GAA8B;AAItC,IAAA,IAAI,CAAC,KAAK,mBAAA,EAAqB;AAC7B,MAAA,IAAA,CAAK,mBAAA,GAAsB,IAAA;AAC3B,MAAA,IAAA,CAAK,eAAA,CAAgB,QAAQ,CAAA,QAAA,KAAY;AACvC,QAAA,QAAA,CAAS,IAAI,CAAA;AAAA,MACf,CAAC,CAAA;AACD,MAAA,IAAA,CAAK,mBAAA,GAAsB,KAAA;AAAA,IAC7B;AAAA,EACF;AACF;;;;"}
{"version":3,"file":"scope.js","sources":["../../src/scope.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { AttributeObject, RawAttribute, RawAttributes } from './attributes';\nimport type { Client } from './client';\nimport { DEBUG_BUILD } from './debug-build';\nimport { updateSession } from './session';\nimport type { Attachment } from './types/attachment';\nimport type { Breadcrumb } from './types/breadcrumb';\nimport type { Context, Contexts } from './types/context';\nimport type { DynamicSamplingContext } from './types/envelope';\nimport type { Event, EventHint } from './types/event';\nimport type { EventProcessor } from './types/eventprocessor';\nimport type { Extra, Extras } from './types/extra';\nimport type { Primitive } from './types/misc';\nimport type { RequestEventData } from './types/request';\nimport type { Session } from './types/session';\nimport type { SeverityLevel } from './types/severity';\nimport type { Span } from './types/span';\nimport type { PropagationContext } from './types/tracing';\nimport type { User } from './types/user';\nimport { debug } from './utils/debug-logger';\nimport { isPlainObject } from './utils/is';\nimport { merge } from './utils/merge';\nimport { uuid4 } from './utils/misc';\nimport { generateTraceId } from './utils/propagationContext';\nimport { safeMathRandom } from './utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from './utils/spanOnScope';\nimport { truncate } from './utils/string';\nimport { dateTimestampInSeconds } from './utils/time';\n\n/**\n * Default value for maximum number of breadcrumbs added to an event.\n */\nconst DEFAULT_MAX_BREADCRUMBS = 100;\n\n/**\n * A context to be used for capturing an event.\n * This can either be a Scope, or a partial ScopeContext,\n * or a callback that receives the current scope and returns a new scope to use.\n */\nexport type CaptureContext = Scope | Partial<ScopeContext> | ((scope: Scope) => Scope);\n\n/**\n * Data that can be converted to a Scope.\n */\nexport interface ScopeContext {\n user: User;\n level: SeverityLevel;\n extra: Extras;\n contexts: Contexts;\n tags: { [key: string]: Primitive };\n attributes?: RawAttributes<Record<string, unknown>>;\n fingerprint: string[];\n propagationContext: PropagationContext;\n conversationId?: string;\n}\n\nexport interface SdkProcessingMetadata {\n [key: string]: unknown;\n requestSession?: {\n status: 'ok' | 'errored' | 'crashed';\n };\n normalizedRequest?: RequestEventData;\n dynamicSamplingContext?: Partial<DynamicSamplingContext>;\n capturedSpanScope?: Scope;\n capturedSpanIsolationScope?: Scope;\n spanCountBeforeProcessing?: number;\n ipAddress?: string;\n}\n\n/**\n * Normalized data of the Scope, ready to be used.\n */\nexport interface ScopeData {\n eventProcessors: EventProcessor[];\n breadcrumbs: Breadcrumb[];\n user: User;\n tags: { [key: string]: Primitive };\n // TODO(v11): Make this a required field (could be subtly breaking if we did it today)\n attributes?: RawAttributes<Record<string, unknown>>;\n extra: Extras;\n contexts: Contexts;\n attachments: Attachment[];\n propagationContext: PropagationContext;\n sdkProcessingMetadata: SdkProcessingMetadata;\n fingerprint: string[];\n level?: SeverityLevel;\n transactionName?: string;\n span?: Span;\n conversationId?: string;\n}\n\n/**\n * Holds additional event information.\n */\nexport class Scope {\n /** Flag if notifying is happening. */\n protected _notifyingListeners: boolean;\n\n /** Callback for client to receive scope changes. */\n protected _scopeListeners: Array<(scope: Scope) => void>;\n\n /** Callback list that will be called during event processing. */\n protected _eventProcessors: EventProcessor[];\n\n /** Array of breadcrumbs. */\n protected _breadcrumbs: Breadcrumb[];\n\n /** User */\n protected _user: User;\n\n /** Tags */\n protected _tags: { [key: string]: Primitive };\n\n /** Attributes */\n protected _attributes: RawAttributes<Record<string, unknown>>;\n\n /** Extra */\n protected _extra: Extras;\n\n /** Contexts */\n protected _contexts: Contexts;\n\n /** Attachments */\n protected _attachments: Attachment[];\n\n /** Propagation Context for distributed tracing */\n protected _propagationContext: PropagationContext;\n\n /**\n * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get\n * sent to Sentry\n */\n protected _sdkProcessingMetadata: SdkProcessingMetadata;\n\n /** Fingerprint */\n protected _fingerprint?: string[];\n\n /** Severity */\n protected _level?: SeverityLevel;\n\n /**\n * Transaction Name\n *\n * IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects.\n * It's purpose is to assign a transaction to the scope that's added to non-transaction events.\n */\n protected _transactionName?: string;\n\n /** Session */\n protected _session?: Session;\n\n /** The client on this scope */\n protected _client?: Client;\n\n /** Contains the last event id of a captured event. */\n protected _lastEventId?: string;\n\n /** Conversation ID */\n protected _conversationId?: string;\n\n // NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.\n\n public constructor() {\n this._notifyingListeners = false;\n this._scopeListeners = [];\n this._eventProcessors = [];\n this._breadcrumbs = [];\n this._attachments = [];\n this._user = {};\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._contexts = {};\n this._sdkProcessingMetadata = {};\n this._propagationContext = {\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n };\n }\n\n /**\n * Clone all data from this scope into a new scope.\n */\n public clone(): Scope {\n const newScope = new Scope();\n newScope._breadcrumbs = [...this._breadcrumbs];\n newScope._tags = { ...this._tags };\n newScope._attributes = { ...this._attributes };\n newScope._extra = { ...this._extra };\n newScope._contexts = { ...this._contexts };\n if (this._contexts.flags) {\n // We need to copy the `values` array so insertions on a cloned scope\n // won't affect the original array.\n newScope._contexts.flags = {\n values: [...this._contexts.flags.values],\n };\n }\n\n newScope._user = this._user;\n newScope._level = this._level;\n newScope._session = this._session;\n newScope._transactionName = this._transactionName;\n newScope._fingerprint = this._fingerprint;\n newScope._eventProcessors = [...this._eventProcessors];\n newScope._attachments = [...this._attachments];\n newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };\n newScope._propagationContext = { ...this._propagationContext };\n newScope._client = this._client;\n newScope._lastEventId = this._lastEventId;\n newScope._conversationId = this._conversationId;\n\n _setSpanForScope(newScope, _getSpanForScope(this));\n\n return newScope;\n }\n\n /**\n * Update the client assigned to this scope.\n * Note that not every scope will have a client assigned - isolation scopes & the global scope will generally not have a client,\n * as well as manually created scopes.\n */\n public setClient(client: Client | undefined): void {\n this._client = client;\n }\n\n /**\n * Set the ID of the last captured error event.\n * This is generally only captured on the isolation scope.\n */\n public setLastEventId(lastEventId: string | undefined): void {\n this._lastEventId = lastEventId;\n }\n\n /**\n * Get the client assigned to this scope.\n */\n public getClient<C extends Client>(): C | undefined {\n return this._client as C | undefined;\n }\n\n /**\n * Get the ID of the last captured error event.\n * This is generally only available on the isolation scope.\n */\n public lastEventId(): string | undefined {\n return this._lastEventId;\n }\n\n /**\n * @inheritDoc\n */\n public addScopeListener(callback: (scope: Scope) => void): void {\n this._scopeListeners.push(callback);\n }\n\n /**\n * Add an event processor that will be called before an event is sent.\n */\n public addEventProcessor(callback: EventProcessor): this {\n this._eventProcessors.push(callback);\n return this;\n }\n\n /**\n * Set the user for this scope.\n * Set to `null` to unset the user.\n */\n public setUser(user: User | null): this {\n // If null is passed we want to unset everything, but still define keys,\n // so that later down in the pipeline any existing values are cleared.\n this._user = user || {\n email: undefined,\n id: undefined,\n ip_address: undefined,\n username: undefined,\n };\n\n if (this._session) {\n updateSession(this._session, { user });\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the user from this scope.\n */\n public getUser(): User | undefined {\n return this._user;\n }\n\n /**\n * Set the conversation ID for this scope.\n * Set to `null` to unset the conversation ID.\n */\n public setConversationId(conversationId: string | null | undefined): this {\n this._conversationId = conversationId || undefined;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set an object that will be merged into existing tags on the scope,\n * and will be sent as tags data with the event.\n */\n public setTags(tags: { [key: string]: Primitive }): this {\n this._tags = {\n ...this._tags,\n ...tags,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single tag that will be sent as tags data with the event.\n */\n public setTag(key: string, value: Primitive): this {\n return this.setTags({ [key]: value });\n }\n\n /**\n * Sets attributes onto the scope.\n *\n * These attributes are applied to logs, metrics and streamed spans.\n *\n * Supported attribute value types are `string`, `number`, `boolean`, `string[]`, `number[]` and `boolean[]`.\n *\n * @param newAttributes - The attributes to set on the scope, as key-value pairs.\n *\n * @example\n * ```typescript\n * scope.setAttributes({\n * is_admin: true,\n * payment_selection: 'credit_card',\n * render_duration: 150,\n * });\n * ```\n */\n public setAttributes<T extends Record<string, unknown>>(newAttributes: RawAttributes<T>): this {\n this._attributes = {\n ...this._attributes,\n ...newAttributes,\n };\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets an attribute onto the scope.\n *\n * These attributes are applied to logs, metrics and streamed spans.\n *\n * Supported attribute value types are `string`, `number`, `boolean`, `string[]`, `number[]` and `boolean[]`.\n *\n * @param key - The attribute key.\n * @param value - The attribute value.\n *\n * @example\n * ```typescript\n * scope.setAttribute('is_admin', true);\n * scope.setAttribute('render_duration', 150);\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public setAttribute<T extends RawAttribute<T> extends { value: any } | { unit: any } ? AttributeObject : unknown>(\n key: string,\n value: RawAttribute<T>,\n ): this {\n return this.setAttributes({ [key]: value });\n }\n\n /**\n * Removes the attribute with the given key from the scope.\n *\n * @param key - The attribute key.\n *\n * @example\n * ```typescript\n * scope.removeAttribute('is_admin');\n * ```\n */\n public removeAttribute(key: string): this {\n if (key in this._attributes) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n this._notifyScopeListeners();\n }\n return this;\n }\n\n /**\n * Set an object that will be merged into existing extra on the scope,\n * and will be sent as extra data with the event.\n */\n public setExtras(extras: Extras): this {\n this._extra = {\n ...this._extra,\n ...extras,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single key:value extra entry that will be sent as extra data with the event.\n */\n public setExtra(key: string, extra: Extra): this {\n this._extra = { ...this._extra, [key]: extra };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the fingerprint on the scope to send with the events.\n * @param {string[]} fingerprint Fingerprint to group events in Sentry.\n */\n public setFingerprint(fingerprint: string[]): this {\n this._fingerprint = fingerprint;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the level on the scope for future events.\n */\n public setLevel(level: SeverityLevel): this {\n this._level = level;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the transaction name on the scope so that the name of e.g. taken server route or\n * the page location is attached to future events.\n *\n * IMPORTANT: Calling this function does NOT change the name of the currently active\n * root span. If you want to change the name of the active root span, use\n * `Sentry.updateSpanName(rootSpan, 'new name')` instead.\n *\n * By default, the SDK updates the scope's transaction name automatically on sensible\n * occasions, such as a page navigation or when handling a new request on the server.\n */\n public setTransactionName(name?: string): this {\n this._transactionName = name;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets context data with the given name.\n * Data passed as context will be normalized. You can also pass `null` to unset the context.\n * Note that context data will not be merged - calling `setContext` will overwrite an existing context with the same key.\n */\n public setContext(key: string, context: Context | null): this {\n if (context === null) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._contexts[key];\n } else {\n this._contexts[key] = context;\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set the session for the scope.\n */\n public setSession(session?: Session): this {\n if (!session) {\n delete this._session;\n } else {\n this._session = session;\n }\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the session from the scope.\n */\n public getSession(): Session | undefined {\n return this._session;\n }\n\n /**\n * Updates the scope with provided data. Can work in three variations:\n * - plain object containing updatable attributes\n * - Scope instance that'll extract the attributes from\n * - callback function that'll receive the current scope as an argument and allow for modifications\n */\n public update(captureContext?: CaptureContext): this {\n if (!captureContext) {\n return this;\n }\n\n const scopeToMerge = typeof captureContext === 'function' ? captureContext(this) : captureContext;\n\n const scopeInstance =\n scopeToMerge instanceof Scope\n ? scopeToMerge.getScopeData()\n : isPlainObject(scopeToMerge)\n ? (captureContext as ScopeContext)\n : undefined;\n\n const {\n tags,\n attributes,\n extra,\n user,\n contexts,\n level,\n fingerprint = [],\n propagationContext,\n conversationId,\n } = scopeInstance || {};\n\n this._tags = { ...this._tags, ...tags };\n this._attributes = { ...this._attributes, ...attributes };\n this._extra = { ...this._extra, ...extra };\n this._contexts = { ...this._contexts, ...contexts };\n\n if (user && Object.keys(user).length) {\n this._user = user;\n }\n\n if (level) {\n this._level = level;\n }\n\n if (fingerprint.length) {\n this._fingerprint = fingerprint;\n }\n\n if (propagationContext) {\n this._propagationContext = propagationContext;\n }\n\n if (conversationId) {\n this._conversationId = conversationId;\n }\n\n return this;\n }\n\n /**\n * Clears the current scope and resets its properties.\n * Note: The client will not be cleared.\n *\n * @deprecated This method will be removed in v11. To reset scope state, re-initialize the SDK or run\n * your code in a fresh scope via `withScope` instead.\n */\n public clear(): this {\n // client is not cleared here on purpose!\n this._breadcrumbs = [];\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._user = {};\n this._contexts = {};\n this._level = undefined;\n this._transactionName = undefined;\n this._fingerprint = undefined;\n this._session = undefined;\n this._conversationId = undefined;\n _setSpanForScope(this, undefined);\n this._attachments = [];\n this.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Adds a breadcrumb to the scope.\n * By default, the last 100 breadcrumbs are kept.\n */\n public addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this {\n const maxCrumbs = typeof maxBreadcrumbs === 'number' ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;\n\n // No data has been changed, so don't notify scope listeners\n if (maxCrumbs <= 0) {\n return this;\n }\n\n const mergedBreadcrumb: Breadcrumb = {\n timestamp: dateTimestampInSeconds(),\n ...breadcrumb,\n // Breadcrumb messages can theoretically be infinitely large and they're held in memory so we truncate them not to leak (too much) memory\n message: breadcrumb.message ? truncate(breadcrumb.message, 2048) : breadcrumb.message,\n };\n\n this._breadcrumbs.push(mergedBreadcrumb);\n if (this._breadcrumbs.length > maxCrumbs) {\n this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);\n this._client?.recordDroppedEvent('buffer_overflow', 'log_item');\n }\n\n this._notifyScopeListeners();\n\n return this;\n }\n\n /**\n * Get the last breadcrumb of the scope.\n */\n public getLastBreadcrumb(): Breadcrumb | undefined {\n return this._breadcrumbs[this._breadcrumbs.length - 1];\n }\n\n /**\n * Clear all breadcrumbs from the scope.\n */\n public clearBreadcrumbs(): this {\n this._breadcrumbs = [];\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Add an attachment to the scope.\n */\n public addAttachment(attachment: Attachment): this {\n this._attachments.push(attachment);\n return this;\n }\n\n /**\n * Clear all attachments from the scope.\n */\n public clearAttachments(): this {\n this._attachments = [];\n return this;\n }\n\n /**\n * Get the data of this scope, which should be applied to an event during processing.\n */\n public getScopeData(): ScopeData {\n return {\n breadcrumbs: this._breadcrumbs,\n attachments: this._attachments,\n contexts: this._contexts,\n tags: this._tags,\n attributes: this._attributes,\n extra: this._extra,\n user: this._user,\n level: this._level,\n fingerprint: this._fingerprint || [],\n eventProcessors: this._eventProcessors,\n propagationContext: this._propagationContext,\n sdkProcessingMetadata: this._sdkProcessingMetadata,\n transactionName: this._transactionName,\n span: _getSpanForScope(this),\n conversationId: this._conversationId,\n };\n }\n\n /**\n * Add data which will be accessible during event processing but won't get sent to Sentry.\n */\n public setSDKProcessingMetadata(newData: SdkProcessingMetadata): this {\n this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2);\n return this;\n }\n\n /**\n * Add propagation context to the scope, used for distributed tracing\n */\n public setPropagationContext(context: PropagationContext): this {\n this._propagationContext = context;\n return this;\n }\n\n /**\n * Get propagation context from the scope, used for distributed tracing\n */\n public getPropagationContext(): PropagationContext {\n return this._propagationContext;\n }\n\n /**\n * Capture an exception for this scope.\n *\n * @returns {string} The id of the captured Sentry event.\n */\n public captureException(exception: unknown, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture exception!');\n return eventId;\n }\n\n const syntheticException = new Error('Sentry syntheticException');\n\n this._client.captureException(\n exception,\n {\n originalException: exception,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a message for this scope.\n *\n * @returns {string} The id of the captured message.\n */\n public captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture message!');\n return eventId;\n }\n\n const syntheticException = hint?.syntheticException ?? new Error(message);\n\n this._client.captureMessage(\n message,\n level,\n {\n originalException: message,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a Sentry event for this scope.\n *\n * @returns {string} The id of the captured event.\n */\n public captureEvent(event: Event, hint?: EventHint): string {\n const eventId = event.event_id || hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture event!');\n return eventId;\n }\n\n this._client.captureEvent(event, { ...hint, event_id: eventId }, this);\n\n return eventId;\n }\n\n /**\n * This will be called on every set call.\n */\n protected _notifyScopeListeners(): void {\n // We need this check for this._notifyingListeners to be able to work on scope during updates\n // If this check is not here we'll produce endless recursion when something is done with the scope\n // during the callback.\n if (!this._notifyingListeners) {\n this._notifyingListeners = true;\n this._scopeListeners.forEach(callback => {\n callback(this);\n });\n this._notifyingListeners = false;\n }\n }\n}\n"],"names":["generateTraceId","safeMathRandom","_setSpanForScope","_getSpanForScope","updateSession","isPlainObject","dateTimestampInSeconds","truncate","merge","uuid4","DEBUG_BUILD","debug"],"mappings":";;;;;;;;;;;;;;AAgCA,MAAM,uBAAA,GAA0B,GAAA;AA8DzB,MAAM,KAAA,CAAM;AAAA;AAAA,EAoEV,WAAA,GAAc;AACnB,IAAA,IAAA,CAAK,mBAAA,GAAsB,KAAA;AAC3B,IAAA,IAAA,CAAK,kBAAkB,EAAC;AACxB,IAAA,IAAA,CAAK,mBAAmB,EAAC;AACzB,IAAA,IAAA,CAAK,eAAe,EAAC;AACrB,IAAA,IAAA,CAAK,eAAe,EAAC;AACrB,IAAA,IAAA,CAAK,QAAQ,EAAC;AACd,IAAA,IAAA,CAAK,QAAQ,EAAC;AACd,IAAA,IAAA,CAAK,cAAc,EAAC;AACpB,IAAA,IAAA,CAAK,SAAS,EAAC;AACf,IAAA,IAAA,CAAK,YAAY,EAAC;AAClB,IAAA,IAAA,CAAK,yBAAyB,EAAC;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AK,eAAA,CAAgB,QAAQ,CAAA,QAAA,KAAY;AACvC,QAAA,QAAA,CAAS,IAAI,CAAA;AAAA,MACf,CAAC,CAAA;AACD,MAAA,IAAA,CAAK,mBAAA,GAAsB,KAAA;AAAA,IAC7B;AAAA,EACF;AACF;;;;"}

@@ -203,2 +203,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

object.addNonEnumerableProperty(childSpan, ROOT_SPAN_FIELD, rootSpan);
if (!spanIsSampled(span)) {
return;
}
if (!span.isRecording() && !rootSpan.isRecording()) {
return;
}
if (span[CHILD_SPANS_FIELD]) {

@@ -205,0 +211,0 @@ span[CHILD_SPANS_FIELD].add(childSpan);

@@ -1,1 +0,1 @@

{"version":3,"file":"spanUtils.js","sources":["../../../src/utils/spanUtils.ts"],"sourcesContent":["// oxlint-disable max-lines\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { RawAttributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getMainCarrier } from '../carrier';\nimport { getCurrentScope } from '../currentScopes';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE,\n} from '../semanticAttributes';\nimport type { SentrySpan } from '../tracing/sentrySpan';\nimport { SPAN_STATUS_OK, SPAN_STATUS_UNSET } from '../tracing/spanstatus';\nimport { getCapturedScopesOnSpan } from '../tracing/utils';\nimport type { TraceContext } from '../types/context';\nimport type { SpanLink, SpanLinkJSON } from '../types/link';\nimport type {\n SerializedStreamedSpan,\n Span,\n SpanAttributes,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { generateSpanId } from '../utils/propagationContext';\nimport { timestampInSeconds } from '../utils/time';\nimport { generateSentryTraceHeader, generateTraceparentHeader } from '../utils/tracing';\nimport { consoleSandbox } from './debug-logger';\nimport { _getSpanForScope } from './spanOnScope';\n\n// These are aligned with OpenTelemetry trace flags\nexport const TRACE_FLAG_NONE = 0x0;\nexport const TRACE_FLAG_SAMPLED = 0x1;\n\nlet hasShownSpanDropWarning = false;\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in an event.\n * By default, this will only include trace_id, span_id & parent_span_id.\n * If `includeAllData` is true, it will also include data, op, status & origin.\n */\nexport function spanToTransactionTraceContext(span: Span): TraceContext {\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n const { data, op, parent_span_id, status, origin, links } = spanToJSON(span);\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n data,\n op,\n status,\n origin,\n links,\n };\n}\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.\n */\nexport function spanToTraceContext(span: Span): TraceContext {\n const { spanId, traceId: trace_id, isRemote } = span.spanContext();\n\n // If the span is remote, we use a random/virtual span as span_id to the trace context,\n // and the remote span as parent_span_id\n const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id;\n const scope = getCapturedScopesOnSpan(span).scope;\n\n const span_id = isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId;\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n };\n}\n\n/**\n * Convert a Span to a Sentry trace header.\n */\nexport function spanToTraceHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateSentryTraceHeader(traceId, spanId, sampled);\n}\n\n/**\n * Convert a Span to a W3C traceparent header.\n */\nexport function spanToTraceparentHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateTraceparentHeader(traceId, spanId, sampled);\n}\n\n/**\n * Converts the span links array to a flattened version to be sent within an envelope.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function convertSpanLinksForEnvelope(links?: SpanLink[]): SpanLinkJSON[] | undefined {\n if (links && links.length > 0) {\n return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n ...restContext,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Converts the span links array to a flattened version with serialized attributes for V2 spans.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function getStreamedSpanLinks(\n links?: SpanLink[],\n): SpanLinkJSON<RawAttributes<Record<string, unknown>>>[] | undefined {\n if (links?.length) {\n return links.map(({ context: { spanId, traceId, traceFlags }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Convert a span time input into a timestamp in seconds.\n */\nexport function spanTimeInputToSeconds(input: SpanTimeInput | undefined): number {\n if (typeof input === 'number') {\n return ensureTimestampInSeconds(input);\n }\n\n if (Array.isArray(input)) {\n // See {@link HrTime} for the array-based time format\n return input[0] + input[1] / 1e9;\n }\n\n if (input instanceof Date) {\n return ensureTimestampInSeconds(input.getTime());\n }\n\n return timestampInSeconds();\n}\n\n/**\n * Converts a timestamp to second, if it was in milliseconds, or keeps it as second.\n */\nfunction ensureTimestampInSeconds(timestamp: number): number {\n const isMs = timestamp > 9999999999;\n return isMs ? timestamp / 1000 : timestamp;\n}\n\n/**\n * Convert a span to a JSON representation.\n */\n// Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).\n// This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.\n// And `spanToJSON` needs the Span class from `span.ts` to check here.\nexport function spanToJSON(span: Span): SpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n span_id,\n trace_id,\n data: attributes,\n description: name,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n // This is [0,0] by default in OTEL, in which case we want to interpret this as no end time\n timestamp: spanTimeInputToSeconds(endTime) || undefined,\n status: getStatusMessage(status),\n op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n links: convertSpanLinksForEnvelope(links),\n };\n }\n\n // Finally, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n data: {},\n };\n}\n\n/**\n * Convert a span to the intermediate {@link StreamedSpanJSON} representation.\n */\nexport function spanToStreamedSpanJSON(span: Span): StreamedSpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getStreamedSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n name,\n span_id,\n trace_id,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n end_timestamp: spanTimeInputToSeconds(endTime),\n is_segment: span === INTERNAL_getSegmentSpan(span),\n status: getSimpleStatus(status),\n attributes: addStatusMessageAttribute(attributes, status),\n links: getStreamedSpanLinks(links),\n };\n }\n\n // Finally, as a fallback, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n name: '',\n end_timestamp: 0,\n status: 'ok',\n is_segment: span === INTERNAL_getSegmentSpan(span),\n };\n}\n\n/**\n * In preparation for the next major of OpenTelemetry, we want to support\n * looking up the parent span id according to the new API\n * In OTel v1, the parent span id is accessed as `parentSpanId`\n * In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`\n */\nfunction getOtelParentSpanId(span: OpenTelemetrySdkTraceBaseSpan): string | undefined {\n return 'parentSpanId' in span\n ? span.parentSpanId\n : 'parentSpanContext' in span\n ? (span.parentSpanContext as { spanId?: string } | undefined)?.spanId\n : undefined;\n}\n\n/**\n * Converts a {@link StreamedSpanJSON} to a {@link SerializedSpan}.\n * This is the final serialized span format that is sent to Sentry.\n * The returned serilaized spans must not be consumed by users or SDK integrations.\n */\nexport function streamedSpanJsonToSerializedSpan(spanJson: StreamedSpanJSON): SerializedStreamedSpan {\n return {\n ...spanJson,\n attributes: serializeAttributes(spanJson.attributes),\n links: spanJson.links?.map(link => ({\n ...link,\n attributes: serializeAttributes(link.attributes),\n })),\n };\n}\n\nfunction spanIsOpenTelemetrySdkTraceBaseSpan(span: Span): span is OpenTelemetrySdkTraceBaseSpan {\n const castSpan = span as Partial<OpenTelemetrySdkTraceBaseSpan>;\n return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;\n}\n\n/** Exported only for tests. */\nexport interface OpenTelemetrySdkTraceBaseSpan extends Span {\n attributes: SpanAttributes;\n startTime: SpanTimeInput;\n name: string;\n status: SpanStatus;\n endTime: SpanTimeInput;\n parentSpanId?: string;\n links?: SpanLink[];\n}\n\n/**\n * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.\n * :( So instead we approximate this by checking if it has the `getSpanJSON` method.\n */\nexport function spanIsSentrySpan(span: Span): span is SentrySpan {\n return typeof (span as SentrySpan).getSpanJSON === 'function';\n}\n\n/**\n * Returns true if a span is sampled.\n * In most cases, you should just use `span.isRecording()` instead.\n * However, this has a slightly different semantic, as it also returns false if the span is finished.\n * So in the case where this distinction is important, use this method.\n */\nexport function spanIsSampled(span: Span): boolean {\n // We align our trace flags with the ones OpenTelemetry use\n // So we also check for sampled the same way they do.\n const { traceFlags } = span.spanContext();\n return traceFlags === TRACE_FLAG_SAMPLED;\n}\n\n/** Get the status message to use for a JSON representation of a span. */\nexport function getStatusMessage(status: SpanStatus | undefined): string | undefined {\n if (!status || status.code === SPAN_STATUS_UNSET) {\n return undefined;\n }\n\n if (status.code === SPAN_STATUS_OK) {\n return 'ok';\n }\n\n return status.message || 'internal_error';\n}\n\n/**\n * Convert the various statuses to the simple ones expected by Sentry for streamed spans ('ok' is default).\n */\nexport function getSimpleStatus(status: SpanStatus | undefined): 'ok' | 'error' {\n return !status ||\n status.code === SPAN_STATUS_OK ||\n status.code === SPAN_STATUS_UNSET ||\n status.message === 'cancelled'\n ? 'ok'\n : 'error';\n}\n\n/**\n * Returns the span's attributes with the SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE attribute added\n * if the span has an error status message worth preserving.\n *\n * An explicitly set attribute is never overwritten.\n */\nexport function addStatusMessageAttribute(\n attributes: SpanAttributes,\n status: SpanStatus | undefined,\n): RawAttributes<Record<string, unknown>> {\n const statusMessage = getSimpleStatus(status) === 'error' ? status?.message : undefined;\n return {\n ...(statusMessage && { [SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]: statusMessage }),\n ...attributes,\n };\n}\n\nconst CHILD_SPANS_FIELD = '_sentryChildSpans';\nconst ROOT_SPAN_FIELD = '_sentryRootSpan';\n\ntype SpanWithPotentialChildren = Span & {\n [CHILD_SPANS_FIELD]?: Set<Span>;\n [ROOT_SPAN_FIELD]?: Span;\n};\n\n/**\n * Adds an opaque child span reference to a span.\n */\nexport function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n // We store the root span reference on the child span\n // We need this for `getRootSpan()` to work\n const rootSpan = span[ROOT_SPAN_FIELD] || span;\n addNonEnumerableProperty(childSpan as SpanWithPotentialChildren, ROOT_SPAN_FIELD, rootSpan);\n\n // We store a list of child spans on the parent span\n // We need this for `getSpanDescendants()` to work\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].add(childSpan);\n } else {\n addNonEnumerableProperty(span, CHILD_SPANS_FIELD, new Set([childSpan]));\n }\n}\n\n/** This is only used internally by Idle Spans. */\nexport function removeChildSpanFromSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].delete(childSpan);\n }\n}\n\n/**\n * Returns an array of the given span and all of its descendants.\n */\nexport function getSpanDescendants(span: SpanWithPotentialChildren): Span[] {\n const resultSet = new Set<Span>();\n\n function addSpanChildren(span: SpanWithPotentialChildren): void {\n // This exit condition is required to not infinitely loop in case of a circular dependency.\n if (resultSet.has(span)) {\n return;\n // We want to ignore unsampled spans (e.g. non recording spans)\n } else if (spanIsSampled(span)) {\n resultSet.add(span);\n const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : [];\n for (const childSpan of childSpans) {\n addSpanChildren(childSpan);\n }\n }\n }\n\n addSpanChildren(span);\n\n return Array.from(resultSet);\n}\n\n/**\n * Returns the root span of a given span.\n */\nexport const getRootSpan = INTERNAL_getSegmentSpan;\n\n/**\n * Returns the segment span of a given span.\n */\nexport function INTERNAL_getSegmentSpan(span: SpanWithPotentialChildren): Span {\n return span[ROOT_SPAN_FIELD] || span;\n}\n\n/**\n * Returns the currently active span.\n */\nexport function getActiveSpan(): Span | undefined {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getActiveSpan) {\n return acs.getActiveSpan();\n }\n\n return _getSpanForScope(getCurrentScope());\n}\n\n/**\n * Logs a warning once if `beforeSendSpan` is used to drop spans.\n */\nexport function showSpanDropWarning(): void {\n if (!hasShownSpanDropWarning) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.',\n );\n });\n hasShownSpanDropWarning = true;\n }\n}\n\n/**\n * Updates the name of the given span and ensures that the span name is not\n * overwritten by the Sentry SDK.\n *\n * Use this function instead of `span.updateName()` if you want to make sure that\n * your name is kept. For some spans, for example root `http.server` spans the\n * Sentry SDK would otherwise overwrite the span name with a high-quality name\n * it infers when the span ends.\n *\n * Use this function in server code or when your span is started on the server\n * and on the client (browser). If you only update a span name on the client,\n * you can also use `span.updateName()` the SDK does not overwrite the name.\n *\n * @param span - The span to update the name of.\n * @param name - The name to set on the span.\n */\nexport function updateSpanName(span: Span, name: string): void {\n span.updateName(name);\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: name,\n });\n}\n"],"names":["getCapturedScopesOnSpan","generateSpanId","generateSentryTraceHeader","generateTraceparentHeader","timestampInSeconds","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","serializeAttributes","SPAN_STATUS_UNSET","SPAN_STATUS_OK","SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE","addNonEnumerableProperty","span","carrier","getMainCarrier","getAsyncContextStrategy","_getSpanForScope","getCurrentScope","consoleSandbox","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME"],"mappings":";;;;;;;;;;;;;;;;AAoCO,MAAM,eAAA,GAAkB;AACxB,MAAM,kBAAA,GAAqB;AAElC,IAAI,uBAAA,GAA0B,KAAA;AAOvB,SAAS,8BAA8B,IAAA,EAA0B;AACtE,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,SAAS,QAAA,EAAS,GAAI,KAAK,WAAA,EAAY;AAChE,EAAA,MAAM,EAAE,MAAM,EAAA,EAAI,cAAA,EAAgB,QAAQ,MAAA,EAAQ,KAAA,EAAM,GAAI,UAAA,CAAW,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,GAAI,EAAC;AACpF,MAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,QAAA,eAAA,CAAgB,SAAS,CAAA;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAEA,EAAA,eAAA,CAAgB,IAAI,CAAA;AAEpB,EAAA,OAAO,KAAA,CAAM,KAAK,SAAS,CAAA;AAC7B;AAKO,MAAM,WAAA,GAAc;AAKpB,SAAS,wBAAwB,IAAA,EAAuC;AAC7E,EAAA,OAAO,IAAA,CAAK,eAAe,CAAA,IAAK,IAAA;AAClC;AAKO,SAAS,aAAA,GAAkC;AAChD,EAAA,MAAMC,YAAUC,sBAAA,EAAe;AAC/B,EAAA,MAAM,GAAA,GAAMC,8BAAwBF,SAAO,CAAA;AAC3C,EAAA,IAAI,IAAI,aAAA,EAAe;AACrB,IAAA,OAAO,IAAI,aAAA,EAAc;AAAA,EAC3B;AAEA,EAAA,OAAOG,4BAAA,CAAiBC,+BAAiB,CAAA;AAC3C;AAKO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,CAAC,uBAAA,EAAyB;AAC5B,IAAAC,0BAAA,CAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AACD,IAAA,uBAAA,GAA0B,IAAA;AAAA,EAC5B;AACF;AAkBO,SAAS,cAAA,CAAe,MAAY,IAAA,EAAoB;AAC7D,EAAA,IAAA,CAAK,WAAW,IAAI,CAAA;AACpB,EAAA,IAAA,CAAK,aAAA,CAAc;AAAA,IACjB,CAACC,mDAAgC,GAAG,QAAA;AAAA,IACpC,CAACC,6DAA0C,GAAG;AAAA,GAC/C,CAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
{"version":3,"file":"spanUtils.js","sources":["../../../src/utils/spanUtils.ts"],"sourcesContent":["// oxlint-disable max-lines\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { RawAttributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getMainCarrier } from '../carrier';\nimport { getCurrentScope } from '../currentScopes';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE,\n} from '../semanticAttributes';\nimport type { SentrySpan } from '../tracing/sentrySpan';\nimport { SPAN_STATUS_OK, SPAN_STATUS_UNSET } from '../tracing/spanstatus';\nimport { getCapturedScopesOnSpan } from '../tracing/utils';\nimport type { TraceContext } from '../types/context';\nimport type { SpanLink, SpanLinkJSON } from '../types/link';\nimport type {\n SerializedStreamedSpan,\n Span,\n SpanAttributes,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { generateSpanId } from '../utils/propagationContext';\nimport { timestampInSeconds } from '../utils/time';\nimport { generateSentryTraceHeader, generateTraceparentHeader } from '../utils/tracing';\nimport { consoleSandbox } from './debug-logger';\nimport { _getSpanForScope } from './spanOnScope';\n\n// These are aligned with OpenTelemetry trace flags\nexport const TRACE_FLAG_NONE = 0x0;\nexport const TRACE_FLAG_SAMPLED = 0x1;\n\nlet hasShownSpanDropWarning = false;\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in an event.\n * By default, this will only include trace_id, span_id & parent_span_id.\n * If `includeAllData` is true, it will also include data, op, status & origin.\n */\nexport function spanToTransactionTraceContext(span: Span): TraceContext {\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n const { data, op, parent_span_id, status, origin, links } = spanToJSON(span);\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n data,\n op,\n status,\n origin,\n links,\n };\n}\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.\n */\nexport function spanToTraceContext(span: Span): TraceContext {\n const { spanId, traceId: trace_id, isRemote } = span.spanContext();\n\n // If the span is remote, we use a random/virtual span as span_id to the trace context,\n // and the remote span as parent_span_id\n const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id;\n const scope = getCapturedScopesOnSpan(span).scope;\n\n const span_id = isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId;\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n };\n}\n\n/**\n * Convert a Span to a Sentry trace header.\n */\nexport function spanToTraceHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateSentryTraceHeader(traceId, spanId, sampled);\n}\n\n/**\n * Convert a Span to a W3C traceparent header.\n */\nexport function spanToTraceparentHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateTraceparentHeader(traceId, spanId, sampled);\n}\n\n/**\n * Converts the span links array to a flattened version to be sent within an envelope.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function convertSpanLinksForEnvelope(links?: SpanLink[]): SpanLinkJSON[] | undefined {\n if (links && links.length > 0) {\n return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n ...restContext,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Converts the span links array to a flattened version with serialized attributes for V2 spans.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function getStreamedSpanLinks(\n links?: SpanLink[],\n): SpanLinkJSON<RawAttributes<Record<string, unknown>>>[] | undefined {\n if (links?.length) {\n return links.map(({ context: { spanId, traceId, traceFlags }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Convert a span time input into a timestamp in seconds.\n */\nexport function spanTimeInputToSeconds(input: SpanTimeInput | undefined): number {\n if (typeof input === 'number') {\n return ensureTimestampInSeconds(input);\n }\n\n if (Array.isArray(input)) {\n // See {@link HrTime} for the array-based time format\n return input[0] + input[1] / 1e9;\n }\n\n if (input instanceof Date) {\n return ensureTimestampInSeconds(input.getTime());\n }\n\n return timestampInSeconds();\n}\n\n/**\n * Converts a timestamp to second, if it was in milliseconds, or keeps it as second.\n */\nfunction ensureTimestampInSeconds(timestamp: number): number {\n const isMs = timestamp > 9999999999;\n return isMs ? timestamp / 1000 : timestamp;\n}\n\n/**\n * Convert a span to a JSON representation.\n */\n// Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).\n// This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.\n// And `spanToJSON` needs the Span class from `span.ts` to check here.\nexport function spanToJSON(span: Span): SpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n span_id,\n trace_id,\n data: attributes,\n description: name,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n // This is [0,0] by default in OTEL, in which case we want to interpret this as no end time\n timestamp: spanTimeInputToSeconds(endTime) || undefined,\n status: getStatusMessage(status),\n op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n links: convertSpanLinksForEnvelope(links),\n };\n }\n\n // Finally, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n data: {},\n };\n}\n\n/**\n * Convert a span to the intermediate {@link StreamedSpanJSON} representation.\n */\nexport function spanToStreamedSpanJSON(span: Span): StreamedSpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getStreamedSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n name,\n span_id,\n trace_id,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n end_timestamp: spanTimeInputToSeconds(endTime),\n is_segment: span === INTERNAL_getSegmentSpan(span),\n status: getSimpleStatus(status),\n attributes: addStatusMessageAttribute(attributes, status),\n links: getStreamedSpanLinks(links),\n };\n }\n\n // Finally, as a fallback, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n name: '',\n end_timestamp: 0,\n status: 'ok',\n is_segment: span === INTERNAL_getSegmentSpan(span),\n };\n}\n\n/**\n * In preparation for the next major of OpenTelemetry, we want to support\n * looking up the parent span id according to the new API\n * In OTel v1, the parent span id is accessed as `parentSpanId`\n * In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`\n */\nfunction getOtelParentSpanId(span: OpenTelemetrySdkTraceBaseSpan): string | undefined {\n return 'parentSpanId' in span\n ? span.parentSpanId\n : 'parentSpanContext' in span\n ? (span.parentSpanContext as { spanId?: string } | undefined)?.spanId\n : undefined;\n}\n\n/**\n * Converts a {@link StreamedSpanJSON} to a {@link SerializedSpan}.\n * This is the final serialized span format that is sent to Sentry.\n * The returned serilaized spans must not be consumed by users or SDK integrations.\n */\nexport function streamedSpanJsonToSerializedSpan(spanJson: StreamedSpanJSON): SerializedStreamedSpan {\n return {\n ...spanJson,\n attributes: serializeAttributes(spanJson.attributes),\n links: spanJson.links?.map(link => ({\n ...link,\n attributes: serializeAttributes(link.attributes),\n })),\n };\n}\n\nfunction spanIsOpenTelemetrySdkTraceBaseSpan(span: Span): span is OpenTelemetrySdkTraceBaseSpan {\n const castSpan = span as Partial<OpenTelemetrySdkTraceBaseSpan>;\n return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;\n}\n\n/** Exported only for tests. */\nexport interface OpenTelemetrySdkTraceBaseSpan extends Span {\n attributes: SpanAttributes;\n startTime: SpanTimeInput;\n name: string;\n status: SpanStatus;\n endTime: SpanTimeInput;\n parentSpanId?: string;\n links?: SpanLink[];\n}\n\n/**\n * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.\n * :( So instead we approximate this by checking if it has the `getSpanJSON` method.\n */\nexport function spanIsSentrySpan(span: Span): span is SentrySpan {\n return typeof (span as SentrySpan).getSpanJSON === 'function';\n}\n\n/**\n * Returns true if a span is sampled.\n * In most cases, you should just use `span.isRecording()` instead.\n * However, this has a slightly different semantic, as it also returns false if the span is finished.\n * So in the case where this distinction is important, use this method.\n */\nexport function spanIsSampled(span: Span): boolean {\n // We align our trace flags with the ones OpenTelemetry use\n // So we also check for sampled the same way they do.\n const { traceFlags } = span.spanContext();\n return traceFlags === TRACE_FLAG_SAMPLED;\n}\n\n/** Get the status message to use for a JSON representation of a span. */\nexport function getStatusMessage(status: SpanStatus | undefined): string | undefined {\n if (!status || status.code === SPAN_STATUS_UNSET) {\n return undefined;\n }\n\n if (status.code === SPAN_STATUS_OK) {\n return 'ok';\n }\n\n return status.message || 'internal_error';\n}\n\n/**\n * Convert the various statuses to the simple ones expected by Sentry for streamed spans ('ok' is default).\n */\nexport function getSimpleStatus(status: SpanStatus | undefined): 'ok' | 'error' {\n return !status ||\n status.code === SPAN_STATUS_OK ||\n status.code === SPAN_STATUS_UNSET ||\n status.message === 'cancelled'\n ? 'ok'\n : 'error';\n}\n\n/**\n * Returns the span's attributes with the SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE attribute added\n * if the span has an error status message worth preserving.\n *\n * An explicitly set attribute is never overwritten.\n */\nexport function addStatusMessageAttribute(\n attributes: SpanAttributes,\n status: SpanStatus | undefined,\n): RawAttributes<Record<string, unknown>> {\n const statusMessage = getSimpleStatus(status) === 'error' ? status?.message : undefined;\n return {\n ...(statusMessage && { [SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]: statusMessage }),\n ...attributes,\n };\n}\n\nconst CHILD_SPANS_FIELD = '_sentryChildSpans';\nconst ROOT_SPAN_FIELD = '_sentryRootSpan';\n\ntype SpanWithPotentialChildren = Span & {\n [CHILD_SPANS_FIELD]?: Set<Span>;\n [ROOT_SPAN_FIELD]?: Span;\n};\n\n/**\n * Adds an opaque child span reference to a span.\n */\nexport function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n // We store the root span reference on the child span\n // We need this for `getRootSpan()` to work\n const rootSpan = span[ROOT_SPAN_FIELD] || span;\n addNonEnumerableProperty(childSpan as SpanWithPotentialChildren, ROOT_SPAN_FIELD, rootSpan);\n\n // `_sentryChildSpans` exists only so `getSpanDescendants()` can walk the tree when the segment span\n // is sent, and that walk stops at an unsampled span without ever visiting its children. So a child\n // tracked here would be held for the parent's lifetime and never read.\n if (!spanIsSampled(span)) {\n return;\n }\n\n // Once the segment span stopped recording, the tree has been read for the last time, and a child\n // starting now belongs to whatever segment comes next: it is re-emitted on its own instead. Tracking\n // it here would pin it for as long as the parent lives, which for a span left active in an async\n // context (e.g. a framework boot span captured by a queue consumer) is the rest of the process. Only\n // a parent that is itself still recording keeps tracking, so a late child that outlives its segment\n // still collects the subtree it is re-emitted with.\n if (!span.isRecording() && !rootSpan.isRecording()) {\n return;\n }\n\n // We store a list of child spans on the parent span\n // We need this for `getSpanDescendants()` to work\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].add(childSpan);\n } else {\n addNonEnumerableProperty(span, CHILD_SPANS_FIELD, new Set([childSpan]));\n }\n}\n\n/** This is only used internally by Idle Spans. */\nexport function removeChildSpanFromSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].delete(childSpan);\n }\n}\n\n/**\n * Returns an array of the given span and all of its descendants.\n */\nexport function getSpanDescendants(span: SpanWithPotentialChildren): Span[] {\n const resultSet = new Set<Span>();\n\n function addSpanChildren(span: SpanWithPotentialChildren): void {\n // This exit condition is required to not infinitely loop in case of a circular dependency.\n if (resultSet.has(span)) {\n return;\n // We want to ignore unsampled spans (e.g. non recording spans)\n } else if (spanIsSampled(span)) {\n resultSet.add(span);\n const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : [];\n for (const childSpan of childSpans) {\n addSpanChildren(childSpan);\n }\n }\n }\n\n addSpanChildren(span);\n\n return Array.from(resultSet);\n}\n\n/**\n * Returns the root span of a given span.\n */\nexport const getRootSpan = INTERNAL_getSegmentSpan;\n\n/**\n * Returns the segment span of a given span.\n */\nexport function INTERNAL_getSegmentSpan(span: SpanWithPotentialChildren): Span {\n return span[ROOT_SPAN_FIELD] || span;\n}\n\n/**\n * Returns the currently active span.\n */\nexport function getActiveSpan(): Span | undefined {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getActiveSpan) {\n return acs.getActiveSpan();\n }\n\n return _getSpanForScope(getCurrentScope());\n}\n\n/**\n * Logs a warning once if `beforeSendSpan` is used to drop spans.\n */\nexport function showSpanDropWarning(): void {\n if (!hasShownSpanDropWarning) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.',\n );\n });\n hasShownSpanDropWarning = true;\n }\n}\n\n/**\n * Updates the name of the given span and ensures that the span name is not\n * overwritten by the Sentry SDK.\n *\n * Use this function instead of `span.updateName()` if you want to make sure that\n * your name is kept. For some spans, for example root `http.server` spans the\n * Sentry SDK would otherwise overwrite the span name with a high-quality name\n * it infers when the span ends.\n *\n * Use this function in server code or when your span is started on the server\n * and on the client (browser). If you only update a span name on the client,\n * you can also use `span.updateName()` the SDK does not overwrite the name.\n *\n * @param span - The span to update the name of.\n * @param name - The name to set on the span.\n */\nexport function updateSpanName(span: Span, name: string): void {\n span.updateName(name);\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: name,\n });\n}\n"],"names":["getCapturedScopesOnSpan","generateSpanId","generateSentryTraceHeader","generateTraceparentHeader","timestampInSeconds","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","serializeAttributes","SPAN_STATUS_UNSET","SPAN_STATUS_OK","SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE","addNonEnumerableProperty","span","carrier","getMainCarrier","getAsyncContextStrategy","_getSpanForScope","getCurrentScope","consoleSandbox","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME"],"mappings":";;;;;;;;;;;;;;;;AAoCO,MAAM,eAAA,GAAkB;AACxB,MAAM,kBAAA,GAAqB;AAElC,IAAI,uBAAA,GAA0B,KAAA;AAOvB,SAAS,8BAA8B,IAAA,EAA0B;AACtE,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,SAAS,QAAA,EAAS,GAAI,KAAK,WAAA,EAAY;AAChE,EAAA,MAAM,EAAE,MAAM,EAAA,EAAI,cAAA,EAAgB,QAAQ,MAAA,EAAQ,KAAA,EAAM,GAAI,UAAA,CAAW,IAAI,CAAA;AAE3E,EAAA,OAAO;AAAA,IACL,cAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,EAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;AAKO,SAAS,mB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C;AACpF,MAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,QAAA,eAAA,CAAgB,SAAS,CAAA;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAEA,EAAA,eAAA,CAAgB,IAAI,CAAA;AAEpB,EAAA,OAAO,KAAA,CAAM,KAAK,SAAS,CAAA;AAC7B;AAKO,MAAM,WAAA,GAAc;AAKpB,SAAS,wBAAwB,IAAA,EAAuC;AAC7E,EAAA,OAAO,IAAA,CAAK,eAAe,CAAA,IAAK,IAAA;AAClC;AAKO,SAAS,aAAA,GAAkC;AAChD,EAAA,MAAMC,YAAUC,sBAAA,EAAe;AAC/B,EAAA,MAAM,GAAA,GAAMC,8BAAwBF,SAAO,CAAA;AAC3C,EAAA,IAAI,IAAI,aAAA,EAAe;AACrB,IAAA,OAAO,IAAI,aAAA,EAAc;AAAA,EAC3B;AAEA,EAAA,OAAOG,4BAAA,CAAiBC,+BAAiB,CAAA;AAC3C;AAKO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,CAAC,uBAAA,EAAyB;AAC5B,IAAAC,0BAAA,CAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AACD,IAAA,uBAAA,GAA0B,IAAA;AAAA,EAC5B;AACF;AAkBO,SAAS,cAAA,CAAe,MAAY,IAAA,EAAoB;AAC7D,EAAA,IAAA,CAAK,WAAW,IAAI,CAAA;AACpB,EAAA,IAAA,CAAK,aAAA,CAAc;AAAA,IACjB,CAACC,mDAAgC,GAAG,QAAA;AAAA,IACpC,CAACC,6DAA0C,GAAG;AAAA,GAC/C,CAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const SDK_VERSION = "10.70.0" ;
const SDK_VERSION = "10.71.0" ;
exports.SDK_VERSION = SDK_VERSION;
//# sourceMappingURL=version.js.map

@@ -117,3 +117,3 @@ import { getEnvelopeEndpointWithUrlEncodedAuth } from './api.js';

}
this._options.enableLogs = this._options.enableLogs ?? this._options._experiments?.enableLogs;
this._options.enableLogs = this._options.enableLogs ?? this._options._experiments?.enableLogs ?? true;
if (this._options.enableLogs) {

@@ -120,0 +120,0 @@ setupWeightBasedFlushing(this, "afterCaptureLog", "flushLogs", estimateLogSizeInBytes, _INTERNAL_flushLogsBuffer);

@@ -1,1 +0,1 @@

{"version":3,"file":"consola.js","sources":["../../../src/integrations/consola.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { getClient } from '../currentScopes';\nimport { _INTERNAL_captureLog } from '../logs/internal';\nimport { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions } from '../logs/utils';\nimport type { LogSeverityLevel } from '../types/log';\nimport { isPlainObject } from '../utils/is';\nimport { normalize } from '../utils/normalize';\n\n/**\n * Result of extracting structured attributes from console arguments.\n */\ninterface ExtractAttributesResult {\n /**\n * The log message to use for the log entry, typically constructed from the console arguments.\n */\n message?: string;\n\n /**\n * The parameterized template string which is added as `sentry.message.template` attribute if applicable.\n */\n messageTemplate?: string;\n\n /**\n * Remaining arguments to process as attributes with keys like `sentry.message.parameter.0`, `sentry.message.parameter.1`, etc.\n */\n messageParameters?: unknown[];\n\n /**\n * Additional attributes to add to the log.\n */\n attributes?: Record<string, unknown>;\n}\n\n/**\n * Options for the Sentry Consola reporter.\n */\ninterface ConsolaReporterOptions {\n /**\n * Use this option to filter which levels should be captured. By default, all levels are captured.\n *\n * @example\n * ```ts\n * const sentryReporter = Sentry.createConsolaReporter({\n * // Only capture error and warn logs\n * levels: ['error', 'warn'],\n * });\n * consola.addReporter(sentryReporter);\n * ```\n */\n levels?: Array<LogSeverityLevel>;\n\n /**\n * Optionally provide a specific Sentry client instance to use for capturing logs.\n * If not provided, the current client will be retrieved using `getClient()`.\n *\n * This is useful when you want to use specific client options for log normalization\n * or when working with multiple client instances.\n *\n * @example\n * ```ts\n * const sentryReporter = Sentry.createConsolaReporter({\n * client: myCustomClient,\n * });\n * ```\n */\n client?: Client;\n}\n\nexport interface ConsolaReporter {\n log: (logObj: ConsolaLogObject) => void;\n}\n\n/**\n * Represents a log object that Consola reporters receive.\n *\n * This interface matches the structure of log objects passed to Consola reporters.\n * See: https://github.com/unjs/consola#custom-reporters\n *\n * @example\n * ```ts\n * const reporter = {\n * log(logObj: ConsolaLogObject) {\n * console.log(`[${logObj.type}] ${logObj.message || logObj.args?.join(' ')}`);\n * }\n * };\n * consola.addReporter(reporter);\n * ```\n */\nexport interface ConsolaLogObject {\n /**\n * Allows additional custom properties to be set on the log object. These properties will be captured as log attributes.\n *\n * Additional properties are set when passing a single object with a `message` (`consola.[type]({ message: '', ... })`) or if the reporter is called directly\n *\n * @example\n * ```ts\n * const reporter = Sentry.createConsolaReporter();\n * reporter.log({\n * type: 'info',\n * message: 'User action',\n * userId: 123,\n * sessionId: 'abc-123'\n * });\n * // Will create attributes: `userId` and `sessionId`\n * ```\n */\n [key: string]: unknown;\n\n /**\n * The numeric log level (0-5) or null.\n *\n * Consola log levels:\n * - 0: Fatal and Error\n * - 1: Warnings\n * - 2: Normal logs\n * - 3: Informational logs, success, fail, ready, start, box, ...\n * - 4: Debug logs\n * - 5: Trace logs\n * - null: Some special types like 'verbose'\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#log-level\n */\n level?: number | null;\n\n /**\n * The log type/method name (e.g., 'error', 'warn', 'info', 'debug', 'trace', 'success', 'fail', etc.).\n *\n * Consola built-in types include:\n * - Standard: silent, fatal, error, warn, log, info, success, fail, ready, start, box, debug, trace, verbose\n * - Custom types can also be defined\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#log-types\n */\n type?: string;\n\n /**\n * An optional tag/scope for the log entry.\n *\n * Tags are created using `consola.withTag('scope')` and help categorize logs.\n *\n * @example\n * ```ts\n * const scopedLogger = consola.withTag('auth');\n * scopedLogger.info('User logged in'); // tag will be 'auth'\n * ```\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#withtagtag\n */\n tag?: string;\n\n /**\n * The raw arguments passed to the log method.\n *\n * These args are typically formatted into the final `message`. In Consola reporters, `message` is not provided. See: https://github.com/unjs/consola/issues/406#issuecomment-3684792551\n *\n * @example\n * ```ts\n * consola.info('Hello', 'world', { user: 'john' });\n * // args = ['Hello', 'world', { user: 'john' }]\n * ```\n *\n * @example\n * ```ts\n * // `message` is a reserved property in Consola\n * consola.log({ message: 'Hello' });\n * // args = ['Hello']\n * ```\n */\n args?: unknown[];\n\n /**\n * The timestamp when the log was created.\n *\n * This is automatically set by Consola when the log is created.\n */\n date?: Date;\n\n /**\n * The formatted log message.\n *\n * When provided, this is the final formatted message. When not provided,\n * the message should be constructed from the `args` array.\n *\n * Note: In reporters, `message` is typically undefined. It is primarily for\n * `consola.[type]({ message: 'xxx' })` usage and is normalized into `args` before\n * reporters receive the log object. See: https://github.com/unjs/consola/issues/406#issuecomment-3684792551\n */\n message?: string;\n}\n\nconst DEFAULT_CAPTURED_LEVELS: Array<LogSeverityLevel> = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];\n\n/**\n * Creates a new Sentry reporter for Consola that forwards logs to Sentry. Requires the `enableLogs` option to be enabled.\n *\n * **Note: This integration supports Consola v3.x only.** The reporter interface and log object structure\n * may differ in other versions of Consola.\n *\n * @param options - Configuration options for the reporter.\n * @returns A Consola reporter that can be added to consola instances.\n *\n * @example\n * ```ts\n * import * as Sentry from '@sentry/node';\n * import { consola } from 'consola';\n *\n * Sentry.init({\n * enableLogs: true,\n * });\n *\n * const sentryReporter = Sentry.createConsolaReporter({\n * // Optional: filter levels to capture\n * levels: ['error', 'warn', 'info'],\n * });\n *\n * consola.addReporter(sentryReporter);\n *\n * // Now consola logs will be captured by Sentry\n * consola.info('This will be sent to Sentry');\n * consola.error('This error will also be sent to Sentry');\n * ```\n */\nexport function createConsolaReporter(options: ConsolaReporterOptions = {}): ConsolaReporter {\n const levels = new Set(options.levels ?? DEFAULT_CAPTURED_LEVELS);\n const providedClient = options.client;\n\n return {\n log(logObj: ConsolaLogObject) {\n // We need to exclude certain known properties from being added as additional attributes\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { type, level, message: consolaMessage, args, tag, date: _date, ...rest } = logObj;\n\n // Get client - use provided client or current client\n const client = providedClient || getClient();\n if (!client) {\n return;\n }\n\n // Determine the log severity level\n const logSeverityLevel = getLogSeverityLevel(type, level);\n\n // Early exit if this level should not be captured\n if (!levels.has(logSeverityLevel)) {\n return;\n }\n\n const { normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();\n\n const attributes: Record<string, unknown> = {};\n\n // Build attributes\n for (const [key, value] of Object.entries(rest)) {\n attributes[key] = normalize(value, normalizeDepth, normalizeMaxBreadth);\n }\n\n attributes['sentry.origin'] = 'auto.log.consola';\n\n if (tag) {\n attributes['consola.tag'] = tag;\n }\n\n if (type) {\n attributes['consola.type'] = type;\n }\n\n // Only add level if it's a valid number (not null/undefined)\n if (level != null && typeof level === 'number') {\n attributes['consola.level'] = level;\n }\n\n const extractionResult = processExtractedAttributes(\n defaultExtractAttributes(args, normalizeDepth, normalizeMaxBreadth),\n normalizeDepth,\n normalizeMaxBreadth,\n );\n\n if (extractionResult?.attributes) {\n Object.assign(attributes, extractionResult.attributes);\n }\n\n _INTERNAL_captureLog({\n level: logSeverityLevel,\n message:\n extractionResult?.message ||\n consolaMessage ||\n (args && formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth)) ||\n '',\n attributes,\n });\n },\n };\n}\n\n// Mapping from consola log types to Sentry log severity levels\nconst CONSOLA_TYPE_TO_LOG_SEVERITY_LEVEL_MAP: Record<string, LogSeverityLevel> = {\n // Consola built-in types\n silent: 'trace',\n fatal: 'fatal',\n error: 'error',\n warn: 'warn',\n log: 'info',\n info: 'info',\n success: 'info',\n fail: 'error',\n ready: 'info',\n start: 'info',\n box: 'info',\n debug: 'debug',\n trace: 'trace',\n verbose: 'debug',\n // Custom types that might exist\n critical: 'fatal',\n notice: 'info',\n};\n\n// Mapping from consola log levels (numbers) to Sentry log severity levels\nconst CONSOLA_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP: Record<number, LogSeverityLevel> = {\n 0: 'fatal', // Fatal and Error\n 1: 'warn', // Warnings\n 2: 'info', // Normal logs\n 3: 'info', // Informational logs, success, fail, ready, start, ...\n 4: 'debug', // Debug logs\n 5: 'trace', // Trace logs\n};\n\n/**\n * Determines the log severity level from Consola type and level.\n *\n * @param type - The Consola log type (e.g., 'error', 'warn', 'info')\n * @param level - The Consola numeric log level (0-5) or null for some types like 'verbose'\n * @returns The corresponding Sentry log severity level\n */\nfunction getLogSeverityLevel(type?: string, level?: number | null): LogSeverityLevel {\n // Handle special case for verbose logs (level can be null with infinite level in Consola)\n if (type === 'verbose') {\n return 'debug';\n }\n\n // Handle silent logs - these should be at trace level\n if (type === 'silent') {\n return 'trace';\n }\n\n // First try to map by type (more specific)\n if (type) {\n const mappedLevel = CONSOLA_TYPE_TO_LOG_SEVERITY_LEVEL_MAP[type];\n if (mappedLevel) {\n return mappedLevel;\n }\n }\n\n // Fallback to level mapping (handle null level)\n if (typeof level === 'number') {\n const mappedLevel = CONSOLA_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP[level];\n if (mappedLevel) {\n return mappedLevel;\n }\n }\n\n // Default fallback\n return 'info';\n}\n\n/**\n * Extracts structured attributes from console arguments. If the first argument is a plain object, its properties are extracted as attributes.\n */\nfunction defaultExtractAttributes(\n args: unknown[] | undefined,\n normalizeDepth: number,\n normalizeMaxBreadth: number,\n): ExtractAttributesResult {\n if (!args?.length) {\n return { message: '' };\n }\n\n // Message looks like how consola logs the message to the console (all args stringified and joined)\n const message = formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth);\n\n const firstArg = args[0];\n\n if (isPlainObject(firstArg)) {\n // Remaining args start from index 2 i f we used second arg as message, otherwise from index 1\n const remainingArgsStartIndex = typeof args[1] === 'string' ? 2 : 1;\n const remainingArgs = args.slice(remainingArgsStartIndex);\n\n return {\n message,\n // Object content from first arg is added as attributes\n attributes: firstArg,\n // Add remaining args as message parameters\n messageParameters: remainingArgs,\n };\n } else {\n const followingArgs = args.slice(1);\n\n const shouldAddTemplateAttr =\n followingArgs.length > 0 && typeof firstArg === 'string' && !hasConsoleSubstitutions(firstArg);\n\n return {\n message,\n messageTemplate: shouldAddTemplateAttr ? firstArg : undefined,\n messageParameters: shouldAddTemplateAttr ? followingArgs : undefined,\n };\n }\n}\n\n/**\n * Processes extracted attributes by normalizing them and preparing message parameter attributes if a template is present.\n */\nfunction processExtractedAttributes(\n extractionResult: ExtractAttributesResult,\n normalizeDepth: number,\n normalizeMaxBreadth: number,\n): { message: string | undefined; attributes: Record<string, unknown> } {\n const { message, attributes, messageTemplate, messageParameters } = extractionResult;\n\n const messageParamAttributes: Record<string, unknown> = {};\n\n if (messageTemplate && messageParameters) {\n const templateAttrs = createConsoleTemplateAttributes(messageTemplate, messageParameters);\n\n for (const [key, value] of Object.entries(templateAttrs)) {\n messageParamAttributes[key] = key.startsWith('sentry.message.parameter.')\n ? normalize(value, normalizeDepth, normalizeMaxBreadth)\n : value;\n }\n } else if (messageParameters && messageParameters.length > 0) {\n messageParameters.forEach((arg, index) => {\n messageParamAttributes[`sentry.message.parameter.${index}`] = normalize(arg, normalizeDepth, normalizeMaxBreadth);\n });\n }\n\n return {\n message: message,\n attributes: {\n ...normalize(attributes, normalizeDepth, normalizeMaxBreadth),\n ...messageParamAttributes,\n },\n };\n}\n"],"names":[],"mappings":";;;;;;AA8LA,MAAM,0BAAmD,CAAC,OAAA,EAAS,SAAS,MAAA,EAAQ,MAAA,EAAQ,SAAS,OAAO,CAAA;AAgCrG,SAAS,qBAAA,CAAsB,OAAA,GAAkC,EAAC,EAAoB;AAC3F,EAAA,MAAM,MAAA,GAAS,IAAI,GAAA,CAAI,OAAA,CAAQ,UAAU,uBAAuB,CAAA;AAChE,EAAA,MAAM,iBAAiB,OAAA,CAAQ,MAAA;AAE/B,EAAA,OAAO;AAAA,IACL,IAA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GACF;AACF;;;;"}
{"version":3,"file":"consola.js","sources":["../../../src/integrations/consola.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { getClient } from '../currentScopes';\nimport { _INTERNAL_captureLog } from '../logs/internal';\nimport { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions } from '../logs/utils';\nimport type { LogSeverityLevel } from '../types/log';\nimport { isPlainObject } from '../utils/is';\nimport { normalize } from '../utils/normalize';\n\n/**\n * Result of extracting structured attributes from console arguments.\n */\ninterface ExtractAttributesResult {\n /**\n * The log message to use for the log entry, typically constructed from the console arguments.\n */\n message?: string;\n\n /**\n * The parameterized template string which is added as `sentry.message.template` attribute if applicable.\n */\n messageTemplate?: string;\n\n /**\n * Remaining arguments to process as attributes with keys like `sentry.message.parameter.0`, `sentry.message.parameter.1`, etc.\n */\n messageParameters?: unknown[];\n\n /**\n * Additional attributes to add to the log.\n */\n attributes?: Record<string, unknown>;\n}\n\n/**\n * Options for the Sentry Consola reporter.\n */\ninterface ConsolaReporterOptions {\n /**\n * Use this option to filter which levels should be captured. By default, all levels are captured.\n *\n * @example\n * ```ts\n * const sentryReporter = Sentry.createConsolaReporter({\n * // Only capture error and warn logs\n * levels: ['error', 'warn'],\n * });\n * consola.addReporter(sentryReporter);\n * ```\n */\n levels?: Array<LogSeverityLevel>;\n\n /**\n * Optionally provide a specific Sentry client instance to use for capturing logs.\n * If not provided, the current client will be retrieved using `getClient()`.\n *\n * This is useful when you want to use specific client options for log normalization\n * or when working with multiple client instances.\n *\n * @example\n * ```ts\n * const sentryReporter = Sentry.createConsolaReporter({\n * client: myCustomClient,\n * });\n * ```\n */\n client?: Client;\n}\n\nexport interface ConsolaReporter {\n log: (logObj: ConsolaLogObject) => void;\n}\n\n/**\n * Represents a log object that Consola reporters receive.\n *\n * This interface matches the structure of log objects passed to Consola reporters.\n * See: https://github.com/unjs/consola#custom-reporters\n *\n * @example\n * ```ts\n * const reporter = {\n * log(logObj: ConsolaLogObject) {\n * console.log(`[${logObj.type}] ${logObj.message || logObj.args?.join(' ')}`);\n * }\n * };\n * consola.addReporter(reporter);\n * ```\n */\nexport interface ConsolaLogObject {\n /**\n * Allows additional custom properties to be set on the log object. These properties will be captured as log attributes.\n *\n * Additional properties are set when passing a single object with a `message` (`consola.[type]({ message: '', ... })`) or if the reporter is called directly\n *\n * @example\n * ```ts\n * const reporter = Sentry.createConsolaReporter();\n * reporter.log({\n * type: 'info',\n * message: 'User action',\n * userId: 123,\n * sessionId: 'abc-123'\n * });\n * // Will create attributes: `userId` and `sessionId`\n * ```\n */\n [key: string]: unknown;\n\n /**\n * The numeric log level (0-5) or null.\n *\n * Consola log levels:\n * - 0: Fatal and Error\n * - 1: Warnings\n * - 2: Normal logs\n * - 3: Informational logs, success, fail, ready, start, box, ...\n * - 4: Debug logs\n * - 5: Trace logs\n * - null: Some special types like 'verbose'\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#log-level\n */\n level?: number | null;\n\n /**\n * The log type/method name (e.g., 'error', 'warn', 'info', 'debug', 'trace', 'success', 'fail', etc.).\n *\n * Consola built-in types include:\n * - Standard: silent, fatal, error, warn, log, info, success, fail, ready, start, box, debug, trace, verbose\n * - Custom types can also be defined\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#log-types\n */\n type?: string;\n\n /**\n * An optional tag/scope for the log entry.\n *\n * Tags are created using `consola.withTag('scope')` and help categorize logs.\n *\n * @example\n * ```ts\n * const scopedLogger = consola.withTag('auth');\n * scopedLogger.info('User logged in'); // tag will be 'auth'\n * ```\n *\n * See: https://github.com/unjs/consola/blob/main/README.md#withtagtag\n */\n tag?: string;\n\n /**\n * The raw arguments passed to the log method.\n *\n * These args are typically formatted into the final `message`. In Consola reporters, `message` is not provided. See: https://github.com/unjs/consola/issues/406#issuecomment-3684792551\n *\n * @example\n * ```ts\n * consola.info('Hello', 'world', { user: 'john' });\n * // args = ['Hello', 'world', { user: 'john' }]\n * ```\n *\n * @example\n * ```ts\n * // `message` is a reserved property in Consola\n * consola.log({ message: 'Hello' });\n * // args = ['Hello']\n * ```\n */\n args?: unknown[];\n\n /**\n * The timestamp when the log was created.\n *\n * This is automatically set by Consola when the log is created.\n */\n date?: Date;\n\n /**\n * The formatted log message.\n *\n * When provided, this is the final formatted message. When not provided,\n * the message should be constructed from the `args` array.\n *\n * Note: In reporters, `message` is typically undefined. It is primarily for\n * `consola.[type]({ message: 'xxx' })` usage and is normalized into `args` before\n * reporters receive the log object. See: https://github.com/unjs/consola/issues/406#issuecomment-3684792551\n */\n message?: string;\n}\n\nconst DEFAULT_CAPTURED_LEVELS: Array<LogSeverityLevel> = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];\n\n/**\n * Creates a new Sentry reporter for Consola that forwards logs to Sentry.\n *\n * **Note: This integration supports Consola v3.x only.** The reporter interface and log object structure\n * may differ in other versions of Consola.\n *\n * @param options - Configuration options for the reporter.\n * @returns A Consola reporter that can be added to consola instances.\n *\n * @example\n * ```ts\n * import * as Sentry from '@sentry/node';\n * import { consola } from 'consola';\n *\n * Sentry.init({\n * dsn: '__DSN__',\n * });\n *\n * const sentryReporter = Sentry.createConsolaReporter({\n * // Optional: filter levels to capture\n * levels: ['error', 'warn', 'info'],\n * });\n *\n * consola.addReporter(sentryReporter);\n *\n * // Now consola logs will be captured by Sentry\n * consola.info('This will be sent to Sentry');\n * consola.error('This error will also be sent to Sentry');\n * ```\n */\nexport function createConsolaReporter(options: ConsolaReporterOptions = {}): ConsolaReporter {\n const levels = new Set(options.levels ?? DEFAULT_CAPTURED_LEVELS);\n const providedClient = options.client;\n\n return {\n log(logObj: ConsolaLogObject) {\n // We need to exclude certain known properties from being added as additional attributes\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { type, level, message: consolaMessage, args, tag, date: _date, ...rest } = logObj;\n\n // Get client - use provided client or current client\n const client = providedClient || getClient();\n if (!client) {\n return;\n }\n\n // Determine the log severity level\n const logSeverityLevel = getLogSeverityLevel(type, level);\n\n // Early exit if this level should not be captured\n if (!levels.has(logSeverityLevel)) {\n return;\n }\n\n const { normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();\n\n const attributes: Record<string, unknown> = {};\n\n // Build attributes\n for (const [key, value] of Object.entries(rest)) {\n attributes[key] = normalize(value, normalizeDepth, normalizeMaxBreadth);\n }\n\n attributes['sentry.origin'] = 'auto.log.consola';\n\n if (tag) {\n attributes['consola.tag'] = tag;\n }\n\n if (type) {\n attributes['consola.type'] = type;\n }\n\n // Only add level if it's a valid number (not null/undefined)\n if (level != null && typeof level === 'number') {\n attributes['consola.level'] = level;\n }\n\n const extractionResult = processExtractedAttributes(\n defaultExtractAttributes(args, normalizeDepth, normalizeMaxBreadth),\n normalizeDepth,\n normalizeMaxBreadth,\n );\n\n if (extractionResult?.attributes) {\n Object.assign(attributes, extractionResult.attributes);\n }\n\n _INTERNAL_captureLog({\n level: logSeverityLevel,\n message:\n extractionResult?.message ||\n consolaMessage ||\n (args && formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth)) ||\n '',\n attributes,\n });\n },\n };\n}\n\n// Mapping from consola log types to Sentry log severity levels\nconst CONSOLA_TYPE_TO_LOG_SEVERITY_LEVEL_MAP: Record<string, LogSeverityLevel> = {\n // Consola built-in types\n silent: 'trace',\n fatal: 'fatal',\n error: 'error',\n warn: 'warn',\n log: 'info',\n info: 'info',\n success: 'info',\n fail: 'error',\n ready: 'info',\n start: 'info',\n box: 'info',\n debug: 'debug',\n trace: 'trace',\n verbose: 'debug',\n // Custom types that might exist\n critical: 'fatal',\n notice: 'info',\n};\n\n// Mapping from consola log levels (numbers) to Sentry log severity levels\nconst CONSOLA_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP: Record<number, LogSeverityLevel> = {\n 0: 'fatal', // Fatal and Error\n 1: 'warn', // Warnings\n 2: 'info', // Normal logs\n 3: 'info', // Informational logs, success, fail, ready, start, ...\n 4: 'debug', // Debug logs\n 5: 'trace', // Trace logs\n};\n\n/**\n * Determines the log severity level from Consola type and level.\n *\n * @param type - The Consola log type (e.g., 'error', 'warn', 'info')\n * @param level - The Consola numeric log level (0-5) or null for some types like 'verbose'\n * @returns The corresponding Sentry log severity level\n */\nfunction getLogSeverityLevel(type?: string, level?: number | null): LogSeverityLevel {\n // Handle special case for verbose logs (level can be null with infinite level in Consola)\n if (type === 'verbose') {\n return 'debug';\n }\n\n // Handle silent logs - these should be at trace level\n if (type === 'silent') {\n return 'trace';\n }\n\n // First try to map by type (more specific)\n if (type) {\n const mappedLevel = CONSOLA_TYPE_TO_LOG_SEVERITY_LEVEL_MAP[type];\n if (mappedLevel) {\n return mappedLevel;\n }\n }\n\n // Fallback to level mapping (handle null level)\n if (typeof level === 'number') {\n const mappedLevel = CONSOLA_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP[level];\n if (mappedLevel) {\n return mappedLevel;\n }\n }\n\n // Default fallback\n return 'info';\n}\n\n/**\n * Extracts structured attributes from console arguments. If the first argument is a plain object, its properties are extracted as attributes.\n */\nfunction defaultExtractAttributes(\n args: unknown[] | undefined,\n normalizeDepth: number,\n normalizeMaxBreadth: number,\n): ExtractAttributesResult {\n if (!args?.length) {\n return { message: '' };\n }\n\n // Message looks like how consola logs the message to the console (all args stringified and joined)\n const message = formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth);\n\n const firstArg = args[0];\n\n if (isPlainObject(firstArg)) {\n // Remaining args start from index 2 i f we used second arg as message, otherwise from index 1\n const remainingArgsStartIndex = typeof args[1] === 'string' ? 2 : 1;\n const remainingArgs = args.slice(remainingArgsStartIndex);\n\n return {\n message,\n // Object content from first arg is added as attributes\n attributes: firstArg,\n // Add remaining args as message parameters\n messageParameters: remainingArgs,\n };\n } else {\n const followingArgs = args.slice(1);\n\n const shouldAddTemplateAttr =\n followingArgs.length > 0 && typeof firstArg === 'string' && !hasConsoleSubstitutions(firstArg);\n\n return {\n message,\n messageTemplate: shouldAddTemplateAttr ? firstArg : undefined,\n messageParameters: shouldAddTemplateAttr ? followingArgs : undefined,\n };\n }\n}\n\n/**\n * Processes extracted attributes by normalizing them and preparing message parameter attributes if a template is present.\n */\nfunction processExtractedAttributes(\n extractionResult: ExtractAttributesResult,\n normalizeDepth: number,\n normalizeMaxBreadth: number,\n): { message: string | undefined; attributes: Record<string, unknown> } {\n const { message, attributes, messageTemplate, messageParameters } = extractionResult;\n\n const messageParamAttributes: Record<string, unknown> = {};\n\n if (messageTemplate && messageParameters) {\n const templateAttrs = createConsoleTemplateAttributes(messageTemplate, messageParameters);\n\n for (const [key, value] of Object.entries(templateAttrs)) {\n messageParamAttributes[key] = key.startsWith('sentry.message.parameter.')\n ? normalize(value, normalizeDepth, normalizeMaxBreadth)\n : value;\n }\n } else if (messageParameters && messageParameters.length > 0) {\n messageParameters.forEach((arg, index) => {\n messageParamAttributes[`sentry.message.parameter.${index}`] = normalize(arg, normalizeDepth, normalizeMaxBreadth);\n });\n }\n\n return {\n message: message,\n attributes: {\n ...normalize(attributes, normalizeDepth, normalizeMaxBreadth),\n ...messageParamAttributes,\n },\n };\n}\n"],"names":[],"mappings":";;;;;;AA8LA,MAAM,0BAAmD,CAAC,OAAA,EAAS,SAAS,MAAA,EAAQ,MAAA,EAAQ,SAAS,OAAO,CAAA;AAgCrG,SAAS,qBAAA,CAAsB,OAAA,GAAkC,EAAC,EAAoB;AAC3F,EAAA,MAAM,MAAA,GAAS,IAAI,GAAA,CAAI,OAAA,CAAQ,UAAU,uBAAuB,CAAA;AAChE,EAAA,MAAM,iBAAiB,OAAA,CAAQ,MAAA;AAE/B,EAAA,OAAO;AAAA,IACL,IAAI,MAAA,EAA0B;AAG5B,MAAA,MAAM,EAAE,IAAA,EAAM,KAAA,EAAO,OAAA,EAAS,cAAA,EAAgB,IAAA,EAAM,GAAA,EAAK,IAAA,EAAM,KAAA,EAAO,GAAG,IAAA,EAAK,GAAI,MAAA;AAGlF,MAAA,MAAM,MAAA,GAAS,kBAAkB,SAAA,EAAU;AAC3C,MAAA,IAAI,CAAC,MAAA,EAAQ;AACX,QAAA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A,cAAA,EACA,mBAAA,EACsE;AACtE,EAAA,MAAM,EAAE,OAAA,EAAS,UAAA,EAAY,eAAA,EAAiB,mBAAkB,GAAI,gBAAA;AAEpE,EAAA,MAAM,yBAAkD,EAAC;AAEzD,EAAA,IAAI,mBAAmB,iBAAA,EAAmB;AACxC,IAAA,MAAM,aAAA,GAAgB,+BAAA,CAAgC,eAAA,EAAiB,iBAAiB,CAAA;AAExF,IAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,aAAa,CAAA,EAAG;AACxD,MAAA,sBAAA,CAAuB,GAAG,CAAA,GAAI,GAAA,CAAI,UAAA,CAAW,2BAA2B,IACpE,SAAA,CAAU,KAAA,EAAO,cAAA,EAAgB,mBAAmB,CAAA,GACpD,KAAA;AAAA,IACN;AAAA,EACF,CAAA,MAAA,IAAW,iBAAA,IAAqB,iBAAA,CAAkB,MAAA,GAAS,CAAA,EAAG;AAC5D,IAAA,iBAAA,CAAkB,OAAA,CAAQ,CAAC,GAAA,EAAK,KAAA,KAAU;AACxC,MAAA,sBAAA,CAAuB,4BAA4B,KAAK,CAAA,CAAE,IAAI,SAAA,CAAU,GAAA,EAAK,gBAAgB,mBAAmB,CAAA;AAAA,IAClH,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,UAAA,EAAY;AAAA,MACV,GAAG,SAAA,CAAU,UAAA,EAAY,cAAA,EAAgB,mBAAmB,CAAA;AAAA,MAC5D,GAAG;AAAA;AACL,GACF;AACF;;;;"}

@@ -88,2 +88,14 @@ import { addBreadcrumb } from '../breadcrumbs.js';

}
function getHeader(headers, name) {
if (!headers) {
return void 0;
}
if (typeof headers.get === "function") {
return headers.get(name) ?? void 0;
}
const plainHeaders = headers;
const lowerCaseName = name.toLowerCase();
const key = Object.keys(plainHeaders).find((headerName) => headerName.toLowerCase() === lowerCaseName);
return key !== void 0 ? plainHeaders[key] : void 0;
}
function extractOperation(method, headers = {}) {

@@ -95,3 +107,3 @@ switch (method) {

case "POST": {
if (headers["Prefer"]?.includes("resolution=")) {
if (getHeader(headers, "Prefer")?.includes("resolution=")) {
return "upsert";

@@ -264,3 +276,3 @@ } else {

"db.url": typedThis.url.origin,
"db.sdk": typedThis.headers["X-Client-Info"],
"db.sdk": getHeader(typedThis.headers, "X-Client-Info"),
"db.system": "postgresql",

@@ -393,3 +405,3 @@ "db.operation": operation,

export { DB_OPERATIONS_TO_INSTRUMENT, FILTER_MAPPINGS, extractOperation, instrumentSupabaseClient, supabaseIntegration, translateFiltersIntoMethods };
export { DB_OPERATIONS_TO_INSTRUMENT, FILTER_MAPPINGS, extractOperation, getHeader, instrumentSupabaseClient, supabaseIntegration, translateFiltersIntoMethods };
//# sourceMappingURL=supabase.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"supabase.js","sources":["../../../src/integrations/supabase.ts"],"sourcesContent":["// Based on Kamil Ogórek's work on:\n// https://github.com/supabase-community/sentry-integration-js\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable max-lines */\nimport { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { captureException } from '../exports';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport { setHttpStatus, SPAN_STATUS_ERROR, SPAN_STATUS_OK, startSpan } from '../tracing';\nimport type { IntegrationFn } from '../types/integration';\nimport { debug } from '../utils/debug-logger';\nimport { isObjectLike, isPlainObject } from '../utils/is';\nimport { addExceptionMechanism } from '../utils/misc';\n\nconst AUTH_OPERATIONS_TO_INSTRUMENT = [\n 'reauthenticate',\n 'signInAnonymously',\n 'signInWithOAuth',\n 'signInWithIdToken',\n 'signInWithOtp',\n 'signInWithPassword',\n 'signInWithSSO',\n 'signOut',\n 'signUp',\n 'verifyOtp',\n];\n\nconst AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT = [\n 'createUser',\n 'deleteUser',\n 'listUsers',\n 'getUserById',\n 'updateUserById',\n 'inviteUserByEmail',\n];\n\nexport const FILTER_MAPPINGS = {\n eq: 'eq',\n neq: 'neq',\n gt: 'gt',\n gte: 'gte',\n lt: 'lt',\n lte: 'lte',\n like: 'like',\n 'like(all)': 'likeAllOf',\n 'like(any)': 'likeAnyOf',\n ilike: 'ilike',\n 'ilike(all)': 'ilikeAllOf',\n 'ilike(any)': 'ilikeAnyOf',\n is: 'is',\n in: 'in',\n cs: 'contains',\n cd: 'containedBy',\n sr: 'rangeGt',\n nxl: 'rangeGte',\n sl: 'rangeLt',\n nxr: 'rangeLte',\n adj: 'rangeAdjacent',\n ov: 'overlaps',\n fts: '',\n plfts: 'plain',\n phfts: 'phrase',\n wfts: 'websearch',\n not: 'not',\n};\n\nexport const DB_OPERATIONS_TO_INSTRUMENT = ['select', 'insert', 'upsert', 'update', 'delete'];\n\ntype AuthOperationFn = (...args: unknown[]) => Promise<unknown>;\ntype AuthOperationName = (typeof AUTH_OPERATIONS_TO_INSTRUMENT)[number];\ntype AuthAdminOperationName = (typeof AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT)[number];\ntype PostgRESTQueryOperationFn = (...args: unknown[]) => PostgRESTFilterBuilder;\n\nexport interface SupabaseClientInstance {\n auth: {\n admin: Record<AuthAdminOperationName, AuthOperationFn>;\n } & Record<AuthOperationName, AuthOperationFn>;\n}\n\nexport interface PostgRESTQueryBuilder {\n [key: string]: PostgRESTQueryOperationFn;\n}\n\nexport interface PostgRESTFilterBuilder {\n method: string;\n headers: Record<string, string>;\n url: URL;\n schema: string;\n body: any;\n}\n\nexport interface SupabaseResponse {\n status?: number;\n error?: {\n message: string;\n code?: string;\n details?: unknown;\n };\n}\n\nexport interface SupabaseError extends Error {\n code?: string;\n details?: unknown;\n}\n\nexport interface SupabaseBreadcrumb {\n type: string;\n category: string;\n message: string;\n data?: {\n query?: string[];\n body?: Record<string, unknown>;\n };\n}\n\nexport interface SupabaseClientConstructor {\n prototype: {\n from: (table: string) => PostgRESTQueryBuilder;\n };\n}\n\nexport interface PostgRESTProtoThenable {\n then: <T>(\n onfulfilled?: ((value: T) => T | PromiseLike<T>) | null,\n onrejected?: ((reason: any) => T | PromiseLike<T>) | null,\n ) => Promise<T>;\n}\n\ntype SentryInstrumented<T> = T & {\n __SENTRY_INSTRUMENTED__?: boolean;\n};\n\nfunction markAsInstrumented<T>(fn: T): void {\n try {\n (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__ = true;\n } catch {\n // ignore errors here\n }\n}\n\nfunction isInstrumented<T>(fn: T): boolean | undefined {\n try {\n return (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__;\n } catch {\n return false;\n }\n}\n\n/**\n * Plain-object bodies are copied into `plainBody`; array inserts (and other non-plain shapes) stay only on `rawBody`.\n * Returns a payload suitable for span attributes / breadcrumbs when operation data collection is enabled.\n */\nfunction getMutationBodyPayloadForTelemetry(rawBody: unknown, plainBody: Record<string, unknown>): unknown | undefined {\n if (Object.keys(plainBody).length > 0) {\n return plainBody;\n }\n if (Array.isArray(rawBody) && rawBody.length > 0) {\n return rawBody;\n }\n return undefined;\n}\n\n/** True when the PostgREST builder carries a mutation body (for `insert(...)`, etc. in span descriptions). */\nfunction hasMutationBodyForDescription(rawBody: unknown, plainBody: Record<string, unknown>): boolean {\n return getMutationBodyPayloadForTelemetry(rawBody, plainBody) !== undefined;\n}\n\n/**\n * Extracts the database operation type from the HTTP method and headers\n * @param method - The HTTP method of the request\n * @param headers - The request headers\n * @returns The database operation type ('select', 'insert', 'upsert', 'update', or 'delete')\n */\nexport function extractOperation(method: string, headers: Record<string, string> = {}): string {\n switch (method) {\n case 'GET': {\n return 'select';\n }\n case 'POST': {\n if (headers['Prefer']?.includes('resolution=')) {\n return 'upsert';\n } else {\n return 'insert';\n }\n }\n case 'PATCH': {\n return 'update';\n }\n case 'DELETE': {\n return 'delete';\n }\n default: {\n return '<unknown-op>';\n }\n }\n}\n\n/**\n * Translates Supabase filter parameters into readable method names for tracing\n * @param key - The filter key from the URL search parameters\n * @param query - The filter value from the URL search parameters\n * @returns A string representation of the filter as a method call\n */\nexport function translateFiltersIntoMethods(key: string, query: string): string {\n if (query === '' || query === '*') {\n return 'select(*)';\n }\n\n if (key === 'select') {\n return `select(${query})`;\n }\n\n if (key === 'or' || key.endsWith('.or')) {\n return `${key}${query}`;\n }\n\n const [filter, ...value] = query.split('.');\n\n let method;\n // Handle optional `configPart` of the filter\n if (filter?.startsWith('fts')) {\n method = 'textSearch';\n } else if (filter?.startsWith('plfts')) {\n method = 'textSearch[plain]';\n } else if (filter?.startsWith('phfts')) {\n method = 'textSearch[phrase]';\n } else if (filter?.startsWith('wfts')) {\n method = 'textSearch[websearch]';\n } else {\n method = (filter && FILTER_MAPPINGS[filter as keyof typeof FILTER_MAPPINGS]) || 'filter';\n }\n\n return `${method}(${key}, ${value.join('.')})`;\n}\n\nfunction instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): AuthOperationFn {\n return new Proxy(operation, {\n apply(target, thisArg, argumentsList) {\n return startSpan(\n {\n name: `auth ${isAdmin ? '(admin) ' : ''}${operation.name}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n 'db.system': 'postgresql',\n 'db.operation': `auth.${isAdmin ? 'admin.' : ''}${operation.name}`,\n },\n },\n span => {\n return Reflect.apply(target, thisArg, argumentsList)\n .then((res: unknown) => {\n if (isObjectLike(res) && 'error' in res && res.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n\n captureException(res.error, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n } else {\n span.setStatus({ code: SPAN_STATUS_OK });\n }\n\n span.end();\n return res;\n })\n .catch((err: unknown) => {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n span.end();\n\n captureException(err, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n\n throw err;\n })\n .then(...argumentsList);\n },\n );\n },\n });\n}\n\nfunction instrumentSupabaseAuthClient(supabaseClientInstance: SupabaseClientInstance): void {\n const auth = supabaseClientInstance.auth;\n\n if (!auth || isInstrumented(supabaseClientInstance.auth)) {\n return;\n }\n\n for (const operation of AUTH_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth[operation] === 'function') {\n supabaseClientInstance.auth[operation] = instrumentAuthOperation(authOperation);\n }\n }\n\n for (const operation of AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth.admin[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth.admin[operation] === 'function') {\n supabaseClientInstance.auth.admin[operation] = instrumentAuthOperation(authOperation, true);\n }\n }\n\n markAsInstrumented(supabaseClientInstance.auth);\n}\n\nfunction instrumentSupabaseClientConstructor(SupabaseClient: unknown, _options: { sendOperationData?: boolean }): void {\n if (isInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from)) {\n return;\n }\n\n (SupabaseClient as SupabaseClientConstructor).prototype.from = new Proxy(\n (SupabaseClient as SupabaseClientConstructor).prototype.from,\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTQueryBuilder = (rv as PostgRESTQueryBuilder).constructor;\n\n instrumentPostgRESTQueryBuilder(PostgRESTQueryBuilder as unknown as new () => PostgRESTQueryBuilder, _options);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from);\n}\n\nfunction instrumentPostgRESTFilterBuilder(\n PostgRESTFilterBuilder: PostgRESTFilterBuilder['constructor'],\n _options: { sendOperationData?: boolean },\n): void {\n if (isInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then)) {\n return;\n }\n\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then = new Proxy(\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then,\n {\n apply(target, thisArg, argumentsList) {\n const operations = DB_OPERATIONS_TO_INSTRUMENT;\n const typedThis = thisArg as PostgRESTFilterBuilder;\n const operation = extractOperation(typedThis.method, typedThis.headers);\n\n if (!operations.includes(operation)) {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n if (!typedThis?.url?.pathname || typeof typedThis.url.pathname !== 'string') {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n const pathParts = typedThis.url.pathname.split('/');\n const table = pathParts.length > 0 ? pathParts[pathParts.length - 1] : '';\n\n const queryItems: string[] = [];\n for (const [key, value] of typedThis.url.searchParams.entries()) {\n // It's possible to have multiple entries for the same key, eg. `id=eq.7&id=eq.3`,\n // so we need to use array instead of object to collect them.\n queryItems.push(translateFiltersIntoMethods(key, value));\n }\n const body: Record<string, unknown> = Object.create(null);\n if (isPlainObject(typedThis.body)) {\n for (const [key, value] of Object.entries(typedThis.body)) {\n body[key] = value;\n }\n }\n\n const client = getClient();\n const shouldSendData =\n _options.sendOperationData ?? client?.getDataCollectionOptions().databaseQueryData === true;\n const bodyPayload = getMutationBodyPayloadForTelemetry(typedThis.body, body);\n\n // Adding operation to the beginning of the description if it's not a `select` operation\n // For example, it can be an `insert` or `update` operation but the query can be `select(...)`\n // For `select` operations, we don't need repeat it in the description\n const mutationPart =\n operation === 'select'\n ? ''\n : `${operation}${hasMutationBodyForDescription(typedThis.body, body) ? '(...) ' : ''}`;\n const queryPart = shouldSendData ? queryItems.join(' ') : queryItems.length > 0 ? '[redacted]' : '';\n const descriptionMiddle = [mutationPart.trimEnd(), queryPart].filter(Boolean).join(' ');\n const description = descriptionMiddle ? `${descriptionMiddle} from(${table})` : `from(${table})`;\n\n const attributes: Record<string, any> = {\n 'db.table': table,\n 'db.schema': typedThis.schema,\n 'db.url': typedThis.url.origin,\n 'db.sdk': typedThis.headers['X-Client-Info'],\n 'db.system': 'postgresql',\n 'db.operation': operation,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n };\n\n if (queryItems.length && shouldSendData) {\n attributes['db.query'] = queryItems;\n }\n\n if (bodyPayload !== undefined && shouldSendData) {\n attributes['db.body'] = bodyPayload;\n }\n\n return startSpan(\n {\n name: description,\n attributes,\n },\n span => {\n return (Reflect.apply(target, thisArg, []) as Promise<SupabaseResponse>)\n .then(\n (res: SupabaseResponse) => {\n if (span) {\n if (res && typeof res === 'object' && 'status' in res) {\n setHttpStatus(span, res.status || 500);\n }\n span.end();\n }\n\n if (res?.error) {\n const err = new Error(res.error.message) as SupabaseError;\n if (res.error.code) {\n err.code = res.error.code;\n }\n if (res.error.details) {\n err.details = res.error.details;\n }\n\n const supabaseContext: Record<string, any> = {};\n if (queryItems.length && shouldSendData) {\n supabaseContext.query = queryItems;\n }\n if (bodyPayload !== undefined && shouldSendData) {\n supabaseContext.body = bodyPayload;\n }\n\n captureException(err, scope => {\n scope.addEventProcessor(e => {\n addExceptionMechanism(e, {\n handled: false,\n type: 'auto.db.supabase.postgres',\n });\n\n return e;\n });\n\n scope.setContext('supabase', supabaseContext);\n\n return scope;\n });\n }\n\n const breadcrumb: SupabaseBreadcrumb = {\n type: 'supabase',\n category: `db.${operation}`,\n message: description,\n };\n\n const data: Record<string, unknown> = {};\n\n if (queryItems.length && shouldSendData) {\n data.query = queryItems;\n }\n\n if (bodyPayload !== undefined && shouldSendData) {\n data.body = bodyPayload;\n }\n\n if (Object.keys(data).length) {\n breadcrumb.data = data;\n }\n\n addBreadcrumb(breadcrumb);\n\n return res;\n },\n (err: Error) => {\n // TODO: shouldn't we capture this error?\n if (span) {\n setHttpStatus(span, 500);\n span.end();\n }\n throw err;\n },\n )\n .then(...argumentsList);\n },\n );\n },\n },\n );\n\n markAsInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then);\n}\n\nfunction instrumentPostgRESTQueryBuilder(\n PostgRESTQueryBuilder: new () => PostgRESTQueryBuilder,\n _options: { sendOperationData?: boolean },\n): void {\n // We need to wrap _all_ operations despite them sharing the same `PostgRESTFilterBuilder`\n // constructor, as we don't know which method will be called first, and we don't want to miss any calls.\n for (const operation of DB_OPERATIONS_TO_INSTRUMENT) {\n if (isInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation])) {\n continue;\n }\n\n type PostgRESTOperation = keyof Pick<PostgRESTQueryBuilder, 'select' | 'insert' | 'upsert' | 'update' | 'delete'>;\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation] = new Proxy(\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation],\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTFilterBuilder = (rv as PostgRESTFilterBuilder).constructor;\n\n DEBUG_BUILD && debug.log(`Instrumenting ${operation} operation's PostgRESTFilterBuilder`);\n\n instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder, _options);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation]);\n }\n}\n\nexport const instrumentSupabaseClient = (\n supabaseClient: unknown,\n options: { sendOperationData?: boolean } = {},\n): void => {\n if (!supabaseClient) {\n DEBUG_BUILD && debug.warn('Supabase integration was not installed because no Supabase client was provided.');\n return;\n }\n const SupabaseClientConstructor =\n supabaseClient.constructor === Function ? supabaseClient : supabaseClient.constructor;\n\n instrumentSupabaseClientConstructor(SupabaseClientConstructor, options);\n instrumentSupabaseAuthClient(supabaseClient as SupabaseClientInstance);\n};\n\ninterface SupabaseIntegrationOptions {\n supabaseClient: any;\n /**\n * Whether to attach PostgREST query filters and mutation body payloads\n * to Sentry telemetry.\n *\n * Falls back to `dataCollection.databaseQueryData` when not set.\n * @default undefined\n */\n sendOperationData?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Supabase' as const;\n\nconst _supabaseIntegration = ((supabaseClient: unknown, options: { sendOperationData?: boolean }) => {\n return {\n setupOnce() {\n instrumentSupabaseClient(supabaseClient, options);\n },\n name: INTEGRATION_NAME,\n };\n}) satisfies IntegrationFn;\n\nexport const supabaseIntegration = defineIntegration((options: SupabaseIntegrationOptions) => {\n return _supabaseIntegration(options.supabaseClient, { sendOperationData: options.sendOperationData });\n}) satisfies IntegrationFn;\n"],"names":[],"mappings":";;;;;;;;;;;;AAiBA,MAAM,6BAAA,GAAgC;AAAA,EACpC,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,iBAAA;AAAA,EACA,mBAAA;AAAA,EACA,eAAA;AAAA,EACA,oBAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA;AAEA,MAAM,mCAAA,GAAsC;AAAA,EAC1C,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF,CAAA;AAEO,MAAM,eAAA,GAAkB;AAAA,EAC7B,EAAA,EAAI,IAAA;AAAA,EACJ,GAAA,EAAK,KAAA;AAAA,EACL,EAAA,EAAI,IAAA;AAAA,EACJ,GAAA,EAAK,KAAA;AAAA,EACL,EAAA,EAAI,IAAA;AAAA,EACJ,GAAA,EAAK,KAAA;AAAA,EACL,IAAA,EAAM,MAAA;AAAA,EACN,WAAA,EAAa,WAAA;AAAA,EACb,WAAA,EAAa,WAAA;AAAA,EACb,KAAA,EAAO,OAAA;AAAA,EACP,YAAA,EAAc,YAAA;AAAA,EACd,YAAA,EAAc,YAAA;AAAA,EACd,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,UAAA;AAAA,EACJ,EAAA,EAAI,aAAA;AAAA,EACJ,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AAiF,CAAA;AAC3G,IAAA;AAAA,EACF;AACA,EAAA,MAAM,yBAAA,GACJ,cAAA,CAAe,WAAA,KAAgB,QAAA,GAAW,iBAAiB,cAAA,CAAe,WAAA;AAE5E,EAAA,mCAAA,CAAoC,2BAA2B,OAAO,CAAA;AACtE,EAAA,4BAAA,CAA6B,cAAwC,CAAA;AACvE;AAcA,MAAM,gBAAA,GAAmB,UAAA;AAEzB,MAAM,oBAAA,IAAwB,CAAC,cAAA,EAAyB,OAAA,KAA6C;AACnG,EAAA,OAAO;AAAA,IACL,SAAA,GAAY;AACV,MAAA,wBAAA,CAAyB,gBAAgB,OAAO,CAAA;AAAA,IAClD,CAAA;AAAA,IACA,IAAA,EAAM;AAAA,GACR;AACF,CAAA,CAAA;AAEO,MAAM,mBAAA,GAAsB,iBAAA,CAAkB,CAAC,OAAA,KAAwC;AAC5F,EAAA,OAAO,qBAAqB,OAAA,CAAQ,cAAA,EAAgB,EAAE,iBAAA,EAAmB,OAAA,CAAQ,mBAAmB,CAAA;AACtG,CAAC;;;;"}
{"version":3,"file":"supabase.js","sources":["../../../src/integrations/supabase.ts"],"sourcesContent":["// Based on Kamil Ogórek's work on:\n// https://github.com/supabase-community/sentry-integration-js\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable max-lines */\nimport { addBreadcrumb } from '../breadcrumbs';\nimport { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { captureException } from '../exports';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport { setHttpStatus, SPAN_STATUS_ERROR, SPAN_STATUS_OK, startSpan } from '../tracing';\nimport type { IntegrationFn } from '../types/integration';\nimport type { WebFetchHeaders } from '../types/webfetchapi';\nimport { debug } from '../utils/debug-logger';\nimport { isObjectLike, isPlainObject } from '../utils/is';\nimport { addExceptionMechanism } from '../utils/misc';\n\nconst AUTH_OPERATIONS_TO_INSTRUMENT = [\n 'reauthenticate',\n 'signInAnonymously',\n 'signInWithOAuth',\n 'signInWithIdToken',\n 'signInWithOtp',\n 'signInWithPassword',\n 'signInWithSSO',\n 'signOut',\n 'signUp',\n 'verifyOtp',\n];\n\nconst AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT = [\n 'createUser',\n 'deleteUser',\n 'listUsers',\n 'getUserById',\n 'updateUserById',\n 'inviteUserByEmail',\n];\n\nexport const FILTER_MAPPINGS = {\n eq: 'eq',\n neq: 'neq',\n gt: 'gt',\n gte: 'gte',\n lt: 'lt',\n lte: 'lte',\n like: 'like',\n 'like(all)': 'likeAllOf',\n 'like(any)': 'likeAnyOf',\n ilike: 'ilike',\n 'ilike(all)': 'ilikeAllOf',\n 'ilike(any)': 'ilikeAnyOf',\n is: 'is',\n in: 'in',\n cs: 'contains',\n cd: 'containedBy',\n sr: 'rangeGt',\n nxl: 'rangeGte',\n sl: 'rangeLt',\n nxr: 'rangeLte',\n adj: 'rangeAdjacent',\n ov: 'overlaps',\n fts: '',\n plfts: 'plain',\n phfts: 'phrase',\n wfts: 'websearch',\n not: 'not',\n};\n\nexport const DB_OPERATIONS_TO_INSTRUMENT = ['select', 'insert', 'upsert', 'update', 'delete'];\n\ntype AuthOperationFn = (...args: unknown[]) => Promise<unknown>;\ntype AuthOperationName = (typeof AUTH_OPERATIONS_TO_INSTRUMENT)[number];\ntype AuthAdminOperationName = (typeof AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT)[number];\ntype PostgRESTQueryOperationFn = (...args: unknown[]) => PostgRESTFilterBuilder;\n\nexport interface SupabaseClientInstance {\n auth: {\n admin: Record<AuthAdminOperationName, AuthOperationFn>;\n } & Record<AuthOperationName, AuthOperationFn>;\n}\n\nexport interface PostgRESTQueryBuilder {\n [key: string]: PostgRESTQueryOperationFn;\n}\n\n/**\n * `postgrest-js` stores the request headers as a plain object up to v1.19.x and as a `Headers`\n * instance from v2.74.0 on (shipped with `supabase-js` 2.74.0), so we have to handle both shapes.\n */\nexport type PostgRESTHeaders = Record<string, string> | WebFetchHeaders;\n\nexport interface PostgRESTFilterBuilder {\n method: string;\n headers: PostgRESTHeaders;\n url: URL;\n schema: string;\n body: any;\n}\n\nexport interface SupabaseResponse {\n status?: number;\n error?: {\n message: string;\n code?: string;\n details?: unknown;\n };\n}\n\nexport interface SupabaseError extends Error {\n code?: string;\n details?: unknown;\n}\n\nexport interface SupabaseBreadcrumb {\n type: string;\n category: string;\n message: string;\n data?: {\n query?: string[];\n body?: Record<string, unknown>;\n };\n}\n\nexport interface SupabaseClientConstructor {\n prototype: {\n from: (table: string) => PostgRESTQueryBuilder;\n };\n}\n\nexport interface PostgRESTProtoThenable {\n then: <T>(\n onfulfilled?: ((value: T) => T | PromiseLike<T>) | null,\n onrejected?: ((reason: any) => T | PromiseLike<T>) | null,\n ) => Promise<T>;\n}\n\ntype SentryInstrumented<T> = T & {\n __SENTRY_INSTRUMENTED__?: boolean;\n};\n\nfunction markAsInstrumented<T>(fn: T): void {\n try {\n (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__ = true;\n } catch {\n // ignore errors here\n }\n}\n\nfunction isInstrumented<T>(fn: T): boolean | undefined {\n try {\n return (fn as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__;\n } catch {\n return false;\n }\n}\n\n/**\n * Plain-object bodies are copied into `plainBody`; array inserts (and other non-plain shapes) stay only on `rawBody`.\n * Returns a payload suitable for span attributes / breadcrumbs when operation data collection is enabled.\n */\nfunction getMutationBodyPayloadForTelemetry(rawBody: unknown, plainBody: Record<string, unknown>): unknown | undefined {\n if (Object.keys(plainBody).length > 0) {\n return plainBody;\n }\n if (Array.isArray(rawBody) && rawBody.length > 0) {\n return rawBody;\n }\n return undefined;\n}\n\n/** True when the PostgREST builder carries a mutation body (for `insert(...)`, etc. in span descriptions). */\nfunction hasMutationBodyForDescription(rawBody: unknown, plainBody: Record<string, unknown>): boolean {\n return getMutationBodyPayloadForTelemetry(rawBody, plainBody) !== undefined;\n}\n\n/**\n * Reads a header off a PostgREST builder, regardless of whether it holds a plain object or a\n * `Headers` instance. Lookup is case-insensitive because `Headers` lower-cases all of its keys.\n * @param headers - The request headers\n * @param name - The header name to look up\n * @returns The header value, or `undefined` if it is not set\n */\nexport function getHeader(headers: PostgRESTHeaders | undefined, name: string): string | undefined {\n if (!headers) {\n return undefined;\n }\n\n if (typeof (headers as WebFetchHeaders).get === 'function') {\n return (headers as WebFetchHeaders).get(name) ?? undefined;\n }\n\n const plainHeaders = headers as Record<string, string>;\n const lowerCaseName = name.toLowerCase();\n const key = Object.keys(plainHeaders).find(headerName => headerName.toLowerCase() === lowerCaseName);\n\n return key !== undefined ? plainHeaders[key] : undefined;\n}\n\n/**\n * Extracts the database operation type from the HTTP method and headers\n * @param method - The HTTP method of the request\n * @param headers - The request headers\n * @returns The database operation type ('select', 'insert', 'upsert', 'update', or 'delete')\n */\nexport function extractOperation(method: string, headers: PostgRESTHeaders = {}): string {\n switch (method) {\n case 'GET': {\n return 'select';\n }\n case 'POST': {\n if (getHeader(headers, 'Prefer')?.includes('resolution=')) {\n return 'upsert';\n } else {\n return 'insert';\n }\n }\n case 'PATCH': {\n return 'update';\n }\n case 'DELETE': {\n return 'delete';\n }\n default: {\n return '<unknown-op>';\n }\n }\n}\n\n/**\n * Translates Supabase filter parameters into readable method names for tracing\n * @param key - The filter key from the URL search parameters\n * @param query - The filter value from the URL search parameters\n * @returns A string representation of the filter as a method call\n */\nexport function translateFiltersIntoMethods(key: string, query: string): string {\n if (query === '' || query === '*') {\n return 'select(*)';\n }\n\n if (key === 'select') {\n return `select(${query})`;\n }\n\n if (key === 'or' || key.endsWith('.or')) {\n return `${key}${query}`;\n }\n\n const [filter, ...value] = query.split('.');\n\n let method;\n // Handle optional `configPart` of the filter\n if (filter?.startsWith('fts')) {\n method = 'textSearch';\n } else if (filter?.startsWith('plfts')) {\n method = 'textSearch[plain]';\n } else if (filter?.startsWith('phfts')) {\n method = 'textSearch[phrase]';\n } else if (filter?.startsWith('wfts')) {\n method = 'textSearch[websearch]';\n } else {\n method = (filter && FILTER_MAPPINGS[filter as keyof typeof FILTER_MAPPINGS]) || 'filter';\n }\n\n return `${method}(${key}, ${value.join('.')})`;\n}\n\nfunction instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): AuthOperationFn {\n return new Proxy(operation, {\n apply(target, thisArg, argumentsList) {\n return startSpan(\n {\n name: `auth ${isAdmin ? '(admin) ' : ''}${operation.name}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n 'db.system': 'postgresql',\n 'db.operation': `auth.${isAdmin ? 'admin.' : ''}${operation.name}`,\n },\n },\n span => {\n return Reflect.apply(target, thisArg, argumentsList)\n .then((res: unknown) => {\n if (isObjectLike(res) && 'error' in res && res.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n\n captureException(res.error, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n } else {\n span.setStatus({ code: SPAN_STATUS_OK });\n }\n\n span.end();\n return res;\n })\n .catch((err: unknown) => {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n span.end();\n\n captureException(err, {\n mechanism: {\n handled: false,\n type: 'auto.db.supabase.auth',\n },\n });\n\n throw err;\n })\n .then(...argumentsList);\n },\n );\n },\n });\n}\n\nfunction instrumentSupabaseAuthClient(supabaseClientInstance: SupabaseClientInstance): void {\n const auth = supabaseClientInstance.auth;\n\n if (!auth || isInstrumented(supabaseClientInstance.auth)) {\n return;\n }\n\n for (const operation of AUTH_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth[operation] === 'function') {\n supabaseClientInstance.auth[operation] = instrumentAuthOperation(authOperation);\n }\n }\n\n for (const operation of AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT) {\n const authOperation = auth.admin[operation];\n\n if (!authOperation) {\n continue;\n }\n\n if (typeof supabaseClientInstance.auth.admin[operation] === 'function') {\n supabaseClientInstance.auth.admin[operation] = instrumentAuthOperation(authOperation, true);\n }\n }\n\n markAsInstrumented(supabaseClientInstance.auth);\n}\n\nfunction instrumentSupabaseClientConstructor(SupabaseClient: unknown, _options: { sendOperationData?: boolean }): void {\n if (isInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from)) {\n return;\n }\n\n (SupabaseClient as SupabaseClientConstructor).prototype.from = new Proxy(\n (SupabaseClient as SupabaseClientConstructor).prototype.from,\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTQueryBuilder = (rv as PostgRESTQueryBuilder).constructor;\n\n instrumentPostgRESTQueryBuilder(PostgRESTQueryBuilder as unknown as new () => PostgRESTQueryBuilder, _options);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((SupabaseClient as SupabaseClientConstructor).prototype.from);\n}\n\nfunction instrumentPostgRESTFilterBuilder(\n PostgRESTFilterBuilder: PostgRESTFilterBuilder['constructor'],\n _options: { sendOperationData?: boolean },\n): void {\n if (isInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then)) {\n return;\n }\n\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then = new Proxy(\n (PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then,\n {\n apply(target, thisArg, argumentsList) {\n const operations = DB_OPERATIONS_TO_INSTRUMENT;\n const typedThis = thisArg as PostgRESTFilterBuilder;\n const operation = extractOperation(typedThis.method, typedThis.headers);\n\n if (!operations.includes(operation)) {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n if (!typedThis?.url?.pathname || typeof typedThis.url.pathname !== 'string') {\n return Reflect.apply(target, thisArg, argumentsList);\n }\n\n const pathParts = typedThis.url.pathname.split('/');\n const table = pathParts.length > 0 ? pathParts[pathParts.length - 1] : '';\n\n const queryItems: string[] = [];\n for (const [key, value] of typedThis.url.searchParams.entries()) {\n // It's possible to have multiple entries for the same key, eg. `id=eq.7&id=eq.3`,\n // so we need to use array instead of object to collect them.\n queryItems.push(translateFiltersIntoMethods(key, value));\n }\n const body: Record<string, unknown> = Object.create(null);\n if (isPlainObject(typedThis.body)) {\n for (const [key, value] of Object.entries(typedThis.body)) {\n body[key] = value;\n }\n }\n\n const client = getClient();\n const shouldSendData =\n _options.sendOperationData ?? client?.getDataCollectionOptions().databaseQueryData === true;\n const bodyPayload = getMutationBodyPayloadForTelemetry(typedThis.body, body);\n\n // Adding operation to the beginning of the description if it's not a `select` operation\n // For example, it can be an `insert` or `update` operation but the query can be `select(...)`\n // For `select` operations, we don't need repeat it in the description\n const mutationPart =\n operation === 'select'\n ? ''\n : `${operation}${hasMutationBodyForDescription(typedThis.body, body) ? '(...) ' : ''}`;\n const queryPart = shouldSendData ? queryItems.join(' ') : queryItems.length > 0 ? '[redacted]' : '';\n const descriptionMiddle = [mutationPart.trimEnd(), queryPart].filter(Boolean).join(' ');\n const description = descriptionMiddle ? `${descriptionMiddle} from(${table})` : `from(${table})`;\n\n const attributes: Record<string, any> = {\n 'db.table': table,\n 'db.schema': typedThis.schema,\n 'db.url': typedThis.url.origin,\n 'db.sdk': getHeader(typedThis.headers, 'X-Client-Info'),\n 'db.system': 'postgresql',\n 'db.operation': operation,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n };\n\n if (queryItems.length && shouldSendData) {\n attributes['db.query'] = queryItems;\n }\n\n if (bodyPayload !== undefined && shouldSendData) {\n attributes['db.body'] = bodyPayload;\n }\n\n return startSpan(\n {\n name: description,\n attributes,\n },\n span => {\n return (Reflect.apply(target, thisArg, []) as Promise<SupabaseResponse>)\n .then(\n (res: SupabaseResponse) => {\n if (span) {\n if (res && typeof res === 'object' && 'status' in res) {\n setHttpStatus(span, res.status || 500);\n }\n span.end();\n }\n\n if (res?.error) {\n const err = new Error(res.error.message) as SupabaseError;\n if (res.error.code) {\n err.code = res.error.code;\n }\n if (res.error.details) {\n err.details = res.error.details;\n }\n\n const supabaseContext: Record<string, any> = {};\n if (queryItems.length && shouldSendData) {\n supabaseContext.query = queryItems;\n }\n if (bodyPayload !== undefined && shouldSendData) {\n supabaseContext.body = bodyPayload;\n }\n\n captureException(err, scope => {\n scope.addEventProcessor(e => {\n addExceptionMechanism(e, {\n handled: false,\n type: 'auto.db.supabase.postgres',\n });\n\n return e;\n });\n\n scope.setContext('supabase', supabaseContext);\n\n return scope;\n });\n }\n\n const breadcrumb: SupabaseBreadcrumb = {\n type: 'supabase',\n category: `db.${operation}`,\n message: description,\n };\n\n const data: Record<string, unknown> = {};\n\n if (queryItems.length && shouldSendData) {\n data.query = queryItems;\n }\n\n if (bodyPayload !== undefined && shouldSendData) {\n data.body = bodyPayload;\n }\n\n if (Object.keys(data).length) {\n breadcrumb.data = data;\n }\n\n addBreadcrumb(breadcrumb);\n\n return res;\n },\n (err: Error) => {\n // TODO: shouldn't we capture this error?\n if (span) {\n setHttpStatus(span, 500);\n span.end();\n }\n throw err;\n },\n )\n .then(...argumentsList);\n },\n );\n },\n },\n );\n\n markAsInstrumented((PostgRESTFilterBuilder.prototype as unknown as PostgRESTProtoThenable).then);\n}\n\nfunction instrumentPostgRESTQueryBuilder(\n PostgRESTQueryBuilder: new () => PostgRESTQueryBuilder,\n _options: { sendOperationData?: boolean },\n): void {\n // We need to wrap _all_ operations despite them sharing the same `PostgRESTFilterBuilder`\n // constructor, as we don't know which method will be called first, and we don't want to miss any calls.\n for (const operation of DB_OPERATIONS_TO_INSTRUMENT) {\n if (isInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation])) {\n continue;\n }\n\n type PostgRESTOperation = keyof Pick<PostgRESTQueryBuilder, 'select' | 'insert' | 'upsert' | 'update' | 'delete'>;\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation] = new Proxy(\n (PostgRESTQueryBuilder.prototype as Record<string, any>)[operation as PostgRESTOperation],\n {\n apply(target, thisArg, argumentsList) {\n const rv = Reflect.apply(target, thisArg, argumentsList);\n const PostgRESTFilterBuilder = (rv as PostgRESTFilterBuilder).constructor;\n\n DEBUG_BUILD && debug.log(`Instrumenting ${operation} operation's PostgRESTFilterBuilder`);\n\n instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder, _options);\n\n return rv;\n },\n },\n );\n\n markAsInstrumented((PostgRESTQueryBuilder.prototype as Record<string, any>)[operation]);\n }\n}\n\nexport const instrumentSupabaseClient = (\n supabaseClient: unknown,\n options: { sendOperationData?: boolean } = {},\n): void => {\n if (!supabaseClient) {\n DEBUG_BUILD && debug.warn('Supabase integration was not installed because no Supabase client was provided.');\n return;\n }\n const SupabaseClientConstructor =\n supabaseClient.constructor === Function ? supabaseClient : supabaseClient.constructor;\n\n instrumentSupabaseClientConstructor(SupabaseClientConstructor, options);\n instrumentSupabaseAuthClient(supabaseClient as SupabaseClientInstance);\n};\n\ninterface SupabaseIntegrationOptions {\n supabaseClient: any;\n /**\n * Whether to attach PostgREST query filters and mutation body payloads\n * to Sentry telemetry.\n *\n * Falls back to `dataCollection.databaseQueryData` when not set.\n * @default undefined\n */\n sendOperationData?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Supabase' as const;\n\nconst _supabaseIntegration = ((supabaseClient: unknown, options: { sendOperationData?: boolean }) => {\n return {\n setupOnce() {\n instrumentSupabaseClient(supabaseClient, options);\n },\n name: INTEGRATION_NAME,\n };\n}) satisfies IntegrationFn;\n\nexport const supabaseIntegration = defineIntegration((options: SupabaseIntegrationOptions) => {\n return _supabaseIntegration(options.supabaseClient, { sendOperationData: options.sendOperationData });\n}) satisfies IntegrationFn;\n"],"names":[],"mappings":";;;;;;;;;;;;AAkBA,MAAM,6BAAA,GAAgC;AAAA,EACpC,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,i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2B,CACtC,cAAA,EACA,OAAA,GAA2C,EAAC,KACnC;AACT,EAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,IAAA,WAAA,IAAe,KAAA,CAAM,KAAK,iFAAiF,CAAA;AAC3G,IAAA;AAAA,EACF;AACA,EAAA,MAAM,yBAAA,GACJ,cAAA,CAAe,WAAA,KAAgB,QAAA,GAAW,iBAAiB,cAAA,CAAe,WAAA;AAE5E,EAAA,mCAAA,CAAoC,2BAA2B,OAAO,CAAA;AACtE,EAAA,4BAAA,CAA6B,cAAwC,CAAA;AACvE;AAcA,MAAM,gBAAA,GAAmB,UAAA;AAEzB,MAAM,oBAAA,IAAwB,CAAC,cAAA,EAAyB,OAAA,KAA6C;AACnG,EAAA,OAAO;AAAA,IACL,SAAA,GAAY;AACV,MAAA,wBAAA,CAAyB,gBAAgB,OAAO,CAAA;AAAA,IAClD,CAAA;AAAA,IACA,IAAA,EAAM;AAAA,GACR;AACF,CAAA,CAAA;AAEO,MAAM,mBAAA,GAAsB,iBAAA,CAAkB,CAAC,OAAA,KAAwC;AAC5F,EAAA,OAAO,qBAAqB,OAAA,CAAQ,cAAA,EAAgB,EAAE,iBAAA,EAAmB,OAAA,CAAQ,mBAAmB,CAAA;AACtG,CAAC;;;;"}

@@ -1,1 +0,1 @@

{"version":3,"file":"console-integration.js","sources":["../../../src/logs/console-integration.ts"],"sourcesContent":["import { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport type { ConsoleLevel } from '../types/instrument';\nimport type { IntegrationFn } from '../types/integration';\nimport { CONSOLE_LEVELS, debug } from '../utils/debug-logger';\nimport { isPlainObject } from '../utils/is';\nimport { normalize } from '../utils/normalize';\nimport { _INTERNAL_captureLog } from './internal';\nimport { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions } from './utils';\n\ninterface CaptureConsoleOptions {\n levels: ConsoleLevel[];\n}\n\nconst INTEGRATION_NAME = 'ConsoleLogs' as const;\n\nconst DEFAULT_ATTRIBUTES = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.log.console',\n};\n\nconst _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {}) => {\n const levels = options.levels || CONSOLE_LEVELS;\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const { enableLogs, normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('`enableLogs` is not enabled, ConsoleLogs integration disabled');\n return;\n }\n\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.includes(level)) {\n return;\n }\n\n const firstArg = args[0];\n const followingArgs = args.slice(1);\n\n if (level === 'assert') {\n if (!firstArg) {\n const assertionMessage =\n followingArgs.length > 0\n ? `Assertion failed: ${formatConsoleArgs(followingArgs, normalizeDepth, normalizeMaxBreadth)}`\n : 'Assertion failed';\n _INTERNAL_captureLog({ level: 'error', message: assertionMessage, attributes: DEFAULT_ATTRIBUTES });\n }\n return;\n }\n\n const isLevelLog = level === 'log';\n\n const attributes: Record<string, unknown> = { ...DEFAULT_ATTRIBUTES };\n\n if (isPlainObject(firstArg)) {\n // Object-first: extract object keys as attributes, remaining args as parameters\n Object.assign(attributes, normalize(firstArg, normalizeDepth, normalizeMaxBreadth));\n\n const remainingArgsStartIndex = typeof args[1] === 'string' ? 2 : 1;\n const remainingArgs = args.slice(remainingArgsStartIndex);\n\n remainingArgs.forEach((arg, index) => {\n attributes[`sentry.message.parameter.${index}`] = normalize(arg, normalizeDepth, normalizeMaxBreadth);\n });\n } else {\n // Fallback: template + parameters when first arg is a string without substitutions\n const shouldGenerateTemplate =\n followingArgs.length > 0 && typeof firstArg === 'string' && !hasConsoleSubstitutions(firstArg);\n\n if (shouldGenerateTemplate) {\n const templateAttrs = createConsoleTemplateAttributes(firstArg, followingArgs);\n for (const [key, value] of Object.entries(templateAttrs)) {\n attributes[key] = key.startsWith('sentry.message.parameter.')\n ? normalize(value, normalizeDepth, normalizeMaxBreadth)\n : value;\n }\n }\n }\n\n _INTERNAL_captureLog({\n level: isLevelLog ? 'info' : level,\n message: formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth),\n severityNumber: isLevelLog ? 10 : undefined,\n attributes,\n });\n });\n\n client.registerCleanup(unsubscribe);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Captures calls to the `console` API as logs in Sentry. Requires the `enableLogs` option to be enabled.\n *\n * @experimental This feature is experimental and may be changed or removed in future versions.\n *\n * By default the integration instruments `console.debug`, `console.info`, `console.warn`, `console.error`,\n * `console.log`, `console.trace`, and `console.assert`. You can use the `levels` option to customize which\n * levels are captured.\n *\n * @example\n *\n * ```ts\n * import * as Sentry from '@sentry/browser';\n *\n * Sentry.init({\n * enableLogs: true,\n * integrations: [Sentry.consoleLoggingIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleLoggingIntegration = defineIntegration(_consoleLoggingIntegration);\n"],"names":[],"mappings":";;;;;;;;;;;AAiBA,MAAM,gBAAA,GAAmB,aAAA;AAEzB,MAAM,kBAAA,GAAqB;AAAA,EACzB,CAAC,gCAAgC,GAAG;AACtC,CAAA;AAEA,MAAM,0BAAA,IAA8B,CAAC,OAAA,GAA0C,EAAC,KAAM;AACpF,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAU,cAAA;AAEjC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AACZ,MAAA,MAAM,EAAE,YAAY,cAAA,GAAiB,CAAA,EAAG,sBAAsB,GAAA,EAAM,GAAI,OAAO,UAAA,EAAW;AAC1F,MAAA,IAAI,CAAC,UAAA,EAAY;AACf,QAAA,WAAA,IAAe,KAAA,CAAM,KAAK,+DAA+D,C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,SAAA,CAAU,GAAA,EAAK,gBAAgB,mBAAmB,CAAA;AAAA,UACtG,CAAC,CAAA;AAAA,QACH,CAAA,MAAO;AAEL,UAAA,MAAM,sBAAA,GACJ,cAAc,MAAA,GAAS,CAAA,IAAK,OAAO,QAAA,KAAa,QAAA,IAAY,CAAC,uBAAA,CAAwB,QAAQ,CAAA;AAE/F,UAAA,IAAI,sBAAA,EAAwB;AAC1B,YAAA,MAAM,aAAA,GAAgB,+BAAA,CAAgC,QAAA,EAAU,aAAa,CAAA;AAC7E,YAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,aAAa,CAAA,EAAG;AACxD,cAAA,UAAA,CAAW,GAAG,CAAA,GAAI,GAAA,CAAI,UAAA,CAAW,2BAA2B,IACxD,SAAA,CAAU,KAAA,EAAO,cAAA,EAAgB,mBAAmB,CAAA,GACpD,KAAA;AAAA,YACN;AAAA,UACF;AAAA,QACF;AAEA,QAAA,oBAAA,CAAqB;AAAA,UACnB,KAAA,EAAO,aAAa,MAAA,GAAS,KAAA;AAAA,UAC7B,OAAA,EAAS,iBAAA,CAAkB,IAAA,EAAM,cAAA,EAAgB,mBAAmB,CAAA;AAAA,UACpE,cAAA,EAAgB,aAAa,EAAA,GAAK,MAAA;AAAA,UAClC;AAAA,SACD,CAAA;AAAA,MACH,CAAC,CAAA;AAED,MAAA,MAAA,CAAO,gBAAgB,WAAW,CAAA;AAAA,IACpC;AAAA,GACF;AACF,CAAA,CAAA;AAsBO,MAAM,yBAAA,GAA4B,kBAAkB,0BAA0B;;;;"}
{"version":3,"file":"console-integration.js","sources":["../../../src/logs/console-integration.ts"],"sourcesContent":["import { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { addConsoleInstrumentationHandler } from '../instrument/console';\nimport { defineIntegration } from '../integration';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';\nimport type { ConsoleLevel } from '../types/instrument';\nimport type { IntegrationFn } from '../types/integration';\nimport { CONSOLE_LEVELS, debug } from '../utils/debug-logger';\nimport { isPlainObject } from '../utils/is';\nimport { normalize } from '../utils/normalize';\nimport { _INTERNAL_captureLog } from './internal';\nimport { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions } from './utils';\n\ninterface CaptureConsoleOptions {\n levels: ConsoleLevel[];\n}\n\nconst INTEGRATION_NAME = 'ConsoleLogs' as const;\n\nconst DEFAULT_ATTRIBUTES = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.log.console',\n};\n\nconst _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {}) => {\n const levels = options.levels || CONSOLE_LEVELS;\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const { enableLogs, normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('`enableLogs` is not enabled, ConsoleLogs integration disabled');\n return;\n }\n\n const unsubscribe = addConsoleInstrumentationHandler(({ args, level }) => {\n if (getClient() !== client || !levels.includes(level)) {\n return;\n }\n\n const firstArg = args[0];\n const followingArgs = args.slice(1);\n\n if (level === 'assert') {\n if (!firstArg) {\n const assertionMessage =\n followingArgs.length > 0\n ? `Assertion failed: ${formatConsoleArgs(followingArgs, normalizeDepth, normalizeMaxBreadth)}`\n : 'Assertion failed';\n _INTERNAL_captureLog({ level: 'error', message: assertionMessage, attributes: DEFAULT_ATTRIBUTES });\n }\n return;\n }\n\n const isLevelLog = level === 'log';\n\n const attributes: Record<string, unknown> = { ...DEFAULT_ATTRIBUTES };\n\n if (isPlainObject(firstArg)) {\n // Object-first: extract object keys as attributes, remaining args as parameters\n Object.assign(attributes, normalize(firstArg, normalizeDepth, normalizeMaxBreadth));\n\n const remainingArgsStartIndex = typeof args[1] === 'string' ? 2 : 1;\n const remainingArgs = args.slice(remainingArgsStartIndex);\n\n remainingArgs.forEach((arg, index) => {\n attributes[`sentry.message.parameter.${index}`] = normalize(arg, normalizeDepth, normalizeMaxBreadth);\n });\n } else {\n // Fallback: template + parameters when first arg is a string without substitutions\n const shouldGenerateTemplate =\n followingArgs.length > 0 && typeof firstArg === 'string' && !hasConsoleSubstitutions(firstArg);\n\n if (shouldGenerateTemplate) {\n const templateAttrs = createConsoleTemplateAttributes(firstArg, followingArgs);\n for (const [key, value] of Object.entries(templateAttrs)) {\n attributes[key] = key.startsWith('sentry.message.parameter.')\n ? normalize(value, normalizeDepth, normalizeMaxBreadth)\n : value;\n }\n }\n }\n\n _INTERNAL_captureLog({\n level: isLevelLog ? 'info' : level,\n message: formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth),\n severityNumber: isLevelLog ? 10 : undefined,\n attributes,\n });\n });\n\n client.registerCleanup(unsubscribe);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Captures calls to the `console` API as logs in Sentry.\n *\n * @experimental This feature is experimental and may be changed or removed in future versions.\n *\n * By default the integration instruments `console.debug`, `console.info`, `console.warn`, `console.error`,\n * `console.log`, `console.trace`, and `console.assert`. You can use the `levels` option to customize which\n * levels are captured.\n *\n * @example\n *\n * ```ts\n * import * as Sentry from '@sentry/browser';\n *\n * Sentry.init({\n * integrations: [Sentry.consoleLoggingIntegration({ levels: ['error', 'warn'] })],\n * });\n * ```\n */\nexport const consoleLoggingIntegration = defineIntegration(_consoleLoggingIntegration);\n"],"names":[],"mappings":";;;;;;;;;;;AAiBA,MAAM,gBAAA,GAAmB,aAAA;AAEzB,MAAM,kBAAA,GAAqB;AAAA,EACzB,CAAC,gCAAgC,GAAG;AACtC,CAAA;AAEA,MAAM,0BAAA,IAA8B,CAAC,OAAA,GAA0C,EAAC,KAAM;AACpF,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAU,cAAA;AAEjC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AACZ,MAAA,MAAM,EAAE,YAAY,c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,CAAK,KAAA,CAAM,uBAAuB,CAAA;AAExD,UAAA,aAAA,CAAc,OAAA,CAAQ,CAAC,GAAA,EAAK,KAAA,KAAU;AACpC,YAAA,UAAA,CAAW,4BAA4B,KAAK,CAAA,CAAE,IAAI,SAAA,CAAU,GAAA,EAAK,gBAAgB,mBAAmB,CAAA;AAAA,UACtG,CAAC,CAAA;AAAA,QACH,CAAA,MAAO;AAEL,UAAA,MAAM,sBAAA,GACJ,cAAc,MAAA,GAAS,CAAA,IAAK,OAAO,QAAA,KAAa,QAAA,IAAY,CAAC,uBAAA,CAAwB,QAAQ,CAAA;AAE/F,UAAA,IAAI,sBAAA,EAAwB;AAC1B,YAAA,MAAM,aAAA,GAAgB,+BAAA,CAAgC,QAAA,EAAU,aAAa,CAAA;AAC7E,YAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,aAAa,CAAA,EAAG;AACxD,cAAA,UAAA,CAAW,GAAG,CAAA,GAAI,GAAA,CAAI,UAAA,CAAW,2BAA2B,IACxD,SAAA,CAAU,KAAA,EAAO,cAAA,EAAgB,mBAAmB,CAAA,GACpD,KAAA;AAAA,YACN;AAAA,UACF;AAAA,QACF;AAEA,QAAA,oBAAA,CAAqB;AAAA,UACnB,KAAA,EAAO,aAAa,MAAA,GAAS,KAAA;AAAA,UAC7B,OAAA,EAAS,iBAAA,CAAkB,IAAA,EAAM,cAAA,EAAgB,mBAAmB,CAAA;AAAA,UACpE,cAAA,EAAgB,aAAa,EAAA,GAAK,MAAA;AAAA,UAClC;AAAA,SACD,CAAA;AAAA,MACH,CAAC,CAAA;AAED,MAAA,MAAA,CAAO,gBAAgB,WAAW,CAAA;AAAA,IACpC;AAAA,GACF;AACF,CAAA,CAAA;AAqBO,MAAM,yBAAA,GAA4B,kBAAkB,0BAA0B;;;;"}

@@ -41,3 +41,3 @@ import { serializeAttributes } from '../attributes.js';

}
const { release, environment, enableLogs = false, beforeSendLog } = client.getOptions();
const { release, environment, enableLogs = true, beforeSendLog } = client.getOptions();
if (!enableLogs) {

@@ -44,0 +44,0 @@ DEBUG_BUILD && debug.warn("logging option not enabled, log will not be captured.");

@@ -1,1 +0,1 @@

{"version":3,"file":"internal.js","sources":["../../../src/logs/internal.ts"],"sourcesContent":["import type { Attributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getGlobalSingleton } from '../carrier';\nimport type { Client } from '../client';\nimport { getClient, getCurrentScope, getIsolationScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Integration } from '../types/integration';\nimport type { Log, SerializedLog } from '../types/log';\nimport { consoleSandbox, debug } from '../utils/debug-logger';\nimport { isParameterizedString } from '../utils/is';\nimport { getCombinedScopeData } from '../utils/scopeData';\nimport { _getSpanForScope } from '../utils/spanOnScope';\nimport { timestampInSeconds } from '../utils/time';\nimport { getSequenceAttribute } from '../utils/timestampSequence';\nimport { _getTraceInfoFromScope } from '../utils/trace-info';\nimport { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';\nimport { createLogEnvelope } from './envelope';\n\nconst MAX_LOG_BUFFER_SIZE = 100;\n\n/**\n * Sets a log attribute if the value exists and the attribute key is not already present.\n *\n * @param logAttributes - The log attributes object to modify.\n * @param key - The attribute key to set.\n * @param value - The value to set (only sets if truthy and key not present).\n * @param setEvenIfPresent - Whether to set the attribute if it is present. Defaults to true.\n */\nfunction setLogAttribute(\n logAttributes: Record<string, unknown>,\n key: string,\n value: unknown,\n setEvenIfPresent = true,\n): void {\n if (value && (!logAttributes[key] || setEvenIfPresent)) {\n logAttributes[key] = value;\n }\n}\n\n/**\n * Captures a serialized log event and adds it to the log buffer for the given client.\n *\n * @param client - A client. Uses the current client if not provided.\n * @param serializedLog - The serialized log event to capture.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureSerializedLog(client: Client, serializedLog: SerializedLog): void {\n const bufferMap = _getBufferMap();\n const logBuffer = _INTERNAL_getLogBuffer(client);\n\n if (logBuffer === undefined) {\n bufferMap.set(client, [serializedLog]);\n } else {\n if (logBuffer.length >= MAX_LOG_BUFFER_SIZE) {\n _INTERNAL_flushLogsBuffer(client, logBuffer);\n bufferMap.set(client, [serializedLog]);\n } else {\n bufferMap.set(client, [...logBuffer, serializedLog]);\n }\n }\n}\n\n/**\n * Captures a log event and sends it to Sentry.\n *\n * @param log - The log event to capture.\n * @param scope - A scope. Uses the current scope if not provided.\n * @param client - A client. Uses the current client if not provided.\n * @param captureSerializedLog - A function to capture the serialized log.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureLog(\n beforeLog: Log,\n currentScope = getCurrentScope(),\n captureSerializedLog: (client: Client, log: SerializedLog) => void = _INTERNAL_captureSerializedLog,\n): void {\n const client = currentScope?.getClient() ?? getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No client available to capture log.');\n return;\n }\n\n const { release, environment, enableLogs = false, beforeSendLog } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('logging option not enabled, log will not be captured.');\n return;\n }\n\n const [, traceContext] = _getTraceInfoFromScope(client, currentScope);\n\n const processedLogAttributes = {\n ...beforeLog.attributes,\n };\n\n const {\n user: { id, email, username },\n attributes: scopeAttributes = {},\n } = getCombinedScopeData(getIsolationScope(), currentScope);\n\n setLogAttribute(processedLogAttributes, 'user.id', id, false);\n setLogAttribute(processedLogAttributes, 'user.email', email, false);\n setLogAttribute(processedLogAttributes, 'user.name', username, false);\n\n setLogAttribute(processedLogAttributes, 'sentry.release', release);\n setLogAttribute(processedLogAttributes, 'sentry.environment', environment);\n\n const { name, version } = client.getSdkMetadata()?.sdk ?? {};\n setLogAttribute(processedLogAttributes, 'sentry.sdk.name', name);\n setLogAttribute(processedLogAttributes, 'sentry.sdk.version', version);\n\n const replay = client.getIntegrationByName<\n Integration & {\n getReplayId: (onlyIfSampled?: boolean) => string;\n getRecordingMode: () => 'session' | 'buffer' | undefined;\n }\n >('Replay');\n\n const replayId = replay?.getReplayId(true);\n setLogAttribute(processedLogAttributes, 'sentry.replay_id', replayId);\n\n if (replayId && replay?.getRecordingMode() === 'buffer') {\n // We send this so we can identify cases where the replayId is attached but the replay itself might not have been sent to Sentry\n setLogAttribute(processedLogAttributes, 'sentry._internal.replay_is_buffering', true);\n }\n\n const beforeLogMessage = beforeLog.message;\n if (isParameterizedString(beforeLogMessage)) {\n const { __sentry_template_string__, __sentry_template_values__ = [] } = beforeLogMessage;\n if (__sentry_template_values__?.length) {\n processedLogAttributes['sentry.message.template'] = __sentry_template_string__;\n }\n __sentry_template_values__.forEach((param, index) => {\n processedLogAttributes[`sentry.message.parameter.${index}`] = param;\n });\n }\n\n const span = _getSpanForScope(currentScope);\n // Add the parent span ID to the log attributes for trace context\n setLogAttribute(processedLogAttributes, 'sentry.trace.parent_span_id', span?.spanContext().spanId);\n\n const processedLog = { ...beforeLog, attributes: processedLogAttributes };\n\n client.emit('beforeCaptureLog', processedLog);\n\n // We need to wrap this in `consoleSandbox` to avoid recursive calls to `beforeSendLog`\n const log = beforeSendLog ? consoleSandbox(() => beforeSendLog(processedLog)) : processedLog;\n if (!log) {\n client.recordDroppedEvent('before_send', 'log_item', 1);\n DEBUG_BUILD && debug.warn('beforeSendLog returned null, log will not be captured.');\n return;\n }\n\n const { level, message, attributes: logAttributes = {}, severityNumber } = log;\n\n const timestamp = timestampInSeconds();\n const sequenceAttr = getSequenceAttribute(timestamp);\n\n const serializedLog: SerializedLog = {\n timestamp,\n level,\n body: _removeLoneSurrogates(String(message)),\n trace_id: traceContext?.trace_id,\n severity_number: severityNumber ?? SEVERITY_TEXT_TO_SEVERITY_NUMBER[level],\n attributes: sanitizeLogAttributes({\n ...serializeAttributes(scopeAttributes),\n ...serializeAttributes(logAttributes, true),\n [sequenceAttr.key]: sequenceAttr.value,\n }),\n };\n\n captureSerializedLog(client, serializedLog);\n\n client.emit('afterCaptureLog', log);\n}\n\n/**\n * Flushes the logs buffer to Sentry.\n *\n * @param client - A client.\n * @param maybeLogBuffer - A log buffer. Uses the log buffer for the given client if not provided.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_flushLogsBuffer(client: Client, maybeLogBuffer?: Array<SerializedLog>): void {\n const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];\n if (logBuffer.length === 0) {\n return;\n }\n\n const clientOptions = client.getOptions();\n const envelope = createLogEnvelope(\n logBuffer,\n clientOptions._metadata,\n clientOptions.tunnel,\n client.getDsn(),\n client.getDataCollectionOptions().userInfo,\n );\n\n // Clear the log buffer after envelopes have been constructed.\n _getBufferMap().set(client, []);\n\n client.emit('flushLogs');\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n\n/**\n * Returns the log buffer for a given client.\n *\n * Exported for testing purposes.\n *\n * @param client - The client to get the log buffer for.\n * @returns The log buffer for the given client.\n */\nexport function _INTERNAL_getLogBuffer(client: Client): Array<SerializedLog> | undefined {\n return _getBufferMap().get(client);\n}\n\nfunction _getBufferMap(): WeakMap<Client, Array<SerializedLog>> {\n // The reference to the Client <> LogBuffer map is stored on the carrier to ensure it's always the same\n return getGlobalSingleton('clientToLogBufferMap', () => new WeakMap<Client, Array<SerializedLog>>());\n}\n\n/**\n * Sanitizes serialized log attributes by replacing lone surrogates in both\n * keys and string values with U+FFFD.\n */\nfunction sanitizeLogAttributes(attributes: Attributes): Attributes {\n const sanitized: Attributes = {};\n for (const [key, attr] of Object.entries(attributes)) {\n const sanitizedKey = _removeLoneSurrogates(key);\n if (attr.type === 'string') {\n sanitized[sanitizedKey] = { ...attr, value: _removeLoneSurrogates(attr.value) };\n } else {\n sanitized[sanitizedKey] = attr;\n }\n }\n return sanitized;\n}\n\n/**\n * Replaces unpaired UTF-16 surrogates with U+FFFD (replacement character).\n *\n * Lone surrogates (U+D800–U+DFFF not part of a valid pair) cause `serde_json`\n * on the server to reject the entire log batch when they appear in\n * JSON-escaped form (e.g. `\\uD800`). Replacing them at the SDK level ensures\n * only the offending characters are lost instead of the whole payload.\n *\n * Uses the native `String.prototype.toWellFormed()` when available\n * (Node 20+, Chrome 111+, Safari 15.4+, Firefox 119+, Hermes).\n * On older runtimes without native support, returns the string as-is.\n *\n * Exported for testing\n */\nexport function _removeLoneSurrogates(str: string): string {\n // isWellFormed/toWellFormed are ES2024 (not in our TS lib target), so we feature-detect via Object().\n const strObj: Record<string, Function> = Object(str);\n const isWellFormed = strObj['isWellFormed'];\n const toWellFormed = strObj['toWellFormed'];\n if (typeof isWellFormed === 'function' && typeof toWellFormed === 'function') {\n return isWellFormed.call(str) ? str : toWellFormed.call(str);\n }\n return str;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,mBAAA,GAAsB,GAAA;AAU5B,SAAS,eAAA,CACP,aAAA,EACA,GAAA,EACA,KAAA,EACA,mBAAmB,IAAA,EACb;AACN,EAAA,IAAI,KAAA,KAAU,CAAC,aAAA,CAAc,GAAG,KAAK,gBAAA,CAAA,EAAmB;AACtD,IAAA,aAAA,CAAc,GAAG,CAAA,GAAI,KAAA;AAAA,EACvB;AACF;AAWO,SAAS,8BAAA,CAA+B,QAAgB,aAAA,EAAoC;AACjG,EAAA,MAAM,YAAY,aAAA,EAAc;AAChC,EAAA,MAAM,SAAA,GAAY,uBAAuB,MAAM,CAAA;AAE/C,EAAA,IAAI,cAAc,MAAA,EAAW;AAC3B,IAAA,SAAA,CAAU,GAAA,CAAI,MAAA,EAAQ,CAAC,aAAa,CAAC,CAAA;AAAA,EACvC,CAAA,MAAO;AACL,IAAA,IAAI,SAAA,CAAU,UAAU,mBAAA,EAAqB;AAC3C,MAAA,yBAAA,CAA0B,QAAQ,SAAS,CAAA;AAC3C,MAAA,SAAA,CAAU,GAAA,CAAI,MA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ACF;AACA,EAAA,OAAO,SAAA;AACT;AAgBO,SAAS,sBAAsB,GAAA,EAAqB;AAEzD,EAAA,MAAM,MAAA,GAAmC,OAAO,GAAG,CAAA;AACnD,EAAA,MAAM,YAAA,GAAe,OAAO,cAAc,CAAA;AAC1C,EAAA,MAAM,YAAA,GAAe,OAAO,cAAc,CAAA;AAC1C,EAAA,IAAI,OAAO,YAAA,KAAiB,UAAA,IAAc,OAAO,iBAAiB,UAAA,EAAY;AAC5E,IAAA,OAAO,aAAa,IAAA,CAAK,GAAG,IAAI,GAAA,GAAM,YAAA,CAAa,KAAK,GAAG,CAAA;AAAA,EAC7D;AACA,EAAA,OAAO,GAAA;AACT;;;;"}
{"version":3,"file":"internal.js","sources":["../../../src/logs/internal.ts"],"sourcesContent":["import type { Attributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getGlobalSingleton } from '../carrier';\nimport type { Client } from '../client';\nimport { getClient, getCurrentScope, getIsolationScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Integration } from '../types/integration';\nimport type { Log, SerializedLog } from '../types/log';\nimport { consoleSandbox, debug } from '../utils/debug-logger';\nimport { isParameterizedString } from '../utils/is';\nimport { getCombinedScopeData } from '../utils/scopeData';\nimport { _getSpanForScope } from '../utils/spanOnScope';\nimport { timestampInSeconds } from '../utils/time';\nimport { getSequenceAttribute } from '../utils/timestampSequence';\nimport { _getTraceInfoFromScope } from '../utils/trace-info';\nimport { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';\nimport { createLogEnvelope } from './envelope';\n\nconst MAX_LOG_BUFFER_SIZE = 100;\n\n/**\n * Sets a log attribute if the value exists and the attribute key is not already present.\n *\n * @param logAttributes - The log attributes object to modify.\n * @param key - The attribute key to set.\n * @param value - The value to set (only sets if truthy and key not present).\n * @param setEvenIfPresent - Whether to set the attribute if it is present. Defaults to true.\n */\nfunction setLogAttribute(\n logAttributes: Record<string, unknown>,\n key: string,\n value: unknown,\n setEvenIfPresent = true,\n): void {\n if (value && (!logAttributes[key] || setEvenIfPresent)) {\n logAttributes[key] = value;\n }\n}\n\n/**\n * Captures a serialized log event and adds it to the log buffer for the given client.\n *\n * @param client - A client. Uses the current client if not provided.\n * @param serializedLog - The serialized log event to capture.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureSerializedLog(client: Client, serializedLog: SerializedLog): void {\n const bufferMap = _getBufferMap();\n const logBuffer = _INTERNAL_getLogBuffer(client);\n\n if (logBuffer === undefined) {\n bufferMap.set(client, [serializedLog]);\n } else {\n if (logBuffer.length >= MAX_LOG_BUFFER_SIZE) {\n _INTERNAL_flushLogsBuffer(client, logBuffer);\n bufferMap.set(client, [serializedLog]);\n } else {\n bufferMap.set(client, [...logBuffer, serializedLog]);\n }\n }\n}\n\n/**\n * Captures a log event and sends it to Sentry.\n *\n * @param log - The log event to capture.\n * @param scope - A scope. Uses the current scope if not provided.\n * @param client - A client. Uses the current client if not provided.\n * @param captureSerializedLog - A function to capture the serialized log.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_captureLog(\n beforeLog: Log,\n currentScope = getCurrentScope(),\n captureSerializedLog: (client: Client, log: SerializedLog) => void = _INTERNAL_captureSerializedLog,\n): void {\n const client = currentScope?.getClient() ?? getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No client available to capture log.');\n return;\n }\n\n const { release, environment, enableLogs = true, beforeSendLog } = client.getOptions();\n if (!enableLogs) {\n DEBUG_BUILD && debug.warn('logging option not enabled, log will not be captured.');\n return;\n }\n\n const [, traceContext] = _getTraceInfoFromScope(client, currentScope);\n\n const processedLogAttributes = {\n ...beforeLog.attributes,\n };\n\n const {\n user: { id, email, username },\n attributes: scopeAttributes = {},\n } = getCombinedScopeData(getIsolationScope(), currentScope);\n\n setLogAttribute(processedLogAttributes, 'user.id', id, false);\n setLogAttribute(processedLogAttributes, 'user.email', email, false);\n setLogAttribute(processedLogAttributes, 'user.name', username, false);\n\n setLogAttribute(processedLogAttributes, 'sentry.release', release);\n setLogAttribute(processedLogAttributes, 'sentry.environment', environment);\n\n const { name, version } = client.getSdkMetadata()?.sdk ?? {};\n setLogAttribute(processedLogAttributes, 'sentry.sdk.name', name);\n setLogAttribute(processedLogAttributes, 'sentry.sdk.version', version);\n\n const replay = client.getIntegrationByName<\n Integration & {\n getReplayId: (onlyIfSampled?: boolean) => string;\n getRecordingMode: () => 'session' | 'buffer' | undefined;\n }\n >('Replay');\n\n const replayId = replay?.getReplayId(true);\n setLogAttribute(processedLogAttributes, 'sentry.replay_id', replayId);\n\n if (replayId && replay?.getRecordingMode() === 'buffer') {\n // We send this so we can identify cases where the replayId is attached but the replay itself might not have been sent to Sentry\n setLogAttribute(processedLogAttributes, 'sentry._internal.replay_is_buffering', true);\n }\n\n const beforeLogMessage = beforeLog.message;\n if (isParameterizedString(beforeLogMessage)) {\n const { __sentry_template_string__, __sentry_template_values__ = [] } = beforeLogMessage;\n if (__sentry_template_values__?.length) {\n processedLogAttributes['sentry.message.template'] = __sentry_template_string__;\n }\n __sentry_template_values__.forEach((param, index) => {\n processedLogAttributes[`sentry.message.parameter.${index}`] = param;\n });\n }\n\n const span = _getSpanForScope(currentScope);\n // Add the parent span ID to the log attributes for trace context\n setLogAttribute(processedLogAttributes, 'sentry.trace.parent_span_id', span?.spanContext().spanId);\n\n const processedLog = { ...beforeLog, attributes: processedLogAttributes };\n\n client.emit('beforeCaptureLog', processedLog);\n\n // We need to wrap this in `consoleSandbox` to avoid recursive calls to `beforeSendLog`\n const log = beforeSendLog ? consoleSandbox(() => beforeSendLog(processedLog)) : processedLog;\n if (!log) {\n client.recordDroppedEvent('before_send', 'log_item', 1);\n DEBUG_BUILD && debug.warn('beforeSendLog returned null, log will not be captured.');\n return;\n }\n\n const { level, message, attributes: logAttributes = {}, severityNumber } = log;\n\n const timestamp = timestampInSeconds();\n const sequenceAttr = getSequenceAttribute(timestamp);\n\n const serializedLog: SerializedLog = {\n timestamp,\n level,\n body: _removeLoneSurrogates(String(message)),\n trace_id: traceContext?.trace_id,\n severity_number: severityNumber ?? SEVERITY_TEXT_TO_SEVERITY_NUMBER[level],\n attributes: sanitizeLogAttributes({\n ...serializeAttributes(scopeAttributes),\n ...serializeAttributes(logAttributes, true),\n [sequenceAttr.key]: sequenceAttr.value,\n }),\n };\n\n captureSerializedLog(client, serializedLog);\n\n client.emit('afterCaptureLog', log);\n}\n\n/**\n * Flushes the logs buffer to Sentry.\n *\n * @param client - A client.\n * @param maybeLogBuffer - A log buffer. Uses the log buffer for the given client if not provided.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n */\nexport function _INTERNAL_flushLogsBuffer(client: Client, maybeLogBuffer?: Array<SerializedLog>): void {\n const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];\n if (logBuffer.length === 0) {\n return;\n }\n\n const clientOptions = client.getOptions();\n const envelope = createLogEnvelope(\n logBuffer,\n clientOptions._metadata,\n clientOptions.tunnel,\n client.getDsn(),\n client.getDataCollectionOptions().userInfo,\n );\n\n // Clear the log buffer after envelopes have been constructed.\n _getBufferMap().set(client, []);\n\n client.emit('flushLogs');\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n\n/**\n * Returns the log buffer for a given client.\n *\n * Exported for testing purposes.\n *\n * @param client - The client to get the log buffer for.\n * @returns The log buffer for the given client.\n */\nexport function _INTERNAL_getLogBuffer(client: Client): Array<SerializedLog> | undefined {\n return _getBufferMap().get(client);\n}\n\nfunction _getBufferMap(): WeakMap<Client, Array<SerializedLog>> {\n // The reference to the Client <> LogBuffer map is stored on the carrier to ensure it's always the same\n return getGlobalSingleton('clientToLogBufferMap', () => new WeakMap<Client, Array<SerializedLog>>());\n}\n\n/**\n * Sanitizes serialized log attributes by replacing lone surrogates in both\n * keys and string values with U+FFFD.\n */\nfunction sanitizeLogAttributes(attributes: Attributes): Attributes {\n const sanitized: Attributes = {};\n for (const [key, attr] of Object.entries(attributes)) {\n const sanitizedKey = _removeLoneSurrogates(key);\n if (attr.type === 'string') {\n sanitized[sanitizedKey] = { ...attr, value: _removeLoneSurrogates(attr.value) };\n } else {\n sanitized[sanitizedKey] = attr;\n }\n }\n return sanitized;\n}\n\n/**\n * Replaces unpaired UTF-16 surrogates with U+FFFD (replacement character).\n *\n * Lone surrogates (U+D800–U+DFFF not part of a valid pair) cause `serde_json`\n * on the server to reject the entire log batch when they appear in\n * JSON-escaped form (e.g. `\\uD800`). Replacing them at the SDK level ensures\n * only the offending characters are lost instead of the whole payload.\n *\n * Uses the native `String.prototype.toWellFormed()` when available\n * (Node 20+, Chrome 111+, Safari 15.4+, Firefox 119+, Hermes).\n * On older runtimes without native support, returns the string as-is.\n *\n * Exported for testing\n */\nexport function _removeLoneSurrogates(str: string): string {\n // isWellFormed/toWellFormed are ES2024 (not in our TS lib target), so we feature-detect via Object().\n const strObj: Record<string, Function> = Object(str);\n const isWellFormed = strObj['isWellFormed'];\n const toWellFormed = strObj['toWellFormed'];\n if (typeof isWellFormed === 'function' && typeof toWellFormed === 'function') {\n return isWellFormed.call(str) ? str : toWellFormed.call(str);\n }\n return str;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,mBAAA,GAAsB,GAAA;AAU5B,SAAS,eAAA,CACP,aAAA,EACA,GAAA,EACA,KAAA,EACA,mBAAmB,IAAA,EACb;AACN,EAAA,IAAI,KAAA,KAAU,CAAC,aAAA,CAAc,GAAG,KAAK,gBAAA,CAAA,EAAmB;AACtD,IAAA,aAAA,CAAc,GAAG,CAAA,GAAI,KAAA;AAAA,EACvB;AACF;AAWO,SAAS,8BAAA,CAA+B,QAAgB,aAAA,EAAoC;AACjG,EAAA,MAAM,YAAY,aAAA,EAAc;AAChC,EAAA,MAAM,SAA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pD,IAAA,MAAM,YAAA,GAAe,sBAAsB,GAAG,CAAA;AAC9C,IAAA,IAAI,IAAA,CAAK,SAAS,QAAA,EAAU;AAC1B,MAAA,SAAA,CAAU,YAAY,IAAI,EAAE,GAAG,MAAM,KAAA,EAAO,qBAAA,CAAsB,IAAA,CAAK,KAAK,CAAA,EAAE;AAAA,IAChF,CAAA,MAAO;AACL,MAAA,SAAA,CAAU,YAAY,CAAA,GAAI,IAAA;AAAA,IAC5B;AAAA,EACF;AACA,EAAA,OAAO,SAAA;AACT;AAgBO,SAAS,sBAAsB,GAAA,EAAqB;AAEzD,EAAA,MAAM,MAAA,GAAmC,OAAO,GAAG,CAAA;AACnD,EAAA,MAAM,YAAA,GAAe,OAAO,cAAc,CAAA;AAC1C,EAAA,MAAM,YAAA,GAAe,OAAO,cAAc,CAAA;AAC1C,EAAA,IAAI,OAAO,YAAA,KAAiB,UAAA,IAAc,OAAO,iBAAiB,UAAA,EAAY;AAC5E,IAAA,OAAO,aAAa,IAAA,CAAK,GAAG,IAAI,GAAA,GAAM,YAAA,CAAa,KAAK,GAAG,CAAA;AAAA,EAC7D;AACA,EAAA,OAAO,GAAA;AACT;;;;"}

@@ -1,1 +0,1 @@

{"version":3,"file":"public-api.js","sources":["../../../src/logs/public-api.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Log, LogSeverityLevel } from '../types/log';\nimport type { ParameterizedString } from '../types/parameterize';\nimport { _INTERNAL_captureLog } from './internal';\n\n/**\n * Capture a log with the given level.\n *\n * @param level - The level of the log.\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.\n * @param scope - The scope to capture the log with.\n * @param severityNumber - The severity number of the log.\n */\nfunction captureLog(\n level: LogSeverityLevel,\n message: ParameterizedString,\n attributes?: Log['attributes'],\n scope?: Scope,\n severityNumber?: Log['severityNumber'],\n): void {\n _INTERNAL_captureLog({ level, message, attributes, severityNumber }, scope);\n}\n\n/**\n * Additional metadata to capture the log with.\n */\ninterface CaptureLogMetadata {\n scope?: Scope;\n}\n\n/**\n * @summary Capture a log with the `trace` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { userId: 100, route: '/dashboard' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.trace('User clicked submit button', {\n * buttonId: 'submit-form',\n * formId: 'user-profile',\n * timestamp: Date.now()\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.trace(Sentry.logger.fmt`User ${user} navigated to ${page}`, {\n * userId: '123',\n * sessionId: 'abc-xyz'\n * });\n * ```\n */\nexport function trace(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('trace', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `debug` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { component: 'Header', state: 'loading' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.debug('Component mounted', {\n * component: 'UserProfile',\n * props: { userId: 123 },\n * renderTime: 150\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.debug(Sentry.logger.fmt`API request to ${endpoint} failed`, {\n * statusCode: 404,\n * requestId: 'req-123',\n * duration: 250\n * });\n * ```\n */\nexport function debug(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('debug', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `info` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { feature: 'checkout', status: 'completed' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.info('User completed checkout', {\n * orderId: 'order-123',\n * amount: 99.99,\n * paymentMethod: 'credit_card'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.info(Sentry.logger.fmt`User ${user} updated profile picture`, {\n * userId: 'user-123',\n * imageSize: '2.5MB',\n * timestamp: Date.now()\n * });\n * ```\n */\nexport function info(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('info', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `warn` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { browser: 'Chrome', version: '91.0' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.warn('Browser compatibility issue detected', {\n * browser: 'Safari',\n * version: '14.0',\n * feature: 'WebRTC',\n * fallback: 'enabled'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.warn(Sentry.logger.fmt`API endpoint ${endpoint} is deprecated`, {\n * recommendedEndpoint: '/api/v2/users',\n * sunsetDate: '2024-12-31',\n * clientVersion: '1.2.3'\n * });\n * ```\n */\nexport function warn(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('warn', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `error` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { error: 'NetworkError', url: '/api/data' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.error('Failed to load user data', {\n * error: 'NetworkError',\n * url: '/api/users/123',\n * statusCode: 500,\n * retryCount: 3\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.error(Sentry.logger.fmt`Payment processing failed for order ${orderId}`, {\n * error: 'InsufficientFunds',\n * amount: 100.00,\n * currency: 'USD',\n * userId: 'user-456'\n * });\n * ```\n */\nexport function error(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('error', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `fatal` level. Requires the `enableLogs` option to be enabled.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { appState: 'corrupted', sessionId: 'abc-123' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.fatal('Application state corrupted', {\n * lastKnownState: 'authenticated',\n * sessionId: 'session-123',\n * timestamp: Date.now(),\n * recoveryAttempted: true\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.fatal(Sentry.logger.fmt`Critical system failure in ${service}`, {\n * service: 'payment-processor',\n * errorCode: 'CRITICAL_FAILURE',\n * affectedUsers: 150,\n * timestamp: Date.now()\n * });\n * ```\n */\nexport function fatal(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('fatal', message, attributes, scope);\n}\n\nexport { fmt } from '../utils/parameterize';\n"],"names":[],"mappings":";;;AAcA,SAAS,UAAA,CACP,KAAA,EACA,OAAA,EACA,UAAA,EACA,OACA,cAAA,EACM;AACN,EAAA,oBAAA,CAAqB,EAAE,KAAA,EAAO,OAAA,EAAS,UAAA,EAAY,cAAA,IAAkB,KAAK,CAAA;AAC5E;AAmCO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA6BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA6BO,SAAS,KACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,MAAA,EAAQ,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAC/C;AA8BO,SAAS,KACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,MAAA,EAAQ,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAC/C;AA+BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA+BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;;;;"}
{"version":3,"file":"public-api.js","sources":["../../../src/logs/public-api.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Log, LogSeverityLevel } from '../types/log';\nimport type { ParameterizedString } from '../types/parameterize';\nimport { _INTERNAL_captureLog } from './internal';\n\n/**\n * Capture a log with the given level.\n *\n * @param level - The level of the log.\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.\n * @param scope - The scope to capture the log with.\n * @param severityNumber - The severity number of the log.\n */\nfunction captureLog(\n level: LogSeverityLevel,\n message: ParameterizedString,\n attributes?: Log['attributes'],\n scope?: Scope,\n severityNumber?: Log['severityNumber'],\n): void {\n _INTERNAL_captureLog({ level, message, attributes, severityNumber }, scope);\n}\n\n/**\n * Additional metadata to capture the log with.\n */\ninterface CaptureLogMetadata {\n scope?: Scope;\n}\n\n/**\n * @summary Capture a log with the `trace` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { userId: 100, route: '/dashboard' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.trace('User clicked submit button', {\n * buttonId: 'submit-form',\n * formId: 'user-profile',\n * timestamp: Date.now()\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.trace(Sentry.logger.fmt`User ${user} navigated to ${page}`, {\n * userId: '123',\n * sessionId: 'abc-xyz'\n * });\n * ```\n */\nexport function trace(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('trace', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `debug` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { component: 'Header', state: 'loading' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.debug('Component mounted', {\n * component: 'UserProfile',\n * props: { userId: 123 },\n * renderTime: 150\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.debug(Sentry.logger.fmt`API request to ${endpoint} failed`, {\n * statusCode: 404,\n * requestId: 'req-123',\n * duration: 250\n * });\n * ```\n */\nexport function debug(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('debug', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `info` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { feature: 'checkout', status: 'completed' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.info('User completed checkout', {\n * orderId: 'order-123',\n * amount: 99.99,\n * paymentMethod: 'credit_card'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.info(Sentry.logger.fmt`User ${user} updated profile picture`, {\n * userId: 'user-123',\n * imageSize: '2.5MB',\n * timestamp: Date.now()\n * });\n * ```\n */\nexport function info(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('info', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `warn` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { browser: 'Chrome', version: '91.0' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.warn('Browser compatibility issue detected', {\n * browser: 'Safari',\n * version: '14.0',\n * feature: 'WebRTC',\n * fallback: 'enabled'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.warn(Sentry.logger.fmt`API endpoint ${endpoint} is deprecated`, {\n * recommendedEndpoint: '/api/v2/users',\n * sunsetDate: '2024-12-31',\n * clientVersion: '1.2.3'\n * });\n * ```\n */\nexport function warn(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('warn', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `error` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { error: 'NetworkError', url: '/api/data' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.error('Failed to load user data', {\n * error: 'NetworkError',\n * url: '/api/users/123',\n * statusCode: 500,\n * retryCount: 3\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.error(Sentry.logger.fmt`Payment processing failed for order ${orderId}`, {\n * error: 'InsufficientFunds',\n * amount: 100.00,\n * currency: 'USD',\n * userId: 'user-456'\n * });\n * ```\n */\nexport function error(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('error', message, attributes, scope);\n}\n\n/**\n * @summary Capture a log with the `fatal` level.\n *\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., { appState: 'corrupted', sessionId: 'abc-123' }.\n * @param metadata - additional metadata to capture the log with.\n *\n * @example\n *\n * ```\n * Sentry.logger.fatal('Application state corrupted', {\n * lastKnownState: 'authenticated',\n * sessionId: 'session-123',\n * timestamp: Date.now(),\n * recoveryAttempted: true\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.fatal(Sentry.logger.fmt`Critical system failure in ${service}`, {\n * service: 'payment-processor',\n * errorCode: 'CRITICAL_FAILURE',\n * affectedUsers: 150,\n * timestamp: Date.now()\n * });\n * ```\n */\nexport function fatal(\n message: ParameterizedString,\n attributes?: Log['attributes'],\n { scope }: CaptureLogMetadata = {},\n): void {\n captureLog('fatal', message, attributes, scope);\n}\n\nexport { fmt } from '../utils/parameterize';\n"],"names":[],"mappings":";;;AAcA,SAAS,UAAA,CACP,KAAA,EACA,OAAA,EACA,UAAA,EACA,OACA,cAAA,EACM;AACN,EAAA,oBAAA,CAAqB,EAAE,KAAA,EAAO,OAAA,EAAS,UAAA,EAAY,cAAA,IAAkB,KAAK,CAAA;AAC5E;AAmCO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA6BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA6BO,SAAS,KACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,MAAA,EAAQ,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAC/C;AA8BO,SAAS,KACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,MAAA,EAAQ,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAC/C;AA+BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;AA+BO,SAAS,MACd,OAAA,EACA,UAAA,EACA,EAAE,KAAA,EAAM,GAAwB,EAAC,EAC3B;AACN,EAAA,UAAA,CAAW,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,KAAK,CAAA;AAChD;;;;"}

@@ -1,1 +0,1 @@

{"type":"module","version":"10.70.0","sideEffects":false}
{"type":"module","version":"10.71.0","sideEffects":false}

@@ -349,2 +349,5 @@ import { DEBUG_BUILD } from './debug-build.js';

* Note: The client will not be cleared.
*
* @deprecated This method will be removed in v11. To reset scope state, re-initialize the SDK or run
* your code in a fresh scope via `withScope` instead.
*/

@@ -351,0 +354,0 @@ clear() {

@@ -1,1 +0,1 @@

{"version":3,"file":"scope.js","sources":["../../src/scope.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { AttributeObject, RawAttribute, RawAttributes } from './attributes';\nimport type { Client } from './client';\nimport { DEBUG_BUILD } from './debug-build';\nimport { updateSession } from './session';\nimport type { Attachment } from './types/attachment';\nimport type { Breadcrumb } from './types/breadcrumb';\nimport type { Context, Contexts } from './types/context';\nimport type { DynamicSamplingContext } from './types/envelope';\nimport type { Event, EventHint } from './types/event';\nimport type { EventProcessor } from './types/eventprocessor';\nimport type { Extra, Extras } from './types/extra';\nimport type { Primitive } from './types/misc';\nimport type { RequestEventData } from './types/request';\nimport type { Session } from './types/session';\nimport type { SeverityLevel } from './types/severity';\nimport type { Span } from './types/span';\nimport type { PropagationContext } from './types/tracing';\nimport type { User } from './types/user';\nimport { debug } from './utils/debug-logger';\nimport { isPlainObject } from './utils/is';\nimport { merge } from './utils/merge';\nimport { uuid4 } from './utils/misc';\nimport { generateTraceId } from './utils/propagationContext';\nimport { safeMathRandom } from './utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from './utils/spanOnScope';\nimport { truncate } from './utils/string';\nimport { dateTimestampInSeconds } from './utils/time';\n\n/**\n * Default value for maximum number of breadcrumbs added to an event.\n */\nconst DEFAULT_MAX_BREADCRUMBS = 100;\n\n/**\n * A context to be used for capturing an event.\n * This can either be a Scope, or a partial ScopeContext,\n * or a callback that receives the current scope and returns a new scope to use.\n */\nexport type CaptureContext = Scope | Partial<ScopeContext> | ((scope: Scope) => Scope);\n\n/**\n * Data that can be converted to a Scope.\n */\nexport interface ScopeContext {\n user: User;\n level: SeverityLevel;\n extra: Extras;\n contexts: Contexts;\n tags: { [key: string]: Primitive };\n attributes?: RawAttributes<Record<string, unknown>>;\n fingerprint: string[];\n propagationContext: PropagationContext;\n conversationId?: string;\n}\n\nexport interface SdkProcessingMetadata {\n [key: string]: unknown;\n requestSession?: {\n status: 'ok' | 'errored' | 'crashed';\n };\n normalizedRequest?: RequestEventData;\n dynamicSamplingContext?: Partial<DynamicSamplingContext>;\n capturedSpanScope?: Scope;\n capturedSpanIsolationScope?: Scope;\n spanCountBeforeProcessing?: number;\n ipAddress?: string;\n}\n\n/**\n * Normalized data of the Scope, ready to be used.\n */\nexport interface ScopeData {\n eventProcessors: EventProcessor[];\n breadcrumbs: Breadcrumb[];\n user: User;\n tags: { [key: string]: Primitive };\n // TODO(v11): Make this a required field (could be subtly breaking if we did it today)\n attributes?: RawAttributes<Record<string, unknown>>;\n extra: Extras;\n contexts: Contexts;\n attachments: Attachment[];\n propagationContext: PropagationContext;\n sdkProcessingMetadata: SdkProcessingMetadata;\n fingerprint: string[];\n level?: SeverityLevel;\n transactionName?: string;\n span?: Span;\n conversationId?: string;\n}\n\n/**\n * Holds additional event information.\n */\nexport class Scope {\n /** Flag if notifying is happening. */\n protected _notifyingListeners: boolean;\n\n /** Callback for client to receive scope changes. */\n protected _scopeListeners: Array<(scope: Scope) => void>;\n\n /** Callback list that will be called during event processing. */\n protected _eventProcessors: EventProcessor[];\n\n /** Array of breadcrumbs. */\n protected _breadcrumbs: Breadcrumb[];\n\n /** User */\n protected _user: User;\n\n /** Tags */\n protected _tags: { [key: string]: Primitive };\n\n /** Attributes */\n protected _attributes: RawAttributes<Record<string, unknown>>;\n\n /** Extra */\n protected _extra: Extras;\n\n /** Contexts */\n protected _contexts: Contexts;\n\n /** Attachments */\n protected _attachments: Attachment[];\n\n /** Propagation Context for distributed tracing */\n protected _propagationContext: PropagationContext;\n\n /**\n * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get\n * sent to Sentry\n */\n protected _sdkProcessingMetadata: SdkProcessingMetadata;\n\n /** Fingerprint */\n protected _fingerprint?: string[];\n\n /** Severity */\n protected _level?: SeverityLevel;\n\n /**\n * Transaction Name\n *\n * IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects.\n * It's purpose is to assign a transaction to the scope that's added to non-transaction events.\n */\n protected _transactionName?: string;\n\n /** Session */\n protected _session?: Session;\n\n /** The client on this scope */\n protected _client?: Client;\n\n /** Contains the last event id of a captured event. */\n protected _lastEventId?: string;\n\n /** Conversation ID */\n protected _conversationId?: string;\n\n // NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.\n\n public constructor() {\n this._notifyingListeners = false;\n this._scopeListeners = [];\n this._eventProcessors = [];\n this._breadcrumbs = [];\n this._attachments = [];\n this._user = {};\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._contexts = {};\n this._sdkProcessingMetadata = {};\n this._propagationContext = {\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n };\n }\n\n /**\n * Clone all data from this scope into a new scope.\n */\n public clone(): Scope {\n const newScope = new Scope();\n newScope._breadcrumbs = [...this._breadcrumbs];\n newScope._tags = { ...this._tags };\n newScope._attributes = { ...this._attributes };\n newScope._extra = { ...this._extra };\n newScope._contexts = { ...this._contexts };\n if (this._contexts.flags) {\n // We need to copy the `values` array so insertions on a cloned scope\n // won't affect the original array.\n newScope._contexts.flags = {\n values: [...this._contexts.flags.values],\n };\n }\n\n newScope._user = this._user;\n newScope._level = this._level;\n newScope._session = this._session;\n newScope._transactionName = this._transactionName;\n newScope._fingerprint = this._fingerprint;\n newScope._eventProcessors = [...this._eventProcessors];\n newScope._attachments = [...this._attachments];\n newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };\n newScope._propagationContext = { ...this._propagationContext };\n newScope._client = this._client;\n newScope._lastEventId = this._lastEventId;\n newScope._conversationId = this._conversationId;\n\n _setSpanForScope(newScope, _getSpanForScope(this));\n\n return newScope;\n }\n\n /**\n * Update the client assigned to this scope.\n * Note that not every scope will have a client assigned - isolation scopes & the global scope will generally not have a client,\n * as well as manually created scopes.\n */\n public setClient(client: Client | undefined): void {\n this._client = client;\n }\n\n /**\n * Set the ID of the last captured error event.\n * This is generally only captured on the isolation scope.\n */\n public setLastEventId(lastEventId: string | undefined): void {\n this._lastEventId = lastEventId;\n }\n\n /**\n * Get the client assigned to this scope.\n */\n public getClient<C extends Client>(): C | undefined {\n return this._client as C | undefined;\n }\n\n /**\n * Get the ID of the last captured error event.\n * This is generally only available on the isolation scope.\n */\n public lastEventId(): string | undefined {\n return this._lastEventId;\n }\n\n /**\n * @inheritDoc\n */\n public addScopeListener(callback: (scope: Scope) => void): void {\n this._scopeListeners.push(callback);\n }\n\n /**\n * Add an event processor that will be called before an event is sent.\n */\n public addEventProcessor(callback: EventProcessor): this {\n this._eventProcessors.push(callback);\n return this;\n }\n\n /**\n * Set the user for this scope.\n * Set to `null` to unset the user.\n */\n public setUser(user: User | null): this {\n // If null is passed we want to unset everything, but still define keys,\n // so that later down in the pipeline any existing values are cleared.\n this._user = user || {\n email: undefined,\n id: undefined,\n ip_address: undefined,\n username: undefined,\n };\n\n if (this._session) {\n updateSession(this._session, { user });\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the user from this scope.\n */\n public getUser(): User | undefined {\n return this._user;\n }\n\n /**\n * Set the conversation ID for this scope.\n * Set to `null` to unset the conversation ID.\n */\n public setConversationId(conversationId: string | null | undefined): this {\n this._conversationId = conversationId || undefined;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set an object that will be merged into existing tags on the scope,\n * and will be sent as tags data with the event.\n */\n public setTags(tags: { [key: string]: Primitive }): this {\n this._tags = {\n ...this._tags,\n ...tags,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single tag that will be sent as tags data with the event.\n */\n public setTag(key: string, value: Primitive): this {\n return this.setTags({ [key]: value });\n }\n\n /**\n * Sets attributes onto the scope.\n *\n * These attributes are applied to logs, metrics and streamed spans.\n *\n * Supported attribute value types are `string`, `number`, `boolean`, `string[]`, `number[]` and `boolean[]`.\n *\n * @param newAttributes - The attributes to set on the scope, as key-value pairs.\n *\n * @example\n * ```typescript\n * scope.setAttributes({\n * is_admin: true,\n * payment_selection: 'credit_card',\n * render_duration: 150,\n * });\n * ```\n */\n public setAttributes<T extends Record<string, unknown>>(newAttributes: RawAttributes<T>): this {\n this._attributes = {\n ...this._attributes,\n ...newAttributes,\n };\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets an attribute onto the scope.\n *\n * These attributes are applied to logs, metrics and streamed spans.\n *\n * Supported attribute value types are `string`, `number`, `boolean`, `string[]`, `number[]` and `boolean[]`.\n *\n * @param key - The attribute key.\n * @param value - The attribute value.\n *\n * @example\n * ```typescript\n * scope.setAttribute('is_admin', true);\n * scope.setAttribute('render_duration', 150);\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public setAttribute<T extends RawAttribute<T> extends { value: any } | { unit: any } ? AttributeObject : unknown>(\n key: string,\n value: RawAttribute<T>,\n ): this {\n return this.setAttributes({ [key]: value });\n }\n\n /**\n * Removes the attribute with the given key from the scope.\n *\n * @param key - The attribute key.\n *\n * @example\n * ```typescript\n * scope.removeAttribute('is_admin');\n * ```\n */\n public removeAttribute(key: string): this {\n if (key in this._attributes) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n this._notifyScopeListeners();\n }\n return this;\n }\n\n /**\n * Set an object that will be merged into existing extra on the scope,\n * and will be sent as extra data with the event.\n */\n public setExtras(extras: Extras): this {\n this._extra = {\n ...this._extra,\n ...extras,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single key:value extra entry that will be sent as extra data with the event.\n */\n public setExtra(key: string, extra: Extra): this {\n this._extra = { ...this._extra, [key]: extra };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the fingerprint on the scope to send with the events.\n * @param {string[]} fingerprint Fingerprint to group events in Sentry.\n */\n public setFingerprint(fingerprint: string[]): this {\n this._fingerprint = fingerprint;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the level on the scope for future events.\n */\n public setLevel(level: SeverityLevel): this {\n this._level = level;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the transaction name on the scope so that the name of e.g. taken server route or\n * the page location is attached to future events.\n *\n * IMPORTANT: Calling this function does NOT change the name of the currently active\n * root span. If you want to change the name of the active root span, use\n * `Sentry.updateSpanName(rootSpan, 'new name')` instead.\n *\n * By default, the SDK updates the scope's transaction name automatically on sensible\n * occasions, such as a page navigation or when handling a new request on the server.\n */\n public setTransactionName(name?: string): this {\n this._transactionName = name;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets context data with the given name.\n * Data passed as context will be normalized. You can also pass `null` to unset the context.\n * Note that context data will not be merged - calling `setContext` will overwrite an existing context with the same key.\n */\n public setContext(key: string, context: Context | null): this {\n if (context === null) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._contexts[key];\n } else {\n this._contexts[key] = context;\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set the session for the scope.\n */\n public setSession(session?: Session): this {\n if (!session) {\n delete this._session;\n } else {\n this._session = session;\n }\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the session from the scope.\n */\n public getSession(): Session | undefined {\n return this._session;\n }\n\n /**\n * Updates the scope with provided data. Can work in three variations:\n * - plain object containing updatable attributes\n * - Scope instance that'll extract the attributes from\n * - callback function that'll receive the current scope as an argument and allow for modifications\n */\n public update(captureContext?: CaptureContext): this {\n if (!captureContext) {\n return this;\n }\n\n const scopeToMerge = typeof captureContext === 'function' ? captureContext(this) : captureContext;\n\n const scopeInstance =\n scopeToMerge instanceof Scope\n ? scopeToMerge.getScopeData()\n : isPlainObject(scopeToMerge)\n ? (captureContext as ScopeContext)\n : undefined;\n\n const {\n tags,\n attributes,\n extra,\n user,\n contexts,\n level,\n fingerprint = [],\n propagationContext,\n conversationId,\n } = scopeInstance || {};\n\n this._tags = { ...this._tags, ...tags };\n this._attributes = { ...this._attributes, ...attributes };\n this._extra = { ...this._extra, ...extra };\n this._contexts = { ...this._contexts, ...contexts };\n\n if (user && Object.keys(user).length) {\n this._user = user;\n }\n\n if (level) {\n this._level = level;\n }\n\n if (fingerprint.length) {\n this._fingerprint = fingerprint;\n }\n\n if (propagationContext) {\n this._propagationContext = propagationContext;\n }\n\n if (conversationId) {\n this._conversationId = conversationId;\n }\n\n return this;\n }\n\n /**\n * Clears the current scope and resets its properties.\n * Note: The client will not be cleared.\n */\n public clear(): this {\n // client is not cleared here on purpose!\n this._breadcrumbs = [];\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._user = {};\n this._contexts = {};\n this._level = undefined;\n this._transactionName = undefined;\n this._fingerprint = undefined;\n this._session = undefined;\n this._conversationId = undefined;\n _setSpanForScope(this, undefined);\n this._attachments = [];\n this.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Adds a breadcrumb to the scope.\n * By default, the last 100 breadcrumbs are kept.\n */\n public addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this {\n const maxCrumbs = typeof maxBreadcrumbs === 'number' ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;\n\n // No data has been changed, so don't notify scope listeners\n if (maxCrumbs <= 0) {\n return this;\n }\n\n const mergedBreadcrumb: Breadcrumb = {\n timestamp: dateTimestampInSeconds(),\n ...breadcrumb,\n // Breadcrumb messages can theoretically be infinitely large and they're held in memory so we truncate them not to leak (too much) memory\n message: breadcrumb.message ? truncate(breadcrumb.message, 2048) : breadcrumb.message,\n };\n\n this._breadcrumbs.push(mergedBreadcrumb);\n if (this._breadcrumbs.length > maxCrumbs) {\n this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);\n this._client?.recordDroppedEvent('buffer_overflow', 'log_item');\n }\n\n this._notifyScopeListeners();\n\n return this;\n }\n\n /**\n * Get the last breadcrumb of the scope.\n */\n public getLastBreadcrumb(): Breadcrumb | undefined {\n return this._breadcrumbs[this._breadcrumbs.length - 1];\n }\n\n /**\n * Clear all breadcrumbs from the scope.\n */\n public clearBreadcrumbs(): this {\n this._breadcrumbs = [];\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Add an attachment to the scope.\n */\n public addAttachment(attachment: Attachment): this {\n this._attachments.push(attachment);\n return this;\n }\n\n /**\n * Clear all attachments from the scope.\n */\n public clearAttachments(): this {\n this._attachments = [];\n return this;\n }\n\n /**\n * Get the data of this scope, which should be applied to an event during processing.\n */\n public getScopeData(): ScopeData {\n return {\n breadcrumbs: this._breadcrumbs,\n attachments: this._attachments,\n contexts: this._contexts,\n tags: this._tags,\n attributes: this._attributes,\n extra: this._extra,\n user: this._user,\n level: this._level,\n fingerprint: this._fingerprint || [],\n eventProcessors: this._eventProcessors,\n propagationContext: this._propagationContext,\n sdkProcessingMetadata: this._sdkProcessingMetadata,\n transactionName: this._transactionName,\n span: _getSpanForScope(this),\n conversationId: this._conversationId,\n };\n }\n\n /**\n * Add data which will be accessible during event processing but won't get sent to Sentry.\n */\n public setSDKProcessingMetadata(newData: SdkProcessingMetadata): this {\n this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2);\n return this;\n }\n\n /**\n * Add propagation context to the scope, used for distributed tracing\n */\n public setPropagationContext(context: PropagationContext): this {\n this._propagationContext = context;\n return this;\n }\n\n /**\n * Get propagation context from the scope, used for distributed tracing\n */\n public getPropagationContext(): PropagationContext {\n return this._propagationContext;\n }\n\n /**\n * Capture an exception for this scope.\n *\n * @returns {string} The id of the captured Sentry event.\n */\n public captureException(exception: unknown, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture exception!');\n return eventId;\n }\n\n const syntheticException = new Error('Sentry syntheticException');\n\n this._client.captureException(\n exception,\n {\n originalException: exception,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a message for this scope.\n *\n * @returns {string} The id of the captured message.\n */\n public captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture message!');\n return eventId;\n }\n\n const syntheticException = hint?.syntheticException ?? new Error(message);\n\n this._client.captureMessage(\n message,\n level,\n {\n originalException: message,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a Sentry event for this scope.\n *\n * @returns {string} The id of the captured event.\n */\n public captureEvent(event: Event, hint?: EventHint): string {\n const eventId = event.event_id || hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture event!');\n return eventId;\n }\n\n this._client.captureEvent(event, { ...hint, event_id: eventId }, this);\n\n return eventId;\n }\n\n /**\n * This will be called on every set call.\n */\n protected _notifyScopeListeners(): void {\n // We need this check for this._notifyingListeners to be able to work on scope during updates\n // If this check is not here we'll produce endless recursion when something is done with the scope\n // during the callback.\n if (!this._notifyingListeners) {\n this._notifyingListeners = true;\n this._scopeListeners.forEach(callback => {\n callback(this);\n });\n this._notifyingListeners = false;\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAgCA,MAAM,uBAAA,GAA0B,GAAA;AA8DzB,MAAM,KAAA,CAAM;AAAA;AAAA,EAoEV,WAAA,GAAc;AACnB,IAAA,IA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AAA,OAAO,OAAA;AAAA,IACT;AAEA,IAAA,IAAA,CAAK,OAAA,CAAQ,aAAa,KAAA,EAAO,EAAE,GAAG,IAAA,EAAM,QAAA,EAAU,OAAA,EAAQ,EAAG,IAAI,CAAA;AAErE,IAAA,OAAO,OAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKU,qBAAA,GAA8B;AAItC,IAAA,IAAI,CAAC,KAAK,mBAAA,EAAqB;AAC7B,MAAA,IAAA,CAAK,mBAAA,GAAsB,IAAA;AAC3B,MAAA,IAAA,CAAK,eAAA,CAAgB,QAAQ,CAAA,QAAA,KAAY;AACvC,QAAA,QAAA,CAAS,IAAI,CAAA;AAAA,MACf,CAAC,CAAA;AACD,MAAA,IAAA,CAAK,mBAAA,GAAsB,KAAA;AAAA,IAC7B;AAAA,EACF;AACF;;;;"}
{"version":3,"file":"scope.js","sources":["../../src/scope.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type { AttributeObject, RawAttribute, RawAttributes } from './attributes';\nimport type { Client } from './client';\nimport { DEBUG_BUILD } from './debug-build';\nimport { updateSession } from './session';\nimport type { Attachment } from './types/attachment';\nimport type { Breadcrumb } from './types/breadcrumb';\nimport type { Context, Contexts } from './types/context';\nimport type { DynamicSamplingContext } from './types/envelope';\nimport type { Event, EventHint } from './types/event';\nimport type { EventProcessor } from './types/eventprocessor';\nimport type { Extra, Extras } from './types/extra';\nimport type { Primitive } from './types/misc';\nimport type { RequestEventData } from './types/request';\nimport type { Session } from './types/session';\nimport type { SeverityLevel } from './types/severity';\nimport type { Span } from './types/span';\nimport type { PropagationContext } from './types/tracing';\nimport type { User } from './types/user';\nimport { debug } from './utils/debug-logger';\nimport { isPlainObject } from './utils/is';\nimport { merge } from './utils/merge';\nimport { uuid4 } from './utils/misc';\nimport { generateTraceId } from './utils/propagationContext';\nimport { safeMathRandom } from './utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from './utils/spanOnScope';\nimport { truncate } from './utils/string';\nimport { dateTimestampInSeconds } from './utils/time';\n\n/**\n * Default value for maximum number of breadcrumbs added to an event.\n */\nconst DEFAULT_MAX_BREADCRUMBS = 100;\n\n/**\n * A context to be used for capturing an event.\n * This can either be a Scope, or a partial ScopeContext,\n * or a callback that receives the current scope and returns a new scope to use.\n */\nexport type CaptureContext = Scope | Partial<ScopeContext> | ((scope: Scope) => Scope);\n\n/**\n * Data that can be converted to a Scope.\n */\nexport interface ScopeContext {\n user: User;\n level: SeverityLevel;\n extra: Extras;\n contexts: Contexts;\n tags: { [key: string]: Primitive };\n attributes?: RawAttributes<Record<string, unknown>>;\n fingerprint: string[];\n propagationContext: PropagationContext;\n conversationId?: string;\n}\n\nexport interface SdkProcessingMetadata {\n [key: string]: unknown;\n requestSession?: {\n status: 'ok' | 'errored' | 'crashed';\n };\n normalizedRequest?: RequestEventData;\n dynamicSamplingContext?: Partial<DynamicSamplingContext>;\n capturedSpanScope?: Scope;\n capturedSpanIsolationScope?: Scope;\n spanCountBeforeProcessing?: number;\n ipAddress?: string;\n}\n\n/**\n * Normalized data of the Scope, ready to be used.\n */\nexport interface ScopeData {\n eventProcessors: EventProcessor[];\n breadcrumbs: Breadcrumb[];\n user: User;\n tags: { [key: string]: Primitive };\n // TODO(v11): Make this a required field (could be subtly breaking if we did it today)\n attributes?: RawAttributes<Record<string, unknown>>;\n extra: Extras;\n contexts: Contexts;\n attachments: Attachment[];\n propagationContext: PropagationContext;\n sdkProcessingMetadata: SdkProcessingMetadata;\n fingerprint: string[];\n level?: SeverityLevel;\n transactionName?: string;\n span?: Span;\n conversationId?: string;\n}\n\n/**\n * Holds additional event information.\n */\nexport class Scope {\n /** Flag if notifying is happening. */\n protected _notifyingListeners: boolean;\n\n /** Callback for client to receive scope changes. */\n protected _scopeListeners: Array<(scope: Scope) => void>;\n\n /** Callback list that will be called during event processing. */\n protected _eventProcessors: EventProcessor[];\n\n /** Array of breadcrumbs. */\n protected _breadcrumbs: Breadcrumb[];\n\n /** User */\n protected _user: User;\n\n /** Tags */\n protected _tags: { [key: string]: Primitive };\n\n /** Attributes */\n protected _attributes: RawAttributes<Record<string, unknown>>;\n\n /** Extra */\n protected _extra: Extras;\n\n /** Contexts */\n protected _contexts: Contexts;\n\n /** Attachments */\n protected _attachments: Attachment[];\n\n /** Propagation Context for distributed tracing */\n protected _propagationContext: PropagationContext;\n\n /**\n * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get\n * sent to Sentry\n */\n protected _sdkProcessingMetadata: SdkProcessingMetadata;\n\n /** Fingerprint */\n protected _fingerprint?: string[];\n\n /** Severity */\n protected _level?: SeverityLevel;\n\n /**\n * Transaction Name\n *\n * IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects.\n * It's purpose is to assign a transaction to the scope that's added to non-transaction events.\n */\n protected _transactionName?: string;\n\n /** Session */\n protected _session?: Session;\n\n /** The client on this scope */\n protected _client?: Client;\n\n /** Contains the last event id of a captured event. */\n protected _lastEventId?: string;\n\n /** Conversation ID */\n protected _conversationId?: string;\n\n // NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.\n\n public constructor() {\n this._notifyingListeners = false;\n this._scopeListeners = [];\n this._eventProcessors = [];\n this._breadcrumbs = [];\n this._attachments = [];\n this._user = {};\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._contexts = {};\n this._sdkProcessingMetadata = {};\n this._propagationContext = {\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n };\n }\n\n /**\n * Clone all data from this scope into a new scope.\n */\n public clone(): Scope {\n const newScope = new Scope();\n newScope._breadcrumbs = [...this._breadcrumbs];\n newScope._tags = { ...this._tags };\n newScope._attributes = { ...this._attributes };\n newScope._extra = { ...this._extra };\n newScope._contexts = { ...this._contexts };\n if (this._contexts.flags) {\n // We need to copy the `values` array so insertions on a cloned scope\n // won't affect the original array.\n newScope._contexts.flags = {\n values: [...this._contexts.flags.values],\n };\n }\n\n newScope._user = this._user;\n newScope._level = this._level;\n newScope._session = this._session;\n newScope._transactionName = this._transactionName;\n newScope._fingerprint = this._fingerprint;\n newScope._eventProcessors = [...this._eventProcessors];\n newScope._attachments = [...this._attachments];\n newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };\n newScope._propagationContext = { ...this._propagationContext };\n newScope._client = this._client;\n newScope._lastEventId = this._lastEventId;\n newScope._conversationId = this._conversationId;\n\n _setSpanForScope(newScope, _getSpanForScope(this));\n\n return newScope;\n }\n\n /**\n * Update the client assigned to this scope.\n * Note that not every scope will have a client assigned - isolation scopes & the global scope will generally not have a client,\n * as well as manually created scopes.\n */\n public setClient(client: Client | undefined): void {\n this._client = client;\n }\n\n /**\n * Set the ID of the last captured error event.\n * This is generally only captured on the isolation scope.\n */\n public setLastEventId(lastEventId: string | undefined): void {\n this._lastEventId = lastEventId;\n }\n\n /**\n * Get the client assigned to this scope.\n */\n public getClient<C extends Client>(): C | undefined {\n return this._client as C | undefined;\n }\n\n /**\n * Get the ID of the last captured error event.\n * This is generally only available on the isolation scope.\n */\n public lastEventId(): string | undefined {\n return this._lastEventId;\n }\n\n /**\n * @inheritDoc\n */\n public addScopeListener(callback: (scope: Scope) => void): void {\n this._scopeListeners.push(callback);\n }\n\n /**\n * Add an event processor that will be called before an event is sent.\n */\n public addEventProcessor(callback: EventProcessor): this {\n this._eventProcessors.push(callback);\n return this;\n }\n\n /**\n * Set the user for this scope.\n * Set to `null` to unset the user.\n */\n public setUser(user: User | null): this {\n // If null is passed we want to unset everything, but still define keys,\n // so that later down in the pipeline any existing values are cleared.\n this._user = user || {\n email: undefined,\n id: undefined,\n ip_address: undefined,\n username: undefined,\n };\n\n if (this._session) {\n updateSession(this._session, { user });\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the user from this scope.\n */\n public getUser(): User | undefined {\n return this._user;\n }\n\n /**\n * Set the conversation ID for this scope.\n * Set to `null` to unset the conversation ID.\n */\n public setConversationId(conversationId: string | null | undefined): this {\n this._conversationId = conversationId || undefined;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set an object that will be merged into existing tags on the scope,\n * and will be sent as tags data with the event.\n */\n public setTags(tags: { [key: string]: Primitive }): this {\n this._tags = {\n ...this._tags,\n ...tags,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single tag that will be sent as tags data with the event.\n */\n public setTag(key: string, value: Primitive): this {\n return this.setTags({ [key]: value });\n }\n\n /**\n * Sets attributes onto the scope.\n *\n * These attributes are applied to logs, metrics and streamed spans.\n *\n * Supported attribute value types are `string`, `number`, `boolean`, `string[]`, `number[]` and `boolean[]`.\n *\n * @param newAttributes - The attributes to set on the scope, as key-value pairs.\n *\n * @example\n * ```typescript\n * scope.setAttributes({\n * is_admin: true,\n * payment_selection: 'credit_card',\n * render_duration: 150,\n * });\n * ```\n */\n public setAttributes<T extends Record<string, unknown>>(newAttributes: RawAttributes<T>): this {\n this._attributes = {\n ...this._attributes,\n ...newAttributes,\n };\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets an attribute onto the scope.\n *\n * These attributes are applied to logs, metrics and streamed spans.\n *\n * Supported attribute value types are `string`, `number`, `boolean`, `string[]`, `number[]` and `boolean[]`.\n *\n * @param key - The attribute key.\n * @param value - The attribute value.\n *\n * @example\n * ```typescript\n * scope.setAttribute('is_admin', true);\n * scope.setAttribute('render_duration', 150);\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public setAttribute<T extends RawAttribute<T> extends { value: any } | { unit: any } ? AttributeObject : unknown>(\n key: string,\n value: RawAttribute<T>,\n ): this {\n return this.setAttributes({ [key]: value });\n }\n\n /**\n * Removes the attribute with the given key from the scope.\n *\n * @param key - The attribute key.\n *\n * @example\n * ```typescript\n * scope.removeAttribute('is_admin');\n * ```\n */\n public removeAttribute(key: string): this {\n if (key in this._attributes) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n this._notifyScopeListeners();\n }\n return this;\n }\n\n /**\n * Set an object that will be merged into existing extra on the scope,\n * and will be sent as extra data with the event.\n */\n public setExtras(extras: Extras): this {\n this._extra = {\n ...this._extra,\n ...extras,\n };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set a single key:value extra entry that will be sent as extra data with the event.\n */\n public setExtra(key: string, extra: Extra): this {\n this._extra = { ...this._extra, [key]: extra };\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the fingerprint on the scope to send with the events.\n * @param {string[]} fingerprint Fingerprint to group events in Sentry.\n */\n public setFingerprint(fingerprint: string[]): this {\n this._fingerprint = fingerprint;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the level on the scope for future events.\n */\n public setLevel(level: SeverityLevel): this {\n this._level = level;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets the transaction name on the scope so that the name of e.g. taken server route or\n * the page location is attached to future events.\n *\n * IMPORTANT: Calling this function does NOT change the name of the currently active\n * root span. If you want to change the name of the active root span, use\n * `Sentry.updateSpanName(rootSpan, 'new name')` instead.\n *\n * By default, the SDK updates the scope's transaction name automatically on sensible\n * occasions, such as a page navigation or when handling a new request on the server.\n */\n public setTransactionName(name?: string): this {\n this._transactionName = name;\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Sets context data with the given name.\n * Data passed as context will be normalized. You can also pass `null` to unset the context.\n * Note that context data will not be merged - calling `setContext` will overwrite an existing context with the same key.\n */\n public setContext(key: string, context: Context | null): this {\n if (context === null) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._contexts[key];\n } else {\n this._contexts[key] = context;\n }\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Set the session for the scope.\n */\n public setSession(session?: Session): this {\n if (!session) {\n delete this._session;\n } else {\n this._session = session;\n }\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Get the session from the scope.\n */\n public getSession(): Session | undefined {\n return this._session;\n }\n\n /**\n * Updates the scope with provided data. Can work in three variations:\n * - plain object containing updatable attributes\n * - Scope instance that'll extract the attributes from\n * - callback function that'll receive the current scope as an argument and allow for modifications\n */\n public update(captureContext?: CaptureContext): this {\n if (!captureContext) {\n return this;\n }\n\n const scopeToMerge = typeof captureContext === 'function' ? captureContext(this) : captureContext;\n\n const scopeInstance =\n scopeToMerge instanceof Scope\n ? scopeToMerge.getScopeData()\n : isPlainObject(scopeToMerge)\n ? (captureContext as ScopeContext)\n : undefined;\n\n const {\n tags,\n attributes,\n extra,\n user,\n contexts,\n level,\n fingerprint = [],\n propagationContext,\n conversationId,\n } = scopeInstance || {};\n\n this._tags = { ...this._tags, ...tags };\n this._attributes = { ...this._attributes, ...attributes };\n this._extra = { ...this._extra, ...extra };\n this._contexts = { ...this._contexts, ...contexts };\n\n if (user && Object.keys(user).length) {\n this._user = user;\n }\n\n if (level) {\n this._level = level;\n }\n\n if (fingerprint.length) {\n this._fingerprint = fingerprint;\n }\n\n if (propagationContext) {\n this._propagationContext = propagationContext;\n }\n\n if (conversationId) {\n this._conversationId = conversationId;\n }\n\n return this;\n }\n\n /**\n * Clears the current scope and resets its properties.\n * Note: The client will not be cleared.\n *\n * @deprecated This method will be removed in v11. To reset scope state, re-initialize the SDK or run\n * your code in a fresh scope via `withScope` instead.\n */\n public clear(): this {\n // client is not cleared here on purpose!\n this._breadcrumbs = [];\n this._tags = {};\n this._attributes = {};\n this._extra = {};\n this._user = {};\n this._contexts = {};\n this._level = undefined;\n this._transactionName = undefined;\n this._fingerprint = undefined;\n this._session = undefined;\n this._conversationId = undefined;\n _setSpanForScope(this, undefined);\n this._attachments = [];\n this.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Adds a breadcrumb to the scope.\n * By default, the last 100 breadcrumbs are kept.\n */\n public addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this {\n const maxCrumbs = typeof maxBreadcrumbs === 'number' ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;\n\n // No data has been changed, so don't notify scope listeners\n if (maxCrumbs <= 0) {\n return this;\n }\n\n const mergedBreadcrumb: Breadcrumb = {\n timestamp: dateTimestampInSeconds(),\n ...breadcrumb,\n // Breadcrumb messages can theoretically be infinitely large and they're held in memory so we truncate them not to leak (too much) memory\n message: breadcrumb.message ? truncate(breadcrumb.message, 2048) : breadcrumb.message,\n };\n\n this._breadcrumbs.push(mergedBreadcrumb);\n if (this._breadcrumbs.length > maxCrumbs) {\n this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);\n this._client?.recordDroppedEvent('buffer_overflow', 'log_item');\n }\n\n this._notifyScopeListeners();\n\n return this;\n }\n\n /**\n * Get the last breadcrumb of the scope.\n */\n public getLastBreadcrumb(): Breadcrumb | undefined {\n return this._breadcrumbs[this._breadcrumbs.length - 1];\n }\n\n /**\n * Clear all breadcrumbs from the scope.\n */\n public clearBreadcrumbs(): this {\n this._breadcrumbs = [];\n this._notifyScopeListeners();\n return this;\n }\n\n /**\n * Add an attachment to the scope.\n */\n public addAttachment(attachment: Attachment): this {\n this._attachments.push(attachment);\n return this;\n }\n\n /**\n * Clear all attachments from the scope.\n */\n public clearAttachments(): this {\n this._attachments = [];\n return this;\n }\n\n /**\n * Get the data of this scope, which should be applied to an event during processing.\n */\n public getScopeData(): ScopeData {\n return {\n breadcrumbs: this._breadcrumbs,\n attachments: this._attachments,\n contexts: this._contexts,\n tags: this._tags,\n attributes: this._attributes,\n extra: this._extra,\n user: this._user,\n level: this._level,\n fingerprint: this._fingerprint || [],\n eventProcessors: this._eventProcessors,\n propagationContext: this._propagationContext,\n sdkProcessingMetadata: this._sdkProcessingMetadata,\n transactionName: this._transactionName,\n span: _getSpanForScope(this),\n conversationId: this._conversationId,\n };\n }\n\n /**\n * Add data which will be accessible during event processing but won't get sent to Sentry.\n */\n public setSDKProcessingMetadata(newData: SdkProcessingMetadata): this {\n this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2);\n return this;\n }\n\n /**\n * Add propagation context to the scope, used for distributed tracing\n */\n public setPropagationContext(context: PropagationContext): this {\n this._propagationContext = context;\n return this;\n }\n\n /**\n * Get propagation context from the scope, used for distributed tracing\n */\n public getPropagationContext(): PropagationContext {\n return this._propagationContext;\n }\n\n /**\n * Capture an exception for this scope.\n *\n * @returns {string} The id of the captured Sentry event.\n */\n public captureException(exception: unknown, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture exception!');\n return eventId;\n }\n\n const syntheticException = new Error('Sentry syntheticException');\n\n this._client.captureException(\n exception,\n {\n originalException: exception,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a message for this scope.\n *\n * @returns {string} The id of the captured message.\n */\n public captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string {\n const eventId = hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture message!');\n return eventId;\n }\n\n const syntheticException = hint?.syntheticException ?? new Error(message);\n\n this._client.captureMessage(\n message,\n level,\n {\n originalException: message,\n syntheticException,\n ...hint,\n event_id: eventId,\n },\n this,\n );\n\n return eventId;\n }\n\n /**\n * Capture a Sentry event for this scope.\n *\n * @returns {string} The id of the captured event.\n */\n public captureEvent(event: Event, hint?: EventHint): string {\n const eventId = event.event_id || hint?.event_id || uuid4();\n\n if (!this._client) {\n DEBUG_BUILD && debug.warn('No client configured on scope - will not capture event!');\n return eventId;\n }\n\n this._client.captureEvent(event, { ...hint, event_id: eventId }, this);\n\n return eventId;\n }\n\n /**\n * This will be called on every set call.\n */\n protected _notifyScopeListeners(): void {\n // We need this check for this._notifyingListeners to be able to work on scope during updates\n // If this check is not here we'll produce endless recursion when something is done with the scope\n // during the callback.\n if (!this._notifyingListeners) {\n this._notifyingListeners = true;\n this._scopeListeners.forEach(callback => {\n callback(this);\n });\n this._notifyingListeners = false;\n }\n }\n}\n"],"names":[],"mappings":";;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AA,EAAM,YAAY,KAAA,EAAM;AAE1D,IAAA,IAAI,CAAC,KAAK,OAAA,EAAS;AACjB,MAAA,WAAA,IAAe,KAAA,CAAM,KAAK,yDAAyD,CAAA;AACnF,MAAA,OAAO,OAAA;AAAA,IACT;AAEA,IAAA,IAAA,CAAK,OAAA,CAAQ,aAAa,KAAA,EAAO,EAAE,GAAG,IAAA,EAAM,QAAA,EAAU,OAAA,EAAQ,EAAG,IAAI,CAAA;AAErE,IAAA,OAAO,OAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKU,qBAAA,GAA8B;AAItC,IAAA,IAAI,CAAC,KAAK,mBAAA,EAAqB;AAC7B,MAAA,IAAA,CAAK,mBAAA,GAAsB,IAAA;AAC3B,MAAA,IAAA,CAAK,eAAA,CAAgB,QAAQ,CAAA,QAAA,KAAY;AACvC,QAAA,QAAA,CAAS,IAAI,CAAA;AAAA,MACf,CAAC,CAAA;AACD,MAAA,IAAA,CAAK,mBAAA,GAAsB,KAAA;AAAA,IAC7B;AAAA,EACF;AACF;;;;"}

@@ -201,2 +201,8 @@ import { getAsyncContextStrategy } from '../asyncContext/index.js';

addNonEnumerableProperty(childSpan, ROOT_SPAN_FIELD, rootSpan);
if (!spanIsSampled(span)) {
return;
}
if (!span.isRecording() && !rootSpan.isRecording()) {
return;
}
if (span[CHILD_SPANS_FIELD]) {

@@ -203,0 +209,0 @@ span[CHILD_SPANS_FIELD].add(childSpan);

@@ -1,1 +0,1 @@

{"version":3,"file":"spanUtils.js","sources":["../../../src/utils/spanUtils.ts"],"sourcesContent":["// oxlint-disable max-lines\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { RawAttributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getMainCarrier } from '../carrier';\nimport { getCurrentScope } from '../currentScopes';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE,\n} from '../semanticAttributes';\nimport type { SentrySpan } from '../tracing/sentrySpan';\nimport { SPAN_STATUS_OK, SPAN_STATUS_UNSET } from '../tracing/spanstatus';\nimport { getCapturedScopesOnSpan } from '../tracing/utils';\nimport type { TraceContext } from '../types/context';\nimport type { SpanLink, SpanLinkJSON } from '../types/link';\nimport type {\n SerializedStreamedSpan,\n Span,\n SpanAttributes,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { generateSpanId } from '../utils/propagationContext';\nimport { timestampInSeconds } from '../utils/time';\nimport { generateSentryTraceHeader, generateTraceparentHeader } from '../utils/tracing';\nimport { consoleSandbox } from './debug-logger';\nimport { _getSpanForScope } from './spanOnScope';\n\n// These are aligned with OpenTelemetry trace flags\nexport const TRACE_FLAG_NONE = 0x0;\nexport const TRACE_FLAG_SAMPLED = 0x1;\n\nlet hasShownSpanDropWarning = false;\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in an event.\n * By default, this will only include trace_id, span_id & parent_span_id.\n * If `includeAllData` is true, it will also include data, op, status & origin.\n */\nexport function spanToTransactionTraceContext(span: Span): TraceContext {\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n const { data, op, parent_span_id, status, origin, links } = spanToJSON(span);\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n data,\n op,\n status,\n origin,\n links,\n };\n}\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.\n */\nexport function spanToTraceContext(span: Span): TraceContext {\n const { spanId, traceId: trace_id, isRemote } = span.spanContext();\n\n // If the span is remote, we use a random/virtual span as span_id to the trace context,\n // and the remote span as parent_span_id\n const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id;\n const scope = getCapturedScopesOnSpan(span).scope;\n\n const span_id = isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId;\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n };\n}\n\n/**\n * Convert a Span to a Sentry trace header.\n */\nexport function spanToTraceHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateSentryTraceHeader(traceId, spanId, sampled);\n}\n\n/**\n * Convert a Span to a W3C traceparent header.\n */\nexport function spanToTraceparentHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateTraceparentHeader(traceId, spanId, sampled);\n}\n\n/**\n * Converts the span links array to a flattened version to be sent within an envelope.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function convertSpanLinksForEnvelope(links?: SpanLink[]): SpanLinkJSON[] | undefined {\n if (links && links.length > 0) {\n return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n ...restContext,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Converts the span links array to a flattened version with serialized attributes for V2 spans.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function getStreamedSpanLinks(\n links?: SpanLink[],\n): SpanLinkJSON<RawAttributes<Record<string, unknown>>>[] | undefined {\n if (links?.length) {\n return links.map(({ context: { spanId, traceId, traceFlags }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Convert a span time input into a timestamp in seconds.\n */\nexport function spanTimeInputToSeconds(input: SpanTimeInput | undefined): number {\n if (typeof input === 'number') {\n return ensureTimestampInSeconds(input);\n }\n\n if (Array.isArray(input)) {\n // See {@link HrTime} for the array-based time format\n return input[0] + input[1] / 1e9;\n }\n\n if (input instanceof Date) {\n return ensureTimestampInSeconds(input.getTime());\n }\n\n return timestampInSeconds();\n}\n\n/**\n * Converts a timestamp to second, if it was in milliseconds, or keeps it as second.\n */\nfunction ensureTimestampInSeconds(timestamp: number): number {\n const isMs = timestamp > 9999999999;\n return isMs ? timestamp / 1000 : timestamp;\n}\n\n/**\n * Convert a span to a JSON representation.\n */\n// Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).\n// This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.\n// And `spanToJSON` needs the Span class from `span.ts` to check here.\nexport function spanToJSON(span: Span): SpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n span_id,\n trace_id,\n data: attributes,\n description: name,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n // This is [0,0] by default in OTEL, in which case we want to interpret this as no end time\n timestamp: spanTimeInputToSeconds(endTime) || undefined,\n status: getStatusMessage(status),\n op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n links: convertSpanLinksForEnvelope(links),\n };\n }\n\n // Finally, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n data: {},\n };\n}\n\n/**\n * Convert a span to the intermediate {@link StreamedSpanJSON} representation.\n */\nexport function spanToStreamedSpanJSON(span: Span): StreamedSpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getStreamedSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n name,\n span_id,\n trace_id,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n end_timestamp: spanTimeInputToSeconds(endTime),\n is_segment: span === INTERNAL_getSegmentSpan(span),\n status: getSimpleStatus(status),\n attributes: addStatusMessageAttribute(attributes, status),\n links: getStreamedSpanLinks(links),\n };\n }\n\n // Finally, as a fallback, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n name: '',\n end_timestamp: 0,\n status: 'ok',\n is_segment: span === INTERNAL_getSegmentSpan(span),\n };\n}\n\n/**\n * In preparation for the next major of OpenTelemetry, we want to support\n * looking up the parent span id according to the new API\n * In OTel v1, the parent span id is accessed as `parentSpanId`\n * In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`\n */\nfunction getOtelParentSpanId(span: OpenTelemetrySdkTraceBaseSpan): string | undefined {\n return 'parentSpanId' in span\n ? span.parentSpanId\n : 'parentSpanContext' in span\n ? (span.parentSpanContext as { spanId?: string } | undefined)?.spanId\n : undefined;\n}\n\n/**\n * Converts a {@link StreamedSpanJSON} to a {@link SerializedSpan}.\n * This is the final serialized span format that is sent to Sentry.\n * The returned serilaized spans must not be consumed by users or SDK integrations.\n */\nexport function streamedSpanJsonToSerializedSpan(spanJson: StreamedSpanJSON): SerializedStreamedSpan {\n return {\n ...spanJson,\n attributes: serializeAttributes(spanJson.attributes),\n links: spanJson.links?.map(link => ({\n ...link,\n attributes: serializeAttributes(link.attributes),\n })),\n };\n}\n\nfunction spanIsOpenTelemetrySdkTraceBaseSpan(span: Span): span is OpenTelemetrySdkTraceBaseSpan {\n const castSpan = span as Partial<OpenTelemetrySdkTraceBaseSpan>;\n return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;\n}\n\n/** Exported only for tests. */\nexport interface OpenTelemetrySdkTraceBaseSpan extends Span {\n attributes: SpanAttributes;\n startTime: SpanTimeInput;\n name: string;\n status: SpanStatus;\n endTime: SpanTimeInput;\n parentSpanId?: string;\n links?: SpanLink[];\n}\n\n/**\n * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.\n * :( So instead we approximate this by checking if it has the `getSpanJSON` method.\n */\nexport function spanIsSentrySpan(span: Span): span is SentrySpan {\n return typeof (span as SentrySpan).getSpanJSON === 'function';\n}\n\n/**\n * Returns true if a span is sampled.\n * In most cases, you should just use `span.isRecording()` instead.\n * However, this has a slightly different semantic, as it also returns false if the span is finished.\n * So in the case where this distinction is important, use this method.\n */\nexport function spanIsSampled(span: Span): boolean {\n // We align our trace flags with the ones OpenTelemetry use\n // So we also check for sampled the same way they do.\n const { traceFlags } = span.spanContext();\n return traceFlags === TRACE_FLAG_SAMPLED;\n}\n\n/** Get the status message to use for a JSON representation of a span. */\nexport function getStatusMessage(status: SpanStatus | undefined): string | undefined {\n if (!status || status.code === SPAN_STATUS_UNSET) {\n return undefined;\n }\n\n if (status.code === SPAN_STATUS_OK) {\n return 'ok';\n }\n\n return status.message || 'internal_error';\n}\n\n/**\n * Convert the various statuses to the simple ones expected by Sentry for streamed spans ('ok' is default).\n */\nexport function getSimpleStatus(status: SpanStatus | undefined): 'ok' | 'error' {\n return !status ||\n status.code === SPAN_STATUS_OK ||\n status.code === SPAN_STATUS_UNSET ||\n status.message === 'cancelled'\n ? 'ok'\n : 'error';\n}\n\n/**\n * Returns the span's attributes with the SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE attribute added\n * if the span has an error status message worth preserving.\n *\n * An explicitly set attribute is never overwritten.\n */\nexport function addStatusMessageAttribute(\n attributes: SpanAttributes,\n status: SpanStatus | undefined,\n): RawAttributes<Record<string, unknown>> {\n const statusMessage = getSimpleStatus(status) === 'error' ? status?.message : undefined;\n return {\n ...(statusMessage && { [SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]: statusMessage }),\n ...attributes,\n };\n}\n\nconst CHILD_SPANS_FIELD = '_sentryChildSpans';\nconst ROOT_SPAN_FIELD = '_sentryRootSpan';\n\ntype SpanWithPotentialChildren = Span & {\n [CHILD_SPANS_FIELD]?: Set<Span>;\n [ROOT_SPAN_FIELD]?: Span;\n};\n\n/**\n * Adds an opaque child span reference to a span.\n */\nexport function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n // We store the root span reference on the child span\n // We need this for `getRootSpan()` to work\n const rootSpan = span[ROOT_SPAN_FIELD] || span;\n addNonEnumerableProperty(childSpan as SpanWithPotentialChildren, ROOT_SPAN_FIELD, rootSpan);\n\n // We store a list of child spans on the parent span\n // We need this for `getSpanDescendants()` to work\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].add(childSpan);\n } else {\n addNonEnumerableProperty(span, CHILD_SPANS_FIELD, new Set([childSpan]));\n }\n}\n\n/** This is only used internally by Idle Spans. */\nexport function removeChildSpanFromSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].delete(childSpan);\n }\n}\n\n/**\n * Returns an array of the given span and all of its descendants.\n */\nexport function getSpanDescendants(span: SpanWithPotentialChildren): Span[] {\n const resultSet = new Set<Span>();\n\n function addSpanChildren(span: SpanWithPotentialChildren): void {\n // This exit condition is required to not infinitely loop in case of a circular dependency.\n if (resultSet.has(span)) {\n return;\n // We want to ignore unsampled spans (e.g. non recording spans)\n } else if (spanIsSampled(span)) {\n resultSet.add(span);\n const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : [];\n for (const childSpan of childSpans) {\n addSpanChildren(childSpan);\n }\n }\n }\n\n addSpanChildren(span);\n\n return Array.from(resultSet);\n}\n\n/**\n * Returns the root span of a given span.\n */\nexport const getRootSpan = INTERNAL_getSegmentSpan;\n\n/**\n * Returns the segment span of a given span.\n */\nexport function INTERNAL_getSegmentSpan(span: SpanWithPotentialChildren): Span {\n return span[ROOT_SPAN_FIELD] || span;\n}\n\n/**\n * Returns the currently active span.\n */\nexport function getActiveSpan(): Span | undefined {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getActiveSpan) {\n return acs.getActiveSpan();\n }\n\n return _getSpanForScope(getCurrentScope());\n}\n\n/**\n * Logs a warning once if `beforeSendSpan` is used to drop spans.\n */\nexport function showSpanDropWarning(): void {\n if (!hasShownSpanDropWarning) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.',\n );\n });\n hasShownSpanDropWarning = true;\n }\n}\n\n/**\n * Updates the name of the given span and ensures that the span name is not\n * overwritten by the Sentry SDK.\n *\n * Use this function instead of `span.updateName()` if you want to make sure that\n * your name is kept. For some spans, for example root `http.server` spans the\n * Sentry SDK would otherwise overwrite the span name with a high-quality name\n * it infers when the span ends.\n *\n * Use this function in server code or when your span is started on the server\n * and on the client (browser). If you only update a span name on the client,\n * you can also use `span.updateName()` the SDK does not overwrite the name.\n *\n * @param span - The span to update the name of.\n * @param name - The name to set on the span.\n */\nexport function updateSpanName(span: Span, name: string): void {\n span.updateName(name);\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: name,\n });\n}\n"],"names":["span"],"mappings":";;;;;;;;;;;;;;AAoCO,MAAM,eAAA,GAAkB;AACxB,MAAM,kBAAA,GAAqB;AAElC,IAAI,uBAAA,GAA0B,KAAA;AAOvB,SAAS,8BAA8B,IAAA,EAA0B;AACtE,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,SAAS,QAAA,EAAS,GAAI,KAAK,WAAA,EAAY;AAChE,EAAA,MAAM,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,iBAAiB,CAAA,GAAI,KAAA,CAAM,KAAKA,KAAAA,CAAK,iBAAiB,CAAC,CAAA,GAAI,EAAC;AACpF,MAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,QAAA,eAAA,CAAgB,SAAS,CAAA;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAEA,EAAA,eAAA,CAAgB,IAAI,CAAA;AAEpB,EAAA,OAAO,KAAA,CAAM,KAAK,SAAS,CAAA;AAC7B;AAKO,MAAM,WAAA,GAAc;AAKpB,SAAS,wBAAwB,IAAA,EAAuC;AAC7E,EAAA,OAAO,IAAA,CAAK,eAAe,CAAA,IAAK,IAAA;AAClC;AAKO,SAAS,aAAA,GAAkC;AAChD,EAAA,MAAM,UAAU,cAAA,EAAe;AAC/B,EAAA,MAAM,GAAA,GAAM,wBAAwB,OAAO,CAAA;AAC3C,EAAA,IAAI,IAAI,aAAA,EAAe;AACrB,IAAA,OAAO,IAAI,aAAA,EAAc;AAAA,EAC3B;AAEA,EAAA,OAAO,gBAAA,CAAiB,iBAAiB,CAAA;AAC3C;AAKO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,CAAC,uBAAA,EAAyB;AAC5B,IAAA,cAAA,CAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AACD,IAAA,uBAAA,GAA0B,IAAA;AAAA,EAC5B;AACF;AAkBO,SAAS,cAAA,CAAe,MAAY,IAAA,EAAoB;AAC7D,EAAA,IAAA,CAAK,WAAW,IAAI,CAAA;AACpB,EAAA,IAAA,CAAK,aAAA,CAAc;AAAA,IACjB,CAAC,gCAAgC,GAAG,QAAA;AAAA,IACpC,CAAC,0CAA0C,GAAG;AAAA,GAC/C,CAAA;AACH;;;;"}
{"version":3,"file":"spanUtils.js","sources":["../../../src/utils/spanUtils.ts"],"sourcesContent":["// oxlint-disable max-lines\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { RawAttributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getMainCarrier } from '../carrier';\nimport { getCurrentScope } from '../currentScopes';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE,\n} from '../semanticAttributes';\nimport type { SentrySpan } from '../tracing/sentrySpan';\nimport { SPAN_STATUS_OK, SPAN_STATUS_UNSET } from '../tracing/spanstatus';\nimport { getCapturedScopesOnSpan } from '../tracing/utils';\nimport type { TraceContext } from '../types/context';\nimport type { SpanLink, SpanLinkJSON } from '../types/link';\nimport type {\n SerializedStreamedSpan,\n Span,\n SpanAttributes,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { generateSpanId } from '../utils/propagationContext';\nimport { timestampInSeconds } from '../utils/time';\nimport { generateSentryTraceHeader, generateTraceparentHeader } from '../utils/tracing';\nimport { consoleSandbox } from './debug-logger';\nimport { _getSpanForScope } from './spanOnScope';\n\n// These are aligned with OpenTelemetry trace flags\nexport const TRACE_FLAG_NONE = 0x0;\nexport const TRACE_FLAG_SAMPLED = 0x1;\n\nlet hasShownSpanDropWarning = false;\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in an event.\n * By default, this will only include trace_id, span_id & parent_span_id.\n * If `includeAllData` is true, it will also include data, op, status & origin.\n */\nexport function spanToTransactionTraceContext(span: Span): TraceContext {\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n const { data, op, parent_span_id, status, origin, links } = spanToJSON(span);\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n data,\n op,\n status,\n origin,\n links,\n };\n}\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.\n */\nexport function spanToTraceContext(span: Span): TraceContext {\n const { spanId, traceId: trace_id, isRemote } = span.spanContext();\n\n // If the span is remote, we use a random/virtual span as span_id to the trace context,\n // and the remote span as parent_span_id\n const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id;\n const scope = getCapturedScopesOnSpan(span).scope;\n\n const span_id = isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId;\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n };\n}\n\n/**\n * Convert a Span to a Sentry trace header.\n */\nexport function spanToTraceHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateSentryTraceHeader(traceId, spanId, sampled);\n}\n\n/**\n * Convert a Span to a W3C traceparent header.\n */\nexport function spanToTraceparentHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateTraceparentHeader(traceId, spanId, sampled);\n}\n\n/**\n * Converts the span links array to a flattened version to be sent within an envelope.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function convertSpanLinksForEnvelope(links?: SpanLink[]): SpanLinkJSON[] | undefined {\n if (links && links.length > 0) {\n return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n ...restContext,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Converts the span links array to a flattened version with serialized attributes for V2 spans.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function getStreamedSpanLinks(\n links?: SpanLink[],\n): SpanLinkJSON<RawAttributes<Record<string, unknown>>>[] | undefined {\n if (links?.length) {\n return links.map(({ context: { spanId, traceId, traceFlags }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Convert a span time input into a timestamp in seconds.\n */\nexport function spanTimeInputToSeconds(input: SpanTimeInput | undefined): number {\n if (typeof input === 'number') {\n return ensureTimestampInSeconds(input);\n }\n\n if (Array.isArray(input)) {\n // See {@link HrTime} for the array-based time format\n return input[0] + input[1] / 1e9;\n }\n\n if (input instanceof Date) {\n return ensureTimestampInSeconds(input.getTime());\n }\n\n return timestampInSeconds();\n}\n\n/**\n * Converts a timestamp to second, if it was in milliseconds, or keeps it as second.\n */\nfunction ensureTimestampInSeconds(timestamp: number): number {\n const isMs = timestamp > 9999999999;\n return isMs ? timestamp / 1000 : timestamp;\n}\n\n/**\n * Convert a span to a JSON representation.\n */\n// Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).\n// This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.\n// And `spanToJSON` needs the Span class from `span.ts` to check here.\nexport function spanToJSON(span: Span): SpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n span_id,\n trace_id,\n data: attributes,\n description: name,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n // This is [0,0] by default in OTEL, in which case we want to interpret this as no end time\n timestamp: spanTimeInputToSeconds(endTime) || undefined,\n status: getStatusMessage(status),\n op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n links: convertSpanLinksForEnvelope(links),\n };\n }\n\n // Finally, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n data: {},\n };\n}\n\n/**\n * Convert a span to the intermediate {@link StreamedSpanJSON} representation.\n */\nexport function spanToStreamedSpanJSON(span: Span): StreamedSpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getStreamedSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n name,\n span_id,\n trace_id,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n end_timestamp: spanTimeInputToSeconds(endTime),\n is_segment: span === INTERNAL_getSegmentSpan(span),\n status: getSimpleStatus(status),\n attributes: addStatusMessageAttribute(attributes, status),\n links: getStreamedSpanLinks(links),\n };\n }\n\n // Finally, as a fallback, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n name: '',\n end_timestamp: 0,\n status: 'ok',\n is_segment: span === INTERNAL_getSegmentSpan(span),\n };\n}\n\n/**\n * In preparation for the next major of OpenTelemetry, we want to support\n * looking up the parent span id according to the new API\n * In OTel v1, the parent span id is accessed as `parentSpanId`\n * In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`\n */\nfunction getOtelParentSpanId(span: OpenTelemetrySdkTraceBaseSpan): string | undefined {\n return 'parentSpanId' in span\n ? span.parentSpanId\n : 'parentSpanContext' in span\n ? (span.parentSpanContext as { spanId?: string } | undefined)?.spanId\n : undefined;\n}\n\n/**\n * Converts a {@link StreamedSpanJSON} to a {@link SerializedSpan}.\n * This is the final serialized span format that is sent to Sentry.\n * The returned serilaized spans must not be consumed by users or SDK integrations.\n */\nexport function streamedSpanJsonToSerializedSpan(spanJson: StreamedSpanJSON): SerializedStreamedSpan {\n return {\n ...spanJson,\n attributes: serializeAttributes(spanJson.attributes),\n links: spanJson.links?.map(link => ({\n ...link,\n attributes: serializeAttributes(link.attributes),\n })),\n };\n}\n\nfunction spanIsOpenTelemetrySdkTraceBaseSpan(span: Span): span is OpenTelemetrySdkTraceBaseSpan {\n const castSpan = span as Partial<OpenTelemetrySdkTraceBaseSpan>;\n return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;\n}\n\n/** Exported only for tests. */\nexport interface OpenTelemetrySdkTraceBaseSpan extends Span {\n attributes: SpanAttributes;\n startTime: SpanTimeInput;\n name: string;\n status: SpanStatus;\n endTime: SpanTimeInput;\n parentSpanId?: string;\n links?: SpanLink[];\n}\n\n/**\n * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.\n * :( So instead we approximate this by checking if it has the `getSpanJSON` method.\n */\nexport function spanIsSentrySpan(span: Span): span is SentrySpan {\n return typeof (span as SentrySpan).getSpanJSON === 'function';\n}\n\n/**\n * Returns true if a span is sampled.\n * In most cases, you should just use `span.isRecording()` instead.\n * However, this has a slightly different semantic, as it also returns false if the span is finished.\n * So in the case where this distinction is important, use this method.\n */\nexport function spanIsSampled(span: Span): boolean {\n // We align our trace flags with the ones OpenTelemetry use\n // So we also check for sampled the same way they do.\n const { traceFlags } = span.spanContext();\n return traceFlags === TRACE_FLAG_SAMPLED;\n}\n\n/** Get the status message to use for a JSON representation of a span. */\nexport function getStatusMessage(status: SpanStatus | undefined): string | undefined {\n if (!status || status.code === SPAN_STATUS_UNSET) {\n return undefined;\n }\n\n if (status.code === SPAN_STATUS_OK) {\n return 'ok';\n }\n\n return status.message || 'internal_error';\n}\n\n/**\n * Convert the various statuses to the simple ones expected by Sentry for streamed spans ('ok' is default).\n */\nexport function getSimpleStatus(status: SpanStatus | undefined): 'ok' | 'error' {\n return !status ||\n status.code === SPAN_STATUS_OK ||\n status.code === SPAN_STATUS_UNSET ||\n status.message === 'cancelled'\n ? 'ok'\n : 'error';\n}\n\n/**\n * Returns the span's attributes with the SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE attribute added\n * if the span has an error status message worth preserving.\n *\n * An explicitly set attribute is never overwritten.\n */\nexport function addStatusMessageAttribute(\n attributes: SpanAttributes,\n status: SpanStatus | undefined,\n): RawAttributes<Record<string, unknown>> {\n const statusMessage = getSimpleStatus(status) === 'error' ? status?.message : undefined;\n return {\n ...(statusMessage && { [SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]: statusMessage }),\n ...attributes,\n };\n}\n\nconst CHILD_SPANS_FIELD = '_sentryChildSpans';\nconst ROOT_SPAN_FIELD = '_sentryRootSpan';\n\ntype SpanWithPotentialChildren = Span & {\n [CHILD_SPANS_FIELD]?: Set<Span>;\n [ROOT_SPAN_FIELD]?: Span;\n};\n\n/**\n * Adds an opaque child span reference to a span.\n */\nexport function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n // We store the root span reference on the child span\n // We need this for `getRootSpan()` to work\n const rootSpan = span[ROOT_SPAN_FIELD] || span;\n addNonEnumerableProperty(childSpan as SpanWithPotentialChildren, ROOT_SPAN_FIELD, rootSpan);\n\n // `_sentryChildSpans` exists only so `getSpanDescendants()` can walk the tree when the segment span\n // is sent, and that walk stops at an unsampled span without ever visiting its children. So a child\n // tracked here would be held for the parent's lifetime and never read.\n if (!spanIsSampled(span)) {\n return;\n }\n\n // Once the segment span stopped recording, the tree has been read for the last time, and a child\n // starting now belongs to whatever segment comes next: it is re-emitted on its own instead. Tracking\n // it here would pin it for as long as the parent lives, which for a span left active in an async\n // context (e.g. a framework boot span captured by a queue consumer) is the rest of the process. Only\n // a parent that is itself still recording keeps tracking, so a late child that outlives its segment\n // still collects the subtree it is re-emitted with.\n if (!span.isRecording() && !rootSpan.isRecording()) {\n return;\n }\n\n // We store a list of child spans on the parent span\n // We need this for `getSpanDescendants()` to work\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].add(childSpan);\n } else {\n addNonEnumerableProperty(span, CHILD_SPANS_FIELD, new Set([childSpan]));\n }\n}\n\n/** This is only used internally by Idle Spans. */\nexport function removeChildSpanFromSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].delete(childSpan);\n }\n}\n\n/**\n * Returns an array of the given span and all of its descendants.\n */\nexport function getSpanDescendants(span: SpanWithPotentialChildren): Span[] {\n const resultSet = new Set<Span>();\n\n function addSpanChildren(span: SpanWithPotentialChildren): void {\n // This exit condition is required to not infinitely loop in case of a circular dependency.\n if (resultSet.has(span)) {\n return;\n // We want to ignore unsampled spans (e.g. non recording spans)\n } else if (spanIsSampled(span)) {\n resultSet.add(span);\n const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : [];\n for (const childSpan of childSpans) {\n addSpanChildren(childSpan);\n }\n }\n }\n\n addSpanChildren(span);\n\n return Array.from(resultSet);\n}\n\n/**\n * Returns the root span of a given span.\n */\nexport const getRootSpan = INTERNAL_getSegmentSpan;\n\n/**\n * Returns the segment span of a given span.\n */\nexport function INTERNAL_getSegmentSpan(span: SpanWithPotentialChildren): Span {\n return span[ROOT_SPAN_FIELD] || span;\n}\n\n/**\n * Returns the currently active span.\n */\nexport function getActiveSpan(): Span | undefined {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getActiveSpan) {\n return acs.getActiveSpan();\n }\n\n return _getSpanForScope(getCurrentScope());\n}\n\n/**\n * Logs a warning once if `beforeSendSpan` is used to drop spans.\n */\nexport function showSpanDropWarning(): void {\n if (!hasShownSpanDropWarning) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.',\n );\n });\n hasShownSpanDropWarning = true;\n }\n}\n\n/**\n * Updates the name of the given span and ensures that the span name is not\n * overwritten by the Sentry SDK.\n *\n * Use this function instead of `span.updateName()` if you want to make sure that\n * your name is kept. For some spans, for example root `http.server` spans the\n * Sentry SDK would otherwise overwrite the span name with a high-quality name\n * it infers when the span ends.\n *\n * Use this function in server code or when your span is started on the server\n * and on the client (browser). If you only update a span name on the client,\n * you can also use `span.updateName()` the SDK does not overwrite the name.\n *\n * @param span - The span to update the name of.\n * @param name - The name to set on the span.\n */\nexport function updateSpanName(span: Span, name: string): void {\n span.updateName(name);\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: name,\n });\n}\n"],"names":["span"],"mappings":";;;;;;;;;;;;;;AAoCO,MAAM,eAAA,GAAkB;AACxB,MAAM,kBAAA,GAAqB;AAElC,IAAI,uBAAA,GAA0B,KAAA;AAOvB,SAAS,8BAA8B,IAAA,EAA0B;AACtE,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,SAAS,QAAA,EAAS,GAAI,KAAK,WAAA,EAAY;AAChE,EAAA,MAAM,EAAE,MAAM,EAAA,EAAI,cAAA,EAAgB,QAAQ,MAAA,EAAQ,KAAA,EAAM,GAAI,UAAA,CAAW,IAAI,CAAA;AAE3E,EAAA,OAAO;AAAA,IACL,cAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,EAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;AAKO,SAAS,mBAAmB,IAAA,EAA0B;AAC3D,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,UAAU,QAAA,EAAS,GAAI,KAAK,WAAA,EAAY;AAIjE,EAAA,MAAM,cAAA,GAAiB,QAAA,GAAW,MAAA,GAAS,UAAA,CAAW,IAAI,CAAA,CAAE,cAAA;AAC5D,EAAA,MAAM,KAAA,GAAQ,uBAAA,CAAwB,IAAI,CAAA,CAAE,KAAA;AAE5C,EAAA,MAAM,UAAU,QAAA,GAAW,KAAA,EAAO,uBAAsB,CAAE,iBAAA,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,EAAA,MAAM,UAAU,cAAA,EAAe;AAC/B,EAAA,MAAM,GAAA,GAAM,wBAAwB,OAAO,CAAA;AAC3C,EAAA,IAAI,IAAI,aAAA,EAAe;AACrB,IAAA,OAAO,IAAI,aAAA,EAAc;AAAA,EAC3B;AAEA,EAAA,OAAO,gBAAA,CAAiB,iBAAiB,CAAA;AAC3C;AAKO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,CAAC,uBAAA,EAAyB;AAC5B,IAAA,cAAA,CAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AACD,IAAA,uBAAA,GAA0B,IAAA;AAAA,EAC5B;AACF;AAkBO,SAAS,cAAA,CAAe,MAAY,IAAA,EAAoB;AAC7D,EAAA,IAAA,CAAK,WAAW,IAAI,CAAA;AACpB,EAAA,IAAA,CAAK,aAAA,CAAc;AAAA,IACjB,CAAC,gCAAgC,GAAG,QAAA;AAAA,IACpC,CAAC,0CAA0C,GAAG;AAAA,GAC/C,CAAA;AACH;;;;"}

@@ -1,4 +0,4 @@

const SDK_VERSION = "10.70.0" ;
const SDK_VERSION = "10.71.0" ;
export { SDK_VERSION };
//# sourceMappingURL=version.js.map

@@ -151,3 +151,3 @@ import { Client } from '../client';

/**
* Creates a new Sentry reporter for Consola that forwards logs to Sentry. Requires the `enableLogs` option to be enabled.
* Creates a new Sentry reporter for Consola that forwards logs to Sentry.
*

@@ -166,3 +166,3 @@ * **Note: This integration supports Consola v3.x only.** The reporter interface and log object structure

* Sentry.init({
* enableLogs: true,
* dsn: '__DSN__',
* });

@@ -169,0 +169,0 @@ *

@@ -0,1 +1,2 @@

import { WebFetchHeaders } from '../types/webfetchapi';
declare const AUTH_OPERATIONS_TO_INSTRUMENT: string[];

@@ -45,5 +46,10 @@ declare const AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT: string[];

}
/**
* `postgrest-js` stores the request headers as a plain object up to v1.19.x and as a `Headers`
* instance from v2.74.0 on (shipped with `supabase-js` 2.74.0), so we have to handle both shapes.
*/
export type PostgRESTHeaders = Record<string, string> | WebFetchHeaders;
export interface PostgRESTFilterBuilder {
method: string;
headers: Record<string, string>;
headers: PostgRESTHeaders;
url: URL;

@@ -83,2 +89,10 @@ schema: string;

/**
* Reads a header off a PostgREST builder, regardless of whether it holds a plain object or a
* `Headers` instance. Lookup is case-insensitive because `Headers` lower-cases all of its keys.
* @param headers - The request headers
* @param name - The header name to look up
* @returns The header value, or `undefined` if it is not set
*/
export declare function getHeader(headers: PostgRESTHeaders | undefined, name: string): string | undefined;
/**
* Extracts the database operation type from the HTTP method and headers

@@ -89,3 +103,3 @@ * @param method - The HTTP method of the request

*/
export declare function extractOperation(method: string, headers?: Record<string, string>): string;
export declare function extractOperation(method: string, headers?: PostgRESTHeaders): string;
/**

@@ -92,0 +106,0 @@ * Translates Supabase filter parameters into readable method names for tracing

@@ -6,3 +6,3 @@ import { ConsoleLevel } from '../types/instrument';

/**
* Captures calls to the `console` API as logs in Sentry. Requires the `enableLogs` option to be enabled.
* Captures calls to the `console` API as logs in Sentry.
*

@@ -21,3 +21,2 @@ * @experimental This feature is experimental and may be changed or removed in future versions.

* Sentry.init({
* enableLogs: true,
* integrations: [Sentry.consoleLoggingIntegration({ levels: ['error', 'warn'] })],

@@ -24,0 +23,0 @@ * });

@@ -11,3 +11,3 @@ import { Scope } from '../scope';

/**
* @summary Capture a log with the `trace` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `trace` level.
*

@@ -39,3 +39,3 @@ * @param message - The message to log.

/**
* @summary Capture a log with the `debug` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `debug` level.
*

@@ -68,3 +68,3 @@ * @param message - The message to log.

/**
* @summary Capture a log with the `info` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `info` level.
*

@@ -97,3 +97,3 @@ * @param message - The message to log.

/**
* @summary Capture a log with the `warn` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `warn` level.
*

@@ -127,3 +127,3 @@ * @param message - The message to log.

/**
* @summary Capture a log with the `error` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `error` level.
*

@@ -158,3 +158,3 @@ * @param message - The message to log.

/**
* @summary Capture a log with the `fatal` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `fatal` level.
*

@@ -161,0 +161,0 @@ * @param message - The message to log.

@@ -288,2 +288,5 @@ import { AttributeObject, RawAttribute, RawAttributes } from './attributes';

* Note: The client will not be cleared.
*
* @deprecated This method will be removed in v11. To reset scope state, re-initialize the SDK or run
* your code in a fresh scope via `withScope` instead.
*/

@@ -290,0 +293,0 @@ clear(): this;

@@ -528,3 +528,3 @@ import { CaptureContext } from '../scope';

*
* @default false
* @default true
*/

@@ -531,0 +531,0 @@ enableLogs?: boolean;

@@ -151,3 +151,3 @@ import type { Client } from '../client';

/**
* Creates a new Sentry reporter for Consola that forwards logs to Sentry. Requires the `enableLogs` option to be enabled.
* Creates a new Sentry reporter for Consola that forwards logs to Sentry.
*

@@ -166,3 +166,3 @@ * **Note: This integration supports Consola v3.x only.** The reporter interface and log object structure

* Sentry.init({
* enableLogs: true,
* dsn: '__DSN__',
* });

@@ -169,0 +169,0 @@ *

@@ -0,1 +1,2 @@

import type { WebFetchHeaders } from '../types/webfetchapi';
declare const AUTH_OPERATIONS_TO_INSTRUMENT: string[];

@@ -45,5 +46,10 @@ declare const AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT: string[];

}
/**
* `postgrest-js` stores the request headers as a plain object up to v1.19.x and as a `Headers`
* instance from v2.74.0 on (shipped with `supabase-js` 2.74.0), so we have to handle both shapes.
*/
export type PostgRESTHeaders = Record<string, string> | WebFetchHeaders;
export interface PostgRESTFilterBuilder {
method: string;
headers: Record<string, string>;
headers: PostgRESTHeaders;
url: URL;

@@ -83,2 +89,10 @@ schema: string;

/**
* Reads a header off a PostgREST builder, regardless of whether it holds a plain object or a
* `Headers` instance. Lookup is case-insensitive because `Headers` lower-cases all of its keys.
* @param headers - The request headers
* @param name - The header name to look up
* @returns The header value, or `undefined` if it is not set
*/
export declare function getHeader(headers: PostgRESTHeaders | undefined, name: string): string | undefined;
/**
* Extracts the database operation type from the HTTP method and headers

@@ -89,3 +103,3 @@ * @param method - The HTTP method of the request

*/
export declare function extractOperation(method: string, headers?: Record<string, string>): string;
export declare function extractOperation(method: string, headers?: PostgRESTHeaders): string;
/**

@@ -92,0 +106,0 @@ * Translates Supabase filter parameters into readable method names for tracing

@@ -1,1 +0,1 @@

{"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../../src/integrations/supabase.ts"],"names":[],"mappings":"AAiBA,QAAA,MAAM,6BAA6B,UAWlC,CAAC;AAEF,QAAA,MAAM,mCAAmC,UAOxC,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4B3B,CAAC;AAEF,eAAO,MAAM,2BAA2B,UAAqD,CAAC;AAE9F,KAAK,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAChE,KAAK,iBAAiB,GAAG,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AACxE,KAAK,sBAAsB,GAAG,CAAC,OAAO,mCAAmC,CAAC,CAAC,MAAM,CAAC,CAAC;AACnF,KAAK,yBAAyB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,sBAAsB,CAAC;AAEhF,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;KACxD,GAAG,MAAM,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,qBAAqB;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,CAAC;CAC1C;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,E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AAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EACvD,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,KACtD,OAAO,CAAC,CAAC,CAAC,CAAC;CACjB;AAyCD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAcjG;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAsBvF;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA8B9E;AAqTD,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,OAAO,EACvB,UAAS;IAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAO,KAC5C,IAUF,CAAC;AAEF,UAAU,0BAA0B;IAClC,cAAc,EAAE,GAAG,CAAC;IACpB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAaD,eAAO,MAAM,mBAAmB;;CAEN,CAAC"}

@@ -6,3 +6,3 @@ import type { ConsoleLevel } from '../types/instrument';

/**
* Captures calls to the `console` API as logs in Sentry. Requires the `enableLogs` option to be enabled.
* Captures calls to the `console` API as logs in Sentry.
*

@@ -21,3 +21,2 @@ * @experimental This feature is experimental and may be changed or removed in future versions.

* Sentry.init({
* enableLogs: true,
* integrations: [Sentry.consoleLoggingIntegration({ levels: ['error', 'warn'] })],

@@ -24,0 +23,0 @@ * });

@@ -1,1 +0,1 @@

{"version":3,"file":"console-integration.d.ts","sourceRoot":"","sources":["../../../src/logs/console-integration.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,UAAU,qBAAqB;IAC7B,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AAiFD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,yBAAyB;;CAAgD,CAAC"}
{"version":3,"file":"console-integration.d.ts","sourceRoot":"","sources":["../../../src/logs/console-integration.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,UAAU,qBAAqB;IAC7B,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AAiFD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yBAAyB;;CAAgD,CAAC"}

@@ -11,3 +11,3 @@ import type { Scope } from '../scope';

/**
* @summary Capture a log with the `trace` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `trace` level.
*

@@ -39,3 +39,3 @@ * @param message - The message to log.

/**
* @summary Capture a log with the `debug` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `debug` level.
*

@@ -68,3 +68,3 @@ * @param message - The message to log.

/**
* @summary Capture a log with the `info` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `info` level.
*

@@ -97,3 +97,3 @@ * @param message - The message to log.

/**
* @summary Capture a log with the `warn` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `warn` level.
*

@@ -127,3 +127,3 @@ * @param message - The message to log.

/**
* @summary Capture a log with the `error` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `error` level.
*

@@ -158,3 +158,3 @@ * @param message - The message to log.

/**
* @summary Capture a log with the `fatal` level. Requires the `enableLogs` option to be enabled.
* @summary Capture a log with the `fatal` level.
*

@@ -161,0 +161,0 @@ * @param message - The message to log.

@@ -288,2 +288,5 @@ import type { AttributeObject, RawAttribute, RawAttributes } from './attributes';

* Note: The client will not be cleared.
*
* @deprecated This method will be removed in v11. To reset scope state, re-initialize the SDK or run
* your code in a fresh scope via `withScope` instead.
*/

@@ -290,0 +293,0 @@ clear(): this;

@@ -1,1 +0,1 @@

{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/scope.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAgBzC;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAA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,GAAG,IAAI;IAK/D;;OAEG;IACI,qBAAqB,IAAI,kBAAkB;IAIlD;;;;OAIG;IACI,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM;IAwBrE;;;;OAIG;IACI,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM;IAyBvF;;;;OAIG;IACI,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM;IAa3D;;OAEG;IACH,SAAS,CAAC,qBAAqB,IAAI,IAAI;CAYxC"}

@@ -528,3 +528,3 @@ import type { CaptureContext } from '../scope';

*
* @default false
* @default true
*/

@@ -531,0 +531,0 @@ enableLogs?: boolean;

@@ -1,1 +0,1 @@

{"version":3,"file":"spanUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/spanUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAWnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EACV,sBAAsB,EACtB,IAAI,EACJ,cAAc,EACd,QAAQ,EAER,aAAa,EACb,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAStD,eAAO,MAAM,eAAe,IAAM,CAAC;AACnC,eAAO,MAAM,kBAAkB,IAAM,CAAC;AAItC;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,IAAI,GAAG,YAAY,CActE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAA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,oBAAoB,CAAC;AAE1C,KAAK,yBAAyB,GAAG,IAAI,GAAG;IACtC,CAAC,iBAAiB,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,yBAAyB,EAAE,SAAS,EAAE,IAAI,GAAG,IAAI,CA8BzF;AAED,kDAAkD;AAClD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,yBAAyB,EAAE,SAAS,EAAE,IAAI,GAAG,IAAI,CAI9F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,EAAE,CAoB1E;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,gCAA0B,CAAC;AAEnD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,CAE7E;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,GAAG,SAAS,CAQhD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAU1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAM7D"}
{
"name": "@sentry/core",
"version": "10.70.0",
"version": "10.71.0",
"description": "Base implementation for all Sentry JavaScript SDKs",

@@ -5,0 +5,0 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display