gatsby-core-theme 30.0.23 → 30.0.25
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
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [30.0.25](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.24...v30.0.25) (2023-11-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* tracker SSR optimizations ([9968c54](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9968c544e423a3671f0edce7d5cfba1831099b09))
|
|
7
|
+
|
|
8
|
+
## [30.0.24](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.23...v30.0.24) (2023-11-23)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* tracker ([3961809](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3961809b1e20695eb8e02b788c77d45c40eb2759))
|
|
14
|
+
|
|
1
15
|
## [30.0.23](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.22...v30.0.23) (2023-11-22)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@ const OperatorCtaButton = ({
|
|
|
30
30
|
const urlParams = [];
|
|
31
31
|
|
|
32
32
|
if (process.env.IS_TRACKING_SSR === 'true') {
|
|
33
|
-
pageTemplate && urlParams.push(`
|
|
33
|
+
pageTemplate && urlParams.push(`page_type=${pageTemplate}`);
|
|
34
34
|
module && urlParams.push(`module=${module}`);
|
|
35
35
|
tracker !== 'main' && urlParams.push(`tracker_name=${tracker}`);
|
|
36
36
|
}
|
|
@@ -2,10 +2,9 @@ import React, { useEffect } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Button from '~atoms/button/button';
|
|
4
4
|
import LazyImage from '~hooks/lazy-image';
|
|
5
|
-
import { imagePrettyUrl, getAltText, translate
|
|
6
|
-
import { generateTrackerLink } from '~helpers/generators';
|
|
5
|
+
import { imagePrettyUrl, getAltText, translate } from '~helpers/getters';
|
|
7
6
|
import styles from './tracker.module.scss';
|
|
8
|
-
import { getAffiliateLink } from '~helpers/tracker';
|
|
7
|
+
import { getAffiliateLink, getTrackerName } from '~helpers/tracker';
|
|
9
8
|
|
|
10
9
|
const Tracker = ({
|
|
11
10
|
pageContext,
|
|
@@ -26,27 +25,8 @@ const Tracker = ({
|
|
|
26
25
|
}) => {
|
|
27
26
|
const { operator, page } = pageContext;
|
|
28
27
|
const translations = page?.translations;
|
|
29
|
-
const trackerLinks = operator ? Object.keys(operator.links) : [];
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
for (let i = 0; i < trackerLinks.length; i += 1) {
|
|
33
|
-
const trackerLink = trackerLinks[i].toLowerCase().replace(' ', '_');
|
|
34
|
-
if (
|
|
35
|
-
generateTrackerLink(operator, trackerLink, false, page.template) === stripTrailingSlash(path)
|
|
36
|
-
) {
|
|
37
|
-
tracker =
|
|
38
|
-
operator.links[
|
|
39
|
-
Object.keys(operator.links).find((key) => key.toLowerCase() === trackerLink.toLowerCase())
|
|
40
|
-
];
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
if (path.includes('ppc_fallback')) {
|
|
44
|
-
// eslint-disable-next-line react/prop-types
|
|
45
|
-
tracker = operator.links['PPC Fallback'];
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
tracker = operator.links.main;
|
|
49
|
-
}
|
|
29
|
+
const tracker = getTrackerName(operator, page, path);
|
|
50
30
|
|
|
51
31
|
const showSplashScreen = typeof window !== 'undefined';
|
|
52
32
|
|
|
@@ -57,7 +37,7 @@ const Tracker = ({
|
|
|
57
37
|
window.location.replace(serverData.result.link);
|
|
58
38
|
} else {
|
|
59
39
|
console.log('FROM LOCAL');
|
|
60
|
-
window.location.replace(tracker);
|
|
40
|
+
window.location.replace(tracker.value);
|
|
61
41
|
}
|
|
62
42
|
}
|
|
63
43
|
}
|
|
@@ -196,7 +176,7 @@ Tracker.propTypes = {
|
|
|
196
176
|
export async function getServerData({ pageContext, url }) {
|
|
197
177
|
let res = '';
|
|
198
178
|
|
|
199
|
-
res = await getAffiliateLink(pageContext.operator, url);
|
|
179
|
+
res = await getAffiliateLink(pageContext.operator, url, pageContext.page.path, pageContext.page);
|
|
200
180
|
return res;
|
|
201
181
|
}
|
|
202
182
|
|
|
@@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Button from '~atoms/button/button';
|
|
4
4
|
import LazyImage from '~hooks/lazy-image';
|
|
5
|
-
import {
|
|
5
|
+
import { imagePrettyUrl, getAltText, translate } from '~helpers/getters';
|
|
6
6
|
import { generateTrackerLink } from '~helpers/generators';
|
|
7
7
|
import styles from './tracker.module.scss';
|
|
8
8
|
|
|
@@ -26,6 +26,8 @@ const Tracker = ({
|
|
|
26
26
|
const translations = page?.translations;
|
|
27
27
|
const trackerLinks = operator ? Object.keys(operator.links) : [];
|
|
28
28
|
|
|
29
|
+
const stripTrailingSlash = (str) => (str.endsWith('/') ? str.slice(0, -1) : str);
|
|
30
|
+
|
|
29
31
|
let tracker = '';
|
|
30
32
|
for (let i = 0; i < trackerLinks.length; i += 1) {
|
|
31
33
|
const trackerLink = trackerLinks[i].toLowerCase().replace(' ', '_');
|
package/src/helpers/getters.mjs
CHANGED
|
@@ -176,12 +176,6 @@ export function getParameterCaseInsensitive(object, key) {
|
|
|
176
176
|
];
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
export function stripTrailingSlash(str) {
|
|
180
|
-
return str.endsWith('/') ?
|
|
181
|
-
str.slice(0, -1) :
|
|
182
|
-
str;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
179
|
export function prettyTracker(
|
|
186
180
|
operator,
|
|
187
181
|
trackerType = 'main',
|
package/src/helpers/tracker.mjs
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
|
+
import { generateTrackerLink } from '~helpers/generators';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export function getTrackerName(operator, page, path) {
|
|
5
|
+
const trackerLinks = operator ? Object.keys(operator.links) : [];
|
|
6
|
+
const stripTrailingSlash = (str) => (str.endsWith('/') ? str.slice(0, -1) : str);
|
|
7
|
+
let trackerName = 'main';
|
|
8
|
+
let tracker = '';
|
|
9
|
+
for (let i = 0; i < trackerLinks.length; i += 1) {
|
|
10
|
+
const trackerLink = trackerLinks[i].toLowerCase().replace(' ', '_');
|
|
11
|
+
if (
|
|
12
|
+
generateTrackerLink(operator, trackerLink, false, page.template) === stripTrailingSlash(path)
|
|
13
|
+
) {
|
|
14
|
+
tracker =
|
|
15
|
+
operator.links[
|
|
16
|
+
Object.keys(operator.links).find((key) => key.toLowerCase() === trackerLink.toLowerCase())
|
|
17
|
+
];
|
|
18
|
+
trackerName = trackerLink.toLowerCase();
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
if (path.includes('ppc_fallback')) {
|
|
22
|
+
// eslint-disable-next-line react/prop-types
|
|
23
|
+
tracker = operator.links['PPC Fallback'];
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
tracker = operator.links.main;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return { name: trackerName, value: tracker };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
1
33
|
/* eslint-disable import/prefer-default-export */
|
|
2
|
-
export async function getAffiliateLink(operator, url) {
|
|
34
|
+
export async function getAffiliateLink(operator, url, path, page) {
|
|
3
35
|
let urlParams = `site_id=${process.env.SITE_ID}&operator_short_name=${
|
|
4
36
|
operator.short_name
|
|
5
37
|
}&operator_type=${operator.type}&language=${operator.market.split('_')[1]}&market_short_code=${
|
|
@@ -12,6 +44,12 @@ export async function getAffiliateLink(operator, url) {
|
|
|
12
44
|
urlParams += `&${urlSplit[1]}`;
|
|
13
45
|
}
|
|
14
46
|
|
|
47
|
+
const trackerName = await getTrackerName(operator, page, path);
|
|
48
|
+
|
|
49
|
+
if(trackerName.name !== 'main') {
|
|
50
|
+
urlParams += `&tracker_name=${trackerName.name}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
15
53
|
const res = await fetch(`${process.env.GATSBY_TRACKING_API_URL}?${urlParams}`).catch(
|
|
16
54
|
(err) => null
|
|
17
55
|
);
|