diff --git a/src/autocapture.ts b/src/autocapture.ts index 9a4ae0a685..09d4aa48f2 100644 --- a/src/autocapture.ts +++ b/src/autocapture.ts @@ -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' @@ -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) { @@ -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 )