Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(utils): Make parameterize function available through browser and node API #10085

Merged
merged 11 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { parameterize } from '@sentry/utils';

const x = 'first';
const y = 'second';

Sentry.captureMessage(parameterize`This is a log statement with ${x} and ${y} params`);
Sentry.captureMessage(Sentry.parameterize`This is a log statement with ${x} and ${y} params`);
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should capture a parameterized representation of the message', async ({ getLocalTestPath, page }) => {
const bundle = process.env.PW_BUNDLE;

if (bundle && bundle.startsWith('bundle_')) {
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as Sentry from '@sentry/node';
import { parameterize } from '@sentry/utils';

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

Sentry.captureMessage(parameterize`This is a log statement with ${x} and ${y} params`);
Sentry.captureMessage(Sentry.parameterize`This is a log statement with ${x} and ${y} params`);
1 change: 1 addition & 0 deletions packages/astro/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export {
startSpanManual,
continueTrace,
cron,
parameterize,
} from '@sentry/node';

// We can still leave this for the carrier init and type exports
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export {
metrics,
functionToStringIntegration,
inboundFiltersIntegration,
parameterize,
} from '@sentry/core';

export { WINDOW } from './helpers';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export { createCheckInEnvelope } from './checkin';
export { hasTracingEnabled } from './utils/hasTracingEnabled';
export { isSentryRequestUrl } from './utils/isSentryRequestUrl';
export { handleCallbackErrors } from './utils/handleCallbackErrors';
export { parameterize } from './utils/parameterize';
export {
spanToTraceHeader,
spanToJSON,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { ParameterizedString } from '@sentry/types';
/**
* Tagged template function which returns paramaterized representation of the message
* For example: parameterize`This is a log statement with ${x} and ${y} params`, would return:
* "__sentry_template_string__": "My raw message with interpreted strings like %s",
* "__sentry_template_values__": ["this"]
* "__sentry_template_string__": 'This is a log statement with %s and %s params',
* "__sentry_template_values__": ['first', 'second']
* @param strings An array of string values splitted between expressions
* @param values Expressions extracted from template string
* @returns String with template information in __sentry_template_string__ and __sentry_template_values__ properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ParameterizedString } from '@sentry/types';

import { parameterize } from '../src/parameterize';
import { parameterize } from '../../../src/utils/parameterize';

describe('parameterize()', () => {
test('works with empty string', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export {
startInactiveSpan,
startSpanManual,
continueTrace,
parameterize,
metrics,
functionToStringIntegration,
inboundFiltersIntegration,
Expand Down
1 change: 1 addition & 0 deletions packages/remix/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export {
Integrations,
Handlers,
cron,
parameterize,
} from '@sentry/node';

// Keeping the `*` exports for backwards compatibility and types
Expand Down
1 change: 1 addition & 0 deletions packages/serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ export {
startInactiveSpan,
startSpanManual,
continueTrace,
parameterize,
} from '@sentry/node';
1 change: 1 addition & 0 deletions packages/sveltekit/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export {
startSpanManual,
continueTrace,
cron,
parameterize,
} from '@sentry/node';

// We can still leave this for the carrier init and type exports
Expand Down
1 change: 0 additions & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export * from './url';
export * from './userIntegrations';
export * from './cache';
export * from './eventbuilder';
export * from './parameterize';
export * from './anr';
export * from './lru';
export * from './buildPolyfills';
Loading