sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Add getTags to Scope

Open simenbrekken-visma opened this issue 3 years ago • 1 comments

Problem Statement

This code example pretty much sums up the problem:

function getTags(hub: Hub): Record<string, number | string | undefined> {
    // @ts-expect-error No other way of accessing protected property _tags
    return hub.getScope()?._tags || {};
}

In our large SPA tags are added and removed pretty often and we'd like to use them in integrations.

Solution Brainstorm

type Tags = { [key: string]: Primitive };

export interface Hub {
  getTags(): Tags;
}

simenbrekken-visma avatar Sep 21 '22 06:09 simenbrekken-visma

Thanks for reaching out! Backlogging for now, since I think we need to make sure we are comfortable with the extra API surface this will introduce.

AbhiPrasad avatar Sep 21 '22 11:09 AbhiPrasad