@next/third-parties 15.0.0-canary.157 → 15.0.0-canary.159

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/dist/google/ga.js CHANGED
@@ -12,7 +12,7 @@ const react_1 = require("react");
12
12
  const script_1 = __importDefault(require("next/script"));
13
13
  let currDataLayerName = undefined;
14
14
  function GoogleAnalytics(props) {
15
- const { gaId, dataLayerName = 'dataLayer', nonce } = props;
15
+ const { gaId, debugMode, dataLayerName = 'dataLayer', nonce } = props;
16
16
  if (currDataLayerName === undefined) {
17
17
  currDataLayerName = dataLayerName;
18
18
  }
@@ -33,7 +33,7 @@ function GoogleAnalytics(props) {
33
33
  function gtag(){window['${dataLayerName}'].push(arguments);}
34
34
  gtag('js', new Date());
35
35
 
36
- gtag('config', '${gaId}');`,
36
+ gtag('config', '${gaId}' ${debugMode ? ",{ 'debug_mode': true }" : ''});`,
37
37
  }, nonce: nonce }), (0, jsx_runtime_1.jsx)(script_1.default, { id: "_next-ga", src: `https://www.googletagmanager.com/gtag/js?id=${gaId}`, nonce: nonce })] }));
38
38
  }
39
39
  function sendGAEvent(..._args) {
@@ -1,3 +1,3 @@
1
1
  import type { GTMParams } from '../types/google';
2
2
  export declare function GoogleTagManager(props: GTMParams): import("react/jsx-runtime").JSX.Element;
3
- export declare const sendGTMEvent: (data: Object) => void;
3
+ export declare const sendGTMEvent: (data: Object, dataLayerName?: string) => void;
@@ -10,12 +10,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
10
10
  // TODO: Evaluate import 'client only'
11
11
  const react_1 = require("react");
12
12
  const script_1 = __importDefault(require("next/script"));
13
- let currDataLayerName = undefined;
13
+ let currDataLayerName = 'dataLayer';
14
14
  function GoogleTagManager(props) {
15
15
  const { gtmId, dataLayerName = 'dataLayer', auth, preview, dataLayer, nonce, } = props;
16
- if (currDataLayerName === undefined) {
17
- currDataLayerName = dataLayerName;
18
- }
16
+ currDataLayerName = dataLayerName;
19
17
  const gtmLayer = dataLayerName !== 'dataLayer' ? `&l=${dataLayerName}` : '';
20
18
  const gtmAuth = auth ? `&gtm_auth=${auth}` : '';
21
19
  const gtmPreview = preview ? `&gtm_preview=${preview}&gtm_cookies_win=x` : '';
@@ -39,16 +37,11 @@ function GoogleTagManager(props) {
39
37
  })(window,'${dataLayerName}');`,
40
38
  }, nonce: nonce }), (0, jsx_runtime_1.jsx)(script_1.default, { id: "_next-gtm", "data-ntpc": "GTM", src: `https://www.googletagmanager.com/gtm.js?id=${gtmId}${gtmLayer}${gtmAuth}${gtmPreview}`, nonce: nonce })] }));
41
39
  }
42
- const sendGTMEvent = (data) => {
43
- if (currDataLayerName === undefined) {
44
- console.warn(`@next/third-parties: GTM has not been initialized`);
45
- return;
46
- }
47
- if (window[currDataLayerName]) {
48
- window[currDataLayerName].push(data);
49
- }
50
- else {
51
- console.warn(`@next/third-parties: GTM dataLayer ${currDataLayerName} does not exist`);
52
- }
40
+ const sendGTMEvent = (data, dataLayerName) => {
41
+ // special case if we are sending events before GTM init and we have custom dataLayerName
42
+ const dataLayer = dataLayerName || currDataLayerName;
43
+ // define dataLayer so we can still queue up events before GTM init
44
+ window[dataLayer] = window[dataLayer] || [];
45
+ window[dataLayer].push(data);
53
46
  };
54
47
  exports.sendGTMEvent = sendGTMEvent;
@@ -20,6 +20,7 @@ export type GTMParams = {
20
20
  export type GAParams = {
21
21
  gaId: string;
22
22
  dataLayerName?: string;
23
+ debugMode?: boolean;
23
24
  nonce?: string;
24
25
  };
25
26
  export type GoogleMapsEmbed = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next/third-parties",
3
- "version": "15.0.0-canary.157",
3
+ "version": "15.0.0-canary.159",
4
4
  "repository": {
5
5
  "url": "vercel/next.js",
6
6
  "directory": "packages/third-parties"
@@ -26,7 +26,7 @@
26
26
  "third-party-capital": "1.0.20"
27
27
  },
28
28
  "devDependencies": {
29
- "next": "15.0.0-canary.157",
29
+ "next": "15.0.0-canary.159",
30
30
  "outdent": "0.8.0",
31
31
  "prettier": "2.5.1"
32
32
  },