Skip to content

Commit d4515ac

Browse files
author
Adam Yeats
committed
Initial commit
0 parents  commit d4515ac

32 files changed

+7878
-0
lines changed

.gitignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# next.js build output
61+
.next
62+
63+
# Parcel cache
64+
.cache
65+
66+
# Ignore Mac DS_Store files
67+
.DS_Store
68+
69+
# Ignore build files
70+
dist/

CONTRIBUTING.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Want to contribute to `appsignal-javascript`? That's great! Here are a few guidelines that will help you contribute. Before we get started: Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md) to ensure that this project is a welcoming place for **everyone** to contribute to. By participating in this project you agree to abide by its terms.
2+
3+
### Overview
4+
5+
- [Contribution workflow]()
6+
- [Guidelines for adding new components]()
7+
- [Contributing to an existing issue]()
8+
- [Our labels]()
9+
10+
## Contribution workflow
11+
12+
- Create a branch. We use `[git flow](https://github.com/nvie/gitflow)` to create branches based on `develop`.
13+
- Make your change or bug fix. Don't forget to add yourself to `.all-contributorsrc` to show up in our contributors list!
14+
- Send a merge request.
15+
- The team will vote using :thumbsup: and :thumbsdown:
16+
- If approved, a maintainer will merge your change.
17+
18+
## Contributing to an existing issue
19+
20+
### Finding an issue to work on
21+
22+
You can view the list of issues [here](https://github.com/appsignal/appsignal-javascript/issues). The issues are labelled, so you can use the labels to get an idea of which issue could be a good fit for you. (Here's [a good article](https://medium.freecodecamp.com/finding-your-first-open-source-project-or-bug-to-work-on-1712f651e5ba) on how to find your first bug to fix).
23+
24+
Before getting to work, take a look at the issue and at the conversation around it. Has someone already offered to work on the issue? Has someone been assigned to the issue? If so, you might want to check with them to see whether they're still actively working on it.
25+
26+
If the issue is a few months old, it might be a good idea to write a short comment to double-check that the issue or feature is still a valid one to jump on.
27+
28+
Feel free to ask for more detail on what is expected: are there any more details or specifications you need to know?
29+
30+
And if at any point you get stuck: don't hesitate to ask for help.
31+
32+
### Making your contribution
33+
34+
We've outlined the contribution workflow [here](). If you're a first-timer, don't worry! GitLab has a ton of guides to help you through your first pull request: You can find out more about pull requests [here](https://docs.gitlab.com/ee/user/project/merge_requests/) and about creating a pull request [here](https://docs.gitlab.com/ee/gitlab-basics/add-merge-request.html).
35+
36+
## Our labels
37+
38+
@TODO: document labels.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 AppSignal
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# AppSignal for JavaScript
2+
3+
- [AppSignal.com website][appsignal]
4+
- [Documentation][docs]
5+
- [Support][contact]
6+
7+
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
8+
9+
## Description
10+
11+
## Usage
12+
13+
First, make sure you've installed AppSignal in your application by following the steps in [Installation](#installation).
14+
15+
### Track any error
16+
17+
Catch an error and report it to AppSignal:
18+
19+
```js
20+
try {
21+
// do something that might throw an error
22+
} catch (error) {
23+
appsignal.sendError(error)
24+
// handle the error
25+
}
26+
27+
// You can catch errors asynchronously by listening to Promises...
28+
asyncActionThatReturnsAPromise().catch(error => appsignal.sendError(error))
29+
30+
// ...or by using async/await
31+
async function() {
32+
try {
33+
const result = await asyncActionThatReturnsAPromise()
34+
} catch (error) {
35+
appsignal.sendError(error)
36+
// handle the error
37+
}
38+
}
39+
40+
// ...or in an event handler or callback function
41+
events.on("event", (err) => {
42+
appsignal.sendError(err)
43+
})
44+
```
45+
46+
**NOTE:** Uncaught exceptions are **not** captured by default. We made the decision to not include this functionality as part of the core library due to the high amount of noise from browser extensions, ad blockers etc. that generally makes libraries such as this less effective.
47+
48+
We recommend using a relevant [integration](#integrations) as a better way to handle exceptions, or, if you _would_ prefer capture uncaught exceptions, you can do so by using the `@appsignal/plugin-window-events` package alongside this one (available soon).
49+
50+
## Installation
51+
52+
First, sign up for an AppSignal account and add the `@appsignal/javascript` package to your `package.json`. Then, run `yarn install`/`npm install`.
53+
54+
You can also add these packages to your `package.json` on the command line:
55+
56+
```bash
57+
yarn add @appsignal/javascript
58+
npm install --save @appsignal/javascript
59+
```
60+
61+
You can then import and use the package in your bundle:
62+
63+
```js
64+
import Appsignal from "@appsignal/javascript" // For ES Module
65+
const Appsignal = require("@appsignal/javascript").default // For CommonJS module
66+
67+
const appsignal = new Appsignal({
68+
key: "YOUR FRONTEND API KEY"
69+
})
70+
```
71+
72+
It's recommended (although not necessarily required) to use the instance of the `Appsignal` object like a singleton. One way that you can do this is by `export`ing an instance of the library from a `.js`/`.ts` file somewhere in your project.
73+
74+
```js
75+
import Appsignal from "@appsignal/javascript"
76+
77+
export default new Appsignal({
78+
key: "YOUR FRONTEND API KEY"
79+
})
80+
```
81+
82+
Currently, we have no plans to supply a CDN-hosted version of this library.
83+
84+
If you're stuck, feel free to [contact us][contact] for help!
85+
86+
## Integrations
87+
88+
An integration is a module that can consume the `Appsignal` object to catch errors from popular libraries or frameworks. These integrations may come in a variety of different forms, and we aim to generally provide APIs that are consistent, and feel idiomatic to use, with the libraries and/or frameworks that you're using.
89+
90+
These currently include:
91+
92+
* React (beta) - `@appsignal/react`
93+
94+
## Supported browsers
95+
96+
This package can be used in any ECMAScript 5 compatible browser. We aim for compatibility down to Internet Explorer 9 [(roughly 0.22% of all browsers used today)](https://www.w3counter.com/globalstats.php). All browsers older than this can only supported on a "best effort" basis, and full functionality cannot be guaranteed.
97+
98+
When developing, don't forget to check browser support on [Can I Use?](https://caniuse.com/) and the [ES6 Compatibility Table](https://kangax.github.io/compat-table/es6/), and provide the appropriate polyfills or fallbacks. **In a small percentage of browsers, a `Promise` polyfill may be required to use this library.**
99+
100+
## Development
101+
102+
### Installation
103+
104+
This repository is a Lerna-managed monorepo, containing packages (located in the `/packages` directory) that map to separate `npm` modules.
105+
106+
To install the dependencies:
107+
108+
```bash
109+
yarn install
110+
lerna bootstrap
111+
```
112+
113+
You can then run the following to start the compiler in _watch_ mode. This automatically compiles both the ES Module and CommonJS variants:
114+
115+
```bash
116+
yarn build:watch
117+
```
118+
119+
You can also build the library without watching the directory:
120+
121+
```
122+
yarn build # build both CJS and ESM
123+
yarn build:cjs # just CJS
124+
yarn build:esm # just ESM
125+
```
126+
127+
### Testing
128+
129+
The tests for this library use [Jest](https://jestjs.io) as the test runner. Once you've installed the dependencies, you can run the following command in the root of this repository to run the tests for all packages, or in the directory of a package to run only the tests pertaining to that package:
130+
131+
```bash
132+
yarn test
133+
```
134+
135+
### Versioning
136+
137+
This repo uses [Semantic Versioning][semver] (often referred to as _semver_). Each package in the repository is versioned independently from one another.
138+
139+
@TODO: define how this works once we know more about releasing
140+
141+
## Contributing
142+
143+
Thinking of contributing to this repo? Awesome! 🚀
144+
145+
Please follow our [Contributing guide][contributing-guide] in our documentation and follow our [Code of Conduct][coc].
146+
147+
Also, we would be very happy to send you Stroopwafles. Have look at everyone we send a package to so far on our [Stroopwafles page][waffles-page].
148+
149+
## Support
150+
151+
[Contact us][contact] and speak directly with the engineers working on AppSignal. They will help you get set up, tweak your code and make sure you get the most out of using AppSignal.
152+
153+
Also see our [SUPPORT.md file](SUPPORT.md).
154+
155+
[appsignal]: https://appsignal.com
156+
[appsignal-sign-up]: https://appsignal.com/users/sign_up
157+
[contact]: mailto:[email protected]
158+
[coc]: https://docs.appsignal.com/appsignal/code-of-conduct.html
159+
[waffles-page]: https://appsignal.com/waffles
160+
[docs]: http://docs.appsignal.com
161+
[contributing-guide]: http://docs.appsignal.com/appsignal/contributing.html
162+
163+
[semver]: http://semver.org/

lerna.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"packages": [
3+
"packages/*"
4+
],
5+
"version": "independent",
6+
"npmClient": "yarn",
7+
"useWorkspaces": true
8+
}

package.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"private": true,
3+
"dependencies": {
4+
"@appsignal/javascript": "file:packages/javascript"
5+
},
6+
"devDependencies": {
7+
"@types/jest": "^24.0.15",
8+
"husky": "^2.4.1",
9+
"jest": "^24.7.1",
10+
"lerna": "^3.15.0",
11+
"lint-staged": "^8.2.1",
12+
"npm-run-all": "^4.1.5",
13+
"prettier": "1.18.2",
14+
"ts-jest": "^24.0.2",
15+
"typescript": "^3.5.2",
16+
"rimraf": "^2.6.3"
17+
},
18+
"scripts": {
19+
"build": "lerna run --stream --concurrency 1 --sort build",
20+
"build:cjs": "lerna run --stream --concurrency 1 --sort build:cjs",
21+
"build:esm": "lerna run --stream --concurrency 1 --sort build:esm",
22+
"build:watch": "lerna run build:watch --stream --no-sort --concurrency 9999",
23+
"clean": "lerna run --stream clean",
24+
"link:yarn": "lerna run --stream --concurrency 1 link:yarn",
25+
"test": "lerna run --stream --concurrency 1 --sort test"
26+
},
27+
"husky": {
28+
"hooks": {
29+
"pre-commit": "lint-staged"
30+
}
31+
},
32+
"lint-staged": {
33+
"linters": {
34+
"*.{ts,tsx}": [
35+
"prettier --write",
36+
"git add"
37+
]
38+
},
39+
"ignore": [
40+
"**/dist/**"
41+
]
42+
},
43+
"workspaces": [
44+
"packages/*"
45+
]
46+
}

packages/javascript/.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!/dist/**/*
3+
*.tsbuildinfo

packages/javascript/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 AppSignal
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/javascript/jest.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "jsdom",
4+
roots: [
5+
"<rootDir>/src"
6+
],
7+
transform: {
8+
"^.+\\.tsx?$": "ts-jest"
9+
},
10+
}

0 commit comments

Comments
 (0)