From 7685c852ccd2167b1318489748712902c8900725 Mon Sep 17 00:00:00 2001 From: Diljit Date: Mon, 23 Sep 2024 08:21:07 +0530 Subject: [PATCH] chore: fix this.rootSpan undefined bug in PageLoadInstrumentation (#36459) --- .../src/UITelemetry/PageLoadInstrumentation.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/client/src/UITelemetry/PageLoadInstrumentation.ts b/app/client/src/UITelemetry/PageLoadInstrumentation.ts index ccb173d0b4af..801038068b11 100644 --- a/app/client/src/UITelemetry/PageLoadInstrumentation.ts +++ b/app/client/src/UITelemetry/PageLoadInstrumentation.ts @@ -41,15 +41,12 @@ export class PageLoadInstrumentation extends InstrumentationBase { this.ignoreResourceUrls = ignoreResourceUrls; // Start the root span for the page load this.rootSpan = startRootSpan("PAGE_LOAD", {}, 0); - } - init() { - // init method is present in the base class and needs to be implemented - // This is method is never called by the OpenTelemetry SDK - // Leaving it empty as it is done by other OpenTelemetry instrumentation classes + // Initialize the instrumentation after starting the root span + this.init(); } - enable(): void { + init() { // Register connection change listener this.addConnectionAttributes(); @@ -71,6 +68,11 @@ export class PageLoadInstrumentation extends InstrumentationBase { } } + enable() { + // enable method is present in the base class and needs to be implemented + // Leaving it empty as there is no need to do anything here + } + private addDeviceAttributes() { this.rootSpan.setAttributes({ deviceMemory: (navigator as TNavigator).deviceMemory,