From d06a45170559665d0069b1afa0f33172f6ee6f2f Mon Sep 17 00:00:00 2001 From: NavaBeginsky <62503538+NavaBeginsky@users.noreply.github.com> Date: Tue, 13 Jul 2021 16:18:16 +0300 Subject: [PATCH] fix(web): window hash (#12) --- packages/web/src/exporter.js | 3 ++- packages/web/src/formatter.js | 4 ++-- .../web/src/instrumentation/documentLoadInstrumentation.js | 1 + packages/web/src/web-tracer.js | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/web/src/exporter.js b/packages/web/src/exporter.js index f981846..56a4ad9 100644 --- a/packages/web/src/exporter.js +++ b/packages/web/src/exporter.js @@ -33,6 +33,7 @@ class EpsagonExporter extends CollectorTraceExporter { } convert(spans) { + console.log(spans) try { const convertedSpans = super.convert(spans); const spansList = convertedSpans.resourceSpans[0].instrumentationLibrarySpans; @@ -149,7 +150,7 @@ class EpsagonExporter extends CollectorTraceExporter { spanErrs.push(spanStringError); const attributesLength = this.addFinalGenericSpanAttrs(span.attributes, span.attributes.length, span); - span.name = window.location.pathname; + span.name = `${window.location.pathname}${window.location.hash}`; span.events.unshift({ name: 'exception', attributes: [ diff --git a/packages/web/src/formatter.js b/packages/web/src/formatter.js index 67fa650..111a8a3 100644 --- a/packages/web/src/formatter.js +++ b/packages/web/src/formatter.js @@ -6,14 +6,14 @@ class EpsagonFormatter { } formatRouteChangeSpan(span, spanAttributes, attributesLength, userAgent) { - span.name = window.location.pathname; + span.name = `${window.location.pathname}${window.location.hash}`; spanAttributes[attributesLength] = { key: 'http.request.headers.User-Agent', value: { stringValue: JSON.stringify(userAgent).replace(/"([^"]+)":/g, '$1:') } }; attributesLength++; return attributesLength; } formatDocumentLoadSpan(span, spanAttributes, attributesLength) { - span.name = window.location.pathname; + span.name = `${window.location.pathname}${window.location.hash}`; spanAttributes[attributesLength] = { key: 'type', value: { stringValue: 'browser' } }; attributesLength++; spanAttributes[attributesLength] = { key: 'operation', value: { stringValue: 'page_load' } }; diff --git a/packages/web/src/instrumentation/documentLoadInstrumentation.js b/packages/web/src/instrumentation/documentLoadInstrumentation.js index 23f0f9a..2c90543 100644 --- a/packages/web/src/instrumentation/documentLoadInstrumentation.js +++ b/packages/web/src/instrumentation/documentLoadInstrumentation.js @@ -45,6 +45,7 @@ class EpsagonDocumentLoadInstrumentation extends DocumentLoadInstrumentation { if (initialSpan && !this.epsParentSpan.currentSpan) { this.epsParentSpan.currentSpan = initialSpan; } + console.log(initialSpan) this.addEpsSpanAttrs(initialSpan); return initialSpan; } diff --git a/packages/web/src/web-tracer.js b/packages/web/src/web-tracer.js index 141c1b1..250badb 100644 --- a/packages/web/src/web-tracer.js +++ b/packages/web/src/web-tracer.js @@ -70,6 +70,7 @@ function tag(key, value){ let _configData; function init (configData) { + console.log('initializing') _configData = configData; if (configData.isEpsagonDisabled) { return;