Skip to content

Commit 6cb5a7d

Browse files
committed
Completely reworked.
1 parent a2770f1 commit 6cb5a7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4739
-4610
lines changed

.eslintignore

-2
This file was deleted.

.eslintrc.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
plugins: [
5+
'@typescript-eslint',
6+
],
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:@typescript-eslint/recommended',
10+
],
11+
};

.eslintrc.json

-30
This file was deleted.

.gitattributes

-17
This file was deleted.

.gitignore

+3-67
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,3 @@
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-
/docs/*
63-
64-
65-
.rpt2_cache
66-
/dist/*
67-
!/docs/*.png
1+
node_modules
2+
dist
3+
/.rpt2_cache/*

.npmignore

+23-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1+
/.github/
2+
/.vscode/
3+
/node_modules/
4+
/build/
5+
/tmp/
6+
.idea/*
7+
/docs/
8+
9+
coverage
10+
*.log
11+
12+
package-lock.json
13+
/example/
14+
/*.tgz
15+
/tmp*
16+
/mnt/
17+
/package/
18+
/src/
19+
/tests/
20+
/.rpt2_cache/
121
.editorconfig
2-
.eslintignore
3-
.eslintrc.json
4-
.gitattributes
5-
.gitignore
6-
.npmignore
7-
.prettierignore
8-
.prettierrc
9-
.rpt2_cache
10-
tests\**
11-
docs
12-
example
13-
src
14-
*.tgz
15-
*.cmd
22+
pack.cmd
23+
browser.test.html
24+
jest.config

.prettierignore

-2
This file was deleted.

.prettierrc

-9
This file was deleted.

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cSpell.words": [
3+
"Salman"
4+
]
5+
}

README.md

+63-47
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,90 @@
11
# JavaScript library for Coderr
22

3-
This library is currently avilable as a release candidate. Feel free to try it, and please give us feedback.
3+
This library is currently available as a release candidate. Feel free to try it, and please give us feedback.
4+
5+
![](./docs/telemetry.gif)
46

57
https://coderr.io
68

7-
## Examples
89

9-
The following examples are just demonstrating basic usage:
10+
This library supports NodeJS and the browser (es6 module). There are also integration libraries that pick up errors automatically from Express, Angular etc.
1011

11-
### Using plain browser scripts
12+
## Installation
1213

13-
```html
14-
<html>
15-
<head>
16-
<script src="coderr.browser.js"></script>
17-
<script>
18-
// Setup
19-
var config = new coderr.Configuration("https://report.coderr.io", "f7aeacfdbe5447cdada6aa9ee21d24fb");
20-
var reporter = new coderr.Coderr(config);
14+
Download this package:
2115

22-
// report all unhandled errors
23-
reporter.catchDomErrors();
16+
```js
17+
npm -I coderr.client
18+
```
2419

20+
Add it to your application:
2521

22+
```js
23+
import * as coderr from "coderr.client";
2624

27-
// This is how manual reporting is done.
28-
//
29-
// In this case not really nessacary since
30-
// "catchDomErrors" would have reported it.
31-
try {
32-
var a = 10 / 0;
33-
}
34-
catch (err){
35-
reporter.report(err, {userName: "arne"});
36-
}
37-
</script>
38-
</head>
39-
</html>
40-
````
25+
coderr.configure("https://reporting.coderr.io", "yourAppKey");
26+
```
4127

42-
**From the Coderr Server UI**
28+
DOM errors will now automatically be reported (for browser-based applications).
4329

44-
![](docs/error_example.png)
30+
To report errors:
4531

46-
Example showing the "userAgent" context collection.
32+
```js
33+
import * as coderr from "coderr.client";
4734

48-
For browsers, Coderr automatically includes information about the window, document, cookies, navigator and screen.
35+
try {
36+
// Do something
37+
// or to just test:
38+
throw new Error("Something failed!");
39+
}
40+
catch (e) {
41+
// You can attach any kind of data.
42+
coderr.report(e, {userId: 11, address: { City: "Falun" }});
43+
}
44+
```
4945

50-
## Using TypeScript
46+
## Configuration
5147

52-
```typescript
53-
import { CoderrClient, Configuration } from "coderr.client";
54-
import { catchVueErrors } from "./Coderr.Vue"
48+
Coderr detects the environment (production/development) automatically when running in node,
49+
for all other types of applications, specify it:
5550

56-
var config = new Configuration("https://report.coderr.io/", "8ffd506b153f4ca690daaf6abd5fdcdf");
57-
config.environmentName = 'production';
58-
config.applicationVersion = 'v1.0';
51+
```js
52+
import * as coderr from "coderr.client";
5953

60-
var client = new CoderrClient(config);
61-
client.catchDomErrors();
62-
catchVueErrors(client);
54+
coderr.configuration.environment = 'production';
6355
```
6456

65-
**Result**
57+
### Application version
6658

67-
![](docs/vue.png)
59+
To see which application version an error exist, specify it:
6860

69-
For VueJs, Coderr collections information about the failing component, the HTML for the rendered component view, selected routes and more.
61+
```js
62+
import * as coderr from "coderr.client";
7063

64+
coderr.configuration.applicationVersion = '1.1.3';
65+
```
7166

72-
# Questions
7367

74-
https://discuss.coderr.io
68+
# Example, integration library
69+
70+
You can, for instance, install the Express package:
71+
72+
```js
73+
npm -I coderr.client.expressjs
74+
```
75+
76+
And then activate it:
77+
78+
```js
79+
import { credentials } from "coderr.client";
80+
import { HttpError, errorMiddleware } from "coderr.client.expressjs";
81+
82+
83+
credentials("https://coderr.io", "yourAppKey", "yourSharedSecret");
84+
```
85+
86+
Finally, activate the error middleware as the last middleware:
87+
88+
```
89+
app.use(errorMiddleware);
90+
```

browser.test.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html>
2+
<head>
3+
<script src="./dist/browser.js"></script>
4+
</head>
5+
6+
<body>
7+
<script>
8+
coderr.configure("https://report.coderr.io", "f7aeacfdbe5447cdada6aa9ee21d24fb");
9+
10+
try {
11+
var a = null;
12+
a();
13+
}
14+
catch (err) {
15+
console.log('reporting', coderr.report);
16+
coderr.report(err, { userName: "arne" });
17+
}
18+
19+
</script>
20+
Open the devtools 👇
21+
</body>
22+
23+
</html>

docs/error_example.png

-45.5 KB
Binary file not shown.

docs/telemetry.gif

3.02 MB
Loading

docs/vue.png

-67 KB
Binary file not shown.

jest.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
roots: ['<rootDir>'],
3+
testMatch: [
4+
"tests/**/*.+(ts|tsx|js)",
5+
"**/?(*.)+(spec|test).+(ts|tsx|js)"
6+
],
7+
transform: {
8+
"^.+\\.(ts|tsx)$": "ts-jest"
9+
},
10+
"verbose": true,
11+
"testURL": "http://localhost/"
12+
}

pack.cmd

-6
This file was deleted.

0 commit comments

Comments
 (0)