Skip to content

Commit

Permalink
Only capture external urls
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Jun 21, 2024
1 parent d065721 commit e60c7e5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/autocapture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import { AUTOCAPTURE_DISABLED_SERVER_SIDE } from './constants'

import { isBoolean, isFunction, isNull, isObject, isUndefined } from './utils/type-utils'
import { logger } from './utils/logger'
import { document, window } from './utils/globals'
import { document, location, window } from './utils/globals'
import { convertToURL } from './utils/request-utils'

const COPY_AUTOCAPTURE_EVENT = '$copy_autocapture'

Expand Down Expand Up @@ -322,8 +323,13 @@ export class Autocapture {
}
}

let externalClickHref: string | undefined
if (href) {
elementsJson[0]['attr__href'] = href
const hrefHost = convertToURL(href)?.host
if (e.type === 'click' && hrefHost && location?.host && hrefHost !== location.host) {
externalClickHref = href
}
}

if (explicitNoCapture) {
Expand All @@ -340,7 +346,7 @@ export class Autocapture {
$elements: elementsJson,
},
elementsJson[0]?.['$el_text'] ? { $el_text: elementsJson[0]?.['$el_text'] } : {},
e.type === 'click' && href ? { $click_href: href } : {},
externalClickHref ? { $external_click_href: externalClickHref } : {},
autocaptureAugmentProperties
)

Expand Down

0 comments on commit e60c7e5

Please sign in to comment.