@griddo/cx 1.65.23 → 1.66.0

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/gatsby-ssr.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable node/no-missing-require */
2
2
  import * as React from 'react';
3
3
  import parse from 'html-react-parser';
4
- const { ssr } = require('components');
4
+ const { ssr, generateAutomaticDimensions = null } = require('components');
5
5
 
6
6
  let analyticsScript = [];
7
7
  let analyticsDimensions = [];
@@ -22,26 +22,38 @@ export const wrapPageElement = ({ props }) => {
22
22
  //Añadir el script. Dependiendo de si lo que recibe es el trackingId o el script
23
23
  const siteScript = siteScriptBulk ? siteScriptBulk.trim() : "";
24
24
  const src = `https://www.googletagmanager.com/gtag/js?id=${siteScript}`;
25
- const scriptCode = siteScript.includes('<script') ? [parse(siteScript)] : [<script async key="site-script" dangerouslySetInnerHTML={{__html: siteScript}}/>]
25
+ const scriptCode = siteScript.includes('<script') ? [parse(siteScript)] : [<script async key="site-script" dangerouslySetInnerHTML={{ __html: siteScript }} />]
26
26
 
27
- analyticsScript=siteScript && siteScript.startsWith('UA-') ?
28
- [<script async src={src}></script>]
27
+ analyticsScript = siteScript && siteScript.startsWith('UA-') ?
28
+ [<script async src={src}></script>]
29
29
  :
30
- (siteScript ? scriptCode : []);
30
+ (siteScript ? scriptCode : []);
31
31
  ;
32
32
 
33
33
  //Las dimensiones o DataLayer
34
- const dimensionValues = JSON.stringify(dimensions?.values);
35
- analyticsDimensions = dimensionValues && (dimensions?.values) !== null ?
36
- [<script
34
+ const dynamicValuePrefix = '__SCRIPT:';
35
+ const dimensionValues = dimensions?.values || {};
36
+ const automaticDimensionValues = generateAutomaticDimensions ? generateAutomaticDimensions(props) : {};
37
+ const allDimensionsValues = {
38
+ ...dimensionValues,
39
+ ...automaticDimensionValues,
40
+ };
41
+ const allDimensions = [];
42
+ for (const dimension of Object.keys(allDimensionsValues)) {
43
+ const dimensionValue = allDimensionsValues[dimension];
44
+ allDimensions.push(`"${dimension}":${dimensionValue?.startsWith(dynamicValuePrefix) ? `${dimensionValue.slice(dynamicValuePrefix.length, dimensionValue.endsWith(';') ? -1 : dimensionValue.length)}` : `"${dimensionValue}"`}`);
45
+ }
46
+
47
+ analyticsDimensions = allDimensions.length ?
48
+ [<script
37
49
  async
38
50
  key="site-script"
39
51
  dangerouslySetInnerHTML={{
40
- __html: `dataLayer.push(${dimensionValues})`
41
- }}/>]
52
+ __html: `dataLayer.push({${allDimensions.join(',')}})`
53
+ }} />]
42
54
  :
43
- []
44
- ;
55
+ []
56
+ ;
45
57
  };
46
58
 
47
59
  export const onRenderBody = props => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/cx",
3
3
  "description": "Griddo SSG based on Gatsby",
4
- "version": "1.65.23",
4
+ "version": "1.66.0",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -64,7 +64,7 @@
64
64
  "react-helmet": "^6.0.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@griddo/eslint-config-back": "^1.65.23",
67
+ "@griddo/eslint-config-back": "^1.66.0",
68
68
  "eslint": "^7.5.0",
69
69
  "eslint-plugin-node": "^11.1.0",
70
70
  "eslint-plugin-react": "7.14.3",
@@ -96,5 +96,5 @@
96
96
  "publishConfig": {
97
97
  "access": "public"
98
98
  },
99
- "gitHead": "7c4d164534c6b253cbd0b50a6292d3ea993fb670"
99
+ "gitHead": "48f0e2027ddcce4188e6bed411ecaab485ddb7e5"
100
100
  }
@@ -2,10 +2,8 @@
2
2
  import * as React from 'react';
3
3
  import { Link, navigate } from 'gatsby';
4
4
  import Seo from './seo';
5
- import { components, templates, providers } from 'components';
6
-
5
+ import { components, templates, SiteProvider } from 'components';
7
6
  import { Page as RenderGriddoPage } from '@griddo/core';
8
- const { SiteProvider } = providers;
9
7
 
10
8
  export default data => {
11
9
  const {