-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(release-health): Prevent sending terminal status session updates #3701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1534e1e
fix(release-health): Prevent sending terminal status session updates
ahmedetefy bc0fd0c
Added test that ensures terminal state sessions are sent only once
ahmedetefy 7b69467
Update user data on session only if it is not set before
ahmedetefy 9840b69
Adds changes that doesn't send updates once a session is errored
ahmedetefy 1c3d0e4
Fixing PR comments
ahmedetefy a2b6f28
Fixed failing test that overwrites user ip address in session once it…
ahmedetefy 838567c
Refactored tests
ahmedetefy ca87b1f
Removed update of user attrs on session + send only session update fo…
ahmedetefy 88d9634
Fixed type
ahmedetefy 74c7bc7
Merge branch 'master' into ahmed-prevent-send-terminal-updates
ahmedetefy 861e778
Merge branch 'master' into ahmed-prevent-send-terminal-updates
ahmedetefy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/node/test/manual/release-health/single-session/errors-in-session-capped-to-one.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const Sentry = require('../../../../dist'); | ||
const { | ||
assertSessions, | ||
constructStrippedSessionObject, | ||
BaseDummyTransport, | ||
validateSessionCountFunction, | ||
} = require('../test-utils'); | ||
|
||
const sessionCounts = { | ||
sessionCounter: 0, | ||
expectedSessions: 2, | ||
}; | ||
|
||
validateSessionCountFunction(sessionCounts); | ||
|
||
class DummyTransport extends BaseDummyTransport { | ||
sendSession(session) { | ||
sessionCounts.sessionCounter++; | ||
if (sessionCounts.sessionCounter === 1) { | ||
assertSessions(constructStrippedSessionObject(session), { | ||
init: true, | ||
status: 'ok', | ||
errors: 1, | ||
release: '1.1', | ||
}); | ||
} else if (sessionCounts.sessionCounter === 2) { | ||
assertSessions(constructStrippedSessionObject(session), { | ||
init: false, | ||
status: 'exited', | ||
errors: 1, | ||
release: '1.1', | ||
}); | ||
} | ||
return super.sendSession(session); | ||
} | ||
} | ||
|
||
Sentry.init({ | ||
dsn: 'http://[email protected]/1337', | ||
release: '1.1', | ||
transport: DummyTransport, | ||
autoSessionTracking: true, | ||
}); | ||
/** | ||
* The following code snippet will throw multiple errors, and thereby send session updates everytime an error is | ||
* captured. However, the number of errors in the session should be capped at 1, regardless of how many errors there are | ||
*/ | ||
for (let i = 0; i < 2; i++) { | ||
Sentry.captureException(new Error('hello world')); | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/node/test/manual/release-health/single-session/terminal-state-sessions-sent-once.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const Sentry = require('../../../../dist'); | ||
const { | ||
assertSessions, | ||
constructStrippedSessionObject, | ||
BaseDummyTransport, | ||
validateSessionCountFunction, | ||
} = require('../test-utils'); | ||
|
||
const sessionCounts = { | ||
sessionCounter: 0, | ||
expectedSessions: 1, | ||
}; | ||
|
||
validateSessionCountFunction(sessionCounts); | ||
|
||
class DummyTransport extends BaseDummyTransport { | ||
sendSession(session) { | ||
sessionCounts.sessionCounter++; | ||
|
||
if (sessionCounts.sessionCounter === 1) { | ||
assertSessions(constructStrippedSessionObject(session), { | ||
init: true, | ||
status: 'crashed', | ||
errors: 1, | ||
release: '1.1', | ||
}); | ||
} | ||
return super.sendSession(session); | ||
} | ||
} | ||
|
||
Sentry.init({ | ||
dsn: 'http://[email protected]/1337', | ||
release: '1.1', | ||
transport: DummyTransport, | ||
autoSessionTracking: true, | ||
}); | ||
|
||
/** | ||
* The following code snippet will throw an exception of `mechanism.handled` equal to `false`, and so this session | ||
* is treated as a Crashed Session. | ||
* However we want to ensure that once a crashed terminal state is achieved, no more session updates are sent regardless | ||
* of whether more crashes happen or not | ||
*/ | ||
new Promise(function(resolve, reject) { | ||
reject(); | ||
}).then(function() { | ||
console.log('Promise Resolved'); | ||
}); | ||
|
||
new Promise(function(resolve, reject) { | ||
reject(); | ||
}).then(function() { | ||
console.log('Promise Resolved'); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't work, because this way you are only passing the initial values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. References 🙄