Skip to content

Commit 542da5b

Browse files
committed
Address review comments.
1 parent a569e16 commit 542da5b

File tree

5 files changed

+44
-35
lines changed

5 files changed

+44
-35
lines changed

packages/angular/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
},
2929
"devDependencies": {
3030
"@angular-devkit/build-angular": "~0.1002.4",
31-
"@angular/animations": "~10.2.5",
3231
"@angular/cli": "^10.2.4",
3332
"@angular/common": "~10.2.5",
3433
"@angular/compiler": "^10.2.5",

packages/angular/test/tracing.test.ts

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ describe('Angular Tracing', () => {
120120

121121
expect(transaction.setName).toHaveBeenCalledTimes(0);
122122
expect(transaction.name).toEqual(url);
123+
expect(transaction.metadata.source).toBe('custom');
123124

124125
env.destroy();
125126
});
@@ -167,9 +168,6 @@ describe('Angular Tracing', () => {
167168
[
168169
'handles the root URL correctly',
169170
'/',
170-
{
171-
root: { firstChild: { routeConfig: null } },
172-
},
173171
'/',
174172
[
175173
{
@@ -181,9 +179,6 @@ describe('Angular Tracing', () => {
181179
[
182180
'does not alter static routes',
183181
'/books',
184-
{
185-
root: { firstChild: { routeConfig: { path: 'books' } } },
186-
},
187182
'/books/',
188183
[
189184
{
@@ -195,9 +190,6 @@ describe('Angular Tracing', () => {
195190
[
196191
'parameterizes IDs in the URL',
197192
'/books/1/details',
198-
{
199-
root: { firstChild: { routeConfig: { path: 'books/:bookId/details' } } },
200-
},
201193
'/books/:bookId/details/',
202194
[
203195
{
@@ -209,9 +201,6 @@ describe('Angular Tracing', () => {
209201
[
210202
'parameterizes multiple IDs in the URL',
211203
'/org/sentry/projects/1234/events/04bc6846-4a1e-4af5-984a-003258f33e31',
212-
{
213-
root: { firstChild: { routeConfig: { path: 'org/:orgId/projects/:projId/events/:eventId' } } },
214-
},
215204
'/org/:orgId/projects/:projId/events/:eventId/',
216205
[
217206
{
@@ -223,17 +212,6 @@ describe('Angular Tracing', () => {
223212
[
224213
'parameterizes URLs from route with child routes',
225214
'/org/sentry/projects/1234/events/04bc6846-4a1e-4af5-984a-003258f33e31',
226-
{
227-
root: {
228-
firstChild: {
229-
routeConfig: { path: 'org/:orgId' },
230-
firstChild: {
231-
routeConfig: { path: 'projects/:projId' },
232-
firstChild: { routeConfig: { path: 'events/:eventId' } },
233-
},
234-
},
235-
},
236-
},
237215
'/org/:orgId/projects/:projId/events/:eventId/',
238216
[
239217
{
@@ -254,15 +232,15 @@ describe('Angular Tracing', () => {
254232
},
255233
],
256234
],
257-
])('%s and sets the source to `route`', async (_, url, routerState, result, routes) => {
235+
])('%s and sets the source to `route`', async (_, url, result, routes) => {
258236
const customStartTransaction = jest.fn(defaultStartTransaction);
259237
const env = await TestEnv.setup({
260238
customStartTransaction,
261239
routes,
262240
startTransactionOnPageLoad: false,
263241
});
264242

265-
await env.navigateInAngular(url, routerState);
243+
await env.navigateInAngular(url);
266244

267245
expect(customStartTransaction).toHaveBeenCalledWith({
268246
name: url,
@@ -304,6 +282,32 @@ describe('Angular Tracing', () => {
304282
env.destroy();
305283
});
306284

285+
it('should use component name as span description', async () => {
286+
const directive = new TraceDirective();
287+
const finishMock = jest.fn();
288+
const customStartTransaction = jest.fn(defaultStartTransaction);
289+
290+
const env = await TestEnv.setup({
291+
components: [TraceDirective],
292+
customStartTransaction,
293+
useTraceService: false,
294+
});
295+
296+
transaction.startChild = jest.fn(() => ({
297+
finish: finishMock,
298+
}));
299+
300+
directive.componentName = 'test-component';
301+
directive.ngOnInit();
302+
303+
expect(transaction.startChild).toHaveBeenCalledWith({
304+
op: 'ui.angular.init',
305+
description: '<test-component>',
306+
});
307+
308+
env.destroy();
309+
});
310+
307311
it('should finish tracingSpan after view init', async () => {
308312
const directive = new TraceDirective();
309313
const finishMock = jest.fn();

packages/angular/test/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ export class TestEnv {
7575
return new TestEnv(router, fixture, traceService);
7676
}
7777

78-
public async navigateInAngular(url: string, routerState?: { [k: string]: any }): Promise<void> {
78+
public async navigateInAngular(url: string): Promise<void> {
7979
return new Promise(resolve => {
8080
return this.fixture.ngZone?.run(() => {
81-
void this.router.navigateByUrl(url, { state: routerState }).then(() => {
81+
void this.router.navigateByUrl(url).then(() => {
8282
this.fixture.detectChanges();
8383
resolve();
8484
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
3+
import { ErrorBoundaryComponent } from './types';
4+
5+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6+
export const withSentry = (OrigErrorBoundary: ErrorBoundaryComponent): ErrorBoundaryComponent => {
7+
return props => {
8+
const caught = props.error;
9+
console.log('CAUGHT', caught);
10+
11+
return <OrigErrorBoundary {...props} />;
12+
};
13+
};

yarn.lock

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@
128128
ora "5.0.0"
129129
rxjs "6.6.2"
130130

131-
"@angular/animations@~10.2.5":
132-
version "10.2.5"
133-
resolved "https://registry.yarnpkg.com/@angular/animations/-/animations-10.2.5.tgz#9b4aaa2a2f88f848decb5a03f2ddaa2aed37642d"
134-
integrity sha512-lIMwjY1pAqpCM4Ayndf2RsvOWRUc5QV7W82XNou6pIBv2T1i1XV6H72I5Sk9Z4sxxBYCWncEaEub+C6NcS8QRg==
135-
dependencies:
136-
tslib "^2.0.0"
137-
138131
"@angular/cli@^10.2.4":
139132
version "10.2.4"
140133
resolved "https://registry.yarnpkg.com/@angular/cli/-/cli-10.2.4.tgz#f8899eee8f774cd805b1831a8f2f865024e9f4e1"

0 commit comments

Comments
 (0)