Skip to content

Commit

Permalink
little refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
EddeCCC committed Oct 10, 2023
1 parent 812f938 commit 9a0d57f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
13 changes: 4 additions & 9 deletions src/impl/instrumentation/documentLoadInstrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,14 @@ export class CustomDocumentLoadInstrumentation extends DocumentLoadInstrumentati
const exposedSpan = span as any as Span;
if(exposedSpan.name == "documentLoad") TransactionSpanManager.setTransactionSpan(span);

if(span && exposedSpan.name == "documentLoad" && requestParameter?.enabled) {
if(requestParameter.excludeKeysFromBeacons) addUrlParams(span, location.href, requestParameter.excludeKeysFromBeacons);
else addUrlParams(span, location.href);
}
if(span && exposedSpan.name == "documentLoad" && requestParameter?.enabled)
addUrlParams(span, location.href, requestParameter.excludeKeysFromBeacons);

return span;
}

//Override function
exposedSuper._endSpan = (span, performanceName, entries) => {

const transactionSpan = TransactionSpanManager.getTransactionSpan();
// Don't close transactionSpan
// transactionSpan will be closed through "beforeunload"-event
Expand All @@ -184,10 +181,8 @@ export class CustomDocumentLoadInstrumentation extends DocumentLoadInstrumentati
const span = _superStartSpan(spanName, performanceName, entries, parentSpan);
const exposedSpan = span as any as Span;

if(span && exposedSpan.name == "documentLoad" && requestParameter?.enabled) {
if(requestParameter.excludeKeysFromBeacons) addUrlParams(span, location.href, requestParameter.excludeKeysFromBeacons);
else addUrlParams(span, location.href);
}
if(span && exposedSpan.name == "documentLoad" && requestParameter?.enabled)
addUrlParams(span, location.href, requestParameter.excludeKeysFromBeacons);

return span;
}
Expand Down
6 changes: 2 additions & 4 deletions src/impl/instrumentation/fetchInstrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ export class CustomFetchInstrumentation extends FetchInstrumentation {
exposedSuper._createSpan = (url, options = {}) => {
const span = _superCreateSpan(url, options);

if(span && requestParameter?.enabled) {
if(requestParameter.excludeKeysFromBeacons) addUrlParams(span, url, requestParameter.excludeKeysFromBeacons);
else addUrlParams(span, url);
}
if(span && requestParameter?.enabled)
addUrlParams(span, url, requestParameter.excludeKeysFromBeacons);

return span;
}
Expand Down
2 changes: 1 addition & 1 deletion src/impl/instrumentation/urlParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function addUrlParams(span: Span, url: string, excludeKeys: string[] = []
const [key, value] = keyValue.split("=");
span.setAttribute(key, value);

if(!excludeKeys.includes(key)) window.BOOMR.addVar(key, value);
if(excludeKeys && !excludeKeys.includes(key)) window.BOOMR.addVar(key, value);
}
}
}
6 changes: 2 additions & 4 deletions src/impl/instrumentation/userInteractionInstrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ export class CustomUserInteractionInstrumentation extends UserInteractionInstrum
exposedSuper._createSpan = (element, eventName, parentSpan) => {
const span = _superCreateSpan(element, eventName, parentSpan);

if(span && requestParameter?.enabled) {
if(requestParameter.excludeKeysFromBeacons) addUrlParams(span, location.href, requestParameter.excludeKeysFromBeacons);
else addUrlParams(span, location.href);
}
if(span && requestParameter?.enabled)
addUrlParams(span, location.href, requestParameter.excludeKeysFromBeacons);

return span;
}
Expand Down
6 changes: 2 additions & 4 deletions src/impl/instrumentation/xmlHttpRequestInstrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ export class CustomXMLHttpRequestInstrumentation extends XMLHttpRequestInstrumen
exposedSuper._createSpan = (xhr, url, method) => {
const span = _superCreateSpan(xhr, url, method);

if(span && requestParameter?.enabled) {
if(requestParameter.excludeKeysFromBeacons) addUrlParams(span, url, requestParameter.excludeKeysFromBeacons);
else addUrlParams(span, url);
}
if(span && requestParameter?.enabled)
addUrlParams(span, url, requestParameter.excludeKeysFromBeacons);

return span;
}
Expand Down

0 comments on commit 9a0d57f

Please sign in to comment.