@gravity-ui/page-constructor 1.15.0-alpha.24 → 1.15.0-alpha.25
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/build/cjs/blocks/Share/Share.js +1 -2
- package/build/cjs/components/BackLink/BackLink.js +1 -2
- package/build/cjs/components/Button/Button.js +1 -2
- package/build/cjs/components/CardBase/CardBase.js +1 -2
- package/build/cjs/components/Link/Link.js +1 -2
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +1 -2
- package/build/cjs/components/YandexForm/YandexForm.js +1 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +1 -1
- package/build/cjs/hooks/index.d.ts +0 -1
- package/build/cjs/hooks/index.js +0 -1
- package/build/cjs/hooks/useAnalytics.d.ts +1 -1
- package/build/cjs/hooks/useAnalytics.js +12 -1
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +2 -2
- package/build/cjs/sub-blocks/HubspotForm/index.js +1 -2
- package/build/cjs/sub-blocks/Quote/Quote.js +1 -2
- package/build/esm/blocks/Share/Share.js +2 -3
- package/build/esm/components/BackLink/BackLink.js +2 -3
- package/build/esm/components/Button/Button.js +2 -3
- package/build/esm/components/CardBase/CardBase.js +2 -3
- package/build/esm/components/Link/Link.js +2 -3
- package/build/esm/components/ReactPlayer/ReactPlayer.js +2 -3
- package/build/esm/components/YandexForm/YandexForm.js +2 -3
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +1 -1
- package/build/esm/hooks/index.d.ts +0 -1
- package/build/esm/hooks/index.js +0 -1
- package/build/esm/hooks/useAnalytics.d.ts +1 -1
- package/build/esm/hooks/useAnalytics.js +13 -2
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +2 -2
- package/build/esm/sub-blocks/HubspotForm/index.js +2 -3
- package/build/esm/sub-blocks/Quote/Quote.js +2 -3
- package/package.json +1 -1
- package/build/cjs/hooks/useAnalyticsEvent.d.ts +0 -7
- package/build/cjs/hooks/useAnalyticsEvent.js +0 -16
- package/build/esm/hooks/useAnalyticsEvent.d.ts +0 -7
- package/build/esm/hooks/useAnalyticsEvent.js +0 -12
|
@@ -23,8 +23,7 @@ const icons = {
|
|
|
23
23
|
const b = (0, utils_1.block)('share-block');
|
|
24
24
|
const Share = ({ items, title }) => {
|
|
25
25
|
const { pathname, hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
26
|
-
const
|
|
27
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
26
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ShareButton);
|
|
28
27
|
const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics(), [handleAnalytics]);
|
|
29
28
|
return (react_1.default.createElement("div", { className: b() },
|
|
30
29
|
react_1.default.createElement("h5", { className: b('title') }, title || (0, i18n_1.default)('constructor-share')),
|
|
@@ -10,8 +10,7 @@ const models_1 = require("../../models");
|
|
|
10
10
|
function BackLink(props) {
|
|
11
11
|
const { history } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
12
12
|
const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
|
|
13
|
-
const
|
|
14
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
13
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ShareButton, url);
|
|
15
14
|
const backActionHandler = (0, react_1.useCallback)(async () => {
|
|
16
15
|
handleAnalytics();
|
|
17
16
|
if (!history) {
|
|
@@ -16,8 +16,7 @@ const Button = (props) => {
|
|
|
16
16
|
const { lang, tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
17
17
|
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = tslib_1.__rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
|
|
18
18
|
const defaultImgPosition = 'left';
|
|
19
|
-
const
|
|
20
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
19
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.Button, url);
|
|
21
20
|
const onClick = (0, react_1.useCallback)(() => {
|
|
22
21
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
23
22
|
handleAnalytics(analyticsEvents);
|
|
@@ -16,8 +16,7 @@ const Footer = () => null;
|
|
|
16
16
|
const Layout = (props) => {
|
|
17
17
|
const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', } = props;
|
|
18
18
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
19
|
-
const
|
|
20
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
19
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(common_1.DefaultEventNames.CardBase, url);
|
|
21
20
|
let header, content, footer, image, headerClass, footerClass;
|
|
22
21
|
function handleChild(child) {
|
|
23
22
|
switch (child.type) {
|
|
@@ -29,8 +29,7 @@ function getArrowSize(size) {
|
|
|
29
29
|
const LinkBlock = (props) => {
|
|
30
30
|
const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
|
|
31
31
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
32
|
-
const
|
|
33
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
32
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.Link, url);
|
|
34
33
|
const { hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
35
34
|
const { tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
36
35
|
const href = (0, utils_1.setUrlTld)(props.url, tld);
|
|
@@ -41,8 +41,7 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
41
41
|
}
|
|
42
42
|
return [];
|
|
43
43
|
}, [analyticsEvents]);
|
|
44
|
-
const
|
|
45
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
44
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ReactPlayerControls);
|
|
46
45
|
(0, react_1.useImperativeHandle)(originRef, () => ({
|
|
47
46
|
pause: () => setIsPlaying(false),
|
|
48
47
|
}));
|
|
@@ -19,8 +19,7 @@ const YandexForm = (props) => {
|
|
|
19
19
|
const iframeRef = (0, react_1.useRef)();
|
|
20
20
|
const yaFormOrigin = customFormOrigin || exports.YANDEX_FORM_ORIGIN;
|
|
21
21
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
22
|
-
const
|
|
23
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
22
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(common_1.DefaultEventNames.YandexFormSubmit);
|
|
24
23
|
const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
|
|
25
24
|
const locale = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
26
25
|
const updateFormIframe = (0, react_1.useCallback)((container) => {
|
package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -35,7 +35,7 @@ const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
|
35
35
|
if ('children' in item && item.children) {
|
|
36
36
|
children = item.children.map(renderer.bind(null, blockId));
|
|
37
37
|
}
|
|
38
|
-
itemElement = (react_1.default.createElement(blockIdContext_1.BlockIdContext.Provider, { value: blockId
|
|
38
|
+
itemElement = (react_1.default.createElement(blockIdContext_1.BlockIdContext.Provider, { value: blockId },
|
|
39
39
|
react_1.default.createElement(ConstructorItem_1.ConstructorItem, { data: item, key: key }, children)));
|
|
40
40
|
}
|
|
41
41
|
return blockTypes.includes(item.type) ? (react_1.default.createElement(ConstructorBlock_1.ConstructorBlock, { data: item, key: key, Component: itemElement })) : (itemElement);
|
|
@@ -3,5 +3,4 @@ export { default as useWindowBreakpoint } from './useWindowBreakpoint';
|
|
|
3
3
|
export { useIntersection } from './useIntersection';
|
|
4
4
|
export { default as useMount } from './useMount';
|
|
5
5
|
export * from './useAnalytics';
|
|
6
|
-
export * from './useAnalyticsEvent';
|
|
7
6
|
export * from './hubspot';
|
package/build/cjs/hooks/index.js
CHANGED
|
@@ -11,5 +11,4 @@ Object.defineProperty(exports, "useIntersection", { enumerable: true, get: funct
|
|
|
11
11
|
var useMount_1 = require("./useMount");
|
|
12
12
|
Object.defineProperty(exports, "useMount", { enumerable: true, get: function () { return tslib_1.__importDefault(useMount_1).default; } });
|
|
13
13
|
tslib_1.__exportStar(require("./useAnalytics"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./useAnalyticsEvent"), exports);
|
|
15
14
|
tslib_1.__exportStar(require("./hubspot"), exports);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnalyticsEvent } from '../models';
|
|
2
|
-
export declare const useAnalytics: (
|
|
2
|
+
export declare const useAnalytics: (name?: string, target?: string) => ((e?: AnalyticsEvent | AnalyticsEvent[]) => void) & import("lodash").MemoizedFunction;
|
|
@@ -3,9 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useAnalytics = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const blockIdContext_1 = require("../context/blockIdContext");
|
|
6
7
|
const analyticsContext_1 = require("../context/analyticsContext");
|
|
7
|
-
const
|
|
8
|
+
const models_1 = require("../models");
|
|
9
|
+
const useAnalytics = (name = '', target) => {
|
|
8
10
|
const { sendEvents, autoEvents } = (0, react_1.useContext)(analyticsContext_1.AnalyticsContext);
|
|
11
|
+
const context = (0, react_1.useContext)(blockIdContext_1.BlockIdContext);
|
|
12
|
+
const defaultEvent = (0, react_1.useMemo)(() => name
|
|
13
|
+
? {
|
|
14
|
+
name,
|
|
15
|
+
context,
|
|
16
|
+
type: models_1.PredefinedEventTypes.Default,
|
|
17
|
+
target: target,
|
|
18
|
+
}
|
|
19
|
+
: undefined, [context, name, target]);
|
|
9
20
|
if (!sendEvents) {
|
|
10
21
|
return (0, lodash_1.memoize)(() => { });
|
|
11
22
|
}
|
|
@@ -11,7 +11,7 @@ const SocialIcon_1 = tslib_1.__importDefault(require("../SocialIcon/SocialIcon")
|
|
|
11
11
|
const utils_2 = require("../../../components/Media/Image/utils");
|
|
12
12
|
const blockIdContext_1 = require("../../../context/blockIdContext");
|
|
13
13
|
const b = (0, utils_1.block)('navigation-item');
|
|
14
|
-
const
|
|
14
|
+
const ANALYTICS_ID = 'navigation';
|
|
15
15
|
const Content = ({ text, icon }) => (react_1.default.createElement(react_1.Fragment, null,
|
|
16
16
|
icon && typeof icon !== 'string' && react_1.default.createElement(components_1.Image, Object.assign({ className: b('icon') }, icon)),
|
|
17
17
|
react_1.default.createElement("span", { className: b('text') }, text)));
|
|
@@ -40,7 +40,7 @@ const NavigationLink = (props) => {
|
|
|
40
40
|
};
|
|
41
41
|
const NavigationButton = (props) => {
|
|
42
42
|
const { url, target } = props;
|
|
43
|
-
return (react_1.default.createElement(blockIdContext_1.BlockIdContext.Provider, { value:
|
|
43
|
+
return (react_1.default.createElement(blockIdContext_1.BlockIdContext.Provider, { value: ANALYTICS_ID }, target ? (react_1.default.createElement(components_1.Button, Object.assign({}, props, { url: url }))) : (react_1.default.createElement(components_1.RouterLink, { href: url },
|
|
44
44
|
react_1.default.createElement(components_1.Button, Object.assign({}, props, { url: url }))))));
|
|
45
45
|
};
|
|
46
46
|
//todo: add types support form component in map
|
|
@@ -15,8 +15,7 @@ const HubspotForm = (props) => {
|
|
|
15
15
|
// hubspotEvents, // TODO: decide how to handle them
|
|
16
16
|
analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, createDOMElement, onSubmitError, } = props;
|
|
17
17
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
18
|
-
const
|
|
19
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
18
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.HubspotFormSubmit);
|
|
20
19
|
const { themeValue } = (0, react_1.useContext)(ThemeValueContext_1.ThemeValueContext);
|
|
21
20
|
const isMobileValue = (0, react_1.useContext)(mobileContext_1.MobileContext);
|
|
22
21
|
const theme = themeProp !== null && themeProp !== void 0 ? themeProp : themeValue;
|
|
@@ -15,8 +15,7 @@ const Quote = (props) => {
|
|
|
15
15
|
const { themeValue: theme } = (0, react_1.useContext)(ThemeValueContext_1.ThemeValueContext);
|
|
16
16
|
const imageThemed = (0, utils_1.getThemedValue)(image, theme);
|
|
17
17
|
const imageData = (0, utils_2.getMediaImage)(imageThemed);
|
|
18
|
-
const
|
|
19
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
18
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.QuoteButton, url);
|
|
20
19
|
const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics(), [handleAnalytics]);
|
|
21
20
|
const renderFooter = Boolean(author || url) && (react_1.default.createElement("div", { className: b('author-wrapper') },
|
|
22
21
|
author && (react_1.default.createElement(components_1.Author, { className: b('author', { theme: textTheme }), author: author, type: models_1.AuthorType.Line })),
|
|
@@ -4,7 +4,7 @@ import { block, getAbsolutePath, getShareLink } from '../../utils';
|
|
|
4
4
|
import { DefaultEventNames } from '../../models';
|
|
5
5
|
import { LocationContext } from '../../context/locationContext';
|
|
6
6
|
import i18n from './i18n';
|
|
7
|
-
import { useAnalytics
|
|
7
|
+
import { useAnalytics } from '../../hooks';
|
|
8
8
|
import { Facebook } from '../../icons/Facebook';
|
|
9
9
|
import { Twitter } from '../../icons/Twitter';
|
|
10
10
|
import { Linkedin } from '../../icons/Linkedin';
|
|
@@ -21,8 +21,7 @@ const icons = {
|
|
|
21
21
|
const b = block('share-block');
|
|
22
22
|
const Share = ({ items, title }) => {
|
|
23
23
|
const { pathname, hostname } = useContext(LocationContext);
|
|
24
|
-
const
|
|
25
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
24
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.ShareButton);
|
|
26
25
|
const handleButtonClick = useCallback(() => handleAnalytics(), [handleAnalytics]);
|
|
27
26
|
return (React.createElement("div", { className: b() },
|
|
28
27
|
React.createElement("h5", { className: b('title') }, title || i18n('constructor-share')),
|
|
@@ -2,13 +2,12 @@ import React, { useCallback, useContext } from 'react';
|
|
|
2
2
|
import { Button, Icon } from '@gravity-ui/uikit';
|
|
3
3
|
import { ArrowSidebar } from '../../icons';
|
|
4
4
|
import { LocationContext } from '../../context/locationContext';
|
|
5
|
-
import { useAnalytics
|
|
5
|
+
import { useAnalytics } from '../../hooks';
|
|
6
6
|
import { DefaultEventNames } from '../../models';
|
|
7
7
|
export default function BackLink(props) {
|
|
8
8
|
const { history } = useContext(LocationContext);
|
|
9
9
|
const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
|
|
10
|
-
const
|
|
11
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
10
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.ShareButton, url);
|
|
12
11
|
const backActionHandler = useCallback(async () => {
|
|
13
12
|
handleAnalytics();
|
|
14
13
|
if (!history) {
|
|
@@ -6,7 +6,7 @@ import { DefaultEventNames } from '../../models';
|
|
|
6
6
|
import { toCommonSize, toCommonView } from './utils';
|
|
7
7
|
import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
8
8
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
9
|
-
import { useAnalytics
|
|
9
|
+
import { useAnalytics } from '../../hooks';
|
|
10
10
|
import { Github } from '../../icons';
|
|
11
11
|
import './Button.css';
|
|
12
12
|
const b = block('button-block');
|
|
@@ -15,8 +15,7 @@ const Button = (props) => {
|
|
|
15
15
|
const { lang, tld } = useContext(LocaleContext);
|
|
16
16
|
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
|
|
17
17
|
const defaultImgPosition = 'left';
|
|
18
|
-
const
|
|
19
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
18
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.Button, url);
|
|
20
19
|
const onClick = useCallback(() => {
|
|
21
20
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
22
21
|
handleAnalytics(analyticsEvents);
|
|
@@ -4,7 +4,7 @@ import BackgroundImage from '../BackgroundImage/BackgroundImage';
|
|
|
4
4
|
import RouterLink from '../RouterLink/RouterLink';
|
|
5
5
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
6
6
|
import { DefaultEventNames } from '../../models/common';
|
|
7
|
-
import { useAnalytics
|
|
7
|
+
import { useAnalytics } from '../../hooks';
|
|
8
8
|
import './CardBase.css';
|
|
9
9
|
const b = block('card-base-block');
|
|
10
10
|
const Header = () => null;
|
|
@@ -13,8 +13,7 @@ const Footer = () => null;
|
|
|
13
13
|
export const Layout = (props) => {
|
|
14
14
|
const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', } = props;
|
|
15
15
|
const handleMetrika = useMetrika();
|
|
16
|
-
const
|
|
17
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
16
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.CardBase, url);
|
|
18
17
|
let header, content, footer, image, headerClass, footerClass;
|
|
19
18
|
function handleChild(child) {
|
|
20
19
|
switch (child.type) {
|
|
@@ -8,7 +8,7 @@ import BackLink from '../BackLink/BackLink';
|
|
|
8
8
|
import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
9
9
|
import { LocationContext } from '../../context/locationContext/locationContext';
|
|
10
10
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
11
|
-
import { useAnalytics
|
|
11
|
+
import { useAnalytics } from '../../hooks';
|
|
12
12
|
import './Link.css';
|
|
13
13
|
const b = block('link-block');
|
|
14
14
|
const WORD_JOINER_SYM = '\u200b';
|
|
@@ -27,8 +27,7 @@ function getArrowSize(size) {
|
|
|
27
27
|
const LinkBlock = (props) => {
|
|
28
28
|
const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
|
|
29
29
|
const handleMetrika = useMetrika();
|
|
30
|
-
const
|
|
31
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
30
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.Link, url);
|
|
32
31
|
const { hostname } = useContext(LocationContext);
|
|
33
32
|
const { tld } = useContext(LocaleContext);
|
|
34
33
|
const href = setUrlTld(props.url, tld);
|
|
@@ -8,7 +8,7 @@ import CustomBarControls from './CustomBarControls';
|
|
|
8
8
|
import { VideoContext } from '../../context/videoContext';
|
|
9
9
|
import { MetrikaContext } from '../../context/metrikaContext';
|
|
10
10
|
import { MobileContext } from '../../context/mobileContext';
|
|
11
|
-
import { useAnalytics
|
|
11
|
+
import { useAnalytics } from '../../hooks';
|
|
12
12
|
import { PlayVideo } from '../../icons';
|
|
13
13
|
import './ReactPlayer.css';
|
|
14
14
|
const b = block('ReactPlayer');
|
|
@@ -38,8 +38,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
38
38
|
}
|
|
39
39
|
return [];
|
|
40
40
|
}, [analyticsEvents]);
|
|
41
|
-
const
|
|
42
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
41
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.ReactPlayerControls);
|
|
43
42
|
useImperativeHandle(originRef, () => ({
|
|
44
43
|
pause: () => setIsPlaying(false),
|
|
45
44
|
}));
|
|
@@ -5,7 +5,7 @@ import { MobileContext } from '../../context/mobileContext';
|
|
|
5
5
|
import { block } from '../../utils';
|
|
6
6
|
import { DefaultEventNames } from '../../models/common';
|
|
7
7
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
8
|
-
import { useAnalytics
|
|
8
|
+
import { useAnalytics } from '../../hooks';
|
|
9
9
|
export const YANDEX_FORM_ORIGIN = 'https://forms.yandex.ru';
|
|
10
10
|
const CONTAINER_ID = 'pc-yandex-form-container';
|
|
11
11
|
const b = block('yandex-form');
|
|
@@ -15,8 +15,7 @@ const YandexForm = (props) => {
|
|
|
15
15
|
const iframeRef = useRef();
|
|
16
16
|
const yaFormOrigin = customFormOrigin || YANDEX_FORM_ORIGIN;
|
|
17
17
|
const handleMetrika = useMetrika();
|
|
18
|
-
const
|
|
19
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
18
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.YandexFormSubmit);
|
|
20
19
|
const isMobile = useContext(MobileContext);
|
|
21
20
|
const locale = useContext(LocaleContext);
|
|
22
21
|
const updateFormIframe = useCallback((container) => {
|
package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -31,7 +31,7 @@ export const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
|
31
31
|
if ('children' in item && item.children) {
|
|
32
32
|
children = item.children.map(renderer.bind(null, blockId));
|
|
33
33
|
}
|
|
34
|
-
itemElement = (React.createElement(BlockIdContext.Provider, { value: blockId
|
|
34
|
+
itemElement = (React.createElement(BlockIdContext.Provider, { value: blockId },
|
|
35
35
|
React.createElement(ConstructorItem, { data: item, key: key }, children)));
|
|
36
36
|
}
|
|
37
37
|
return blockTypes.includes(item.type) ? (React.createElement(ConstructorBlock, { data: item, key: key, Component: itemElement })) : (itemElement);
|
|
@@ -3,5 +3,4 @@ export { default as useWindowBreakpoint } from './useWindowBreakpoint';
|
|
|
3
3
|
export { useIntersection } from './useIntersection';
|
|
4
4
|
export { default as useMount } from './useMount';
|
|
5
5
|
export * from './useAnalytics';
|
|
6
|
-
export * from './useAnalyticsEvent';
|
|
7
6
|
export * from './hubspot';
|
package/build/esm/hooks/index.js
CHANGED
|
@@ -3,5 +3,4 @@ export { default as useWindowBreakpoint } from './useWindowBreakpoint';
|
|
|
3
3
|
export { useIntersection } from './useIntersection';
|
|
4
4
|
export { default as useMount } from './useMount';
|
|
5
5
|
export * from './useAnalytics';
|
|
6
|
-
export * from './useAnalyticsEvent';
|
|
7
6
|
export * from './hubspot';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnalyticsEvent } from '../models';
|
|
2
|
-
export declare const useAnalytics: (
|
|
2
|
+
export declare const useAnalytics: (name?: string, target?: string) => ((e?: AnalyticsEvent | AnalyticsEvent[]) => void) & import("lodash").MemoizedFunction;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { memoize } from 'lodash';
|
|
2
|
-
import { useContext } from 'react';
|
|
2
|
+
import { useContext, useMemo } from 'react';
|
|
3
|
+
import { BlockIdContext } from '../context/blockIdContext';
|
|
3
4
|
import { AnalyticsContext } from '../context/analyticsContext';
|
|
4
|
-
|
|
5
|
+
import { PredefinedEventTypes } from '../models';
|
|
6
|
+
export const useAnalytics = (name = '', target) => {
|
|
5
7
|
const { sendEvents, autoEvents } = useContext(AnalyticsContext);
|
|
8
|
+
const context = useContext(BlockIdContext);
|
|
9
|
+
const defaultEvent = useMemo(() => name
|
|
10
|
+
? {
|
|
11
|
+
name,
|
|
12
|
+
context,
|
|
13
|
+
type: PredefinedEventTypes.Default,
|
|
14
|
+
target: target,
|
|
15
|
+
}
|
|
16
|
+
: undefined, [context, name, target]);
|
|
6
17
|
if (!sendEvents) {
|
|
7
18
|
return memoize(() => { });
|
|
8
19
|
}
|
|
@@ -10,7 +10,7 @@ import { getMediaImage } from '../../../components/Media/Image/utils';
|
|
|
10
10
|
import { BlockIdContext } from '../../../context/blockIdContext';
|
|
11
11
|
import './NavigationItem.css';
|
|
12
12
|
const b = block('navigation-item');
|
|
13
|
-
const
|
|
13
|
+
const ANALYTICS_ID = 'navigation';
|
|
14
14
|
const Content = ({ text, icon }) => (React.createElement(Fragment, null,
|
|
15
15
|
icon && typeof icon !== 'string' && React.createElement(Image, Object.assign({ className: b('icon') }, icon)),
|
|
16
16
|
React.createElement("span", { className: b('text') }, text)));
|
|
@@ -39,7 +39,7 @@ const NavigationLink = (props) => {
|
|
|
39
39
|
};
|
|
40
40
|
const NavigationButton = (props) => {
|
|
41
41
|
const { url, target } = props;
|
|
42
|
-
return (React.createElement(BlockIdContext.Provider, { value:
|
|
42
|
+
return (React.createElement(BlockIdContext.Provider, { value: ANALYTICS_ID }, target ? (React.createElement(Button, Object.assign({}, props, { url: url }))) : (React.createElement(RouterLink, { href: url },
|
|
43
43
|
React.createElement(Button, Object.assign({}, props, { url: url }))))));
|
|
44
44
|
};
|
|
45
45
|
//todo: add types support form component in map
|
|
@@ -4,7 +4,7 @@ import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
|
|
|
4
4
|
import { MobileContext } from '../../context/mobileContext';
|
|
5
5
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
6
6
|
import { DefaultEventNames } from '../../models';
|
|
7
|
-
import { useHandleHubspotEvents, useAnalytics
|
|
7
|
+
import { useHandleHubspotEvents, useAnalytics } from '../../hooks';
|
|
8
8
|
import HubspotFormContainer from './HubspotFormContainer';
|
|
9
9
|
import './HubspotForm.css';
|
|
10
10
|
const b = block('hubspot-form');
|
|
@@ -13,8 +13,7 @@ const HubspotForm = (props) => {
|
|
|
13
13
|
// hubspotEvents, // TODO: decide how to handle them
|
|
14
14
|
analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, createDOMElement, onSubmitError, } = props;
|
|
15
15
|
const handleMetrika = useMetrika();
|
|
16
|
-
const
|
|
17
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
16
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.HubspotFormSubmit);
|
|
18
17
|
const { themeValue } = useContext(ThemeValueContext);
|
|
19
18
|
const isMobileValue = useContext(MobileContext);
|
|
20
19
|
const theme = themeProp !== null && themeProp !== void 0 ? themeProp : themeValue;
|
|
@@ -5,7 +5,7 @@ import { AuthorType, DefaultEventNames } from '../../models';
|
|
|
5
5
|
import { Author, Image, HTML } from '../../components';
|
|
6
6
|
import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
|
|
7
7
|
import { getMediaImage } from '../../components/Media/Image/utils';
|
|
8
|
-
import { useAnalytics
|
|
8
|
+
import { useAnalytics } from '../../hooks';
|
|
9
9
|
import './Quote.css';
|
|
10
10
|
const b = block('quote');
|
|
11
11
|
const Quote = (props) => {
|
|
@@ -13,8 +13,7 @@ const Quote = (props) => {
|
|
|
13
13
|
const { themeValue: theme } = useContext(ThemeValueContext);
|
|
14
14
|
const imageThemed = getThemedValue(image, theme);
|
|
15
15
|
const imageData = getMediaImage(imageThemed);
|
|
16
|
-
const
|
|
17
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
16
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.QuoteButton, url);
|
|
18
17
|
const handleButtonClick = useCallback(() => handleAnalytics(), [handleAnalytics]);
|
|
19
18
|
const renderFooter = Boolean(author || url) && (React.createElement("div", { className: b('author-wrapper') },
|
|
20
19
|
author && (React.createElement(Author, { className: b('author', { theme: textTheme }), author: author, type: AuthorType.Line })),
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useAnalyticsEvent = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const models_1 = require("../models");
|
|
6
|
-
const blockIdContext_1 = require("../context/blockIdContext");
|
|
7
|
-
const useAnalyticsEvent = (name, target) => {
|
|
8
|
-
const context = (0, react_1.useContext)(blockIdContext_1.BlockIdContext);
|
|
9
|
-
return (0, react_1.useMemo)(() => ({
|
|
10
|
-
name,
|
|
11
|
-
context,
|
|
12
|
-
type: models_1.PredefinedEventTypes.Default,
|
|
13
|
-
target,
|
|
14
|
-
}), [context, name, target]);
|
|
15
|
-
};
|
|
16
|
-
exports.useAnalyticsEvent = useAnalyticsEvent;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useContext, useMemo } from 'react';
|
|
2
|
-
import { PredefinedEventTypes } from '../models';
|
|
3
|
-
import { BlockIdContext } from '../context/blockIdContext';
|
|
4
|
-
export const useAnalyticsEvent = (name, target) => {
|
|
5
|
-
const context = useContext(BlockIdContext);
|
|
6
|
-
return useMemo(() => ({
|
|
7
|
-
name,
|
|
8
|
-
context,
|
|
9
|
-
type: PredefinedEventTypes.Default,
|
|
10
|
-
target,
|
|
11
|
-
}), [context, name, target]);
|
|
12
|
-
};
|