gatsby-core-theme 30.0.48 → 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 CHANGED
@@ -1,3 +1,14 @@
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
+
1
12
  ## [30.0.48](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.47...v30.0.48) (2024-01-09)
2
13
 
3
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "30.0.48",
3
+ "version": "30.0.49",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -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, getCookie } from '~helpers/cookies';
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
- urlParams.request_url = url;
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?.link_text && <TitleTag>{res?.label}</TitleTag>}
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?.link_text && <TitleTag>{res?.label}</TitleTag>}
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/tests/envVars.js CHANGED
@@ -6,3 +6,4 @@ process.env.TRACKER_LINK_FORMAT_NON_MAIN = '[no],[visit],short_name,type,[tracke
6
6
 
7
7
  process.env.SITE_ID = 82;
8
8
  process.env.GATSBY_TRACKING_API_URL = 'testlink';
9
+ process.env.IS_TRACKING_SSR = true;