@next/third-parties 16.0.2 → 16.0.4
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/gtm.js +16 -5
- package/dist/types/google.d.ts +10 -3
- package/package.json +2 -2
package/dist/google/gtm.js
CHANGED
|
@@ -12,11 +12,22 @@ const react_1 = require("react");
|
|
|
12
12
|
const script_1 = __importDefault(require("next/script"));
|
|
13
13
|
let currDataLayerName = 'dataLayer';
|
|
14
14
|
function GoogleTagManager(props) {
|
|
15
|
-
const { gtmId, gtmScriptUrl
|
|
15
|
+
const { gtmId, gtmScriptUrl, dataLayerName = 'dataLayer', auth, preview, dataLayer, nonce, } = props;
|
|
16
16
|
currDataLayerName = dataLayerName;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const scriptUrl = new URL(gtmScriptUrl || 'https://www.googletagmanager.com/gtm.js');
|
|
18
|
+
if (gtmId) {
|
|
19
|
+
scriptUrl.searchParams.set('id', gtmId);
|
|
20
|
+
}
|
|
21
|
+
if (dataLayerName !== 'dataLayer') {
|
|
22
|
+
scriptUrl.searchParams.set('l', dataLayerName);
|
|
23
|
+
}
|
|
24
|
+
if (auth) {
|
|
25
|
+
scriptUrl.searchParams.set('gtm_auth', auth);
|
|
26
|
+
}
|
|
27
|
+
if (preview) {
|
|
28
|
+
scriptUrl.searchParams.set('gtm_preview', preview);
|
|
29
|
+
scriptUrl.searchParams.set('gtm_cookies_win', 'x');
|
|
30
|
+
}
|
|
20
31
|
(0, react_1.useEffect)(() => {
|
|
21
32
|
// performance.mark is being used as a feature use signal. While it is traditionally used for performance
|
|
22
33
|
// benchmarking it is low overhead and thus considered safe to use in production and it is a widely available
|
|
@@ -35,7 +46,7 @@ function GoogleTagManager(props) {
|
|
|
35
46
|
w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
|
|
36
47
|
${dataLayer ? `w[l].push(${JSON.stringify(dataLayer)})` : ''}
|
|
37
48
|
})(window,'${dataLayerName}');`,
|
|
38
|
-
}, nonce: nonce }), (0, jsx_runtime_1.jsx)(script_1.default, { id: "_next-gtm", "data-ntpc": "GTM", src:
|
|
49
|
+
}, nonce: nonce }), (0, jsx_runtime_1.jsx)(script_1.default, { id: "_next-gtm", "data-ntpc": "GTM", src: scriptUrl.href, nonce: nonce })] }));
|
|
39
50
|
}
|
|
40
51
|
const sendGTMEvent = (data, dataLayerName) => {
|
|
41
52
|
// special case if we are sending events before GTM init and we have custom dataLayerName
|
package/dist/types/google.d.ts
CHANGED
|
@@ -7,9 +7,7 @@ declare global {
|
|
|
7
7
|
type JSONValue = string | number | boolean | JSONValue[] | {
|
|
8
8
|
[key: string]: JSONValue;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
gtmId: string;
|
|
12
|
-
gtmScriptUrl?: string;
|
|
10
|
+
type GTMParamsBaseParams = {
|
|
13
11
|
dataLayer?: {
|
|
14
12
|
[key: string]: JSONValue;
|
|
15
13
|
};
|
|
@@ -18,6 +16,15 @@ export type GTMParams = {
|
|
|
18
16
|
preview?: string;
|
|
19
17
|
nonce?: string;
|
|
20
18
|
};
|
|
19
|
+
type GTMParamsWithId = GTMParamsBaseParams & {
|
|
20
|
+
gtmId: string;
|
|
21
|
+
gtmScriptUrl?: string;
|
|
22
|
+
};
|
|
23
|
+
type GTMParamsWithScriptUrl = GTMParamsBaseParams & {
|
|
24
|
+
gtmId?: string;
|
|
25
|
+
gtmScriptUrl: string;
|
|
26
|
+
};
|
|
27
|
+
export type GTMParams = GTMParamsWithId | GTMParamsWithScriptUrl;
|
|
21
28
|
export type GAParams = {
|
|
22
29
|
gaId: string;
|
|
23
30
|
dataLayerName?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next/third-parties",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.4",
|
|
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": "16.0.
|
|
29
|
+
"next": "16.0.4",
|
|
30
30
|
"outdent": "0.8.0",
|
|
31
31
|
"prettier": "2.5.1",
|
|
32
32
|
"typescript": "5.9.2"
|