Skip to content

Commit eb1852c

Browse files
committed
logging: Set undefined for server version tags if server version absent.
Instead of omitting them. We're about to start keeping these tags on the global scope, which means we have to listen to and propagate all changes in the server version, including changes where the server version disappears. It's been reported [1] that passing `undefined` as a tag's value in `setTags` will clear the tag from the current scope, and I've verified this experimentally. [1] getsentry/sentry-javascript#3108 (comment)
1 parent 83772f7 commit eb1852c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/utils/logging.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,29 @@ function withScope<R>(callback: Scope => R): R {
2222
return ((ret: $FlowFixMe): R);
2323
}
2424

25+
type ServerVersionTags = {|
26+
rawServerVersion: string | void,
27+
coarseServerVersion: string | void,
28+
fineServerVersion: string | void,
29+
|};
30+
2531
/**
2632
* Get server-version tags at various levels of granularity.
33+
*
34+
* If the server version isn't found in the logging context, all the
35+
* tags will be `undefined`.
2736
*/
28-
const getServerVersionTags = () => {
37+
const getServerVersionTags = (): ServerVersionTags => {
2938
const zulipVersion = getLoggingContext()?.serverVersion;
3039

3140
// Why might we not have the server version? If there's no active
3241
// account.
3342
if (!zulipVersion) {
34-
return {};
43+
return {
44+
rawServerVersion: undefined,
45+
coarseServerVersion: undefined,
46+
fineServerVersion: undefined,
47+
};
3548
}
3649

3750
const raw = zulipVersion.raw();

0 commit comments

Comments
 (0)