1- import type { ParameterizedString } from '../types-hoist' ;
1+ import type { ParameterizedAnyValueString } from '../types-hoist' ;
22
33/**
44 * Tagged template function which returns parameterized representation of the message
@@ -8,9 +8,21 @@ import type { ParameterizedString } from '../types-hoist';
88 * @param strings An array of string values splitted between expressions
99 * @param values Expressions extracted from template string
1010 * @returns String with template information in __sentry_template_string__ and __sentry_template_values__ properties
11+ * @deprecated Use parameterizeAny instead
1112 */
12- export function parameterize ( strings : TemplateStringsArray , ...values : string [ ] ) : ParameterizedString {
13- const formatted = new String ( String . raw ( strings , ...values ) ) as ParameterizedString ;
13+ export const parameterize = parameterizeAny < string > ;
14+
15+ /**
16+ * Tagged template function which returns parameterized representation of the message
17+ * For example: parameterize`This is a log statement with ${x} and ${y} params`, would return:
18+ * "__sentry_template_string__": 'This is a log statement with %s and %s params',
19+ * "__sentry_template_values__": ['first', 'second']
20+ * @param strings An array of string values splitted between expressions
21+ * @param values Expressions extracted from template string, types provided by the generic.
22+ * @returns String with template information in __sentry_template_string__ and __sentry_template_values__ properties
23+ */
24+ export function parameterizeAny < T > ( strings : TemplateStringsArray , ...values : T [ ] ) : ParameterizedAnyValueString < T > {
25+ const formatted = new String ( String . raw ( strings , ...values ) ) as ParameterizedAnyValueString < T > ;
1426 formatted . __sentry_template_string__ = strings . join ( '\x00' ) . replace ( / % / g, '%%' ) . replace ( / \0 / g, '%s' ) ;
1527 formatted . __sentry_template_values__ = values ;
1628 return formatted ;
0 commit comments