Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

Add stopSession() and resumeSession() to public API #314

Merged
merged 9 commits into from
Mar 5, 2019

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Mar 1, 2019

Goal

Adds the ability to stop and resume sessions. This prevents the handled/unhandled error count from incrementing when a session is in the stopped state, which may be desirable if a user manually tracks sessions and does not want crashes that occurred in the background to count towards their stability score.

Note: the first two commits of this changeset updates vendored code which has already passed review. It may be easier to review these changes in isolation by viewing this diff.

For reference, the PRs which add this functionality for Android/Cocoa can be found here:

bugsnag/bugsnag-android#429
bugsnag/bugsnag-cocoa#325

Changeset

  • Updated bugsnag-android from 4.11.0 to 4.12.0
  • Updated bugsnag-cocoa from 5.17.3 to 5.19.0
  • Added stopSession() and resumeSession() to the JS API, which forward the call onto the NativeClient
  • Updated TypeScript definition to include new methods
  • Added inline code documentation for JS API
  • Added stopSession() and resumeSession() implementations in the Android + Cocoa native package. These are invoked asychronously across the React Native bridge by the JS methods, and in turn invoke the appropriate method in bugsnag-android/bugsnag-cocoa
  • Update autoCapture behaviour to call resumeSession rather than startSession (rationale described further in design doc)

Tests

I performed the following manual tests on the 'plain' example project on Android/iOS release builds (see contributing guide for instructions), by inspecting the payload sent to netcat:

  • Handled error with started session has session info
  • Handled error with stopped session has no session info
  • Resuming session resumes the session
  • Unhandled error with started session has session info
  • Unhandled error with stopped session has no session info

Note: Mazerunner scenarios will be added in a separate PR, once implementation of this functionality on bugsnag-unity is complete.

src/Bugsnag.js Outdated Show resolved Hide resolved
src/Bugsnag.js Show resolved Hide resolved
@fractalwrench
Copy link
Contributor Author

Thanks for the review - I have update the inline code docs to clarify when an error counts towards the stability score.

Copy link
Contributor

@bengourley bengourley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually tested and it works as expected 👍

The only thing I would change is adding the session methods to the TypeScript app test/app.ts that is used to assert the types are correct. I already tried this out on my working copy and the tests pass but it would be helpful to catch any regressions:

 client.notify(new Error('flop'))
 client.setUser('123', 'B. Nag', 'bugs.nag@bugsnag.com')
 client.setUser(undefined, undefined, undefined)
 client.setUser()
+client.stopSession()
+client.startSession()
+client.resumeSession()

@fractalwrench fractalwrench merged commit d7c3bc7 into next Mar 5, 2019
@fractalwrench fractalwrench deleted the stop-sessions branch March 5, 2019 11:20
Jekiwijaya pushed a commit to Jekiwijaya/bugsnag-react-native that referenced this pull request Mar 11, 2019
Restore mach handler to full functionality. There was a 
missing import which led to an undefined `define` which
was required, causing fallback to the signal handler in
situations where more debugging information was available.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants