gatsby-core-theme 44.6.5 → 44.7.1
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.
- package/CHANGELOG.md +29 -0
- package/package.json +1 -1
- package/src/helpers/tracker.mjs +61 -38
- package/src/helpers/tracker.test.js +43 -33
- package/src/resolver/modules.mjs +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## [44.7.1](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.7.0...v44.7.1) (2025-11-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* process faq ([4c47357](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/4c473570c2d0beeed83203c3df210886ec14dadb))
|
|
7
|
+
|
|
8
|
+
# [44.7.0](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.6.5...v44.7.0) (2025-11-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* check if document is defined ([66d9a72](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/66d9a72b0558554f067397eeecc5154babf511e8))
|
|
14
|
+
* check if document is defined ([f494c2e](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/f494c2eb9ac11fde9cca672e19ee188a11f59fa9))
|
|
15
|
+
* check if url is defined ([fd48ca0](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/fd48ca061cf9f28214b2da2fba94df10715d2a5a))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
* Merge branch 'en-219-aff-object' into 'master' ([dc0c407](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/dc0c4077fe66195a7ec18cb72b822a07a85379fc))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* affObject helper ([9933dd5](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/9933dd593c2de10742a4a6385bf8a66ff6316a82))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Tests
|
|
27
|
+
|
|
28
|
+
* aff object ([16e96a1](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/16e96a1ae81531a12cfa0c295ff245062076a586))
|
|
29
|
+
|
|
1
30
|
## [44.6.5](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.6.4...v44.6.5) (2025-11-10)
|
|
2
31
|
|
|
3
32
|
|
package/package.json
CHANGED
package/src/helpers/tracker.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable no-underscore-dangle */
|
|
3
3
|
import { generateTrackerLink } from "./generators.mjs";
|
|
4
4
|
import { stripSuffixSlash } from "./strings.mjs";
|
|
5
|
+
import { getCookie } from "./cookies.js";
|
|
5
6
|
|
|
6
7
|
export function getTrackerName(operator, page, path) {
|
|
7
8
|
const trackerLinks = operator ? Object.keys(operator.links) : [];
|
|
@@ -64,25 +65,24 @@ function clean(obj) {
|
|
|
64
65
|
|
|
65
66
|
export function filterCfKeys(data) {
|
|
66
67
|
const allowedKeys = [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
"cf-iplongitude",
|
|
69
|
+
"cf-iplatitude",
|
|
70
|
+
"cf-ipcontinent",
|
|
71
|
+
"cf-ipcity",
|
|
72
|
+
"cf-region-code",
|
|
73
|
+
"cf-region",
|
|
74
|
+
"cf-postal-code",
|
|
75
|
+
"cf-ipcountry",
|
|
75
76
|
];
|
|
76
77
|
|
|
77
78
|
return Object.keys(data)
|
|
78
|
-
.filter(key => allowedKeys.includes(key))
|
|
79
|
+
.filter((key) => allowedKeys.includes(key))
|
|
79
80
|
.reduce((obj, key) => {
|
|
80
81
|
obj[key] = data[key];
|
|
81
82
|
return obj;
|
|
82
83
|
}, {});
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
|
|
86
86
|
// Helper to parse cookies from headers
|
|
87
87
|
function parseCookies(headers) {
|
|
88
88
|
const cookies = headers?.get("cookie");
|
|
@@ -95,19 +95,21 @@ function parseCookies(headers) {
|
|
|
95
95
|
acc[key.trim().replace('"', "")] = value;
|
|
96
96
|
return acc;
|
|
97
97
|
}, {});
|
|
98
|
-
}
|
|
98
|
+
}
|
|
99
99
|
|
|
100
100
|
// Helper to extract URL query parameters
|
|
101
101
|
function extractUrlParams(url) {
|
|
102
102
|
if (!url || !url.includes("?")) return null;
|
|
103
103
|
return deparam(url.split("?")[1]);
|
|
104
|
-
}
|
|
104
|
+
}
|
|
105
105
|
|
|
106
106
|
// Helper to construct URL parameters
|
|
107
107
|
function buildUrlParams(operator, trackerName, headers, cookie, extraParams) {
|
|
108
108
|
const ip = headers?.get("x-real-ip") || headers?.get("host") || "127.0.0.1";
|
|
109
109
|
const userAgent = headers?.get("user-agent") || null;
|
|
110
|
-
const affObject = isJsonString(cookie.affObject)
|
|
110
|
+
const affObject = isJsonString(cookie.affObject)
|
|
111
|
+
? JSON.parse(cookie.affObject)
|
|
112
|
+
: {};
|
|
111
113
|
|
|
112
114
|
if (extraParams && extraParams.pt) affObject.module = extraParams.pt;
|
|
113
115
|
|
|
@@ -130,10 +132,12 @@ function buildUrlParams(operator, trackerName, headers, cookie, extraParams) {
|
|
|
130
132
|
facebook_pixel_id: process.env.PIXEL_ID || null,
|
|
131
133
|
cookie: JSON.stringify(cookie),
|
|
132
134
|
...(affObject || {}),
|
|
133
|
-
...(affObject && !affObject.referer
|
|
135
|
+
...(affObject && !affObject.referer
|
|
136
|
+
? { referer: headers?.get("referrer") }
|
|
137
|
+
: {}),
|
|
134
138
|
...(extraParams || {}),
|
|
135
139
|
};
|
|
136
|
-
}
|
|
140
|
+
}
|
|
137
141
|
|
|
138
142
|
// Main function
|
|
139
143
|
export async function getAffiliateLink(operator, path, page, headers, url) {
|
|
@@ -141,8 +145,14 @@ export async function getAffiliateLink(operator, path, page, headers, url) {
|
|
|
141
145
|
const trackerName = await getTrackerName(operator, page, path);
|
|
142
146
|
const cookie = parseCookies(headers);
|
|
143
147
|
const extraParams = extractUrlParams(url);
|
|
144
|
-
|
|
145
|
-
const urlParam = buildUrlParams(
|
|
148
|
+
|
|
149
|
+
const urlParam = buildUrlParams(
|
|
150
|
+
operator,
|
|
151
|
+
trackerName,
|
|
152
|
+
headers,
|
|
153
|
+
cookie,
|
|
154
|
+
extraParams
|
|
155
|
+
);
|
|
146
156
|
|
|
147
157
|
const queryString = new URLSearchParams(clean(urlParam)).toString();
|
|
148
158
|
const trackingUrl = `${process.env.GATSBY_TRACKING_API_URL}?${queryString}`;
|
|
@@ -154,12 +164,44 @@ export async function getAffiliateLink(operator, path, page, headers, url) {
|
|
|
154
164
|
// Parse the response
|
|
155
165
|
const data = res.ok ? await res.json() : { success: false };
|
|
156
166
|
return { props: data };
|
|
157
|
-
|
|
158
167
|
} catch (error) {
|
|
159
168
|
console.error("Error fetching affiliate link:", error);
|
|
160
169
|
return { props: { success: false } };
|
|
161
170
|
}
|
|
162
171
|
}
|
|
172
|
+
export function getSocialIDs(url) {
|
|
173
|
+
const affObject = {};
|
|
174
|
+
|
|
175
|
+
if (url && url.split("?").length === 2) {
|
|
176
|
+
// eslint-disable-next-line prefer-destructuring
|
|
177
|
+
affObject.request_url = url.split("?")[0];
|
|
178
|
+
const extraData = deparam(url.split("?")[1]);
|
|
179
|
+
|
|
180
|
+
if (extraData.msclkid) {
|
|
181
|
+
affObject.microsoft_click_id = extraData.msclkid;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (extraData.gclid) {
|
|
185
|
+
affObject.google_click_id = extraData.gclid;
|
|
186
|
+
}
|
|
187
|
+
if (extraData.fbclid) {
|
|
188
|
+
affObject.facebook_click_id = extraData.fbclid;
|
|
189
|
+
}
|
|
190
|
+
} else if (url) {
|
|
191
|
+
affObject.request_url = url;
|
|
192
|
+
}
|
|
193
|
+
if (typeof document !== "undefined") {
|
|
194
|
+
const facebookBrowserId = getCookie("_fbp");
|
|
195
|
+
|
|
196
|
+
if (facebookBrowserId) affObject.facebook_browser_id = facebookBrowserId;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const pixelId = process.env.PIXEL_ID;
|
|
200
|
+
|
|
201
|
+
if (pixelId) affObject.facebook_pixel_id = pixelId;
|
|
202
|
+
|
|
203
|
+
return affObject;
|
|
204
|
+
}
|
|
163
205
|
|
|
164
206
|
export function getTrackingAPIParams(
|
|
165
207
|
pageTemplate,
|
|
@@ -172,7 +214,6 @@ export function getTrackingAPIParams(
|
|
|
172
214
|
itemPosition
|
|
173
215
|
) {
|
|
174
216
|
const urlParams = {};
|
|
175
|
-
let extraData = {};
|
|
176
217
|
|
|
177
218
|
if (pageTemplate) {
|
|
178
219
|
urlParams.page_type = pageTemplate;
|
|
@@ -199,25 +240,7 @@ export function getTrackingAPIParams(
|
|
|
199
240
|
if (itemPosition) {
|
|
200
241
|
urlParams.module_click_position = itemPosition;
|
|
201
242
|
}
|
|
202
|
-
|
|
203
|
-
if (url && url.split("?").length === 2) {
|
|
204
|
-
// eslint-disable-next-line prefer-destructuring
|
|
205
|
-
urlParams.request_url = url.split("?")[0];
|
|
206
|
-
extraData = deparam(url.split("?")[1]);
|
|
207
|
-
|
|
208
|
-
if (extraData.msclkid) {
|
|
209
|
-
extraData.microsoft_click_id = extraData.msclkid;
|
|
210
|
-
delete extraData.msclkid;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (extraData.gclid) {
|
|
214
|
-
extraData.google_click_id = extraData.gclid;
|
|
215
|
-
delete extraData.gclid;
|
|
216
|
-
}
|
|
217
|
-
} else if (url) {
|
|
218
|
-
urlParams.request_url = url;
|
|
219
|
-
}
|
|
220
|
-
|
|
243
|
+
const extraData = getSocialIDs(url);
|
|
221
244
|
return { ...urlParams, ...extraData };
|
|
222
245
|
}
|
|
223
246
|
|
|
@@ -18,7 +18,17 @@ describe("Tracker Helper", () => {
|
|
|
18
18
|
market: "ie_en",
|
|
19
19
|
links: {},
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
test("getSocialIDs", () => {
|
|
22
|
+
const affObject = Tracker.getSocialIDs(
|
|
23
|
+
"https://example.com?fbclid=12345&gclid=67890&msclkid=abcde"
|
|
24
|
+
);
|
|
25
|
+
expect(affObject).toEqual({
|
|
26
|
+
request_url: "https://example.com",
|
|
27
|
+
facebook_click_id: "12345",
|
|
28
|
+
google_click_id: "67890",
|
|
29
|
+
microsoft_click_id: "abcde",
|
|
30
|
+
});
|
|
31
|
+
});
|
|
22
32
|
test("trackerLinkActive with main tracker", () => {
|
|
23
33
|
const trackerValid = Tracker.trackerLinkActive(operator);
|
|
24
34
|
expect(trackerValid).toEqual("testing main link");
|
|
@@ -115,7 +125,7 @@ describe("Tracker Helper", () => {
|
|
|
115
125
|
tracker_name: tracker.name,
|
|
116
126
|
market_short_code: operator.market,
|
|
117
127
|
ip_address: "127.0.0.1",
|
|
118
|
-
cookie: '{"affObject":"{}"}'
|
|
128
|
+
cookie: '{"affObject":"{}"}',
|
|
119
129
|
};
|
|
120
130
|
|
|
121
131
|
expect(fetch).toHaveBeenCalledTimes(1);
|
|
@@ -158,55 +168,55 @@ describe("Tracker Helper", () => {
|
|
|
158
168
|
expect(params.request_url).toEqual("urlValue");
|
|
159
169
|
});
|
|
160
170
|
|
|
161
|
-
test(
|
|
171
|
+
test("should only return the allowed cf- keys", () => {
|
|
162
172
|
const inputData = {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
"cf-iplongitude": "6.91320",
|
|
174
|
+
"cf-iplatitude": "52.32560",
|
|
175
|
+
"cf-ipcontinent": "EU",
|
|
176
|
+
"cf-ipcity": "Oldenzaal",
|
|
177
|
+
"cf-region-code": "OV",
|
|
178
|
+
"cf-region": "Overijssel",
|
|
179
|
+
"cf-postal-code": "7577",
|
|
180
|
+
"cf-ipcountry": "NL",
|
|
181
|
+
"cf-ray": "8c1ea35e39439a30", // Should be filtered out
|
|
182
|
+
"some-other-key": "test", // Should be filtered out
|
|
173
183
|
};
|
|
174
184
|
|
|
175
185
|
const expectedOutput = {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
186
|
+
"cf-iplongitude": "6.91320",
|
|
187
|
+
"cf-iplatitude": "52.32560",
|
|
188
|
+
"cf-ipcontinent": "EU",
|
|
189
|
+
"cf-ipcity": "Oldenzaal",
|
|
190
|
+
"cf-region-code": "OV",
|
|
191
|
+
"cf-region": "Overijssel",
|
|
192
|
+
"cf-postal-code": "7577",
|
|
193
|
+
"cf-ipcountry": "NL",
|
|
184
194
|
};
|
|
185
195
|
|
|
186
196
|
expect(Tracker.filterCfKeys(inputData)).toEqual(expectedOutput);
|
|
187
197
|
});
|
|
188
198
|
|
|
189
|
-
test(
|
|
199
|
+
test("should return an empty object if none of the allowed keys are present", () => {
|
|
190
200
|
const inputData = {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
201
|
+
"cf-ray": "8c1ea35e39439a30",
|
|
202
|
+
"cf-visitor": '{"scheme":"https"}',
|
|
203
|
+
"random-key": "random-value",
|
|
194
204
|
};
|
|
195
205
|
|
|
196
206
|
expect(Tracker.filterCfKeys(inputData)).toEqual({});
|
|
197
207
|
});
|
|
198
208
|
|
|
199
|
-
test(
|
|
209
|
+
test("should return the correct keys even if some allowed keys are missing", () => {
|
|
200
210
|
const inputData = {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
211
|
+
"cf-iplatitude": "52.32560",
|
|
212
|
+
"cf-ipcity": "Oldenzaal",
|
|
213
|
+
"cf-postal-code": "7577",
|
|
204
214
|
};
|
|
205
215
|
|
|
206
216
|
const expectedOutput = {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
217
|
+
"cf-iplatitude": "52.32560",
|
|
218
|
+
"cf-ipcity": "Oldenzaal",
|
|
219
|
+
"cf-postal-code": "7577",
|
|
210
220
|
};
|
|
211
221
|
|
|
212
222
|
expect(Tracker.filterCfKeys(inputData)).toEqual(expectedOutput);
|
|
@@ -221,7 +231,7 @@ describe("Tracker Helper", () => {
|
|
|
221
231
|
"urlValue?fbclid=param1&msclkid=param2&gclid=param3"
|
|
222
232
|
);
|
|
223
233
|
expect(params.request_url).toEqual("urlValue");
|
|
224
|
-
|
|
234
|
+
expect(params.facebook_click_id).toEqual("param1");
|
|
225
235
|
expect(params.microsoft_click_id).toEqual("param2");
|
|
226
236
|
expect(params.google_click_id).toEqual("param3");
|
|
227
237
|
});
|
package/src/resolver/modules.mjs
CHANGED
|
@@ -283,7 +283,8 @@ export function processCardsV2(
|
|
|
283
283
|
prefilledFilters?.providers;
|
|
284
284
|
|
|
285
285
|
const moduleSelectedTypes =
|
|
286
|
-
(module?.cards_selector_filters &&
|
|
286
|
+
(module?.cards_selector_filters &&
|
|
287
|
+
module?.cards_selector_filters.types) ||
|
|
287
288
|
prefilledFilters?.types;
|
|
288
289
|
|
|
289
290
|
const limit =
|
|
@@ -602,7 +603,6 @@ export function processFaq(module = {}, content, relationData, previewPageID) {
|
|
|
602
603
|
)) ||
|
|
603
604
|
""
|
|
604
605
|
);
|
|
605
|
-
item.answer = trailingSlash(content ? content[item.answer] : "");
|
|
606
606
|
});
|
|
607
607
|
}
|
|
608
608
|
|