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

Types revamp #423

Merged
merged 18 commits into from
Nov 21, 2018
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ install:
- npm install
- npx lerna bootstrap
before_script:
- npx lerna run build
- npm run build
script:
- npm run test:browser
env:
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
- npm install
- npx lerna bootstrap
before_script:
- npx lerna run build
- npm run build
script:
- npm run test:node
env: BROWSER=na
Expand Down
27 changes: 16 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ Users of the CDN just need to update the link:
- https://d2wy8f7a9ursnm.cloudfront.net/v5.0.0/bugsnag.min.js
```

#### Node.js

Users of the existing `bugsnag` (node) package should note that this upgrade is **not** backwards compatible and should follow the new [integration guides](https://docs.bugsnag.com/platforms/javascript).

Please note the signature of the `notify()` function is similar, but has some noteworthy differences:

`bugsnagClient.notify(error, opts)`

- Previously `metaData` could be provided by passing arbitrary keys to `opts`. Now, it must be passed explicitly as `opts.metaData`.
- `groupingHash` is no longer an option, but it can be set using `report.groupingHash` in a `beforeSend` callback.

Please refer to the documentation, since `notify()` will ignore `opts` that it doesn't recognize.


#### npm/yarn users

Users of the `bugsnag-js` browser JS package will need to remove that dependency and add `@bugsnag/js`.
Expand Down Expand Up @@ -89,15 +103,6 @@ yarn add @bugsnag/plugin-{vue|react|angular}
- import BugsnagErrorHandler from 'bugsnag-angular'
```

## Node.js

