clearUserInfo() doesn't clear the cached user id, so baggage keeps the previous user's id
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, react-native, typescript
调研方向
从 packages/core/src/sdk/UserInfoSingleton/UserInfoSingleton.ts 开始,其中 clearUserInfo 只把 this.userInfo 设为 undefined,同时查看旁边 AccountInfoProvider 的 clearAccountInfo 方法。rum/helper.ts 模块已经导出了 clearCachedUserId 和 clearCachedAccountId,但它们没有任何调用方。完成的标准是:两个 clear 方法都调用这些 helper,并且一个先调用 setUserInfo 再调用 clearUserInfo、期望 getCachedUserId 返回 undefined 的测试能够通过。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
DdSdkReactNative.clearUserInfo() doesn't clear the cached user id that resource tracking uses for the baggage header, so after a logout the app keeps sending the previous user's id in baggage on first-party requests.
UserInfoProvider.setUserInfo calls setCachedUserId(userInfo.id) (added in df2b8e68, "Cache userId and accountId when first set"), and RequestContext reads getCachedUserId() to build baggage: user.id=…. But UserInfoProvider.clearUserInfo only resets this.userInfo:
// packages/core/src/sdk/UserInfoSingleton/UserInfoSingleton.ts
clearUserInfo = () => {
this.userInfo = undefined;
};
clearCachedUserId() exists in rum/helper.ts but has no callers. AccountInfoProvider.clearAccountInfo has the same gap with clearCachedAccountId().
The effect is that every traced request after clearUserInfo() (signed-out requests, and the next user's first requests before setUserInfo runs again) carries the previous user's id in baggage. Backends that tag or propagate baggage (e.g. dd-trace's default DD_TRACE_BAGGAGE_TAG_KEYS) then attribute those requests to the wrong user, and may forward the id downstream.
Reproduction steps
- Initialize the SDK with
firstPartyHostsfor a host you control and resource tracking enabled. await DdSdkReactNative.setUserInfo({ id: 'user-a' }), then make a request to that host.baggagecontainsuser.id=user-a(expected).await DdSdkReactNative.clearUserInfo(), then make another request to that host.baggagestill containsuser.id=user-a.
Minimal check without a network request:
UserInfoSingleton.getInstance().setUserInfo({ id: 'user-a' });
UserInfoSingleton.getInstance().clearUserInfo();
getCachedUserId(); // 'user-a', expected undefined
Expected behavior
After clearUserInfo(), baggage omits user.id (the header builder already skips it when the cached id is undefined). Same for account.id after clearAccountInfo().
Suggested fix:
-import { setCachedUserId } from '../../rum/helper';
+import { clearCachedUserId, setCachedUserId } from '../../rum/helper';
...
clearUserInfo = () => {
this.userInfo = undefined;
+ clearCachedUserId();
};
and the equivalent clearCachedAccountId() call in AccountInfoProvider.clearAccountInfo. We're carrying this as a patch-package patch on 3.8.0 for now.
Affected SDK versions
3.0.0 through 3.10.0 (still present on develop)
Latest working SDK version
2.x (no cached user id)
Did you confirm if the latest SDK version fixes the bug?
Yes, checked develop / 3.10.0 and it's still present.
Integration Methods
NPM
React Native Version
0.86.3 (Expo SDK 57)
Other relevant information
Both iOS and Android are affected, since the header is built in the JS request proxy.
- 主要语言
- TypeScript
- 星标
- 145
- 派生
- 65
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 19
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DataDog/dd-sdk-reactnative 的其他 Issue
-
bug
难度 3/5 1-2 天 新手友好度 62/100
DataDog/dd-sdk-reactnative#1486 · 3 条评论 ·
维护者通常 2 天内回复
-
Expose Android app startup Activity filtering in the React Native SDK可能已有人在做 @sbarrio 于 7 天前认领。 未关闭enhancement
难度 4/5 3-5 天 新手友好度 35/100
DataDog/dd-sdk-reactnative#1485 · 1 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
GraphQL variables with non-ASCII contents will make Apollo Client request throw error可能已有人在做 @cdn34dd 于 9 天前认领。 未关闭awaiting response bug
难度 4/5 3-5 天 新手友好度 42/100
DataDog/dd-sdk-reactnative#1482 · 2 条评论 · 1 个 reaction · 已指派 1 人 ·
维护者通常 2 天内回复
-
Interaction tracking records nothing: the babel plugin's injected import makes Metro bundle a second copy of the SDK, so DdBabelInteractionTracking.config is set on a different class than instrumented handlers call可能已有人在做 @cdn34dd 于 7 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
DataDog/dd-sdk-reactnative#1377 · 1 条评论 · 1 个 reaction · 已指派 1 人 ·
维护者通常 2 天内回复
-
Babel plugin emits untransformed JSX when a tracked component has .map() children, breaking the Hermes build可能已有人在做 @cdn34dd 于 7 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 76/100
DataDog/dd-sdk-reactnative#1353 · 1 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
查看 DataDog/dd-sdk-reactnative 的全部 Issue
相似的 Issue
-
bnv-manager-v2: accept_invite creates the Mailcow domain admin before the commit可能已有人在做 @myOmikron 今天认领。 未关闭bug ready-for-agent
难度 2/5 1-3 小时 新手友好度 82/100
-
platform:windows tool triaged wontfix
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
nicolettas-muggelbude/RechnungsFee#448 ·
维护者通常 1 天内回复
-
Android bug feature/error-tracking react-native team/error-tracking
难度 2/5 1-3 小时 新手友好度 72/100
PostHog/posthog-js#5310 · 1 条评论 ·
维护者通常 1 天内回复