clearUserInfo() doesn't clear the cached user id, so baggage keeps the previous user's id
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, react-native, typescript
Direzione di ricerca
Inizia da packages/core/src/sdk/UserInfoSingleton/UserInfoSingleton.ts, dove clearUserInfo si limita a impostare this.userInfo su undefined, e dal metodo clearAccountInfo di AccountInfoProvider accanto ad esso. Il modulo rum/helper.ts esporta già clearCachedUserId e clearCachedAccountId, che non hanno chiamanti. È completato quando entrambi i metodi clear chiamano anche questi helper e un test che chiama setUserInfo e poi clearUserInfo, aspettandosi che getCachedUserId restituisca undefined, passa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 145
- Fork
- 65
- Merge medio
- 2g 16h
- PR unite (30g)
- 19
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di DataDog/dd-sdk-reactnative
-
[actionNameAttribute] prop doesn't accept value with curly bracesForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
DataDog/dd-sdk-reactnative#1486 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Expose Android app startup Activity filtering in the React Native SDKForse già presa @sbarrio l’ha presa 8 giorni fa. Apertaenhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
DataDog/dd-sdk-reactnative#1485 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
GraphQL variables with non-ASCII contents will make Apollo Client request throw errorForse già presa @cdn34dd l’ha presa 10 giorni fa. Apertaawaiting response bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
DataDog/dd-sdk-reactnative#1482 · 2 commenti · 1 reazione · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
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 callForse già presa @cdn34dd l’ha presa 8 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
DataDog/dd-sdk-reactnative#1377 · 1 commento · 1 reazione · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
Babel plugin emits untransformed JSX when a tracked component has .map() children, breaking the Hermes buildForse già presa @cdn34dd l’ha presa 8 giorni fa. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
DataDog/dd-sdk-reactnative#1353 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di DataDog/dd-sdk-reactnative
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Chocobozzz/PeerTube#7832 ·
I maintainer di solito rispondono entro 3 giorni
-
Pay to use?Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 66/100
darkreader/darkreader#16108 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Add: Dak Nong TV SDApertacheck:passed streams:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
bug engine
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
frostney/GocciaScript#1746 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
agilepathway/label-checker#739 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno