@artginzburg/next-ym 1.2.1 → 1.2.2
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/README.md +1 -1
- package/dist/components/MetricaPixel.js +3 -10
- package/dist/components/MetricaPixel.js.map +1 -1
- package/dist/components/YandexMetricaProvider.d.ts +1 -0
- package/dist/components/YandexMetricaProvider.js +15 -21
- package/dist/components/YandexMetricaProvider.js.map +1 -1
- package/dist/constants/defaults.js +1 -4
- package/dist/constants/defaults.js.map +1 -1
- package/dist/hooks/useEcommerce.js +21 -16
- package/dist/hooks/useEcommerce.js.map +1 -1
- package/dist/hooks/useMetrica.js +15 -19
- package/dist/hooks/useMetrica.js.map +1 -1
- package/dist/hooks/useTrackRouteChange.js +9 -36
- package/dist/hooks/useTrackRouteChange.js.map +1 -1
- package/dist/index.js +7 -37
- package/dist/index.js.map +1 -1
- package/dist/lib/ecommerce.d.ts +32 -6
- package/dist/lib/ecommerce.js +1 -5
- package/dist/lib/ecommerce.js.map +1 -1
- package/dist/lib/types/events.js +1 -2
- package/dist/lib/types/options.js +1 -2
- package/dist/lib/types/parameters.d.ts +1 -1
- package/dist/lib/types/parameters.js +1 -2
- package/dist/lib/types/ym.js +1 -2
- package/dist/lib/ym.js +1 -5
- package/dist/lib/ym.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://badge.fury.io/js/next-yandex-metrica)
|
|
4
4
|
[](https://codecov.io/github/reapziq/next-yandex-metrica)
|
|
5
5
|
|
|
6
|
-
Yandex Metrica integration for Next.js v14 (App Router)
|
|
6
|
+
Yandex Metrica integration for Next.js v14+ (App Router)
|
|
7
7
|
|
|
8
8
|
> ### Fork reasoning
|
|
9
9
|
>
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MetricaPixel = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const image_1 = __importDefault(require("next/image"));
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Image from 'next/image';
|
|
9
3
|
/** @todo shouldUseAlternativeCDN */
|
|
10
|
-
const MetricaPixel = ({ tagID }) => ((
|
|
11
|
-
exports.MetricaPixel = MetricaPixel;
|
|
4
|
+
export const MetricaPixel = ({ tagID }) => (_jsx("div", { children: _jsx(Image, { height: "1", width: "1", style: { display: 'none', position: 'absolute', left: -9999 }, src: `https://mc.yandex.ru/watch/${tagID}`, alt: "", unoptimized: true }) }));
|
|
12
5
|
//# sourceMappingURL=MetricaPixel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetricaPixel.js","sourceRoot":"","sources":["../../src/components/MetricaPixel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MetricaPixel.js","sourceRoot":"","sources":["../../src/components/MetricaPixel.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAO/B,oCAAoC;AACpC,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAChE,wBACE,KAAC,KAAK,IACJ,MAAM,EAAC,GAAG,EACV,KAAK,EAAC,GAAG,EACT,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,EAC7D,GAAG,EAAE,8BAA8B,KAAK,EAAE,EAC1C,GAAG,EAAC,EAAE,EACN,WAAW,SACX,GACE,CACP,CAAC"}
|
|
@@ -19,4 +19,5 @@ export interface YandexMetricaProviderProps {
|
|
|
19
19
|
nextJsNativeLoading?: boolean;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
+
/** Caveat: make it the top-most wrapper of your layout's `{children}`. Otherwise some issues might occur, e.g. I've tried to have it lower in the tree than 'zustand' store provider and 'swr' config provider, and this caused 'nextjs-toploader' to indefinitely show a loading state. */
|
|
22
23
|
export declare const YandexMetricaProvider: FC<YandexMetricaProviderProps>;
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
'use client';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const MetricaPixel_1 = require("./MetricaPixel");
|
|
13
|
-
exports.MetricaTagIDContext = (0, react_1.createContext)(null);
|
|
14
|
-
exports.MetricaEcommerceContext = (0, react_1.createContext)(null);
|
|
15
|
-
const YandexMetricaProvider = ({ children, tagID, strategy = 'afterInteractive', initParameters, shouldUseAlternativeCDN = false, experimental, }) => {
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import Script from 'next/script';
|
|
4
|
+
import { createContext, useMemo } from 'react';
|
|
5
|
+
import { useTrackRouteChange } from '../hooks/useTrackRouteChange';
|
|
6
|
+
import { MetricaPixel } from './MetricaPixel';
|
|
7
|
+
export const MetricaTagIDContext = createContext(null);
|
|
8
|
+
export const MetricaEcommerceContext = createContext(null);
|
|
9
|
+
/** Caveat: make it the top-most wrapper of your layout's `{children}`. Otherwise some issues might occur, e.g. I've tried to have it lower in the tree than 'zustand' store provider and 'swr' config provider, and this caused 'nextjs-toploader' to indefinitely show a loading state. */
|
|
10
|
+
export const YandexMetricaProvider = ({ children, tagID, strategy = 'afterInteractive', initParameters, shouldUseAlternativeCDN = false, experimental, }) => {
|
|
16
11
|
const YANDEX_METRICA_ID = process.env.NEXT_PUBLIC_YANDEX_METRICA_ID;
|
|
17
|
-
const id =
|
|
18
|
-
|
|
12
|
+
const id = useMemo(() => tagID !== null && tagID !== void 0 ? tagID : (YANDEX_METRICA_ID ? Number(YANDEX_METRICA_ID) : null), [YANDEX_METRICA_ID, tagID]);
|
|
13
|
+
useTrackRouteChange({ tagID: id });
|
|
19
14
|
if (!id) {
|
|
20
15
|
console.warn('[next-yandex-metrica] Yandex.Metrica tag ID is not defined');
|
|
21
|
-
return (
|
|
16
|
+
return _jsx(_Fragment, { children: children });
|
|
22
17
|
}
|
|
23
18
|
const scriptSrc = shouldUseAlternativeCDN
|
|
24
19
|
? 'https://cdn.jsdelivr.net/npm/yandex-metrica-watch/tag.js'
|
|
@@ -27,24 +22,23 @@ const YandexMetricaProvider = ({ children, tagID, strategy = 'afterInteractive',
|
|
|
27
22
|
ym(${id}, "init", ${JSON.stringify(initParameters !== null && initParameters !== void 0 ? initParameters : {})});
|
|
28
23
|
${initEcommerce(initParameters === null || initParameters === void 0 ? void 0 : initParameters.ecommerce)}
|
|
29
24
|
`;
|
|
30
|
-
return ((
|
|
25
|
+
return (_jsxs(_Fragment, { children: [(experimental === null || experimental === void 0 ? void 0 : experimental.nextJsNativeLoading) ? (_jsxs(_Fragment, { children: [_jsx(Script, { id: "yandex-metrika-init", strategy: "beforeInteractive", children: `
|
|
31
26
|
window.ym = window.ym || function() {
|
|
32
27
|
(window.ym.a = window.ym.a || []).push(arguments);
|
|
33
28
|
};
|
|
34
29
|
window.ym.l = 1 * new Date();
|
|
35
30
|
${sharedInit}
|
|
36
|
-
` }), (
|
|
31
|
+
` }), _jsx(Script, { src: scriptSrc, strategy: strategy, async: true })] })) : (_jsx(Script, { id: "yandex-metrica", strategy: strategy, children: `
|
|
37
32
|
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
|
|
38
33
|
m[i].l=1*new Date();
|
|
39
34
|
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
|
|
40
35
|
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
|
41
36
|
(window, document, "script", "${scriptSrc}", "ym");
|
|
42
37
|
${sharedInit}
|
|
43
|
-
` })), (
|
|
38
|
+
` })), _jsx("noscript", { id: "yandex-metrica-pixel", children: _jsx(MetricaPixel, { tagID: id }) }), _jsx(MetricaTagIDContext.Provider, { value: id, children: (initParameters === null || initParameters === void 0 ? void 0 : initParameters.ecommerce) ? (_jsx(MetricaEcommerceContext.Provider, { value: typeof (initParameters === null || initParameters === void 0 ? void 0 : initParameters.ecommerce) === 'string'
|
|
44
39
|
? initParameters === null || initParameters === void 0 ? void 0 : initParameters.ecommerce
|
|
45
40
|
: 'dataLayer', children: children })) : (children) })] }));
|
|
46
41
|
};
|
|
47
|
-
exports.YandexMetricaProvider = YandexMetricaProvider;
|
|
48
42
|
function initEcommerce(paramEcommerce) {
|
|
49
43
|
if (!paramEcommerce)
|
|
50
44
|
return '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YandexMetricaProvider.js","sourceRoot":"","sources":["../../src/components/YandexMetricaProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"YandexMetricaProvider.js","sourceRoot":"","sources":["../../src/components/YandexMetricaProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,MAAuB,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,aAAa,EAAiB,OAAO,EAAE,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAgB,IAAI,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAgB,IAAI,CAAC,CAAC;AAmB1E,4RAA4R;AAC5R,MAAM,CAAC,MAAM,qBAAqB,GAAmC,CAAC,EACpE,QAAQ,EACR,KAAK,EACL,QAAQ,GAAG,kBAA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AAQ,EAAE,QAAQ,YAC3C;;;;;0CAK+B,SAAS;YACvC,UAAU;SACb,GACQ,CACV,EACD,mBAAU,EAAE,EAAC,sBAAsB,YACjC,KAAC,YAAY,IAAC,KAAK,EAAE,EAAE,GAAI,GAClB,EACX,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,YACpC,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,SAAS,EAAC,CAAC,CAAC,CAC3B,KAAC,uBAAuB,CAAC,QAAQ,IAC/B,KAAK,EACH,OAAO,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,SAAS,CAAA,KAAK,QAAQ;wBAC3C,CAAC,CAAC,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,SAAS;wBAC3B,CAAC,CAAC,WAAW,YAGhB,QAAQ,GACwB,CACpC,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,GAC4B,IAC9B,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,aAAa,CAAC,cAA2C;IAChE,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;IAE/B,MAAM,aAAa,GAAG,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC;IACxF,OAAO,UAAU,aAAa,aAAa,aAAa,SAAS,CAAC;AACpE,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.standardYMInitParameters = void 0;
|
|
4
1
|
/** The standard init parameters that are suggested when you create a new Metrica tag */
|
|
5
|
-
|
|
2
|
+
export const standardYMInitParameters = {
|
|
6
3
|
clickmap: true,
|
|
7
4
|
trackLinks: true,
|
|
8
5
|
accurateTrackBounce: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/constants/defaults.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/constants/defaults.ts"],"names":[],"mappings":"AAEA,wFAAwF;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;IAChB,mBAAmB,EAAE,IAAI;CACD,CAAC"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const dataLayerName = (0, react_1.useContext)(YandexMetricaProvider_1.MetricaEcommerceContext);
|
|
9
|
-
const pushToDataLayer = (0, react_1.useCallback)((data) => {
|
|
10
|
-
(0, ecommerce_1.dataLayerPush)(dataLayerName, { ecommerce: data });
|
|
1
|
+
import { useCallback, useContext, useMemo } from 'react';
|
|
2
|
+
import { MetricaEcommerceContext } from '../components/YandexMetricaProvider';
|
|
3
|
+
import { dataLayerPush } from '../lib/ecommerce';
|
|
4
|
+
export function useEcommerce(defaults) {
|
|
5
|
+
const dataLayerName = useContext(MetricaEcommerceContext);
|
|
6
|
+
const pushToDataLayer = useCallback((data) => {
|
|
7
|
+
dataLayerPush(dataLayerName, { ecommerce: data });
|
|
11
8
|
}, [dataLayerName]);
|
|
12
|
-
const makeStandardTrackProduct =
|
|
9
|
+
const makeStandardTrackProduct = useCallback((actionType) => (data) => {
|
|
13
10
|
var _a;
|
|
14
11
|
return pushToDataLayer({
|
|
15
12
|
currencyCode: (_a = defaults === null || defaults === void 0 ? void 0 : defaults.currencyCode) !== null && _a !== void 0 ? _a : data.currencyCode,
|
|
16
13
|
[actionType]: { products: [data.product] },
|
|
17
14
|
});
|
|
18
15
|
}, [defaults === null || defaults === void 0 ? void 0 : defaults.currencyCode, pushToDataLayer]);
|
|
19
|
-
const trackViewProduct =
|
|
20
|
-
const trackAddItemToBasket =
|
|
21
|
-
const trackRemoveItemFromBasket =
|
|
22
|
-
const trackPurchase =
|
|
16
|
+
const trackViewProduct = useMemo(() => makeStandardTrackProduct('detail'), [makeStandardTrackProduct]);
|
|
17
|
+
const trackAddItemToBasket = useMemo(() => makeStandardTrackProduct('add'), [makeStandardTrackProduct]);
|
|
18
|
+
const trackRemoveItemFromBasket = useMemo(() => makeStandardTrackProduct('remove'), [makeStandardTrackProduct]);
|
|
19
|
+
const trackPurchase = useCallback((data) => {
|
|
23
20
|
var _a;
|
|
24
21
|
pushToDataLayer({
|
|
25
22
|
currencyCode: (_a = defaults === null || defaults === void 0 ? void 0 : defaults.currencyCode) !== null && _a !== void 0 ? _a : data.currencyCode,
|
|
@@ -29,6 +26,15 @@ function useEcommerce(defaults) {
|
|
|
29
26
|
},
|
|
30
27
|
});
|
|
31
28
|
}, [defaults === null || defaults === void 0 ? void 0 : defaults.currencyCode, pushToDataLayer]);
|
|
29
|
+
// TODO Возможные значения:
|
|
30
|
+
// impressions — просмотр списка товаров;
|
|
31
|
+
// click — клик по товару в списке;
|
|
32
|
+
// detail — просмотр товара; // DONE
|
|
33
|
+
// add — добавление товара в корзину; // DONE
|
|
34
|
+
// remove — удаление товара из корзины; // DONE
|
|
35
|
+
// purchase — покупка; // DONE
|
|
36
|
+
// promoView — просмотр внутренней рекламы;
|
|
37
|
+
// promoClick — клик по внутренней рекламе.
|
|
32
38
|
return {
|
|
33
39
|
trackViewProduct,
|
|
34
40
|
trackAddItemToBasket,
|
|
@@ -37,5 +43,4 @@ function useEcommerce(defaults) {
|
|
|
37
43
|
pushToDataLayer,
|
|
38
44
|
};
|
|
39
45
|
}
|
|
40
|
-
exports.useEcommerce = useEcommerce;
|
|
41
46
|
//# sourceMappingURL=useEcommerce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEcommerce.js","sourceRoot":"","sources":["../../src/hooks/useEcommerce.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEcommerce.js","sourceRoot":"","sources":["../../src/hooks/useEcommerce.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AC,wBAAwB,CAAC,CAC3B,CAAC;IAEF,MAAM,aAAa,GAAG,WAAW,CAC/B,CACE,IAEwD,EACxD,EAAE;;QACF,eAAe,CAAC;YACd,YAAY,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,mCAAK,IAAI,CAAC,YAAuB;YACrE,QAAQ,EAAE;gBACR,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB;SACF,CAAC,CAAC;IACL,CAAC,EACD,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,EAAE,eAAe,CAAC,CAC1C,CAAC;IAEF,2BAA2B;IAC3B,yCAAyC;IACzC,mCAAmC;IACnC,oCAAoC;IACpC,6CAA6C;IAC7C,+CAA+C;IAC/C,8BAA8B;IAC9B,2CAA2C;IAC3C,2CAA2C;IAE3C,OAAO;QACL,gBAAgB;QAChB,oBAAoB;QACpB,yBAAyB;QACzB,aAAa;QAEb,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
package/dist/hooks/useMetrica.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const tagID = (0, react_1.useContext)(YandexMetricaProvider_1.MetricaTagIDContext);
|
|
9
|
-
const notBounce = (0, react_1.useCallback)((options) => {
|
|
10
|
-
(0, ym_1.ym)(tagID, 'notBounce', options);
|
|
1
|
+
import { useCallback, useContext } from 'react';
|
|
2
|
+
import { MetricaTagIDContext } from '../components/YandexMetricaProvider';
|
|
3
|
+
import { ym } from '../lib/ym';
|
|
4
|
+
export const useMetrica = () => {
|
|
5
|
+
const tagID = useContext(MetricaTagIDContext);
|
|
6
|
+
const notBounce = useCallback((options) => {
|
|
7
|
+
ym(tagID, 'notBounce', options);
|
|
11
8
|
}, [tagID]);
|
|
12
|
-
const reachGoal =
|
|
9
|
+
const reachGoal = useCallback((target,
|
|
13
10
|
/** Session parameters. @see https://yandex.com/support/metrica/objects/params-method.html */
|
|
14
11
|
params, callback) => {
|
|
15
|
-
|
|
12
|
+
ym(tagID, 'reachGoal', target, params, callback);
|
|
16
13
|
}, [tagID]);
|
|
17
|
-
const setUserID =
|
|
18
|
-
|
|
14
|
+
const setUserID = useCallback((userID) => {
|
|
15
|
+
ym(tagID, 'setUserID', userID);
|
|
19
16
|
}, [tagID]);
|
|
20
|
-
const userParams =
|
|
21
|
-
|
|
17
|
+
const userParams = useCallback((parameters) => {
|
|
18
|
+
ym(tagID, 'userParams', parameters);
|
|
22
19
|
}, [tagID]);
|
|
23
|
-
const ymEvent =
|
|
20
|
+
const ymEvent = useCallback((...parameters) => {
|
|
24
21
|
// @ts-expect-error silly overload logic
|
|
25
|
-
|
|
22
|
+
ym(tagID, ...parameters);
|
|
26
23
|
}, [tagID]);
|
|
27
24
|
return { notBounce, reachGoal, setUserID, userParams, ymEvent };
|
|
28
25
|
};
|
|
29
|
-
exports.useMetrica = useMetrica;
|
|
30
26
|
//# sourceMappingURL=useMetrica.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMetrica.js","sourceRoot":"","sources":["../../src/hooks/useMetrica.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useMetrica.js","sourceRoot":"","sources":["../../src/hooks/useMetrica.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAiB1E,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAE/B,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE;IAC7B,MAAM,KAAK,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAE9C,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,OAA0B,EA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
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.useTrackRouteChange = void 0;
|
|
27
|
-
const router_1 = __importStar(require("next/router"));
|
|
28
|
-
const react_1 = require("react");
|
|
29
|
-
const ym_1 = require("../lib/ym");
|
|
30
|
-
const useTrackRouteChange = ({ tagID, verbose, }) => {
|
|
31
|
-
const usingPagesDirectory = !!router_1.default.router;
|
|
32
|
-
(0, react_1.useEffect)(() => {
|
|
1
|
+
import Router, { Router as RouterClass } from 'next/router';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { ym } from '../lib/ym';
|
|
4
|
+
export const useTrackRouteChange = ({ tagID, verbose, }) => {
|
|
5
|
+
const usingPagesDirectory = !!Router.router;
|
|
6
|
+
useEffect(() => {
|
|
33
7
|
const handleRouteChange = (url) => {
|
|
34
8
|
if (verbose)
|
|
35
9
|
console.log('[next-yandex-metrica] (verbose): Sending "hit"', url);
|
|
36
|
-
|
|
10
|
+
ym(tagID, 'hit', url.toString());
|
|
37
11
|
};
|
|
38
12
|
if (usingPagesDirectory || process.env.NODE_ENV === 'test') {
|
|
39
13
|
// TODO test this logic branch with urls starting with '?'
|
|
40
|
-
|
|
14
|
+
RouterClass.events.on('routeChangeComplete', handleRouteChange);
|
|
41
15
|
return () => {
|
|
42
|
-
|
|
16
|
+
RouterClass.events.off('routeChangeComplete', handleRouteChange);
|
|
43
17
|
};
|
|
44
18
|
}
|
|
45
19
|
else {
|
|
@@ -76,5 +50,4 @@ const useTrackRouteChange = ({ tagID, verbose, }) => {
|
|
|
76
50
|
}
|
|
77
51
|
}, [tagID, usingPagesDirectory, verbose]);
|
|
78
52
|
};
|
|
79
|
-
exports.useTrackRouteChange = useTrackRouteChange;
|
|
80
53
|
//# sourceMappingURL=useTrackRouteChange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTrackRouteChange.js","sourceRoot":"","sources":["../../src/hooks/useTrackRouteChange.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTrackRouteChange.js","sourceRoot":"","sources":["../../src/hooks/useTrackRouteChange.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAE/B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,KAAK,EACL,OAAO,GAIR,EAAE,EAAE;IACH,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAE5C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,iBAAiB,GAAG,CAAC,GAAiB,EAAQ,EAAE;YACpD,IAAI,OAAO;gBAAE,OAAO,CAAC,GAAG,CAAC,gDAAgD,EAAE,GAAG,CAAC,CAAC;YAEhF,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnC,CAAC,CAAC;QAEF,IAAI,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;YAC3D,0DAA0D;YAC1D,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,qBAAqB,EAAE,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AG,iBAAiB,CAAC;gBACtC,OAAO,CAAC,YAAY,GAAG,oBAAoB,CAAC;YAC9C,CAAC,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ym = exports.Ecommerce = exports.useMetrica = exports.useEcommerce = exports.standardYMInitParameters = exports.YandexMetricaProvider = void 0;
|
|
27
|
-
var YandexMetricaProvider_1 = require("./components/YandexMetricaProvider");
|
|
28
|
-
Object.defineProperty(exports, "YandexMetricaProvider", { enumerable: true, get: function () { return YandexMetricaProvider_1.YandexMetricaProvider; } });
|
|
29
|
-
var defaults_1 = require("./constants/defaults");
|
|
30
|
-
Object.defineProperty(exports, "standardYMInitParameters", { enumerable: true, get: function () { return defaults_1.standardYMInitParameters; } });
|
|
31
|
-
var useEcommerce_1 = require("./hooks/useEcommerce");
|
|
32
|
-
Object.defineProperty(exports, "useEcommerce", { enumerable: true, get: function () { return useEcommerce_1.useEcommerce; } });
|
|
33
|
-
var useMetrica_1 = require("./hooks/useMetrica");
|
|
34
|
-
Object.defineProperty(exports, "useMetrica", { enumerable: true, get: function () { return useMetrica_1.useMetrica; } });
|
|
35
|
-
exports.Ecommerce = __importStar(require("./lib/ecommerce"));
|
|
36
|
-
var ym_1 = require("./lib/ym");
|
|
37
|
-
Object.defineProperty(exports, "ym", { enumerable: true, get: function () { return ym_1.ym; } });
|
|
1
|
+
export { YandexMetricaProvider } from './components/YandexMetricaProvider';
|
|
2
|
+
export { standardYMInitParameters } from './constants/defaults';
|
|
3
|
+
export { useEcommerce } from './hooks/useEcommerce';
|
|
4
|
+
export { useMetrica } from './hooks/useMetrica';
|
|
5
|
+
import * as Ecommerce_1 from './lib/ecommerce';
|
|
6
|
+
export { Ecommerce_1 as Ecommerce };
|
|
7
|
+
export { ym } from './lib/ym';
|
|
38
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;6BACrB,iBAAiB;wBAAhC,SAAS;AACrB,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/lib/ecommerce.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type Product = ({
|
|
|
31
31
|
} | {
|
|
32
32
|
id: string;
|
|
33
33
|
name: string;
|
|
34
|
-
}) & {
|
|
34
|
+
}) & Partial<{
|
|
35
35
|
/** The brand or trademark associated with the item. For example, "Yandex" */
|
|
36
36
|
brand: UniversalAnalytics.FieldsObject['brand'];
|
|
37
37
|
/**
|
|
@@ -42,18 +42,44 @@ export type Product = ({
|
|
|
42
42
|
category: UniversalAnalytics.FieldsObject['category'];
|
|
43
43
|
/** A promo code associated with the item. For example, "PARTNER_SITE_15" */
|
|
44
44
|
coupon: UniversalAnalytics.FieldsObject['coupon'];
|
|
45
|
-
/**
|
|
45
|
+
/** Discount amount as a number. */
|
|
46
|
+
discount: number | undefined;
|
|
47
|
+
/**
|
|
48
|
+
List that the item belongs to.
|
|
49
|
+
|
|
50
|
+
To evaluate the effectiveness of the list at different stages of user interaction with the product, we recommend specifying the product list in all events that occurred after the list was viewed.
|
|
51
|
+
*/
|
|
52
|
+
list: string | undefined;
|
|
53
|
+
/** Position of item in the list (Integer). For example, 2 */
|
|
46
54
|
position: number | undefined;
|
|
55
|
+
/** Price per unit */
|
|
47
56
|
price: number | undefined;
|
|
48
57
|
quantity: UniversalAnalytics.FieldsObject['quantity'];
|
|
49
58
|
/** A variation of the item. For example, "Red" */
|
|
50
59
|
variant: UniversalAnalytics.FieldsObject['variant'];
|
|
51
|
-
}
|
|
60
|
+
}>;
|
|
61
|
+
/** @see https://yandex.ru/support/metrica/ru/ecommerce/data#action_data */
|
|
52
62
|
type ActionField = {
|
|
63
|
+
/**
|
|
64
|
+
ID of the order, associated with the whole purchase.
|
|
65
|
+
@example 'TRX#54321'
|
|
66
|
+
*/
|
|
53
67
|
id: string;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
68
|
+
/** @inheritdoc */
|
|
69
|
+
coupon?: Product['coupon'];
|
|
70
|
+
/**
|
|
71
|
+
The goal number. Specified if this action was the goal.
|
|
72
|
+
The goal must be set as a JavaScript event type.
|
|
73
|
+
|
|
74
|
+
To see the goal number, go to Settings (the Goals tab) in the Yandex Metrica interface.
|
|
75
|
+
*/
|
|
76
|
+
goal_id?: number | undefined;
|
|
77
|
+
/**
|
|
78
|
+
The revenue received.
|
|
79
|
+
|
|
80
|
+
If omitted, it is calculated automatically as the sum of the prices of all the items associated with the purchase
|
|
81
|
+
*/
|
|
82
|
+
revenue?: number | undefined;
|
|
57
83
|
};
|
|
58
84
|
/** @see https://yandex.com/support/metrica/ecommerce/data.html */
|
|
59
85
|
export declare function dataLayerPush(dataLayerName: string | null, ...args: DataObject[]): void;
|
package/dist/lib/ecommerce.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dataLayerPush = void 0;
|
|
4
1
|
/** @see https://yandex.com/support/metrica/ecommerce/data.html */
|
|
5
|
-
function dataLayerPush(dataLayerName, ...args) {
|
|
2
|
+
export function dataLayerPush(dataLayerName, ...args) {
|
|
6
3
|
if (!dataLayerName)
|
|
7
4
|
return;
|
|
8
5
|
if (!(dataLayerName in window)) {
|
|
@@ -15,5 +12,4 @@ function dataLayerPush(dataLayerName, ...args) {
|
|
|
15
12
|
}
|
|
16
13
|
dataLayer.push(...args);
|
|
17
14
|
}
|
|
18
|
-
exports.dataLayerPush = dataLayerPush;
|
|
19
15
|
//# sourceMappingURL=ecommerce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecommerce.js","sourceRoot":"","sources":["../../src/lib/ecommerce.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ecommerce.js","sourceRoot":"","sources":["../../src/lib/ecommerce.ts"],"names":[],"mappings":"AAsFA,kEAAkE;AAClE,MAAM,UAAU,aAAa,CAAC,aAA4B,EAAE,GAAG,IAAkB;IAC/E,IAAI,CAAC,aAAa;QAAE,OAAO;IAE3B,IAAI,CAAC,CAAC,aAAa,IAAI,MAAM,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CACX,gCAAgC,aAAa,sGAAsG,CACpJ,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,aAAoC,CAA2B,CAAC;IAEzF,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IAED,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/lib/types/events.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutocompleteUnknownString } from '@artginzburg/experimental';
|
|
1
|
+
import type { AutocompleteUnknownString } from '@artginzburg/experimental/strong-ts/typed-string';
|
|
2
2
|
/** Session parameters. @see https://yandex.com/support/metrica/objects/params-method.html */
|
|
3
3
|
export interface VisitParameters {
|
|
4
4
|
/**
|
package/dist/lib/types/ym.js
CHANGED
package/dist/lib/ym.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ym = void 0;
|
|
4
1
|
// The implementation with a single function definition
|
|
5
|
-
function ym(tagID, ...parameters) {
|
|
2
|
+
export function ym(tagID, ...parameters) {
|
|
6
3
|
if (!('ym' in window)) {
|
|
7
4
|
console.error('[next-yandex-metrica] window.ym is not defined. Make sure to use YandexMetricaProvider');
|
|
8
5
|
return;
|
|
@@ -13,5 +10,4 @@ function ym(tagID, ...parameters) {
|
|
|
13
10
|
}
|
|
14
11
|
ym(tagID, ...parameters);
|
|
15
12
|
}
|
|
16
|
-
exports.ym = ym;
|
|
17
13
|
//# sourceMappingURL=ym.js.map
|
package/dist/lib/ym.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ym.js","sourceRoot":"","sources":["../../src/lib/ym.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ym.js","sourceRoot":"","sources":["../../src/lib/ym.ts"],"names":[],"mappings":"AA+BA,uDAAuD;AACvD,MAAM,UAAU,EAAE,CAAC,KAAoB,EAAE,GAAG,UAA2B;IACrE,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,KAAK,CACX,wFAAwF,CACzF,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,CAAC,EAAqB,CAAC;IAExC,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO;IACT,CAAC;IAED,EAAE,CAAC,KAAK,EAAE,GAAG,UAAU,CAAC,CAAC;AAC3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artginzburg/next-ym",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Yandex Metrica integration for Next.js v14",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"analytics"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
+
"@artginzburg/experimental": "^0.1.6",
|
|
33
34
|
"@testing-library/jest-dom": "^6.1.5",
|
|
34
35
|
"@testing-library/react": "^14.1.2",
|
|
35
36
|
"@types/google.analytics": "^0.0.46",
|