MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / ngOnInit

Method ngOnInit

packages/angular/src/tracing.ts:263–281  ·  view source on GitHub ↗

* Implementation of OnInit lifecycle method * @inheritdoc

()

Source from the content-addressed store, hash-verified

261 * @inheritdoc
262 */
263 public ngOnInit(): void {
264 if (!this.componentName) {
265 // Technically, the `trace` binding should always be provided.
266 // However, if it is incorrectly declared on the element without a
267 // value (e.g., `<app-component trace />`), we fall back to using `tagName`
268 // (which is e.g. `APP-COMPONENT`).
269 this.componentName = this._host.nativeElement.tagName.toLowerCase();
270 }
271
272 if (getActiveSpan()) {
273 this._tracingSpan = runOutsideAngular(() =>
274 startInactiveSpan({
275 name: `<${this.componentName}>`,
276 op: ANGULAR_INIT_OP,
277 attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular.trace_directive' },
278 }),
279 );
280 }
281 }
282
283 /**
284 * Implementation of AfterViewInit lifecycle method

Callers

nothing calls this directly

Calls 3

runOutsideAngularFunction · 0.90
getActiveSpanFunction · 0.50
startInactiveSpanFunction · 0.50

Tested by

no test coverage detected