-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(replay): Add flush
method to integration
#6776
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,6 +185,17 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`, | |
this._replay.stop(); | ||
} | ||
|
||
/** | ||
* Immediately send all pending events. | ||
*/ | ||
public flush(): Promise<void> | void { | ||
if (!this._replay || !this._replay.isEnabled()) { | ||
return; | ||
} | ||
|
||
return this._replay.flushImmediate(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it better to only allow users to use debounced flush to reduce risk of being flooded with flushes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this would kind of defeat the purpose (a bit) of this - as e.g. if a user clicks a button, we trigger debounced flush, the user closes the window --> we may not have sent the stuff yet. IMHO it's OK to put this burden on the SDK users - it's up to them to only use this sparingly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm good with that |
||
} | ||
|
||
/** Setup the integration. */ | ||
private _setup(): void { | ||
// Client is not available in constructor, so we need to wait until setupOnce | ||
|
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.
l: Just wondering if we should check for
isPaused()
here as well... technically, recording could be paused b/c of rate limiting and we wouldn't want to flush in this case. But overall, I think chances are pretty low that this would actually happen. And even if it does, the consequences wouldn't be bad, as we're already handling rate limit responses while being rate-limited. WDYT?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.
Yeah, I thought the same. I'd say it is OK, as (theoretically) when paused the event buffer has to be empty always, so it wouldn't even attempt to send anything. I'd say it is OK to leave it like this?
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.
Not necessarily, pause just stops DOM recording, we could have events from
window.performance
, but in that case, might be ok to try to flush.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.
hmm yeah, true, I'd say that is not incorrect to flush the stuff that has not been sent yet due to being paused?