@funnelsgrove/runtime 0.1.61 → 0.1.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -22,6 +22,15 @@ const EVENT_ATTRIBUTION_CLICK_ID_KEYS = new Set([
|
|
|
22
22
|
'twclid',
|
|
23
23
|
'wbraid',
|
|
24
24
|
]);
|
|
25
|
+
const EVENT_ATTRIBUTION_FILTER_KEYS = new Set([
|
|
26
|
+
'utm_source',
|
|
27
|
+
'utm_medium',
|
|
28
|
+
'utm_campaign',
|
|
29
|
+
'utm_content',
|
|
30
|
+
'utm_term',
|
|
31
|
+
'adset_id',
|
|
32
|
+
]);
|
|
33
|
+
const MAX_EVENT_ATTRIBUTION_FILTER_VALUE_CODE_POINTS = 256;
|
|
25
34
|
const POSTHOG_CONTEXT_MAPPINGS = {
|
|
26
35
|
$geoip_city_name: 'cityName',
|
|
27
36
|
$geoip_country_code: 'countryCode',
|
|
@@ -57,12 +66,18 @@ const normalizeTouch = (value) => {
|
|
|
57
66
|
return [[normalizedKey, normalizedValue]];
|
|
58
67
|
}));
|
|
59
68
|
};
|
|
60
|
-
const isEventAttributionKey = (key) => {
|
|
61
|
-
const normalizedKey = key.trim().toLowerCase();
|
|
62
|
-
return normalizedKey.startsWith('utm_') || EVENT_ATTRIBUTION_CLICK_ID_KEYS.has(normalizedKey);
|
|
63
|
-
};
|
|
64
69
|
const normalizeEventAttributionTouch = (value) => {
|
|
65
|
-
return Object.fromEntries(Object.entries(normalizeTouch(value)).
|
|
70
|
+
return Object.fromEntries(Object.entries(normalizeTouch(value)).flatMap(([key, normalizedValue]) => {
|
|
71
|
+
const canonicalKey = key.toLowerCase();
|
|
72
|
+
if (EVENT_ATTRIBUTION_FILTER_KEYS.has(canonicalKey)) {
|
|
73
|
+
return Array.from(normalizedValue).length <= MAX_EVENT_ATTRIBUTION_FILTER_VALUE_CODE_POINTS
|
|
74
|
+
? [[canonicalKey, normalizedValue]]
|
|
75
|
+
: [];
|
|
76
|
+
}
|
|
77
|
+
return EVENT_ATTRIBUTION_CLICK_ID_KEYS.has(canonicalKey)
|
|
78
|
+
? [[key, normalizedValue]]
|
|
79
|
+
: [];
|
|
80
|
+
}));
|
|
66
81
|
};
|
|
67
82
|
const normalizeContext = (value) => {
|
|
68
83
|
if (!isRecord(value)) {
|