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

Commit 4dd7851

Browse files
Merge pull request #317 from bugsnag/stop-sessions-mazerunner
Add mazerunner scenarios for stopping and resuming sessions
2 parents d7c3bc7 + b9923e8 commit 4dd7851

5 files changed

Lines changed: 66 additions & 2 deletions

File tree

features/fixtures/sampler/App.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, {Component} from 'react'
22
import {StyleSheet, Text, View} from 'react-native'
3+
import bugsnag from './index.js';
34

45
function longStackB(index) {
56
if (index < 1200) {
@@ -14,6 +15,21 @@ function longStackA(index) {
1415
throw new TypeError('Forever and a day')
1516
}
1617

18+
function stoppedSession() {
19+
bugsnag.startSession()
20+
bugsnag.stopSession()
21+
bugsnag.notify(new Error("Stopped session error"))
22+
}
23+
24+
function resumedSession() {
25+
bugsnag.startSession()
26+
bugsnag.notify(new Error("First error"))
27+
bugsnag.stopSession()
28+
bugsnag.notify(new Error("Second error"))
29+
bugsnag.resumeSession()
30+
bugsnag.notify(new Error("Third error"))
31+
}
32+
1733
type Props = {};
1834
export default class App extends Component<Props> {
1935
render () {
@@ -25,6 +41,12 @@ export default class App extends Component<Props> {
2541
case 'unhandledRejection':
2642
Promise.reject(new SyntaxError('no'))
2743
break
44+
case 'StoppedSessionScenario':
45+
stoppedSession();
46+
break;
47+
case 'ResumedSessionScenario':
48+
resumedSession();
49+
break;
2850
}
2951
}, 10)
3052
return (

features/fixtures/sampler/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const config = new Configuration('my API key!')
66
var endpoint = Platform.OS === 'ios' ? 'http://localhost:9339' : 'http://10.0.2.2:9339'
77
config.delivery = new StandardDelivery(endpoint, endpoint)
88
config.autoCaptureSessions = false
9-
const _bugsnag = new Client(config)
9+
const bugsnag = new Client(config)
10+
11+
export default bugsnag;
1012

1113
import {AppRegistry} from 'react-native'
1214
import App from './App'

features/session_stopping.feature

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Feature: Stopping and resuming sessions
2+
3+
Scenario Outline: When a session is stopped the error has no session information
4+
When I launch an <platform> app with "StoppedSessionScenario"
5+
Then I should receive 2 requests
6+
And the request 0 is valid for the session tracking API
7+
And the request 1 is valid for the error reporting API
8+
And the payload field "events.0.session" is null for request 1
9+
10+
Examples:
11+
| platform |
12+
| Android |
13+
| iOS |
14+
15+
Scenario Outline: When a session is resumed on Android the error uses the previous session
16+
When I launch an Android app with "ResumedSessionScenario"
17+
Then I should receive 4 requests
18+
And the request 0 is valid for the session tracking API
19+
And the request 1 is valid for the error reporting API
20+
And the request 2 is valid for the error reporting API
21+
And the request 3 is valid for the error reporting API
22+
And the payload field "events.0.session.events.handled" equals 1 for request 1
23+
And the payload field "events.0.session" is null for request 2
24+
And the payload field "events.0.session.events.handled" equals 2 for request 3
25+
And the payload field "events.0.session.events.unhandled" equals 0 for request 3
26+
And the payload field "events.0.session.id" of request 1 equals the payload field "events.0.session.id" of request 3
27+
28+
Scenario Outline: When a session is resumed on iOS the error uses the previous session
29+
When I launch an iOS app with "ResumedSessionScenario"
30+
Then I should receive 2 requests
31+
And the request 0 is valid for the session tracking API
32+
And the request 1 is valid for the error reporting API
33+
And the payload field "events.0.session.events.handled" equals 1 for request 1
34+
And the payload field "events.1.session" is null for request 1
35+
And the payload field "events.2.session.events.handled" equals 2 for request 1
36+
And the payload field "events.2.session.events.unhandled" equals 0 for request 1
37+
And the payload field "events.0.session.id" of request 1 equals the payload field "events.2.session.id" of request 1

features/steps/app_steps.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ def launch_crashy_app(os, event)
99
run_required_commands([["features/scripts/launch_#{os}_app_crash.sh"]])
1010
end
1111

12+
When(/^I launch an (\w+) app with "(\w+)"$/) do |os, event_type|
13+
launch_crashy_app(os.downcase, event_type)
14+
end
1215
When(/^I launch an (\w+) app which has an uncaught exception$/) do |os|
1316
launch_crashy_app(os.downcase, "uncaughtException")
1417
end

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)