Skip to content

Commit a27deca

Browse files
authored
feat: Make parameterize function available through browser and node API (#10085)
Move `parameterize` function to core, export it to upstream packages via browser and node.
1 parent 7e3207d commit a27deca

File tree

14 files changed

+13
-15
lines changed

14 files changed

+13
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { parameterize } from '@sentry/utils';
2-
31
const x = 'first';
42
const y = 'second';
53

6-
Sentry.captureMessage(parameterize`This is a log statement with ${x} and ${y} params`);
4+
Sentry.captureMessage(Sentry.parameterize`This is a log statement with ${x} and ${y} params`);

dev-packages/browser-integration-tests/suites/public-api/captureMessage/parameterized_message/test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ import { sentryTest } from '../../../../utils/fixtures';
55
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
66

77
sentryTest('should capture a parameterized representation of the message', async ({ getLocalTestPath, page }) => {
8-
const bundle = process.env.PW_BUNDLE;
9-
10-
if (bundle && bundle.startsWith('bundle_')) {
11-
sentryTest.skip();
12-
}
13-
148
const url = await getLocalTestPath({ testDir: __dirname });
159

1610
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as Sentry from '@sentry/node';
2-
import { parameterize } from '@sentry/utils';
32

43
Sentry.init({
54
dsn: 'https://[email protected]/1337',
@@ -9,4 +8,4 @@ Sentry.init({
98
const x = 'first';
109
const y = 'second';
1110

12-
Sentry.captureMessage(parameterize`This is a log statement with ${x} and ${y} params`);
11+
Sentry.captureMessage(Sentry.parameterize`This is a log statement with ${x} and ${y} params`);

packages/astro/src/index.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export {
7777
startSpanManual,
7878
continueTrace,
7979
cron,
80+
parameterize,
8081
} from '@sentry/node';
8182

8283
// We can still leave this for the carrier init and type exports

packages/browser/src/exports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export {
7272
metrics,
7373
functionToStringIntegration,
7474
inboundFiltersIntegration,
75+
parameterize,
7576
} from '@sentry/core';
7677

7778
export { WINDOW } from './helpers';

packages/bun/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export {
8383
inboundFiltersIntegration,
8484
linkedErrorsIntegration,
8585
requestDataIntegration,
86+
parameterize,
8687
} from '@sentry/core';
8788
export type { SpanStatusType } from '@sentry/core';
8889
export { autoDiscoverNodePerformanceMonitoringIntegrations, cron } from '@sentry/node';

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export { createCheckInEnvelope } from './checkin';
8080
export { hasTracingEnabled } from './utils/hasTracingEnabled';
8181
export { isSentryRequestUrl } from './utils/isSentryRequestUrl';
8282
export { handleCallbackErrors } from './utils/handleCallbackErrors';
83+
export { parameterize } from './utils/parameterize';
8384
export {
8485
spanToTraceHeader,
8586
spanToJSON,

packages/utils/src/parameterize.ts renamed to packages/core/src/utils/parameterize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { ParameterizedString } from '@sentry/types';
33
/**
44
* Tagged template function which returns paramaterized representation of the message
55
* For example: parameterize`This is a log statement with ${x} and ${y} params`, would return:
6-
* "__sentry_template_string__": "My raw message with interpreted strings like %s",
7-
* "__sentry_template_values__": ["this"]
6+
* "__sentry_template_string__": 'This is a log statement with %s and %s params',
7+
* "__sentry_template_values__": ['first', 'second']
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

packages/utils/test/parameterize.test.ts renamed to packages/core/test/lib/utils/parameterize.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ParameterizedString } from '@sentry/types';
22

3-
import { parameterize } from '../src/parameterize';
3+
import { parameterize } from '../../../src/utils/parameterize';
44

55
describe('parameterize()', () => {
66
test('works with empty string', () => {

packages/node/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export {
7979
startInactiveSpan,
8080
startSpanManual,
8181
continueTrace,
82+
parameterize,
8283
metrics,
8384
functionToStringIntegration,
8485
inboundFiltersIntegration,

packages/remix/src/index.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export {
6868
Integrations,
6969
Handlers,
7070
cron,
71+
parameterize,
7172
} from '@sentry/node';
7273

7374
// Keeping the `*` exports for backwards compatibility and types

packages/serverless/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@ export {
7676
startInactiveSpan,
7777
startSpanManual,
7878
continueTrace,
79+
parameterize,
7980
} from '@sentry/node';

packages/sveltekit/src/server/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export {
7474
startSpanManual,
7575
continueTrace,
7676
cron,
77+
parameterize,
7778
} from '@sentry/node';
7879

7980
// We can still leave this for the carrier init and type exports

packages/utils/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export * from './url';
3232
export * from './userIntegrations';
3333
export * from './cache';
3434
export * from './eventbuilder';
35-
export * from './parameterize';
3635
export * from './anr';
3736
export * from './lru';
3837
export * from './buildPolyfills';

0 commit comments

Comments
 (0)