Skip to content

Commit

Permalink
fix: attr__href missing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
seeratawan01 committed Oct 16, 2024
1 parent 7da38c3 commit 841bb22
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/javascript-sdk/src/tracking/autocapture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,21 @@ class AutoCapture {

private getElementsJson(targetElementList: Element[], e: Event): any[] {
const elementsJson: any[] = [];
let href;
let href: false | string | null = null;
let explicitNoCapture = false;

_each(targetElementList, (el) => {
if (isTag(el, 'a')) {
href = el.getAttribute('href');
href = shouldCaptureElement(el) && shouldCaptureValue(href) && href;
}

// Check for 'ph-no-capture' class
const classes = getClassName(el).split(' ');
if (_includes(classes, 'ph-no-capture')) {
explicitNoCapture = true;
}

elementsJson.push(this.getPropertiesFromElement(el));
});

Expand All @@ -178,7 +185,7 @@ class AutoCapture {
elementsJson[0]['attr__href'] = this.sanitizeUrl(href);
}

return elementsJson;
return explicitNoCapture ? [] : elementsJson;
}

private getPropertiesFromElement(element: Element): any {
Expand Down

0 comments on commit 841bb22

Please sign in to comment.