(options?: TraceClassOptions)
| 312 | * Decorator function that can be used to capture initialization lifecycle of the whole component. |
| 313 | */ |
| 314 | export function TraceClass(options?: TraceClassOptions): ClassDecorator { |
| 315 | let tracingSpan: Span; |
| 316 | |
| 317 | /* eslint-disable @typescript-eslint/no-unsafe-member-access */ |
| 318 | return target => { |
| 319 | const originalOnInit = target.prototype.ngOnInit; |
| 320 | target.prototype.ngOnInit = function (...args: unknown[]): ReturnType<typeof originalOnInit> { |
| 321 | tracingSpan = runOutsideAngular(() => |
| 322 | startInactiveSpan({ |
| 323 | onlyIfParent: true, |
| 324 | name: `<${options?.name || 'unnamed'}>`, |
| 325 | op: ANGULAR_INIT_OP, |
| 326 | attributes: { |
| 327 | [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular.trace_class_decorator', |
| 328 | }, |
| 329 | }), |
| 330 | ); |
| 331 | |
| 332 | if (originalOnInit) { |
| 333 | return originalOnInit.apply(this, args); |
| 334 | } |
| 335 | }; |
| 336 | |
| 337 | const originalAfterViewInit = target.prototype.ngAfterViewInit; |
| 338 | target.prototype.ngAfterViewInit = function (...args: unknown[]): ReturnType<typeof originalAfterViewInit> { |
| 339 | if (tracingSpan) { |
| 340 | runOutsideAngular(() => tracingSpan.end()); |
| 341 | } |
| 342 | if (originalAfterViewInit) { |
| 343 | return originalAfterViewInit.apply(this, args); |
| 344 | } |
| 345 | }; |
| 346 | }; |
| 347 | /* eslint-enable @typescript-eslint/no-unsafe-member-access */ |
| 348 | } |
| 349 | |
| 350 | interface TraceMethodOptions { |
| 351 | /** |
no test coverage detected