Skip to content
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

V7: Tweak enabledReleaseStages logic #689

Merged
merged 3 commits into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class Client {
}

// exit early if events should not be sent on the current releaseStage
if (this._config.enabledReleaseStages.length > 0 && !includes(this._config.enabledReleaseStages, this._config.releaseStage)) {
if (this._config.enabledReleaseStages !== null && !includes(this._config.enabledReleaseStages, this._config.releaseStage)) {
this._logger.warn('Event not sent due to releaseStage/enabledReleaseStages configuration')
return cb(null, event)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ module.exports.schema = {
validate: val => val === true || val === false
},
enabledReleaseStages: {
defaultValue: () => [],
defaultValue: () => null,
message: 'should be an array of strings',
validate: value => isArray(value) && filter(value, f => typeof f === 'string').length === value.length
validate: value => value === null || (isArray(value) && filter(value, f => typeof f === 'string').length === value.length)
},
releaseStage: {
defaultValue: () => 'production',
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-browser-session/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const sessionDelegate = {
sessionClient._pausedSession = null

// exit early if the current releaseStage is not enabled
if (sessionClient._config.enabledReleaseStages.length > 0 && !includes(sessionClient._config.enabledReleaseStages, sessionClient._config.releaseStage)) {
if (sessionClient._config.enabledReleaseStages !== null && !includes(sessionClient._config.enabledReleaseStages, sessionClient._config.releaseStage)) {
sessionClient._logger.warn('Session not sent due to releaseStage/enabledReleaseStages configuration')
return sessionClient
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-server-session/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = {

const sendSessionSummary = client => sessionCounts => {
// exit early if the current releaseStage is not enabled
if (client._config.enabledReleaseStages.length > 0 && !includes(client._config.enabledReleaseStages, client._config.releaseStage)) {
if (client._config.enabledReleaseStages !== null && !includes(client._config.enabledReleaseStages, client._config.releaseStage)) {
client._logger.warn('Session not sent due to releaseStage/enabledReleaseStages configuration')
return
}
Expand Down
22 changes: 22 additions & 0 deletions test/browser/features/fixtures/release_stage/script/e.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="/node_modules/@bugsnag/browser/dist/bugsnag.min.js"></script>
<script type="text/javascript">
var ENDPOINT = decodeURIComponent(window.location.search.match(/ENDPOINT=([^&]+)/)[1])
var API_KEY = decodeURIComponent(window.location.search.match(/API_KEY=([^&]+)/)[1])
var bugsnagClient = bugsnag({
apiKey: API_KEY,
endpoints: { notify: ENDPOINT, sessions: '/noop' },
enabledReleaseStages: null,
releaseStage: 'development'
})
</script>
</head>
<body>
<script>
bugsnagClient.notify(new Error('release stage does work'))
</script>
</body>
</html>
21 changes: 21 additions & 0 deletions test/browser/features/fixtures/release_stage/script/f.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="/node_modules/@bugsnag/browser/dist/bugsnag.min.js"></script>
<script type="text/javascript">
var ENDPOINT = decodeURIComponent(window.location.search.match(/ENDPOINT=([^&]+)/)[1])
var API_KEY = decodeURIComponent(window.location.search.match(/API_KEY=([^&]+)/)[1])
var bugsnagClient = bugsnag({
apiKey: API_KEY,
endpoints: { notify: ENDPOINT, sessions: '/noop' },
enabledReleaseStages: []
})
</script>
</head>
<body>
<script>
bugsnagClient.notify(new Error('release stage does work'))
</script>
</body>
</html>
11 changes: 11 additions & 0 deletions test/browser/features/release_stage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ Scenario: setting releaseStage=staging enabledReleaseStages=[production,staging]
Then I wait to receive a request
And the request is a valid browser payload for the error reporting API
And the event "app.releaseStage" equals "staging"

Scenario: setting releaseStage=development enabledReleaseStages=null
When I navigate to the URL "/release_stage/script/e.html"
Then I wait to receive a request
And the request is a valid browser payload for the error reporting API
And the event "app.releaseStage" equals "development"

Scenario: setting enabledReleaseStages=[]
When I navigate to the URL "/release_stage/script/f.html"
And I wait for 2 seconds
Then I should receive no requests