Content-Length: 299249 | pFad | http://github.com/getsentry/sentry-javascript/pull/15812

75 feat(core): Add support for parameterizing logs by AbhiPrasad · Pull Request #15812 · getsentry/sentry-javascript · GitHub
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(core): Add support for parameterizing logs #15812

Merged
merged 2 commits into from
Mar 25, 2025

Conversation

AbhiPrasad
Copy link
Member

ref #15526

This adds support for parameterizing logs via the existing ParameterizedString type and parameterize function exported from the SDK. This works for all usages of the logger, so browser and Node.js.

Usage:

Sentry.logger.info(Sentry.logger.fmt`User ${user} updated profile picture`, {
  userId: 'user-123',
  imageSize: '2.5MB',
  timestamp: Date.now()
});

fmt is an alias to Sentry.parameterize that is exported from the logger namespace.

To support this change, I changed the typing of ParameterizedString to accept unknown[] for __sentry_template_values__. This is broadening the type, so should not be a breaking change. logentry.params should accept all kinds of values, relay handles formatting them correctly.

@AbhiPrasad AbhiPrasad requested a review from a team March 24, 2025 18:08
@AbhiPrasad AbhiPrasad self-assigned this Mar 24, 2025
@AbhiPrasad AbhiPrasad requested review from stephanie-anderson, andreiborza, Lms24 and chargome and removed request for a team March 24, 2025 18:08
@AbhiPrasad AbhiPrasad mentioned this pull request Mar 24, 2025
7 tasks
*/
export function parameterize(strings: TemplateStringsArray, ...values: string[]): ParameterizedString {
export function parameterize(strings: TemplateStringsArray, ...values: unknown[]): ParameterizedString {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we deprecate this then or do we just keep both?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna actually remove the fmt alias globally in favour of just leaving it in the logger namespace. We can revaluate this later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually nvm I thought about it again, and let's keep it because it makes the re-export super easy.

We can keep both, and evaluate deprecating parameterize at a later time.

@AbhiPrasad AbhiPrasad merged commit d650218 into develop Mar 25, 2025
151 of 152 checks passed
@AbhiPrasad AbhiPrasad deleted the abhi-parameterize-logs branch March 25, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/getsentry/sentry-javascript/pull/15812

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy