@next/third-parties 14.0.5-canary.6 → 14.0.5-canary.8
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/ThirdPartyScriptEmbed.d.ts +2 -2
- package/dist/google/ga.d.ts +8 -0
- package/dist/google/ga.js +51 -0
- package/dist/google/gtm.js +1 -0
- package/dist/google/index.d.ts +1 -0
- package/dist/google/index.js +4 -1
- package/dist/types/google.d.ts +10 -5
- package/google.d.ts +1 -0
- package/package.json +4 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export type ScriptEmbed = {
|
|
3
3
|
html?: string | null;
|
|
4
|
-
height?: number | null;
|
|
5
|
-
width?: number | null;
|
|
4
|
+
height?: string | number | null;
|
|
5
|
+
width?: string | number | null;
|
|
6
6
|
children?: React.ReactElement | React.ReactElement[];
|
|
7
7
|
dataNtpc?: string;
|
|
8
8
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GAParams } from '../types/google';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
dataLayer?: Object[];
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare function GoogleAnalytics(props: GAParams): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const sendGAEvent: (...args: Object[]) => void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.sendGAEvent = exports.GoogleAnalytics = void 0;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
// TODO: Evaluate import 'client only'
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const script_1 = __importDefault(require("next/script"));
|
|
12
|
+
let currDataLayerName = undefined;
|
|
13
|
+
function GoogleAnalytics(props) {
|
|
14
|
+
const { gaId, dataLayerName = 'dataLayer' } = props;
|
|
15
|
+
if (currDataLayerName === undefined) {
|
|
16
|
+
currDataLayerName = dataLayerName;
|
|
17
|
+
}
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
// performance.mark is being used as a feature use signal. While it is traditionally used for performance
|
|
20
|
+
// benchmarking it is low overhead and thus considered safe to use in production and it is a widely available
|
|
21
|
+
// existing API.
|
|
22
|
+
// The performance measurement will be handled by Chrome Aurora
|
|
23
|
+
performance.mark('mark_feature_usage', {
|
|
24
|
+
detail: {
|
|
25
|
+
feature: 'next-third-parties-ga',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}, []);
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(script_1.default, { id: "_next-ga-init", dangerouslySetInnerHTML: {
|
|
30
|
+
__html: `
|
|
31
|
+
window['${dataLayerName}'] = window['${dataLayerName}'] || [];
|
|
32
|
+
function gtag(){window['${dataLayerName}'].push(arguments);}
|
|
33
|
+
gtag('js', new Date());
|
|
34
|
+
|
|
35
|
+
gtag('config', '${gaId}');`,
|
|
36
|
+
} }), (0, jsx_runtime_1.jsx)(script_1.default, { id: "_next-ga", src: `https://www.googletagmanager.com/gtag/js?id=${gaId}` })] }));
|
|
37
|
+
}
|
|
38
|
+
exports.GoogleAnalytics = GoogleAnalytics;
|
|
39
|
+
const sendGAEvent = (...args) => {
|
|
40
|
+
if (currDataLayerName === undefined) {
|
|
41
|
+
console.warn(`@next/third-parties: GA has not been initialized`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (window[currDataLayerName]) {
|
|
45
|
+
window[currDataLayerName].push(...args);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.warn(`@next/third-parties: GA dataLayer ${currDataLayerName} does not exist`);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.sendGAEvent = sendGAEvent;
|
package/dist/google/gtm.js
CHANGED
|
@@ -22,6 +22,7 @@ function GoogleTagManager(props) {
|
|
|
22
22
|
// performance.mark is being used as a feature use signal. While it is traditionally used for performance
|
|
23
23
|
// benchmarking it is low overhead and thus considered safe to use in production and it is a widely available
|
|
24
24
|
// existing API.
|
|
25
|
+
// The performance measurement will be handled by Chrome Aurora
|
|
25
26
|
performance.mark('mark_feature_usage', {
|
|
26
27
|
detail: {
|
|
27
28
|
feature: 'next-third-parties-gtm',
|
package/dist/google/index.d.ts
CHANGED
package/dist/google/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sendGTMEvent = exports.GoogleTagManager = exports.YouTubeEmbed = exports.GoogleMapsEmbed = void 0;
|
|
6
|
+
exports.sendGAEvent = exports.GoogleAnalytics = exports.sendGTMEvent = exports.GoogleTagManager = exports.YouTubeEmbed = exports.GoogleMapsEmbed = void 0;
|
|
7
7
|
var google_maps_embed_1 = require("./google-maps-embed");
|
|
8
8
|
Object.defineProperty(exports, "GoogleMapsEmbed", { enumerable: true, get: function () { return __importDefault(google_maps_embed_1).default; } });
|
|
9
9
|
var youtube_embed_1 = require("./youtube-embed");
|
|
@@ -11,3 +11,6 @@ Object.defineProperty(exports, "YouTubeEmbed", { enumerable: true, get: function
|
|
|
11
11
|
var gtm_1 = require("./gtm");
|
|
12
12
|
Object.defineProperty(exports, "GoogleTagManager", { enumerable: true, get: function () { return gtm_1.GoogleTagManager; } });
|
|
13
13
|
Object.defineProperty(exports, "sendGTMEvent", { enumerable: true, get: function () { return gtm_1.sendGTMEvent; } });
|
|
14
|
+
var ga_1 = require("./ga");
|
|
15
|
+
Object.defineProperty(exports, "GoogleAnalytics", { enumerable: true, get: function () { return ga_1.GoogleAnalytics; } });
|
|
16
|
+
Object.defineProperty(exports, "sendGAEvent", { enumerable: true, get: function () { return ga_1.sendGAEvent; } });
|
package/dist/types/google.d.ts
CHANGED
|
@@ -11,15 +11,20 @@ export type GTMParams = {
|
|
|
11
11
|
auth?: string;
|
|
12
12
|
preview?: string;
|
|
13
13
|
};
|
|
14
|
+
export type GAParams = {
|
|
15
|
+
gaId: string;
|
|
16
|
+
dataLayerName?: string;
|
|
17
|
+
};
|
|
14
18
|
export type GoogleMapsEmbed = {
|
|
15
|
-
height?: number;
|
|
16
|
-
width?: number;
|
|
19
|
+
height?: number | string;
|
|
20
|
+
width?: number | string;
|
|
17
21
|
mode: 'place' | 'view' | 'directions' | 'streetview' | 'search';
|
|
18
22
|
apiKey: string;
|
|
19
|
-
style
|
|
20
|
-
allowfullscreen
|
|
21
|
-
loading
|
|
23
|
+
style?: string;
|
|
24
|
+
allowfullscreen?: boolean;
|
|
25
|
+
loading?: 'eager' | 'lazy';
|
|
22
26
|
q?: string;
|
|
27
|
+
id?: string;
|
|
23
28
|
center?: string;
|
|
24
29
|
zoom?: string;
|
|
25
30
|
maptype?: string;
|
package/google.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/google/index'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next/third-parties",
|
|
3
|
-
"version": "14.0.5-canary.
|
|
3
|
+
"version": "14.0.5-canary.8",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "vercel/next.js",
|
|
6
6
|
"directory": "packages/third-parties"
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"dist"
|
|
15
|
+
"dist",
|
|
16
|
+
"google.d.ts"
|
|
16
17
|
],
|
|
17
18
|
"license": "MIT",
|
|
18
19
|
"scripts": {
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
"third-party-capital": "1.0.20"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"next": "14.0.5-canary.
|
|
29
|
+
"next": "14.0.5-canary.8",
|
|
29
30
|
"outdent": "0.8.0",
|
|
30
31
|
"prettier": "2.5.1"
|
|
31
32
|
},
|