Skip to content

Commit

Permalink
Merge pull request #870 from bugsnag/release/v7.1.1
Browse files Browse the repository at this point in the history
Release v7.1.1
  • Loading branch information
bengourley committed May 26, 2020
2 parents 05dd390 + f3a2a7e commit 3a3ef6c
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 13 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog


## 7.1.1 (2020-05-26)

### Fixed

- (plugin-express): Use import syntax that works without TypeScript's `esModuleInterop` compiler flag [#866](https://github.com/bugsnag/bugsnag-js/pull/866)
- (expo-cli): Ensure version detection logic for @bugsnag/expo works after v7.0.0 [#865](https://github.com/bugsnag/bugsnag-js/pull/865)
- (core): Ensure callbacks supplied in config permit functions with no named arguments [#863](https://github.com/bugsnag/bugsnag-js/pull/863)


## 7.1.0 (2020-05-21)

This update contains some substantial changes to plugin type definitions. If you are using TypeScript alongside a framework, you may need to make changes to your app. Please refer to the [upgrade guide](./UPGRADING.md).
Expand Down
6 changes: 3 additions & 3 deletions packages/core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ class Client {
if (config.logger) this._logger = config.logger

// add callbacks
if (config.onError && config.onError.length) this._cbs.e = this._cbs.e.concat(config.onError)
if (config.onBreadcrumb && config.onBreadcrumb.length) this._cbs.b = this._cbs.b.concat(config.onBreadcrumb)
if (config.onSession && config.onSession.length) this._cbs.s = this._cbs.s.concat(config.onSession)
if (config.onError) this._cbs.e = this._cbs.e.concat(config.onError)
if (config.onBreadcrumb) this._cbs.b = this._cbs.b.concat(config.onBreadcrumb)
if (config.onSession) this._cbs.s = this._cbs.s.concat(config.onSession)

// finally warn about any invalid config where we fell back to the default
if (keys(errors).length) {
Expand Down
40 changes: 32 additions & 8 deletions packages/core/test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,36 @@ describe('@bugsnag/core/client', () => {
})
})
// eslint-disable-next-line jest/expect-expect
it('supports preventing send by returning false', done => {
it('supports preventing send by returning false in onError callback', done => {
const client = new Client({
apiKey: 'API_KEY_YEAH',
onError: () => false
})

client._setDelivery(client => ({
sendEvent: (payload) => {
done('sendEvent() should not be called')
},
sendSession: () => {}
}))

client.notify(new Error('oh em gee'))

// give the event loop a tick to see if the event gets sent
process.nextTick(() => done())
})
// eslint-disable-next-line jest/expect-expect
it('supports preventing send by returning false in notify callback', done => {
const client = new Client({ apiKey: 'API_KEY_YEAH' })

client._setDelivery(client => ({
sendEvent: (payload) => {
done('sendEvent() should not be called')
},
sendSession: () => {}
}))

client.notify(new Error('oh em gee'), event => false)
client.notify(new Error('oh em gee'), () => false)

// give the event loop a tick to see if the event gets sent
process.nextTick(() => done())
Expand Down Expand Up @@ -362,10 +382,12 @@ describe('@bugsnag/core/client', () => {

it('should call the callback even if the event doesn’t send (enabledReleaseStages)', done => {
const client = new Client({ apiKey: 'API_KEY', enabledReleaseStages: ['production'], releaseStage: 'development' })

client._setDelivery(client => ({
sendSession: () => {},
sendEvent: (payload, cb) => cb(null)
sendEvent: () => { done('sendEvent() should not be called') }
}))

// @ts-ignore
client.notify(new Error('111'), {}, (err, event) => {
expect(err).toBe(null)
Expand All @@ -377,10 +399,12 @@ describe('@bugsnag/core/client', () => {

it('should call the callback even if the event doesn’t send (onError)', done => {
const client = new Client({ apiKey: 'API_KEY', onError: () => false })

client._setDelivery(client => ({
sendSession: () => {},
sendEvent: (payload, cb) => cb(null)
sendEvent: () => { done('sendEvent() should not be called') }
}))

// @ts-ignore
client.notify(new Error('111'), {}, (err, event) => {
expect(err).toBe(null)
Expand Down Expand Up @@ -462,7 +486,7 @@ describe('@bugsnag/core/client', () => {
let calls = 0
const client = new Client({
apiKey: 'API_KEY_YEAH',
onBreadcrumb: b => {
onBreadcrumb: () => {
calls++
return false
}
Expand All @@ -476,7 +500,7 @@ describe('@bugsnag/core/client', () => {
let calls = 0
const client = new Client({
apiKey: 'API_KEY_YEAH',
onBreadcrumb: b => {
onBreadcrumb: () => {
calls++
throw new Error('uh oh')
}
Expand Down Expand Up @@ -560,7 +584,7 @@ describe('@bugsnag/core/client', () => {
})

it('does not start the session if onSession returns false', () => {
const client = new Client({ apiKey: 'API_KEY', onSession: s => false })
const client = new Client({ apiKey: 'API_KEY', onSession: () => false })
const sessionDelegate = {
startSession: () => {},
pauseSession: () => {},
Expand All @@ -577,7 +601,7 @@ describe('@bugsnag/core/client', () => {
it('tolerates errors in onSession callbacks', () => {
const client = new Client({
apiKey: 'API_KEY',
onSession: s => {
onSession: () => {
throw new Error('oh no')
}
})
Expand Down
2 changes: 1 addition & 1 deletion packages/expo-cli/lib/insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Bugsnag.start();

const getCode = async (projectRoot) => {
const manifestRange = await detectInstalled(projectRoot)
const isPostV7 = !manifestRange || semver.satisfies('7.0.0', manifestRange)
const isPostV7 = !manifestRange || semver.ltr('6.99.99', manifestRange)
return code[isPostV7 ? 'postV7' : 'preV7']
}

Expand Down
21 changes: 21 additions & 0 deletions packages/expo-cli/lib/test/fixtures/already-installed-01/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const React = require('react')
const { StyleSheet, Text, View } = require('react-native')

export default class App extends React.Component {
render () {
return (
<View style={styles.container}>
<Text>Hello Expo!</Text>
</View>
)
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center'
}
})
39 changes: 39 additions & 0 deletions packages/expo-cli/lib/test/fixtures/already-installed-01/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"expo": {
"name": "Bugsnag test fixture",
"slug": "bugsnag-test-fixture",
"privacy": "unlisted",
"sdkVersion": "32.0.0",
"platforms": [
"ios",
"android"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"extra": {
"bugsnag": {
"apiKey": "XoXoXoXoXoXo"
}
},
"hooks": {
"postPublish": [
{
"file": "@bugsnag/expo/hooks/post-publish.js",
"config": {}
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "bugsnag-test-fixture-05",
"private": "true",
"version": "0.0.0",
"dependencies": {
"@bugsnag/expo": "^7.0.1"
}
}
8 changes: 8 additions & 0 deletions packages/expo-cli/lib/test/insert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ describe('expo-cli: insert', () => {
const appJs = await promisify(readFile)(`${projectRoot}/App.js`, 'utf8')
expect(appJs).toMatch(/^import bugsnag from '@bugsnag\/expo';\sconst bugsnagClient = bugsnag\(\);\s/)
})

it('inserts correct code for post v7.0.0 versions of Bugsnag', async () => {
const projectRoot = await prepareFixture('already-installed-01')
const msg = await insert(projectRoot)
expect(msg).toBe(undefined)
const appJs = await promisify(readFile)(`${projectRoot}/App.js`, 'utf8')
expect(appJs).toMatch(/^import Bugsnag from '@bugsnag\/expo';\sBugsnag\.start\(\);\s/)
})
})
2 changes: 1 addition & 1 deletion packages/plugin-express/types/bugsnag-express.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Plugin, Client } from '@bugsnag/core'
import express from 'express'
import * as express from 'express'

declare const bugsnagPluginExpress: Plugin
export default bugsnagPluginExpress
Expand Down

0 comments on commit 3a3ef6c

Please sign in to comment.