@funnelsgrove/runtime 0.11.1 → 0.11.2

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.
@@ -68,6 +68,39 @@ const asTrimmedString = (value) => {
68
68
  const trimmed = value.trim();
69
69
  return trimmed || null;
70
70
  };
71
+ const readCookieValue = (name) => {
72
+ var _a;
73
+ if (typeof document === 'undefined') {
74
+ return null;
75
+ }
76
+ let cookieHeader;
77
+ try {
78
+ cookieHeader = document.cookie;
79
+ }
80
+ catch (_b) {
81
+ return null;
82
+ }
83
+ const encodedValue = (_a = cookieHeader
84
+ .split(';')
85
+ .map((part) => part.trim())
86
+ .find((part) => part.startsWith(`${name}=`))) === null || _a === void 0 ? void 0 : _a.slice(name.length + 1);
87
+ if (!encodedValue) {
88
+ return null;
89
+ }
90
+ try {
91
+ const value = asTrimmedString(decodeURIComponent(encodedValue));
92
+ return value && value.length <= 2048 ? value : null;
93
+ }
94
+ catch (_c) {
95
+ const value = asTrimmedString(encodedValue);
96
+ return value && value.length <= 2048 ? value : null;
97
+ }
98
+ };
99
+ const collectMetaCookieTouch = () => {
100
+ const fbc = readCookieValue('_fbc');
101
+ const fbp = readCookieValue('_fbp');
102
+ return Object.assign(Object.assign({}, (fbc ? { fbc } : {})), (fbp ? { fbp } : {}));
103
+ };
71
104
  const isRecord = (value) => {
72
105
  return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
73
106
  };
@@ -242,7 +275,7 @@ export const collectCurrentFunnelAttribution = (input = {}) => {
242
275
  const timeZone = asTrimmedString(input.timeZone) || browserContext.timeZone;
243
276
  const currentUrl = toUrl(href);
244
277
  const referrerUrl = toUrl(referrer);
245
- const firstTouch = collectTouchFromUrl(currentUrl);
278
+ const firstTouch = Object.assign(Object.assign({}, collectMetaCookieTouch()), collectTouchFromUrl(currentUrl));
246
279
  const posthogContext = collectPostHogContext(resolvePostHogProperties(input.posthogProperties));
247
280
  return {
248
281
  firstTouch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",