Skip to content

feat(core): Add experimental scopeValuesAppliedToLogs option #16020

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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

AbhiPrasad
Copy link
Member

We've gotten some requests for being able to get user info (from the scope) onto logs. See: https://linear.app/getsentry/issue/LOGS-21

To experiment with how this feels, we're going to try adding a new option/api to the JS SDK, scopeValuesAppliedToLogs. This right now only works for user and tags, but we might open it up for more contexts in the future.

In browser JS browser/os/device and request are all parsed from relay, so there's no SDK changes to be made here.

Usage:

Sentry.init({
  _experiments: {
    enableLogs: true,
    scopeValuesAppliedToLogs: ['user', 'tags'],
  },
});

Sentry.setTag("service", "omega_star");
Sentry.setTag("is_iso_compliant", "false");

Sentry.setUser({ id: "very_cool_developer" });

// gets attached:
// `sentry.tag.service="omega_star"`
// `sentry.tag.is_iso_compliant="false"`
// `sentry.user.id="very_cool_developer"`
Sentry.logger.info("test");

resolves https://linear.app/getsentry/issue/JSC-294

@AbhiPrasad AbhiPrasad requested a review from a team April 9, 2025 14:59
@AbhiPrasad AbhiPrasad self-assigned this Apr 9, 2025
@AbhiPrasad AbhiPrasad requested review from mydea and s1gr1d and removed request for a team April 9, 2025 14:59
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.

1 participant