Skip to content

Apply Scope Attributes to Logs #5488

@antonis

Description

@antonis

The JS SDK 10.32.0 adds scope attributes to logs (see below) and we need to check if this should be synced to native.
****
feat(core): Apply scope attributes to logs (#18184)

You can now set attributes on the SDK's scopes which will be applied to all logs as long as the respective scopes are active. For the time being, only string, number and boolean attribute values are supported.

Sentry.geGlobalScope().setAttributes({ is_admin: true, auth_provider: 'google' });
Sentry.withScope(scope => {
  scope.setAttribute('step', 'authentication');
  // scope attributes `is_admin`, `auth_provider` and `step` are added
  Sentry.logger.info(`user ${user.id} logged in`, { activeSince: 100 });
  Sentry.logger.info(`updated ${user.id} last activity`);
});
// scope attributes `is_admin` and `auth_provider` are added
Sentry.logger.warn('stale website version, reloading page');

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions