Files
klz-cables.com/.pnpm-store/v10/files/8a/0f3ca31e99d157e9dc0a0b46453afd2b32209acbb30e2612de07a8d77305f29e068f7400160cf4264bd18663b8db65ccca01a2b9fb24b6dc68c5a40d967342
Marc Mintel 5397309103
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
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

69 lines
2.3 KiB
Plaintext

import { isPrimitive } from '../utils/is.js';
import { normalize } from '../utils/normalize.js';
import { GLOBAL_OBJ } from '../utils/worldwide.js';
/**
* Formats the given values into a string.
*
* @param values - The values to format.
* @param normalizeDepth - The depth to normalize the values.
* @param normalizeMaxBreadth - The max breadth to normalize the values.
* @returns The formatted string.
*/
function formatConsoleArgs(values, normalizeDepth, normalizeMaxBreadth) {
return 'util' in GLOBAL_OBJ && typeof (GLOBAL_OBJ ).util.format === 'function'
? (GLOBAL_OBJ ).util.format(...values)
: safeJoinConsoleArgs(values, normalizeDepth, normalizeMaxBreadth);
}
/**
* Joins the given values into a string.
*
* @param values - The values to join.
* @param normalizeDepth - The depth to normalize the values.
* @param normalizeMaxBreadth - The max breadth to normalize the values.
* @returns The joined string.
*/
function safeJoinConsoleArgs(values, normalizeDepth, normalizeMaxBreadth) {
return values
.map(value =>
isPrimitive(value) ? String(value) : JSON.stringify(normalize(value, normalizeDepth, normalizeMaxBreadth)),
)
.join(' ');
}
/**
* Checks if a string contains console substitution patterns like %s, %d, %i, %f, %o, %O, %c.
*
* @param str - The string to check
* @returns true if the string contains console substitution patterns
*/
function hasConsoleSubstitutions(str) {
// Match console substitution patterns: %s, %d, %i, %f, %o, %O, %c
return /%[sdifocO]/.test(str);
}
/**
* Creates template attributes for multiple console arguments.
*
* @param args - The console arguments
* @returns An object with template and parameter attributes
*/
function createConsoleTemplateAttributes(firstArg, followingArgs) {
const attributes = {};
// Create template with placeholders for each argument
const template = new Array(followingArgs.length).fill('{}').join(' ');
attributes['sentry.message.template'] = `${firstArg} ${template}`;
// Add each argument as a parameter
followingArgs.forEach((arg, index) => {
attributes[`sentry.message.parameter.${index}`] = arg;
});
return attributes;
}
export { createConsoleTemplateAttributes, formatConsoleArgs, hasConsoleSubstitutions, safeJoinConsoleArgs };
//# sourceMappingURL=utils.js.map