Skip to content

Commit

Permalink
Merge pull request #32 from BugSplat-Git/typescript
Browse files Browse the repository at this point in the history
ESM
  • Loading branch information
bobbyg603 authored Dec 28, 2020
2 parents 2d503f3 + d27a770 commit 3dfffce
Show file tree
Hide file tree
Showing 19 changed files with 346 additions and 566 deletions.
48 changes: 22 additions & 26 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,27 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Test",
"args": [
"${workspaceRoot}/node_modules/jasmine/bin/jasmine.js",
"spec/bugsplat.spec.js"
],
"env": {
"NODE_PATH": "."
}
},
{
"type": "node",
"request": "launch",
"name": "E2E",
"args": [
"${workspaceRoot}/node_modules/jasmine/bin/jasmine.js",
"e2e/bugsplat.e2e.spec.js"
],
"env": {
"NODE_PATH": "."
}
}


{
"name": "Test",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script", "test"
],
"port": 5858
},
{
"name": "E2E",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script", "e2e"
],
"port": 5858
}
]
}
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ To add the bugsplat package to your application, run the following shell command
npm install --save bugsplat
```

Require the bugsplat module at the entry point of your application.
Depending on your project's module system you can either `import` or `require` BugSplat:
### ESM
```js
const BugSplat = require("bugsplat");
import { BugSplat } from 'bugsplat';
```

### CommonJS
```
const { BugSplat } = require('bugsplat');
```

Create a new instance of the BugSplat class with the name of your BugSplat database, the name of your application and the version of your application:
```js
const bugsplat = new BugSplat("DatabaseName", "AppName", "1.0.0.0");
```
```js
const bugsplat = new BugSplat("DatabaseName", "AppName", "1.0.0.0");
```

Listen for window.onerror events and post them to BugSplat:
```js
Expand Down Expand Up @@ -70,14 +76,15 @@ bugsplat.setDefaultAppKey(appKey); // Additional metadata that can be queried vi
bugsplat.setDefaultUser(user); // The name or id of your user
bugsplat.setDefaultEmail(email); // The email of your user
bugsplat.setDefaultDescription(description); // Additional info about your crash that gets reset after every post
bugsplat.post(error, options); // Posts an arbitrary Error object to BugSplat
async bugsplat.post(error, options); // Posts an arbitrary Error object to BugSplat
// If the values options.appKey, options.user, options.email, options.description are set the corresponding default values will be overwritten
// Returns a promise that resolves with properties: error (if there was an error posting to BugSplat), response (the response from the BugSplat crash post API), and original (the error passed by bugsplat.post)
```

## Upgrading

If you are developing a Node.js application and were using bugsplat-js <= 5.0.0 please upgrade to [bugsplat-node](https://www.npmjs.com/package/bugsplat-node). BugSplat-node has the same consumer APIs as bugsplat-js <= 5.0.0. Additionally, support for file attachments and exiting the Node process in the error handler have been moved to [bugsplat-node](https://www.npmjs.com/package/bugsplat-node) so that bugsplat-js can be run in browsers as well as Node.js environments.
If you are developing a Node.js application and were using bugsplat-js <= 5.0.0 please upgrade to [bugsplat-node](https://www.npmjs.com/package/bugsplat-node). BugSplat-node has the same consumer APIs as bugsplat-js <= 5.0.0. Additionally, support for file attachments and exiting the Node process in the error handler have been moved to [bugsplat-node](https://www.npmjs.com/package/bugsplat-node) so that bugsplat-js can be run in browsers as well as Node.js environments.

## Contributing

BugSplat loves open source software! Please check out our project on [GitHub](https://github.com/BugSplat-Git/bugsplat-js) and send us a Pull Request.
36 changes: 0 additions & 36 deletions bugsplat.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion e2e/files/additionalFile.txt

This file was deleted.

5 changes: 5 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// JS extensions are required for ES6 modules, see https://stackoverflow.com/questions/44979976/typescript-compiler-is-forgetting-to-add-file-extensions-to-es6-module-imports
export { BugSplat } from './src/bugsplat.js';
export { BugSplatOptions } from './src/bugsplat-options.js';
export { BugSplatResponse } from './src/bugsplat-response.js';
export { FormDataParam } from './src/form-data-param.js';
8 changes: 0 additions & 8 deletions jsconfig.json

This file was deleted.

Loading

0 comments on commit 3dfffce

Please sign in to comment.