Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
3.8 KiB
Plaintext
1 line
3.8 KiB
Plaintext
{"version":3,"file":"utils.js","sources":["../../../src/logs/utils.ts"],"sourcesContent":["import { isPrimitive } from '../utils/is';\nimport { normalize } from '../utils/normalize';\nimport { GLOBAL_OBJ } from '../utils/worldwide';\n\ntype GlobalObjectWithUtil = typeof GLOBAL_OBJ & {\n util: {\n format: (...args: unknown[]) => string;\n };\n};\n\n/**\n * Formats the given values into a string.\n *\n * @param values - The values to format.\n * @param normalizeDepth - The depth to normalize the values.\n * @param normalizeMaxBreadth - The max breadth to normalize the values.\n * @returns The formatted string.\n */\nexport function formatConsoleArgs(values: unknown[], normalizeDepth: number, normalizeMaxBreadth: number): string {\n return 'util' in GLOBAL_OBJ && typeof (GLOBAL_OBJ as GlobalObjectWithUtil).util.format === 'function'\n ? (GLOBAL_OBJ as GlobalObjectWithUtil).util.format(...values)\n : safeJoinConsoleArgs(values, normalizeDepth, normalizeMaxBreadth);\n}\n\n/**\n * Joins the given values into a string.\n *\n * @param values - The values to join.\n * @param normalizeDepth - The depth to normalize the values.\n * @param normalizeMaxBreadth - The max breadth to normalize the values.\n * @returns The joined string.\n */\nexport function safeJoinConsoleArgs(values: unknown[], normalizeDepth: number, normalizeMaxBreadth: number): string {\n return values\n .map(value =>\n isPrimitive(value) ? String(value) : JSON.stringify(normalize(value, normalizeDepth, normalizeMaxBreadth)),\n )\n .join(' ');\n}\n\n/**\n * Checks if a string contains console substitution patterns like %s, %d, %i, %f, %o, %O, %c.\n *\n * @param str - The string to check\n * @returns true if the string contains console substitution patterns\n */\nexport function hasConsoleSubstitutions(str: string): boolean {\n // Match console substitution patterns: %s, %d, %i, %f, %o, %O, %c\n return /%[sdifocO]/.test(str);\n}\n\n/**\n * Creates template attributes for multiple console arguments.\n *\n * @param args - The console arguments\n * @returns An object with template and parameter attributes\n */\nexport function createConsoleTemplateAttributes(firstArg: unknown, followingArgs: unknown[]): Record<string, unknown> {\n const attributes: Record<string, unknown> = {};\n\n // Create template with placeholders for each argument\n const template = new Array(followingArgs.length).fill('{}').join(' ');\n attributes['sentry.message.template'] = `${firstArg} ${template}`;\n\n // Add each argument as a parameter\n followingArgs.forEach((arg, index) => {\n attributes[`sentry.message.parameter.${index}`] = arg;\n });\n\n return attributes;\n}\n"],"names":[],"mappings":";;;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,MAAM,EAAa,cAAc,EAAU,mBAAmB,EAAkB;AAClH,EAAE,OAAO,MAAA,IAAU,UAAA,IAAc,OAAO,CAAC,UAAA,GAAoC,IAAI,CAAC,WAAW;AAC7F,MAAM,CAAC,UAAA,GAAoC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM;AAChE,MAAM,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,mBAAmB,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,MAAM,EAAa,cAAc,EAAU,mBAAmB,EAAkB;AACpH,EAAE,OAAO;AACT,KAAK,GAAG,CAAC,KAAA;AACT,MAAM,WAAW,CAAC,KAAK,CAAA,GAAI,MAAM,CAAC,KAAK,CAAA,GAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,mBAAmB,CAAC,CAAC;AAChH;AACA,KAAK,IAAI,CAAC,GAAG,CAAC;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,GAAG,EAAmB;AAC9D;AACA,EAAE,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CA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