Skip to content

Commit 87c3aa2

Browse files
committed
Add angular example using angular 19
Update angular test Add CLAUDE.md Update whitespace and comments Update test to verify expected data actually reported
1 parent 7011e2c commit 87c3aa2

31 files changed

+15867
-114
lines changed

CLAUDE.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Rollbar.js Development Guide
2+
3+
## Build/Lint/Test Commands
4+
- Build: `npm run build`
5+
- Lint: `npm run lint`
6+
- Test all: `npm run test`
7+
- Test browser: `npm run test-browser`
8+
- Test server: `npm run test-server`
9+
- Single test: `./node_modules/.bin/karma start --single-run --files={path/to/test}`
10+
11+
## Code Style
12+
- Use ESLint with extends: `eslint:recommended`
13+
- Single quotes for strings
14+
- CamelCase for variables (properties excluded)
15+
- Trailing commas for all multi-line objects/arrays
16+
- Maximum complexity: 35
17+
- Underscore prefix allowed for private methods/variables
18+
- Prefix unused parameters with underscore: `function(data, _unused)`
19+
- Use Prettier with default config for formatting
20+
21+
## Error Handling
22+
- Prefer try/catch blocks around risky operations
23+
- Log errors through Rollbar's own logger system
24+
- Scrub sensitive fields in error payloads (see package.json defaults)
25+
26+
## TypeScript Support
27+
- Type definitions in index.d.ts
28+
- Add JSDoc types to enable intellisense when needed

examples/angular/.editorconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
ij_typescript_use_double_quotes = false
14+
15+
[*.md]
16+
max_line_length = off
17+
trim_trailing_whitespace = false

