Skip to content

Commit b3dad24

Browse files
authored
feat(angular): Support Angular 19 (#14398)
Add support for the new major version by bumping peer dependencies and adding an Angular 19 e2e test app.
1 parent 2435b87 commit b3dad24

26 files changed

+866
-7
lines changed
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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
43+
44+
test-results
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Angular 19
2+
3+
E2E test app for Angular 19 and `@sentry/angular`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"angular-19": {
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-19",
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+
},
34+
"configurations": {
35+
"production": {
36+
"budgets": [
37+
{
38+
"type": "initial",
39+
"maximumWarning": "500kB",
40+
"maximumError": "1MB"
41+
},
42+
{
43+
"type": "anyComponentStyle",
44+
"maximumWarning": "4kB",
45+
"maximumError": "8kB"
46+
}
47+
],
48+
"outputHashing": "all"
49+
},
50+
"development": {
51+
"optimization": false,
52+
"extractLicenses": false,
53+
"sourceMap": true
54+
}
55+
},
56+
"defaultConfiguration": "production"
57+
},
58+
"serve": {
59+
"builder": "@angular-devkit/build-angular:dev-server",
60+
"configurations": {
61+
"production": {
62+
"buildTarget": "angular-19:build:production"
63+
},
64+
"development": {
65+
"buildTarget": "angular-19:build:development"
66+
}
67+
},
68+
"defaultConfiguration": "development"
69+
},
70+
"extract-i18n": {
71+
"builder": "@angular-devkit/build-angular:extract-i18n"
72+
},
73+
"test": {
74+
"builder": "@angular-devkit/build-angular:karma",
75+
"options": {
76+
"polyfills": [
77+
"zone.js",
78+
"zone.js/testing"
79+
],
80+
"tsConfig": "tsconfig.spec.json",
81+
"assets": [
82+
{
83+
"glob": "**/*",
84+
"input": "public"
85+
}
86+
],
87+
"styles": [
88+
"src/styles.css"
89+
],
90+
"scripts": []
91+
}
92+
}
93+
}
94+
}
95+
}
96+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "angular-19",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"dev": "ng serve",
7+
"proxy": "node start-event-proxy.mjs",
8+
"preview": "http-server dist/angular-19/browser --port 8080",
9+
"build": "ng build",
10+
"watch": "ng build --watch --configuration development",
11+
"test": "playwright test",
12+
"test:build": "pnpm install && npx playwright install && pnpm build",
13+
"test:assert": "playwright test",
14+
"clean": "npx rimraf .angular node_modules pnpm-lock.yaml dist"
15+
},
16+
"private": true,
17+
"dependencies": {
18+
"@angular/animations": "^19.0.0",
19+
"@angular/common": "^19.0.0",
20+
"@angular/compiler": "^19.0.0",
21+
"@angular/core": "^19.0.0",
22+
"@angular/forms": "^19.0.0",
23+
"@angular/platform-browser": "^19.0.0",
24+
"@angular/platform-browser-dynamic": "^19.0.0",
25+
"@angular/router": "^19.0.0",
26+
"@sentry/angular": "* || latest",
27+
"rxjs": "~7.8.0",
28+
"tslib": "^2.3.0",
29+
"zone.js": "~0.15.0"
30+
},
31+
"devDependencies": {
32+
"@angular-devkit/build-angular": "^19.0.0",
33+
"@angular/cli": "^19.0.0",
34+
"@angular/compiler-cli": "^19.0.0",
35+
"@playwright/test": "^1.44.1",
36+
"@sentry-internal/test-utils": "link:../../../test-utils",
37+
"@types/jasmine": "~5.1.0",
38+
"http-server": "^14.1.1",
39+
"jasmine-core": "~5.4.0",
40+
"karma": "~6.4.0",
41+
"karma-chrome-launcher": "~3.2.0",
42+
"karma-coverage": "~2.2.0",
43+
"karma-jasmine": "~5.1.0",
44+
"karma-jasmine-html-reporter": "~2.1.0",
45+
"typescript": "~5.6.2"
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const config = getPlaywrightConfig({
4+
startCommand: `pnpm preview`,
5+
port: 8080,
6+
});
7+
8+
export default config;
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Component } from '@angular/core';
2+
import { RouterOutlet } from '@angular/router';
3+
4+
@Component({
5+
selector: 'app-root',
6+
standalone: true,
7+
imports: [RouterOutlet],
8+
template: `<router-outlet></router-outlet>`,
9+
})
10+
export class AppComponent {
11+
title = 'angular-19';
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
ApplicationConfig,
3+
ErrorHandler,
4+
inject,
5+
provideAppInitializer,
6+
provideZoneChangeDetection,
7+
} from '@angular/core';
8+
import { Router, provideRouter } from '@angular/router';
9+
10+
import { TraceService, createErrorHandler } from '@sentry/angular';
11+
import { routes } from './app.routes';
12+
13+
export const appConfig: ApplicationConfig = {
14+
providers: [
15+
provideZoneChangeDetection({ eventCoalescing: true }),
16+
provideRouter(routes),
17+
{
18+
provide: ErrorHandler,
19+
useValue: createErrorHandler(),
20+
},
21+
{
22+
provide: TraceService,
23+
deps: [Router],
24+
},
25+
provideAppInitializer(() => {
26+
inject(TraceService);
27+
}),
28+
],
29+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Routes } from '@angular/router';
2+
import { cancelGuard } from './cancel-guard.guard';
3+
import { CancelComponent } from './cancel/cancel.components';
4+
import { ComponentTrackingComponent } from './component-tracking/component-tracking.components';
5+
import { HomeComponent } from './home/home.component';
6+
import { UserComponent } from './user/user.component';
7+
8+
export const routes: Routes = [
9+
{
10+
path: 'users/:id',
11+
component: UserComponent,
12+
},
13+
{
14+
path: 'home',
15+
component: HomeComponent,
16+
},
17+
{
18+
path: 'cancel',
19+
component: CancelComponent,
20+
canActivate: [cancelGuard],
21+
},
22+
{
23+
path: 'component-tracking',
24+
component: ComponentTrackingComponent,
25+
},
26+
{
27+
path: 'redirect1',
28+
redirectTo: '/redirect2',
29+
},
30+
{
31+
path: 'redirect2',
32+
redirectTo: '/redirect3',
33+
},
34+
{
35+
path: 'redirect3',
36+
redirectTo: '/users/456',
37+
},
38+
{
39+
path: '**',
40+
redirectTo: 'home',
41+
},
42+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ActivatedRouteSnapshot, CanActivateFn, RouterStateSnapshot } from '@angular/router';
2+
3+
export const cancelGuard: CanActivateFn = (_next: ActivatedRouteSnapshot, _state: RouterStateSnapshot) => {
4+
return false;
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-cancel',
5+
standalone: true,
6+
template: `<div></div>`,
7+
})
8+
export class CancelComponent {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { AfterViewInit, Component, OnInit } from '@angular/core';
2+
import { TraceClass, TraceMethod, TraceModule } from '@sentry/angular';
3+
import { SampleComponent } from '../sample-component/sample-component.components';
4+
5+
@Component({
6+
selector: 'app-cancel',
7+
standalone: true,
8+
imports: [TraceModule, SampleComponent],
9+
template: `<app-sample-component [trace]="'sample-component'"></app-sample-component>`,
10+
})
11+
@TraceClass({ name: 'ComponentTrackingComponent' })
12+
export class ComponentTrackingComponent implements OnInit, AfterViewInit {
13+
@TraceMethod({ name: 'ngOnInit' })
14+
ngOnInit() {}
15+
16+
@TraceMethod()
17+
ngAfterViewInit() {}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Component } from '@angular/core';
2+
import { RouterLink } from '@angular/router';
3+
4+
@Component({
5+
selector: 'app-home',
6+
standalone: true,
7+
imports: [RouterLink],
8+
template: `
9+
<main>
10+
<h1>Welcome to Sentry's Angular 19 E2E test app</h1>
11+
<ul>
12+
<li> <a id="navLink" [routerLink]="['/users', '123']">Visit User 123</a> </li>
13+
<li> <a id="redirectLink" [routerLink]="['/redirect1']">Redirect</a> </li>
14+
<li> <a id="cancelLink" [routerLink]="['/cancel']">Cancel</a> </li>
15+
<li> <a id="nonExistentLink" [routerLink]="['/non-existent']">Error</a> </li>
16+
<li> <a id="componentTracking" [routerLink]="['/component-tracking']">Component Tracking</a> </li>
17+
</ul>
18+
<button id="errorBtn" (click)="throwError()">Throw error</button>
19+
</main>
20+
`,
21+
})
22+
export class HomeComponent {
23+
throwError() {
24+
throw new Error('Error thrown from Angular 18 E2E test app');
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-sample-component',
5+
standalone: true,
6+
template: `<div>Component</div>`,
7+
})
8+
export class SampleComponent implements OnInit {
9+
ngOnInit() {
10+
console.log('SampleComponent');
11+
}
12+
}

0 commit comments

Comments
 (0)