Skip to content

Commit 82efa18

Browse files
authored
Merge pull request #1147 from rollbar/update-angular-example
Update angular example
2 parents c4975ab + ee0d636 commit 82efa18

Some content is hidden

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

73 files changed

+15810
-122782
lines changed

CLAUDE.md

Lines changed: 28 additions & 0 deletions
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/angular2/.editorconfig renamed to examples/angular/.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ indent_size = 2
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11+
[*.ts]
12+
quote_type = single
13+
ij_typescript_use_double_quotes = false
14+
1115
[*.md]
1216
max_line_length = off
1317
trim_trailing_whitespace = false
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
1-
# See http://help.github.com/ignore-files/ for more about ignoring files.
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
22

3-
# compiled output
3+
# Compiled output
4+
/dist
45
/tmp
56
/out-tsc
6-
# Only exists if Bazel was run
77
/bazel-out
88

9-
# dependencies
9+
# Node
1010
/node_modules
11-
12-
# profiling files
13-
chrome-profiler-events.json
14-
speed-measure-plugin.json
11+
npm-debug.log
12+
yarn-error.log
1513

1614
# IDEs and editors
17-
/.idea
15+
.idea/
1816
.project
1917
.classpath
2018
.c9/
2119
*.launch
2220
.settings/
2321
*.sublime-workspace
2422

25-
# IDE - VSCode
23+
# Visual Studio Code
2624
.vscode/*
2725
!.vscode/settings.json
2826
!.vscode/tasks.json
2927
!.vscode/launch.json
3028
!.vscode/extensions.json
3129
.history/*
3230

33-
# misc
34-
/.sass-cache
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
3534
/connect.lock
3635
/coverage
3736
/libpeerconnection.log
38-
npm-debug.log
39-
yarn-error.log
4037
testem.log
4138
/typings
4239

43-
# System Files
40+
# System files
4441
.DS_Store
4542
Thumbs.db
Lines changed: 4 additions & 0 deletions
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+
}
Lines changed: 20 additions & 0 deletions
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+
}
Lines changed: 42 additions & 0 deletions
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

Lines changed: 45 additions & 0 deletions
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 support@rollbar.com

examples/angular/angular.json

Lines changed: 101 additions & 0 deletions
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)