examples/angular/.gitignore

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
.history/*
30+
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
testem.log
38+
/typings
39+
40+
# System files
41+
.DS_Store
42+
Thumbs.db
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3+
"recommendations": ["angular.ng-template"]
4+
}

examples/angular/.vscode/launch.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3+
"version": "0.2.0",
4+
"configurations": [
5+
{
6+
"name": "ng serve",
7+
"type": "chrome",
8+
"request": "launch",
9+
"preLaunchTask": "npm: start",
10+
"url": "http://localhost:4200/"
11+
},
12+
{
13+
"name": "ng test",
14+
"type": "chrome",
15+
"request": "launch",
16+
"preLaunchTask": "npm: test",
17+
"url": "http://localhost:9876/debug.html"
18+
}
19+
]
20+
}

examples/angular/.vscode/tasks.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3+
"version": "2.0.0",
4+
"tasks": [
5+
{
6+
"type": "npm",
7+
"script": "start",
8+
"isBackground": true,
9+
"problemMatcher": {
10+
"owner": "typescript",
11+
"pattern": "$tsc",
12+
"background": {
13+
"activeOnStart": true,
14+
"beginsPattern": {
15+
"regexp": "(.*?)"
16+
},
17+
"endsPattern": {
18+
"regexp": "bundle generation complete"
19+
}
20+
}
21+
}
22+
},
23+
{
24+
"type": "npm",
25+
"script": "test",
26+
"isBackground": true,
27+
"problemMatcher": {
28+
"owner": "typescript",
29+
"pattern": "$tsc",
30+
"background": {
31+
"activeOnStart": true,
32+
"beginsPattern": {
33+
"regexp": "(.*?)"
34+
},
35+
"endsPattern": {
36+
"regexp": "bundle generation complete"
37+
}
38+
}
39+
}
40+
}
41+
]
42+
}

examples/angular/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Angular + Rollbar.js
2+
3+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.0.6, with server-side rendering (Angular Universal) enabled, with updates to add rollbar.js integration for client-side and server-side errors.
4+
5+
## Add your Rollbar tokens
6+
7+
To use this example, add your Rollbar tokens. You can find the tokens in the Rollbar UI for your project. Go to Project Settings, then Project Access Tokens, and note the post_client_item token (client-side token) and post_server_item token (server-side token, if using).
8+
9+
Add the client-side token in src/app/rollbar.config.ts by replacing `ROLLBAR_POST_CLIENT_ITEM_TOKEN` with your post_client_item token.
10+
11+
Add the server-side token in src/server.ts by replacing `ROLLBAR_POST_SERVER_ITEM_TOKEN` with your post_server_item token.
12+
13+
## Development server - client-side
14+
15+
To start a local development server, run:
16+
17+
```bash
18+
ng serve
19+
```
20+
21+
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
22+
23+
Now, you can test the Rollbar integration by clicking the buttons "Throw an Error" and "Log a Warning". You
24+
25+
## Development server - server-side
26+
27+
To run the server-side rendering server, first build:
28+
29+
```bash
30+
npm run build
31+
```
32+
33+
then run:
34+
35+
```bash
36+
npm run serve:ssr:angular
37+
```
38+
39+
Once the server is running, open your browser and navigate to `http://localhost:4000/`
40+
41+
Now, you can test the Rollbar integration by navigating to the url `http://localhost:4000/api/server-error`. You should see "Server error logged to Rollbar" in your browser and the error should appear in the Rollbar UI within a few seconds.
42+
43+
## Additional Resources
44+
45+
Need help? Rollbar Support can be reached via email at [email protected]

examples/angular/angular.json

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"angular": {
7+
"projectType": "application",
8+
"schematics": {},
9+
"root": "",
10+
"sourceRoot": "src",
11+
"prefix": "app",
12+
"architect": {
13+
"build": {
14+
"builder": "@angular-devkit/build-angular:application",
15+
"options": {
16+
"outputPath": "dist/angular",
17+
"index": "src/index.html",
18+
"browser": "src/main.ts",
19+
"polyfills": [
20+
"zone.js"
21+
],
22+
"tsConfig": "tsconfig.app.json",
23+
"assets": [
24+
{
25+
"glob": "**/*",
26+
"input": "public"
27+
}
28+
],
29+
"styles": [
30+
"src/styles.css"
31+
],
32+
"scripts": [],
33+
"server": "src/main.server.ts",
34+
"prerender": true,
35+
"ssr": {
36+
"entry": "src/server.ts"
37+
}
38+
},
39+
"configurations": {
40+
"production": {
41+
"budgets": [
42+
{
43+
"type": "initial",
44+
"maximumWarning": "500kB",
45+
"maximumError": "1MB"
46+
},
47+
{
48+
"type": "anyComponentStyle",
49+
"maximumWarning": "4kB",
50+
"maximumError": "8kB"
51+
}
52+
],
53+
"outputHashing": "all"
54+
},
55+
"development": {
56+
"optimization": false,
57+
"extractLicenses": false,
58+
"sourceMap": true
59+
}
60+
},
61+
"defaultConfiguration": "production"
62+
},
63+
"serve": {
64+
"builder": "@angular-devkit/build-angular:dev-server",
65+
"configurations": {
66+
"production": {
67+
"buildTarget": "angular:build:production"
68+
},
69+
"development": {
70+
"buildTarget": "angular:build:development"
71+
}
72+
},
73+
"defaultConfiguration": "development"
74+
},
75+
"extract-i18n": {
76+
"builder": "@angular-devkit/build-angular:extract-i18n"
77+
},
78+
"test": {
79+
"builder": "@angular-devkit/build-angular:karma",
80+
"options": {
81+
"polyfills": [
82+
"zone.js",
83+
"zone.js/testing"
84+
],
85+
"tsConfig": "tsconfig.spec.json",
86+
"assets": [
87+
{
88+
"glob": "**/*",
89+
"input": "public"
90+
}
91+
],
92+
"styles": [
93+
"src/styles.css"
94+
],
95+
"scripts": []
96+
}
97+
}
98+
}
99+
}
100+
}
101+
}

0 commit comments

Comments
 (0)