gatsby-core-theme 30.0.47 → 30.0.49
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 +18 -0
- package/package.json +1 -1
- package/src/components/atoms/button/operator-cta.js +28 -2
- package/src/components/atoms/button/operator-cta.test.js +42 -1
- package/src/components/molecules/spotlights_v2/image-text/template-one/index.js +1 -1
- package/src/components/molecules/spotlights_v2/image-text/template-two/index.js +1 -1
- package/src/components/pages/tracker/index-ssr.js +2 -1
- package/src/helpers/tracker.mjs +19 -2
- package/src/helpers/tracker.test.js +29 -0
- package/tests/envVars.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## [30.0.49](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.48...v30.0.49) (2024-01-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* tracker params ([4050591](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/40505912dc53368f58bb9d50293ebfc1fdfde61d))
|
|
7
|
+
* update spotlight module ([dc93784](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/dc937841290a57a072d448a4ef6d6a61a34684d4))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
* Merge branch 'spotlight-bug' into 'master' ([9582e39](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9582e396e844dcc3d9cef30d08017cd769b2758a))
|
|
11
|
+
|
|
12
|
+
## [30.0.48](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.47...v30.0.48) (2024-01-09)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* tracker params ([3047a28](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3047a289212ecad77bb74391908d5e508a95e0f7))
|
|
18
|
+
|
|
1
19
|
## [30.0.47](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.46...v30.0.47) (2024-01-08)
|
|
2
20
|
|
|
3
21
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import React, { useContext } from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { Context } from '~context/MainProvider';
|
|
5
5
|
import { prettyTracker, translate } from '~helpers/getters';
|
|
6
|
-
import { setCookie
|
|
6
|
+
import { setCookie } from '~helpers/cookies';
|
|
7
7
|
|
|
8
8
|
import styles from './button.module.scss';
|
|
9
9
|
|
|
@@ -30,6 +30,16 @@ const OperatorCtaButton = ({
|
|
|
30
30
|
const url = typeof window !== 'undefined' ? window.location.href : '';
|
|
31
31
|
const urlParams = {};
|
|
32
32
|
|
|
33
|
+
function deparam(paramStr) {
|
|
34
|
+
const paramArr = paramStr.split('&');
|
|
35
|
+
const paramObj = {};
|
|
36
|
+
paramArr.forEach((e) => {
|
|
37
|
+
const param = e.split('=');
|
|
38
|
+
paramObj[param[0]] = decodeURIComponent(param[1]);
|
|
39
|
+
});
|
|
40
|
+
return paramObj;
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
if (process.env.IS_TRACKING_SSR === 'true') {
|
|
34
44
|
if (pageTemplate) {
|
|
35
45
|
urlParams.page_type = pageTemplate;
|
|
@@ -40,7 +50,23 @@ const OperatorCtaButton = ({
|
|
|
40
50
|
if (tracker !== 'main') {
|
|
41
51
|
urlParams.tracker_name = tracker;
|
|
42
52
|
}
|
|
43
|
-
|
|
53
|
+
|
|
54
|
+
if (url && url.split('?').length === 2) {
|
|
55
|
+
// eslint-disable-next-line prefer-destructuring
|
|
56
|
+
urlParams.request_url = url.split('?')[0];
|
|
57
|
+
const extraData = deparam(url.split('?')[1]);
|
|
58
|
+
if (extraData.fbclid) {
|
|
59
|
+
urlParams.facebook_click_id = extraData.fbclid;
|
|
60
|
+
}
|
|
61
|
+
if (extraData.msclkid) {
|
|
62
|
+
urlParams.microsoft_click_id = extraData.msclkid;
|
|
63
|
+
}
|
|
64
|
+
if (extraData.gclid) {
|
|
65
|
+
urlParams.google_click_id = extraData.gclid;
|
|
66
|
+
}
|
|
67
|
+
} else if (url) {
|
|
68
|
+
urlParams.request_url = url;
|
|
69
|
+
}
|
|
44
70
|
}
|
|
45
71
|
|
|
46
72
|
const prettyLink = `${prettyTracker(operator, trackerType, false, pageTemplate)}`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-lone-blocks */
|
|
2
2
|
/* eslint-disable no-unused-expressions */
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { render, cleanup } from '@testing-library/react';
|
|
4
|
+
import { render, cleanup, fireEvent } from '@testing-library/react';
|
|
5
5
|
import '@testing-library/jest-dom/extend-expect';
|
|
6
6
|
|
|
7
7
|
import OperatorCtaButton from './operator-cta';
|
|
@@ -43,6 +43,47 @@ describe('OperatorCtaButton Component', () => {
|
|
|
43
43
|
const { getByText } = render(<OperatorCtaButton {...data('coming_soon')} />);
|
|
44
44
|
expect(getByText('Soon Available')).toBeTruthy();
|
|
45
45
|
});
|
|
46
|
+
|
|
47
|
+
test('Affiliate object in cookie', () => {
|
|
48
|
+
window = Object.create(window);
|
|
49
|
+
const url = 'http://test.com/?fbclid=param1&msclkid=param2&gclid=param3';
|
|
50
|
+
Object.defineProperty(window, 'location', {
|
|
51
|
+
value: {
|
|
52
|
+
href: url,
|
|
53
|
+
},
|
|
54
|
+
writable: true, // possibility to override
|
|
55
|
+
});
|
|
56
|
+
const { container } = render(
|
|
57
|
+
<OperatorCtaButton {...data()} pageTemplate="test" module="test2" tracker="testing" />
|
|
58
|
+
);
|
|
59
|
+
const button = container.querySelector('a');
|
|
60
|
+
fireEvent.click(button);
|
|
61
|
+
const affObject = JSON.parse(document.cookie.split('=')[1]);
|
|
62
|
+
expect(affObject.page_type).toEqual('test');
|
|
63
|
+
expect(affObject.module).toEqual('test2');
|
|
64
|
+
expect(affObject.request_url).toEqual('http://test.com/');
|
|
65
|
+
expect(affObject.facebook_click_id).toEqual('param1');
|
|
66
|
+
expect(affObject.microsoft_click_id).toEqual('param2');
|
|
67
|
+
expect(affObject.google_click_id).toEqual('param3');
|
|
68
|
+
expect(affObject.tracker_name).toEqual('testing');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('Default Affiliate object in cookie', () => {
|
|
72
|
+
window = Object.create(window);
|
|
73
|
+
const url = 'http://testdomain.com/';
|
|
74
|
+
Object.defineProperty(window, 'location', {
|
|
75
|
+
value: {
|
|
76
|
+
href: url,
|
|
77
|
+
},
|
|
78
|
+
writable: true, // possibility to override
|
|
79
|
+
});
|
|
80
|
+
const { container } = render(<OperatorCtaButton {...data()} />);
|
|
81
|
+
const button = container.querySelector('a');
|
|
82
|
+
fireEvent.click(button);
|
|
83
|
+
const affObject = JSON.parse(document.cookie.split('=')[1]);
|
|
84
|
+
expect(affObject.page_type).toEqual('default');
|
|
85
|
+
expect(affObject.request_url).toEqual('http://testdomain.com/');
|
|
86
|
+
});
|
|
46
87
|
});
|
|
47
88
|
|
|
48
89
|
afterEach(() => {
|
|
@@ -23,7 +23,7 @@ export default function TemplateOne({ module, scrollableContent = false }) {
|
|
|
23
23
|
{res?.image && (
|
|
24
24
|
<LazyImage width={300} height={176} src={imagePrettyUrl(res?.image)} />
|
|
25
25
|
)}
|
|
26
|
-
{res?.
|
|
26
|
+
{res?.label && <TitleTag>{res.label}</TitleTag>}
|
|
27
27
|
{res.subtitle && <span>{res.subtitle}</span>}
|
|
28
28
|
<div
|
|
29
29
|
className={`${styles.desc} ${scrollableContent ? styles.scroll : ''}`}
|
|
@@ -23,7 +23,7 @@ export default function TemplateOne({ module }) {
|
|
|
23
23
|
{res?.image && (
|
|
24
24
|
<LazyImage width={104} height={104} src={imagePrettyUrl(res?.image)} />
|
|
25
25
|
)}
|
|
26
|
-
{res?.
|
|
26
|
+
{res?.label && <TitleTag>{res.label}</TitleTag>}
|
|
27
27
|
{res.subtitle && <span>{res.subtitle}</span>}
|
|
28
28
|
<div className={`${styles.desc}`} dangerouslySetInnerHTML={{ __html: res?.text }} />
|
|
29
29
|
</div>
|
package/src/helpers/tracker.mjs
CHANGED
|
@@ -39,11 +39,20 @@ function isJsonString(str) {
|
|
|
39
39
|
return true;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function deparam(paramStr) {
|
|
43
|
+
const paramArr = paramStr.split('&');
|
|
44
|
+
const paramObj = {};
|
|
45
|
+
paramArr.forEach(e=>{
|
|
46
|
+
const param = e.split('=');
|
|
47
|
+
paramObj[param[0]] = decodeURIComponent(param[1]);
|
|
48
|
+
});
|
|
49
|
+
return paramObj;
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
/* eslint-disable no-return-assign */
|
|
43
53
|
/* eslint-disable import/prefer-default-export */
|
|
44
|
-
export async function getAffiliateLink(operator, path, page, headers) {
|
|
54
|
+
export async function getAffiliateLink(operator, path, page, headers, url) {
|
|
45
55
|
const trackerName = await getTrackerName(operator, page, path);
|
|
46
|
-
|
|
47
56
|
const cookie =
|
|
48
57
|
headers && headers.get('cookie')
|
|
49
58
|
? headers
|
|
@@ -53,6 +62,12 @@ export async function getAffiliateLink(operator, path, page, headers) {
|
|
|
53
62
|
.reduce((acc, [k, v]) => (acc[k.trim().replace('"', '')] = v) && acc, {})
|
|
54
63
|
: { affObject: JSON.stringify({}) };
|
|
55
64
|
|
|
65
|
+
|
|
66
|
+
let extraParams = null
|
|
67
|
+
if(url && url.split('?').length === 2) {
|
|
68
|
+
extraParams = deparam(`${url.split('?')[1]}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
56
71
|
const urlParam = {
|
|
57
72
|
site_id: process.env.SITE_ID,
|
|
58
73
|
operator_short_name: operator.short_name,
|
|
@@ -62,7 +77,9 @@ export async function getAffiliateLink(operator, path, page, headers) {
|
|
|
62
77
|
market_short_code: operator.market,
|
|
63
78
|
ip_address: headers ? headers.get('x-real-ip') || headers.get('host') : '127.0.0.1',
|
|
64
79
|
...(isJsonString(cookie.affObject) ? JSON.parse(cookie.affObject) : {}),
|
|
80
|
+
...(extraParams || {})
|
|
65
81
|
};
|
|
82
|
+
|
|
66
83
|
const res = await fetch(
|
|
67
84
|
`${process.env.GATSBY_TRACKING_API_URL}?${new URLSearchParams(urlParam).toString()}`
|
|
68
85
|
).catch((err) => null);
|
|
@@ -73,4 +73,33 @@ describe('Tracker Helper', () => {
|
|
|
73
73
|
`${process.env.GATSBY_TRACKING_API_URL}?${new URLSearchParams(urlParam).toString()}`
|
|
74
74
|
);
|
|
75
75
|
});
|
|
76
|
+
|
|
77
|
+
test('getAffiliateLink url params extras', async () => {
|
|
78
|
+
await Tracker.getAffiliateLink(
|
|
79
|
+
operator,
|
|
80
|
+
'/no/visit/rizk',
|
|
81
|
+
{ template: 'default' },
|
|
82
|
+
null,
|
|
83
|
+
'/path?extraparam=val&extraparam2=val2'
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const tracker = Tracker.getTrackerName(operator, 'default', '/no/visit/rizk');
|
|
87
|
+
|
|
88
|
+
const urlParam = {
|
|
89
|
+
site_id: process.env.SITE_ID,
|
|
90
|
+
operator_short_name: operator.short_name,
|
|
91
|
+
operator_type: operator.type,
|
|
92
|
+
language: operator.market.split('_')[1],
|
|
93
|
+
tracker_name: tracker.name,
|
|
94
|
+
market_short_code: operator.market,
|
|
95
|
+
ip_address: '127.0.0.1',
|
|
96
|
+
extraparam: 'val',
|
|
97
|
+
extraparam2: 'val2',
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
expect(fetch).toBeCalledTimes(1);
|
|
101
|
+
expect(fetch).toBeCalledWith(
|
|
102
|
+
`${process.env.GATSBY_TRACKING_API_URL}?${new URLSearchParams(urlParam).toString()}`
|
|
103
|
+
);
|
|
104
|
+
});
|
|
76
105
|
});
|
package/tests/envVars.js
CHANGED