Skip to content

Commit 5b95e98

Browse files
authored
Fix infinite loop on session creation (signalfx#72)
1 parent 9b47d4b commit 5b95e98

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

example/__tests__/e2e/specs/http.e2e.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@ describe('Http request', () => {
4242
expect(fetchSpan.tags['http.url']).toBe(
4343
'https://raw.githubusercontent.com/signalfx/splunk-otel-react-native/main/package.json'
4444
);
45+
expect(fetchSpan.tags['splunk.rumSessionId']).toBeDefined();
4546
});
4647
});

example/__tests__/e2e/specs/navigation.e2e.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ describe('Navigation', () => {
4949
expect(createSpan.tags['screen.name']).toBe('Details');
5050
expect(createSpan.tags['app']).toBe('RnExample');
5151
expect(createSpan.tags['device.model.name']).toBeDefined();
52+
expect(createSpan.tags['splunk.rumSessionId']).toBeDefined();
5253
});
5354
});

src/session.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ AppState.addEventListener('change', (nextAppState) => {
6060

6161
export function getSessionId() {
6262
if (hasExpired() || hasTimedOut()) {
63+
bump();
6364
newSessionId();
65+
} else {
66+
bump();
6467
}
65-
bump();
6668
return session.id;
6769
}
6870

0 commit comments

Comments
 (0)