Skip to content

Commit

Permalink
Merge pull request #118 from usermaven/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
seeratawan01 authored Oct 16, 2024
2 parents 06c80bc + 841bb22 commit b43252d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/javascript-sdk/src/core/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export class UsermavenClient {
let processedProps = eventProps || {};

const payload: any = {
event_id: generateId(),
event_id: '',
user: {
anonymous_id: this.anonymousId,
id: userId,
Expand Down
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 b43252d

Please sign in to comment.