Users of the existing `bugsnag` (node) package should note that this upgrade is **not** backwards compatible and should follow the new [integration guides](https://docs.bugsnag.com/platforms/javascript).

Please note the signature of the `notify()` function is similar, but has some noteworthy differences:
#### TypeScript

`bugsnagClient.notify(error, opts)`

- Previously `metaData` could be provided by passing arbitrary keys to `opts`. Now, it must be passed explicitly as `opts.metaData`.
- `groupingHash` is no longer an option, but it can be set using `report.groupingHash` in a `beforeSend` callback.

Please refer to the documentation, since `notify()` will ignore `opts` that it doesn't recognize.
TypeScript definitions are bundled with each of the published modules and should "just work".
16 changes: 16 additions & 0 deletions bin/bundle-types
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# exit on all errors
set -e

# ensure directory exists
mkdir -p dist/types/bugsnag-core

# copy all .d.ts files from @bugsnag/core
cp node_modules/@bugsnag/core/types/*.d.ts dist/types/bugsnag-core

# copy all .d.ts files from this module
cp types/*.d.ts dist/types

# replace any references to @bugsnag/core with the new, bundled, local path
cat types/bugsnag.d.ts | sed 's/@bugsnag\/core/\.\/bugsnag-core/' > dist/types/bugsnag.d.ts
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"packages": [
"packages/*"
],
"version": "5.0.0-rc.1"
"version": "5.0.0-rc.4"
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"uglify-js": "^3.4.9"
},
"scripts": {
"build": "lerna run build --scope '@bugsnag/node' --scope '@bugsnag/browser' && lerna run build --ignore '@bugsnag/node' --ignore '@bugsnag/browser'",
"test:lint": "standard",
"test:unit": "lerna run test --ignore '@bugsnag/browser' --ignore '@bugsnag/node'",
"test:types": "lerna run test:types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"dependencies": {
"es3ify-webpack-plugin": "0.0.1",
"uglifyjs-webpack-plugin": "2.0.1",
"webpack": "^3.11.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"dependencies": {
"es3ify-webpack-plugin": "0.0.1",
"uglifyjs-webpack-plugin": "2.0.1",
"webpack": "^4.8.1",
"webpack-cli": "^3.1.2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"es3ify-webpack-plugin": "0.0.1",
"uglifyjs-webpack-plugin": "2.0.1",
"react": "^16.5.0",
"react-dom": "^16.5.0",
"webpack": "^4.8.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"dependencies": {
"es3ify-webpack-plugin": "0.0.1",
"uglifyjs-webpack-plugin": "2.0.1",
"vue": "^2.5.17",
"webpack": "^4.8.1",
"webpack-cli": "^3.1.2"
Expand Down
44 changes: 22 additions & 22 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@bugsnag/browser",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.4",
"main": "dist/bugsnag.js",
"types": "types/bugsnag.d.ts",
"types": "dist/types/bugsnag.d.ts",
"description": "Bugsnag error reporter for browser JavaScript",
"homepage": "https://www.bugsnag.com/",
"repository": {
Expand All @@ -13,13 +13,13 @@
"access": "public"
},
"files": [
"dist",
"types"
"dist"
],
"scripts": {
"size": "./bin/size",
"clean": "rm -fr dist && mkdir dist",
"build": "npm run clean && npm run build:dist && npm run build:dist:min",
"bundle-types": "../../bin/bundle-types",
"build": "npm run clean && npm run build:dist && npm run build:dist:min && npm run bundle-types",
"build:dist": "NODE_ENV=production IS_BROWSER=yes ../../bin/bundle src/notifier.js --standalone=bugsnag | ../../bin/extract-source-map dist/bugsnag.js",
"build:dist:min": "NODE_ENV=production IS_BROWSER=yes ../../bin/bundle src/notifier.js --standalone=bugsnag | ../../bin/minify dist/bugsnag.min.js",
"test:types": "tslint -c ../../tslint.json types/*.d.ts && jasmine 'types/**/*.test.js'",
Expand All @@ -30,23 +30,23 @@
"author": "Bugsnag",
"license": "MIT",
"devDependencies": {
"@bugsnag/core": "^5.0.0-rc.1",
"@bugsnag/delivery-x-domain-request": "^5.0.0-rc.1",
"@bugsnag/delivery-xml-http-request": "^5.0.0-rc.1",
"@bugsnag/plugin-browser-context": "^5.0.0-rc.1",
"@bugsnag/plugin-browser-device": "^5.0.0-rc.1",
"@bugsnag/plugin-browser-request": "^5.0.0-rc.1",
"@bugsnag/plugin-browser-session": "^5.0.0-rc.1",
"@bugsnag/plugin-client-ip": "^5.0.0-rc.1",
"@bugsnag/plugin-console-breadcrumbs": "^5.0.0-rc.1",
"@bugsnag/plugin-inline-script-content": "^5.0.0-rc.1",
"@bugsnag/plugin-interaction-breadcrumbs": "^5.0.0-rc.1",
"@bugsnag/plugin-navigation-breadcrumbs": "^5.0.0-rc.1",
"@bugsnag/plugin-network-breadcrumbs": "^5.0.0-rc.1",
"@bugsnag/plugin-simple-throttle": "^5.0.0-rc.1",
"@bugsnag/plugin-strip-query-string": "^5.0.0-rc.1",
"@bugsnag/plugin-window-onerror": "^5.0.0-rc.1",
"@bugsnag/plugin-window-unhandled-rejection": "^5.0.0-rc.1",
"@bugsnag/core": "^5.0.0-rc.4",
"@bugsnag/delivery-x-domain-request": "^5.0.0-rc.4",
"@bugsnag/delivery-xml-http-request": "^5.0.0-rc.4",
"@bugsnag/plugin-browser-context": "^5.0.0-rc.4",
"@bugsnag/plugin-browser-device": "^5.0.0-rc.4",
"@bugsnag/plugin-browser-request": "^5.0.0-rc.4",
"@bugsnag/plugin-browser-session": "^5.0.0-rc.4",
"@bugsnag/plugin-client-ip": "^5.0.0-rc.4",
"@bugsnag/plugin-console-breadcrumbs": "^5.0.0-rc.4",
"@bugsnag/plugin-inline-script-content": "^5.0.0-rc.4",
"@bugsnag/plugin-interaction-breadcrumbs": "^5.0.0-rc.4",
"@bugsnag/plugin-navigation-breadcrumbs": "^5.0.0-rc.4",
"@bugsnag/plugin-network-breadcrumbs": "^5.0.0-rc.4",
"@bugsnag/plugin-simple-throttle": "^5.0.0-rc.4",
"@bugsnag/plugin-strip-query-string": "^5.0.0-rc.4",
"@bugsnag/plugin-window-onerror": "^5.0.0-rc.4",
"@bugsnag/plugin-window-unhandled-rejection": "^5.0.0-rc.4",
"cloudfront": "^0.4.1",
"jasmine": "^3.1.0",
"knox": "^0.9.2",
Expand Down
49 changes: 32 additions & 17 deletions packages/browser/types/bugsnag.d.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
import * as Bugsnag from "@bugsnag/core";
import * as BugsnagCore from "@bugsnag/core";

// augment config interface
// overwrite config interface, adding browser-specific options
declare module "@bugsnag/core" {
namespace Bugnsag {
interface IConfig {
// deprecated options which are still supported
endpoint?: string;
sessionEndpoint?: string;
// options for all bundled browser plugins
maxEvents?: number;
consoleBreadcrumbsEnabled?: boolean;
networkBreadcrumbsEnabled?: boolean;
navigationBreadcrumbsEnabled?: boolean;
interactionBreadcrumbsEnabled?: boolean;
collectUserIp?: boolean;
}
interface IConfig {
apiKey: string;
beforeSend?: BugsnagCore.BeforeSend | BugsnagCore.BeforeSend[];
autoBreadcrumbs?: boolean;
autoNotify?: boolean;
appVersion?: string;
appType?: string;
endpoints?: { notify: string, sessions?: string };
autoCaptureSessions?: boolean;
notifyReleaseStages?: string[];
releaseStage?: string;
maxBreadcrumbs?: number;
user?: object | null;
metaData?: object | null;
logger?: BugsnagCore.ILogger | null;
filters?: Array<string | RegExp>;
// catch-all for any missing options
[key: string]: any;
// deprecated options which are still supported
endpoint?: string;
sessionEndpoint?: string;
// options for all bundled browser plugins
maxEvents?: number;
consoleBreadcrumbsEnabled?: boolean;
networkBreadcrumbsEnabled?: boolean;
navigationBreadcrumbsEnabled?: boolean;
interactionBreadcrumbsEnabled?: boolean;
collectUserIp?: boolean;
}
}

// two ways to call the exported function: apiKey or config object
declare function bugsnag(apiKeyOrOpts: string | Bugsnag.IConfig): Bugsnag.Client;
declare function bugsnag(apiKeyOrOpts: string | BugsnagCore.IConfig): BugsnagCore.Client;

// commonjs/requirejs export
export default bugsnag;
export { Bugsnag };
export { BugsnagCore as Bugsnag };
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bugsnag/core",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.4",
"types": "types/index.d.ts",
"description": "Core classes and utilities for Bugsnag notifiers",
"homepage": "https://www.bugsnag.com/",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/types/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ declare class Client {
public BugsnagBreadcrumb: typeof Breadcrumb;
public BugsnagSession: typeof Session;

public use(plugin: common.IPlugin): Client;
public use(plugin: common.IPlugin, ...args: any[]): Client;
public getPlugin(name: string): any;
public setOptions(opts: common.IConfig): Client;
public configure(schema?: common.IConfigSchema): Client;
Expand Down
4 changes: 2 additions & 2 deletions packages/delivery-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bugsnag/delivery-node",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.4",
"main": "delivery.js",
"description": "@bugsnag/node delivery mechanism",
"homepage": "https://www.bugsnag.com/",
Expand All @@ -20,7 +20,7 @@
"author": "Bugsnag",
"license": "MIT",
"dependencies": {
"@bugsnag/core": "^5.0.0-rc.1",
"@bugsnag/core": "^5.0.0-rc.4",
"request": "^2.87.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/delivery-x-domain-request/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bugsnag/delivery-x-domain-request",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.4",
"main": "delivery.js",
"description": "@bugsnag/js delivery mechanism for IE 8, 9 and 10",
"homepage": "https://www.bugsnag.com/",
Expand All @@ -20,7 +20,7 @@
"author": "Bugsnag",
"license": "MIT",
"dependencies": {
"@bugsnag/core": "^5.0.0-rc.1"
"@bugsnag/core": "^5.0.0-rc.4"
},
"devDependencies": {
"jasmine": "^3.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/delivery-xml-http-request/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bugsnag/delivery-xml-http-request",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.4",
"main": "delivery.js",
"description": "@bugsnag/js delivery mechanism for most browsers",
"homepage": "https://www.bugsnag.com/",
Expand All @@ -20,7 +20,7 @@
"author": "Bugsnag",
"license": "MIT",
"dependencies": {
"@bugsnag/core": "^5.0.0-rc.1"
"@bugsnag/core": "^5.0.0-rc.4"
},
"devDependencies": {
"jasmine": "^3.1.0",
Expand Down
9 changes: 3 additions & 6 deletions packages/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bugsnag/js",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.4",
"main": "node/notifier.js",
"browser": "browser/notifier.js",
"types": "types.d.ts",
Expand Down Expand Up @@ -30,14 +30,11 @@
"node",
"types.d.ts"
],
"scripts": {
"postversion": "npm run build"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was on the wrong package, it should have been on node.

},
"author": "Bugsnag",
"license": "MIT",
"dependencies": {
"@bugsnag/browser": "^5.0.0-rc.1",
"@bugsnag/node": "^5.0.0-rc.1"
"@bugsnag/browser": "^5.0.0-rc.4",
"@bugsnag/node": "^5.0.0-rc.4"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
Expand Down
35 changes: 18 additions & 17 deletions packages/node/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@bugsnag/node",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.4",
"main": "dist/bugsnag.js",
"types": "types/bugsnag.d.ts",
"types": "dist/types/bugsnag.d.ts",
"description": "Bugsnag error reporter for Node.js",
"homepage": "https://www.bugsnag.com/",
"repository": {
Expand All @@ -13,29 +13,30 @@
"access": "public"
},
"files": [
"dist",
"types"
"dist"
],
"scripts": {
"clean": "rm -fr dist && mkdir dist",
"build": "npm run clean && npm run build:dist",
"bundle-types": "../../bin/bundle-types",
"build": "npm run clean && npm run build:dist && npm run bundle-types",
"build:dist": "../../bin/bundle src/notifier.js --node --exclude=iserror,stack-generator,error-stack-parser,request,pump,byline --standalone=bugsnag | ../../bin/extract-source-map dist/bugsnag.js",
"test": "bundle exec maze-runner"
"test": "bundle exec maze-runner",
"postversion": "npm run build"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The node assets were not built when each version was created. This was the cause.

},
"author": "Bugsnag",
"license": "MIT",
"devDependencies": {
"@bugsnag/core": "^5.0.0-rc.1",
"@bugsnag/delivery-node": "^5.0.0-rc.1",
"@bugsnag/plugin-contextualize": "^5.0.0-rc.1",
"@bugsnag/plugin-intercept": "^5.0.0-rc.1",
"@bugsnag/plugin-node-device": "^5.0.0-rc.1",
"@bugsnag/plugin-node-in-project": "^5.0.0-rc.1",
"@bugsnag/plugin-node-surrounding-code": "^5.0.0-rc.1",
"@bugsnag/plugin-node-uncaught-exception": "^5.0.0-rc.1",
"@bugsnag/plugin-node-unhandled-rejection": "^5.0.0-rc.1",
"@bugsnag/plugin-server-session": "^5.0.0-rc.1",
"@bugsnag/plugin-strip-project-root": "^5.0.0-rc.1",
"@bugsnag/core": "^5.0.0-rc.4",
"@bugsnag/delivery-node": "^5.0.0-rc.4",
"@bugsnag/plugin-contextualize": "^5.0.0-rc.4",
"@bugsnag/plugin-intercept": "^5.0.0-rc.4",
"@bugsnag/plugin-node-device": "^5.0.0-rc.4",
"@bugsnag/plugin-node-in-project": "^5.0.0-rc.4",
"@bugsnag/plugin-node-surrounding-code": "^5.0.0-rc.4",
"@bugsnag/plugin-node-uncaught-exception": "^5.0.0-rc.4",
"@bugsnag/plugin-node-unhandled-rejection": "^5.0.0-rc.4",
"@bugsnag/plugin-server-session": "^5.0.0-rc.4",
"@bugsnag/plugin-strip-project-root": "^5.0.0-rc.4",
"jasmine": "^3.1.0",
"nyc": "^12.0.2"
},
Expand Down
Loading