From 9e10449d42daac28f5c75cd34fa4e67a5138c03c Mon Sep 17 00:00:00 2001 From: Ben Gourley Date: Tue, 7 Jan 2020 10:41:30 +0000 Subject: [PATCH 1/4] refactor(expo-cli): Insert code that matches the updated static interface --- packages/expo-cli/lib/insert.js | 4 ++-- .../expo-cli/lib/test/fixtures/already-configured-00/App.js | 4 ++-- .../expo-cli/lib/test/fixtures/already-configured-01/App.js | 4 ++-- packages/expo-cli/lib/test/insert.test.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/expo-cli/lib/insert.js b/packages/expo-cli/lib/insert.js index 60c44f6e95..3eb72b393e 100644 --- a/packages/expo-cli/lib/insert.js +++ b/packages/expo-cli/lib/insert.js @@ -23,6 +23,6 @@ module.exports = async (projectRoot) => { } module.exports.code = -`import bugsnag from '@bugsnag/expo'; -const bugsnagClient = bugsnag(); +`import Bugsnag from '@bugsnag/expo'; +Bugsnag.init(); ` diff --git a/packages/expo-cli/lib/test/fixtures/already-configured-00/App.js b/packages/expo-cli/lib/test/fixtures/already-configured-00/App.js index a514bb00e1..9572d41d29 100644 --- a/packages/expo-cli/lib/test/fixtures/already-configured-00/App.js +++ b/packages/expo-cli/lib/test/fixtures/already-configured-00/App.js @@ -1,8 +1,8 @@ -import bugsnag from '@bugsnag/expo' +import Bugsnag from '@bugsnag/expo' import React from 'react' import { StyleSheet, Text, View } from 'react-native' -const bugsnagClient = bugsnag() +Bugsnag.init() export default class App extends React.Component { render () { diff --git a/packages/expo-cli/lib/test/fixtures/already-configured-01/App.js b/packages/expo-cli/lib/test/fixtures/already-configured-01/App.js index f02e245f67..102b179e54 100644 --- a/packages/expo-cli/lib/test/fixtures/already-configured-01/App.js +++ b/packages/expo-cli/lib/test/fixtures/already-configured-01/App.js @@ -1,8 +1,8 @@ -const bugsnag = require('@bugsnag/expo') +const Bugsnag = require('@bugsnag/expo') const React = require('react') const { StyleSheet, Text, View } = require('react-native') -const bugsnagClient = bugsnag() +Bugsnag.init() export default class App extends React.Component { render () { diff --git a/packages/expo-cli/lib/test/insert.test.js b/packages/expo-cli/lib/test/insert.test.js index f6e26d4946..bb6e4e38a7 100644 --- a/packages/expo-cli/lib/test/insert.test.js +++ b/packages/expo-cli/lib/test/insert.test.js @@ -11,7 +11,7 @@ describe('expo-cli: insert', () => { 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';\sconst bugsnagClient = bugsnag\(\);\s/) + expect(appJs).toMatch(/^import Bugsnag from '@bugsnag\/expo';\sBugsnag.init\(\);\s/) }) it('shouldn’t insert if @bugsnag/expo is already imported (import)', async () => { From 99f9f3c1e2b314e024e2cce0ba72933eb0fc081d Mon Sep 17 00:00:00 2001 From: Ben Gourley Date: Tue, 7 Jan 2020 10:42:14 +0000 Subject: [PATCH 2/4] test(browser): Update release_stage tests --- test/browser/features/fixtures/release_stage/script/e.html | 4 ++-- test/browser/features/fixtures/release_stage/script/f.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/browser/features/fixtures/release_stage/script/e.html b/test/browser/features/fixtures/release_stage/script/e.html index 9790e91673..0eea414e7e 100644 --- a/test/browser/features/fixtures/release_stage/script/e.html +++ b/test/browser/features/fixtures/release_stage/script/e.html @@ -6,7 +6,7 @@ diff --git a/test/browser/features/fixtures/release_stage/script/f.html b/test/browser/features/fixtures/release_stage/script/f.html index fa9e74b772..735078f445 100644 --- a/test/browser/features/fixtures/release_stage/script/f.html +++ b/test/browser/features/fixtures/release_stage/script/f.html @@ -6,7 +6,7 @@ From 3c130982519ebfd9a85d7ac0bf6cbd265b27af3e Mon Sep 17 00:00:00 2001 From: Ben Gourley Date: Tue, 7 Jan 2020 10:42:58 +0000 Subject: [PATCH 3/4] docs: Update plugin readmes to use updated static interface --- packages/plugin-angular/README.md | 12 ++++++------ packages/plugin-react/README.md | 8 ++++---- packages/plugin-vue/README.md | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/plugin-angular/README.md b/packages/plugin-angular/README.md index 6d64903667..a2fcf48d98 100644 --- a/packages/plugin-angular/README.md +++ b/packages/plugin-angular/README.md @@ -19,16 +19,16 @@ yarn add @bugsnag/js @bugsnag/plugin-angular In your the root of your angular app, typically `app.module.ts`: ```typescript -// Import bugsnag-js and bugsnag-angular -import BugsnagErrorHandler from 'bugsnag-angular' -import bugsnag from 'bugsnag-js' +// Import bugsnag-js and @bugsnag/angular +import { BugsnagErrorHandler } from '@bugsnag/plugin-angular' +import Bugsnag from 'bugsnag-js' // configure Bugsnag ASAP, before any other imports -const bugsnagClient = bugsnag('API_KEY') +Bugsnag.init('API_KEY') -// create a factory which will return the bugsnag error handler +// create a factory which will return the Bugsnag error handler export function errorHandlerFactory() { - return new BugsnagErrorHandler(bugsnagClient) + return new BugsnagErrorHandler() } import { ErrorHandler, NgModule } from '@angular/core' diff --git a/packages/plugin-react/README.md b/packages/plugin-react/README.md index d29e3de37d..b712f8e0b5 100644 --- a/packages/plugin-react/README.md +++ b/packages/plugin-react/README.md @@ -25,16 +25,16 @@ Depending on how your application is structured, usage differs slightly: ```js // initialize bugsnag ASAP, before other imports -import bugsnag from '@bugsnag/js' -const bugsnagClient = bugsnag('API_KEY') +import Bugsnag from '@bugsnag/js' +Bugsnag('API_KEY') import ReactDOM from 'react-dom' import React from 'react' import bugsnagReact from '@bugsnag/plugin-react' -bugsnagClient.use(bugsnagReact, React) +Bugsnag.use(bugsnagReact, React) // wrap your entire app tree in the ErrorBoundary provided -const ErrorBoundary = bugsnagClient.getPlugin('react'); +const ErrorBoundary = Bugsnag.getPlugin('react'); ReactDOM.render( diff --git a/packages/plugin-vue/README.md b/packages/plugin-vue/README.md index 7110b07604..99bb1ed15e 100644 --- a/packages/plugin-vue/README.md +++ b/packages/plugin-vue/README.md @@ -20,11 +20,11 @@ yarn add bugsnag-js @bugsnag/plugin-vue ```js const Vue = require('vue') -const bugsnag = require('@bugsnag/js') +const Bugsnag = require('@bugsnag/js') const bugsnagVue = require('@bugsnag/plugin-vue') -const bugsnagClient = bugsnag('API_KEY') -bugsnagClient.use(bugsnagVue, Vue) +Bugsnag.init('API_KEY') +Bugsnag.use(bugsnagVue, Vue) ``` ## Support From 1678d05de2642cef4aedc7677bd9daf0930d174c Mon Sep 17 00:00:00 2001 From: Ben Gourley Date: Tue, 7 Jan 2020 13:00:35 +0000 Subject: [PATCH 4/4] fix: Typos --- packages/plugin-angular/README.md | 2 +- packages/plugin-react/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin-angular/README.md b/packages/plugin-angular/README.md index a2fcf48d98..dc537eea74 100644 --- a/packages/plugin-angular/README.md +++ b/packages/plugin-angular/README.md @@ -19,7 +19,7 @@ yarn add @bugsnag/js @bugsnag/plugin-angular In your the root of your angular app, typically `app.module.ts`: ```typescript -// Import bugsnag-js and @bugsnag/angular +// Import bugsnag-js and @bugsnag/plugin-angular import { BugsnagErrorHandler } from '@bugsnag/plugin-angular' import Bugsnag from 'bugsnag-js' diff --git a/packages/plugin-react/README.md b/packages/plugin-react/README.md index b712f8e0b5..579ca3dd4d 100644 --- a/packages/plugin-react/README.md +++ b/packages/plugin-react/README.md @@ -26,7 +26,7 @@ Depending on how your application is structured, usage differs slightly: ```js // initialize bugsnag ASAP, before other imports import Bugsnag from '@bugsnag/js' -Bugsnag('API_KEY') +Bugsnag.init('API_KEY') import ReactDOM from 'react-dom' import React from 'react'