From a95fec2aa9fa55df9c0481f4c303b07908b27acf Mon Sep 17 00:00:00 2001 From: Xinyi Ye Date: Thu, 29 Aug 2024 11:29:24 -0700 Subject: [PATCH] fix: configuration.defaultTracking is false --- src/amplitude-wrapper.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/amplitude-wrapper.js b/src/amplitude-wrapper.js index 1050053..530ef54 100644 --- a/src/amplitude-wrapper.js +++ b/src/amplitude-wrapper.js @@ -155,14 +155,16 @@ var amplitudeUserAgentEnrichmentPlugin=function(i){"use strict";var e=function() const argsLength = args.length; const configuration = args[argsLength - 1]; - const excludeReferrers = [ - ...configuration.defaultTracking.attribution.excludeReferrersText || [], - ...configuration.defaultTracking.attribution.excludeReferrersRegex?.map(item => new RegExp(item)) || [] - ]; - delete configuration.defaultTracking.attribution.excludeReferrersText; - delete configuration.defaultTracking.attribution.excludeReferrersRegex; - configuration.defaultTracking.attribution.excludeReferrers = excludeReferrers; - + if (configuration.defaultTracking.attribution) { + const excludeReferrers = [ + ...(configuration.defaultTracking.attribution.excludeReferrersText || []), + ...(configuration.defaultTracking.attribution.excludeReferrersRegex?.map(item => new RegExp(item)) || []) + ]; + delete configuration.defaultTracking.attribution.excludeReferrersText; + delete configuration.defaultTracking.attribution.excludeReferrersRegex; + configuration.defaultTracking.attribution.excludeReferrers = excludeReferrers; + } + const userAgentEnrichmentOptions = configuration['userAgentEnrichmentOptions']; const pageViewLegacy = configuration['pageViewLegacy'];