@gravity-ui/page-constructor 1.15.0-alpha.5 → 1.15.0-alpha.7
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/Banner/schema.d.ts +18 -0
- package/build/cjs/blocks/Media/schema.d.ts +6 -0
- package/build/cjs/blocks/Share/Share.js +7 -6
- package/build/cjs/components/BackLink/BackLink.js +8 -7
- package/build/cjs/components/Button/Button.js +8 -11
- package/build/cjs/components/ButtonTabs/ButtonTabs.js +10 -4
- package/build/cjs/components/CardBase/CardBase.js +7 -2
- package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +7 -6
- package/build/cjs/components/Link/Link.js +7 -2
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +11 -29
- package/build/cjs/components/YandexForm/YandexForm.js +8 -8
- package/build/cjs/constants.d.ts +1 -0
- package/build/cjs/constants.js +2 -1
- package/build/cjs/context/analyticsContext/analyticsContext.d.ts +1 -1
- package/build/cjs/hooks/useAnalytics.d.ts +2 -2
- package/build/cjs/hooks/useAnalytics.js +11 -4
- package/build/cjs/models/common.d.ts +1 -1
- package/build/cjs/schema/validators/common.d.ts +12 -0
- package/build/cjs/schema/validators/event.d.ts +3 -0
- package/build/cjs/schema/validators/event.js +3 -0
- package/build/cjs/sub-blocks/HubspotForm/index.js +7 -7
- package/build/cjs/sub-blocks/Quote/Quote.js +7 -6
- package/build/esm/blocks/Banner/schema.d.ts +18 -0
- package/build/esm/blocks/Media/schema.d.ts +6 -0
- package/build/esm/blocks/Share/Share.js +7 -6
- package/build/esm/components/BackLink/BackLink.js +8 -7
- package/build/esm/components/Button/Button.js +8 -11
- package/build/esm/components/ButtonTabs/ButtonTabs.js +10 -4
- package/build/esm/components/CardBase/CardBase.js +7 -2
- package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +7 -6
- package/build/esm/components/Link/Link.js +7 -2
- package/build/esm/components/ReactPlayer/ReactPlayer.js +11 -29
- package/build/esm/components/YandexForm/YandexForm.js +8 -8
- package/build/esm/constants.d.ts +1 -0
- package/build/esm/constants.js +1 -0
- package/build/esm/context/analyticsContext/analyticsContext.d.ts +1 -1
- package/build/esm/hooks/useAnalytics.d.ts +2 -2
- package/build/esm/hooks/useAnalytics.js +11 -4
- package/build/esm/models/common.d.ts +1 -1
- package/build/esm/schema/validators/common.d.ts +12 -0
- package/build/esm/schema/validators/event.d.ts +3 -0
- package/build/esm/schema/validators/event.js +3 -0
- package/build/esm/sub-blocks/HubspotForm/index.js +7 -7
- package/build/esm/sub-blocks/Quote/Quote.js +7 -6
- package/package.json +1 -1
- package/server/models/common.d.ts +1 -1
|
@@ -206,6 +206,9 @@ export declare const BannerCardProps: {
|
|
|
206
206
|
};
|
|
207
207
|
};
|
|
208
208
|
};
|
|
209
|
+
blockName: {
|
|
210
|
+
type: string;
|
|
211
|
+
};
|
|
209
212
|
};
|
|
210
213
|
} | {
|
|
211
214
|
type: string;
|
|
@@ -241,6 +244,9 @@ export declare const BannerCardProps: {
|
|
|
241
244
|
};
|
|
242
245
|
};
|
|
243
246
|
};
|
|
247
|
+
blockName: {
|
|
248
|
+
type: string;
|
|
249
|
+
};
|
|
244
250
|
};
|
|
245
251
|
};
|
|
246
252
|
})[];
|
|
@@ -483,6 +489,9 @@ export declare const BannerBlock: {
|
|
|
483
489
|
};
|
|
484
490
|
};
|
|
485
491
|
};
|
|
492
|
+
blockName: {
|
|
493
|
+
type: string;
|
|
494
|
+
};
|
|
486
495
|
};
|
|
487
496
|
} | {
|
|
488
497
|
type: string;
|
|
@@ -518,6 +527,9 @@ export declare const BannerBlock: {
|
|
|
518
527
|
};
|
|
519
528
|
};
|
|
520
529
|
};
|
|
530
|
+
blockName: {
|
|
531
|
+
type: string;
|
|
532
|
+
};
|
|
521
533
|
};
|
|
522
534
|
};
|
|
523
535
|
})[];
|
|
@@ -761,6 +773,9 @@ export declare const BannerCard: {
|
|
|
761
773
|
};
|
|
762
774
|
};
|
|
763
775
|
};
|
|
776
|
+
blockName: {
|
|
777
|
+
type: string;
|
|
778
|
+
};
|
|
764
779
|
};
|
|
765
780
|
} | {
|
|
766
781
|
type: string;
|
|
@@ -796,6 +811,9 @@ export declare const BannerCard: {
|
|
|
796
811
|
};
|
|
797
812
|
};
|
|
798
813
|
};
|
|
814
|
+
blockName: {
|
|
815
|
+
type: string;
|
|
816
|
+
};
|
|
799
817
|
};
|
|
800
818
|
};
|
|
801
819
|
})[];
|
|
@@ -459,6 +459,9 @@ export declare const MediaBlock: {
|
|
|
459
459
|
};
|
|
460
460
|
};
|
|
461
461
|
};
|
|
462
|
+
blockName: {
|
|
463
|
+
type: string;
|
|
464
|
+
};
|
|
462
465
|
};
|
|
463
466
|
} | {
|
|
464
467
|
type: string;
|
|
@@ -494,6 +497,9 @@ export declare const MediaBlock: {
|
|
|
494
497
|
};
|
|
495
498
|
};
|
|
496
499
|
};
|
|
500
|
+
blockName: {
|
|
501
|
+
type: string;
|
|
502
|
+
};
|
|
497
503
|
};
|
|
498
504
|
};
|
|
499
505
|
})[];
|
|
@@ -10,6 +10,7 @@ import { Twitter } from '../../icons/Twitter';
|
|
|
10
10
|
import { Linkedin } from '../../icons/Linkedin';
|
|
11
11
|
import { Vk } from '../../icons/Vk';
|
|
12
12
|
import { Telegram } from '../../icons/Telegram';
|
|
13
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
13
14
|
import './Share.css';
|
|
14
15
|
const icons = {
|
|
15
16
|
facebook: Facebook,
|
|
@@ -21,12 +22,12 @@ const icons = {
|
|
|
21
22
|
const b = block('share-block');
|
|
22
23
|
const Share = ({ items, title, blockName = BlockType.ShareBlock }) => {
|
|
23
24
|
const { pathname, hostname } = useContext(LocationContext);
|
|
24
|
-
const handleAnalytics = useAnalytics(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const handleAnalytics = useAnalytics({
|
|
26
|
+
name: 'share-button-click',
|
|
27
|
+
type: DEFAULT_EVENT_TYPE,
|
|
28
|
+
blockName: blockName,
|
|
29
|
+
});
|
|
30
|
+
const handleButtonClick = useCallback(() => handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(), [handleAnalytics]);
|
|
30
31
|
return (React.createElement("div", { className: b() },
|
|
31
32
|
React.createElement("h5", { className: b('title') }, title || i18n('constructor-share')),
|
|
32
33
|
React.createElement("div", { className: b('items') }, items.map((type) => {
|
|
@@ -3,17 +3,18 @@ import { Button, Icon } from '@gravity-ui/uikit';
|
|
|
3
3
|
import { ArrowSidebar } from '../../icons';
|
|
4
4
|
import { LocationContext } from '../../context/locationContext';
|
|
5
5
|
import { useAnalytics } from '../../hooks';
|
|
6
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
6
7
|
const COMPONENT_NAME = 'backlink';
|
|
7
8
|
export default function BackLink(props) {
|
|
8
9
|
const { history } = useContext(LocationContext);
|
|
9
|
-
const handleAnalytics = useAnalytics();
|
|
10
10
|
const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, blockName = COMPONENT_NAME, } = props;
|
|
11
|
+
const handleAnalytics = useAnalytics({
|
|
12
|
+
name: 'back-link-click',
|
|
13
|
+
type: DEFAULT_EVENT_TYPE,
|
|
14
|
+
blockName: blockName,
|
|
15
|
+
});
|
|
11
16
|
const backActionHandler = useCallback(async () => {
|
|
12
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(
|
|
13
|
-
name: 'default',
|
|
14
|
-
type: 'button',
|
|
15
|
-
block: blockName,
|
|
16
|
-
});
|
|
17
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics();
|
|
17
18
|
if (!history) {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
@@ -26,7 +27,7 @@ export default function BackLink(props) {
|
|
|
26
27
|
else {
|
|
27
28
|
history.push({ pathname: url });
|
|
28
29
|
}
|
|
29
|
-
}, [
|
|
30
|
+
}, [handleAnalytics, history, onClick, url]);
|
|
30
31
|
return (React.createElement(Button, { className: className, view: theme === 'special' ? 'flat-contrast' : 'flat-secondary', size: size, href: shouldHandleBackAction ? undefined : url, onClick: shouldHandleBackAction ? backActionHandler : undefined },
|
|
31
32
|
React.createElement(Icon, { data: ArrowSidebar, size: 24 }),
|
|
32
33
|
React.createElement("span", null, title)));
|
|
@@ -7,30 +7,27 @@ import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
|
7
7
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
8
8
|
import { useAnalytics } from '../../hooks';
|
|
9
9
|
import { Github } from '../../icons';
|
|
10
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
10
11
|
import './Button.css';
|
|
11
12
|
const COMPONENT_NAME = 'button';
|
|
12
13
|
const b = block('button-block');
|
|
13
14
|
const Button = (props) => {
|
|
14
15
|
const handleMetrika = useMetrika();
|
|
15
|
-
const handleAnalytics = useAnalytics();
|
|
16
16
|
const { lang, tld } = useContext(LocaleContext);
|
|
17
17
|
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text, blockName = COMPONENT_NAME } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text", "blockName"]);
|
|
18
18
|
const defaultImgPosition = 'left';
|
|
19
|
+
const handleAnalytics = useAnalytics({
|
|
20
|
+
name: 'button-click',
|
|
21
|
+
type: DEFAULT_EVENT_TYPE,
|
|
22
|
+
blockName: blockName,
|
|
23
|
+
});
|
|
19
24
|
const onClick = useCallback(() => {
|
|
20
25
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
21
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
26
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
22
27
|
if (onClickOrigin) {
|
|
23
28
|
onClickOrigin();
|
|
24
29
|
}
|
|
25
|
-
}, [
|
|
26
|
-
handleMetrika,
|
|
27
|
-
metrikaGoals,
|
|
28
|
-
pixelEvents,
|
|
29
|
-
handleAnalytics,
|
|
30
|
-
analyticsEvents,
|
|
31
|
-
blockName,
|
|
32
|
-
onClickOrigin,
|
|
33
|
-
]);
|
|
30
|
+
}, [handleMetrika, metrikaGoals, pixelEvents, handleAnalytics, analyticsEvents, onClickOrigin]);
|
|
34
31
|
const buttonImg = img instanceof Object
|
|
35
32
|
? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
|
|
36
33
|
: { url: img, position: defaultImgPosition };
|
|
@@ -2,11 +2,17 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
2
2
|
import { block } from '../../utils';
|
|
3
3
|
import { Button } from '../index';
|
|
4
4
|
import { useAnalytics } from '../../hooks';
|
|
5
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
5
6
|
import './ButtonTabs.css';
|
|
6
7
|
const b = block('button-tabs');
|
|
8
|
+
const COMPONENT_NAME = 'button-tabs';
|
|
7
9
|
const ButtonTabs = (props) => {
|
|
8
|
-
const { className, items, activeTab, onSelectTab, blockName =
|
|
9
|
-
const handleAnalytics = useAnalytics(
|
|
10
|
+
const { className, items, activeTab, onSelectTab, blockName = COMPONENT_NAME } = props;
|
|
11
|
+
const handleAnalytics = useAnalytics({
|
|
12
|
+
name: 'button-tabs-click',
|
|
13
|
+
type: DEFAULT_EVENT_TYPE,
|
|
14
|
+
blockName: blockName,
|
|
15
|
+
});
|
|
10
16
|
const activeTabId = useMemo(() => {
|
|
11
17
|
if (activeTab) {
|
|
12
18
|
return activeTab;
|
|
@@ -14,11 +20,11 @@ const ButtonTabs = (props) => {
|
|
|
14
20
|
return items[0].id;
|
|
15
21
|
}, [activeTab, items]);
|
|
16
22
|
const handleClick = useCallback((tabId) => {
|
|
17
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(
|
|
23
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics();
|
|
18
24
|
if (onSelectTab) {
|
|
19
25
|
onSelectTab(tabId);
|
|
20
26
|
}
|
|
21
|
-
}, [
|
|
27
|
+
}, [handleAnalytics, onSelectTab]);
|
|
22
28
|
return (React.createElement("div", { className: b(null, className) }, items.map((item) => {
|
|
23
29
|
const isActive = item.id === activeTabId;
|
|
24
30
|
return (React.createElement(Button, { text: item.title, className: b('item', { active: isActive }), key: item.title, size: 'l', onClick: () => handleClick(item.id), theme: isActive ? 'monochrome' : 'normal' }));
|
|
@@ -4,6 +4,7 @@ import BackgroundImage from '../BackgroundImage/BackgroundImage';
|
|
|
4
4
|
import RouterLink from '../RouterLink/RouterLink';
|
|
5
5
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
6
6
|
import { useAnalytics } from '../../hooks';
|
|
7
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
7
8
|
import './CardBase.css';
|
|
8
9
|
const COMPONENT_NAME = 'card-base';
|
|
9
10
|
const b = block('card-base-block');
|
|
@@ -13,7 +14,11 @@ const Footer = () => null;
|
|
|
13
14
|
export const Layout = (props) => {
|
|
14
15
|
const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', blockName = COMPONENT_NAME, } = props;
|
|
15
16
|
const handleMetrika = useMetrika();
|
|
16
|
-
const handleAnalytics = useAnalytics(
|
|
17
|
+
const handleAnalytics = useAnalytics({
|
|
18
|
+
name: 'card-base-click',
|
|
19
|
+
type: DEFAULT_EVENT_TYPE,
|
|
20
|
+
blockName: blockName,
|
|
21
|
+
});
|
|
17
22
|
let header, content, footer, image, headerClass, footerClass;
|
|
18
23
|
function handleChild(child) {
|
|
19
24
|
switch (child.type) {
|
|
@@ -46,7 +51,7 @@ export const Layout = (props) => {
|
|
|
46
51
|
const fullClassName = b({ border }, className);
|
|
47
52
|
const onClick = () => {
|
|
48
53
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
49
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
54
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
50
55
|
};
|
|
51
56
|
return url ? (React.createElement(RouterLink, { href: url },
|
|
52
57
|
React.createElement("a", { href: url, target: target, rel: target === '_blank' ? 'noopener noreferrer' : undefined, className: fullClassName, draggable: false, onDragStart: (e) => e.preventDefault(), onClick: onClick }, cardContent))) : (React.createElement("div", { className: fullClassName }, cardContent));
|
|
@@ -2,20 +2,21 @@ import React from 'react';
|
|
|
2
2
|
import { block } from '../../utils';
|
|
3
3
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
4
4
|
import { useAnalytics } from '../../hooks';
|
|
5
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
5
6
|
import './HeaderBreadcrumbs.css';
|
|
6
7
|
const b = block('header-breadcrumbs');
|
|
7
8
|
const COMPONENT_NAME = 'header-breadcrumbs';
|
|
8
9
|
export default function HeaderBreadcrumbs(props) {
|
|
9
10
|
const { items, metrikaGoals, pixelEvents, analyticsEvents, theme = 'light', blockName = COMPONENT_NAME, className, } = props;
|
|
10
11
|
const handleMetrika = useMetrika();
|
|
11
|
-
const handleAnalytics = useAnalytics(
|
|
12
|
+
const handleAnalytics = useAnalytics({
|
|
13
|
+
name: 'header-breadcrumbs-click',
|
|
14
|
+
type: DEFAULT_EVENT_TYPE,
|
|
15
|
+
blockName: blockName,
|
|
16
|
+
});
|
|
12
17
|
const onClick = () => {
|
|
13
18
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
14
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
15
|
-
name: 'default',
|
|
16
|
-
type: 'header-breadcrumbs',
|
|
17
|
-
block: blockName,
|
|
18
|
-
});
|
|
19
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
19
20
|
};
|
|
20
21
|
return (React.createElement("div", { className: b({ theme }, className) }, items.map((item) => (React.createElement("div", { className: b('item'), key: item.url },
|
|
21
22
|
React.createElement("a", { href: item.url, className: b('text'), onClick: onClick }, item.text))))));
|
|
@@ -8,6 +8,7 @@ import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
|
8
8
|
import { LocationContext } from '../../context/locationContext/locationContext';
|
|
9
9
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
10
10
|
import { useAnalytics } from '../../hooks';
|
|
11
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
11
12
|
import './Link.css';
|
|
12
13
|
const b = block('link-block');
|
|
13
14
|
const WORD_JOINER_SYM = '\u200b';
|
|
@@ -27,14 +28,18 @@ function getArrowSize(size) {
|
|
|
27
28
|
const LinkBlock = (props) => {
|
|
28
29
|
const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, blockName = COMPONENT_NAME, } = props;
|
|
29
30
|
const handleMetrika = useMetrika();
|
|
30
|
-
const handleAnalytics = useAnalytics(
|
|
31
|
+
const handleAnalytics = useAnalytics({
|
|
32
|
+
name: 'link-click',
|
|
33
|
+
type: DEFAULT_EVENT_TYPE,
|
|
34
|
+
blockName: blockName,
|
|
35
|
+
});
|
|
31
36
|
const { hostname } = useContext(LocationContext);
|
|
32
37
|
const { tld } = useContext(LocaleContext);
|
|
33
38
|
const href = setUrlTld(props.url, tld);
|
|
34
39
|
const defaultTextSize = theme === 'back' ? 'l' : 'm';
|
|
35
40
|
const onClick = () => {
|
|
36
41
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
37
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
42
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
38
43
|
};
|
|
39
44
|
const getLinkByType = () => {
|
|
40
45
|
switch (theme) {
|
|
@@ -10,6 +10,7 @@ import { MetrikaContext } from '../../context/metrikaContext';
|
|
|
10
10
|
import { MobileContext } from '../../context/mobileContext';
|
|
11
11
|
import { PlayVideo } from '../../icons';
|
|
12
12
|
import { useAnalytics } from '../../hooks';
|
|
13
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
13
14
|
import './ReactPlayer.css';
|
|
14
15
|
const b = block('ReactPlayer');
|
|
15
16
|
const FPS = 60;
|
|
@@ -33,7 +34,11 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
33
34
|
const [started, setStarted] = useState(autoPlay);
|
|
34
35
|
const [paused, setPaused] = useState(false);
|
|
35
36
|
const [ended, setEnded] = useState(false);
|
|
36
|
-
const handleAnalytics = useAnalytics(
|
|
37
|
+
const handleAnalytics = useAnalytics({
|
|
38
|
+
name: 'react-player-controls-click',
|
|
39
|
+
type: DEFAULT_EVENT_TYPE,
|
|
40
|
+
blockName: blockName,
|
|
41
|
+
});
|
|
37
42
|
useImperativeHandle(originRef, () => ({
|
|
38
43
|
pause: () => setIsPlaying(false),
|
|
39
44
|
}));
|
|
@@ -109,30 +114,14 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
109
114
|
metrika.reachGoals(goal, counterName);
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (events) {
|
|
115
|
-
handleAnalytics(events, {
|
|
116
|
-
type: 'react-player-change-mute',
|
|
117
|
-
block: blockName,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
117
|
+
const events = isMuted ? playEvents : stopEvents;
|
|
118
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(events);
|
|
121
119
|
if (isMuted) {
|
|
122
120
|
setProps({ playingVideoRef: ref.current });
|
|
123
121
|
}
|
|
124
122
|
// In order to the progress bar to update (equals 0) before displaying
|
|
125
123
|
setTimeout(() => setMuted(!isMuted), 0);
|
|
126
|
-
}, [
|
|
127
|
-
playerRef,
|
|
128
|
-
metrika,
|
|
129
|
-
videoMetrika,
|
|
130
|
-
handleAnalytics,
|
|
131
|
-
playEvents,
|
|
132
|
-
stopEvents,
|
|
133
|
-
blockName,
|
|
134
|
-
setProps,
|
|
135
|
-
]);
|
|
124
|
+
}, [playerRef, metrika, videoMetrika, handleAnalytics, playEvents, stopEvents, setProps]);
|
|
136
125
|
const handleClick = useCallback(() => changeMute(muted), [changeMute, muted]);
|
|
137
126
|
const handleClickPreview = useCallback(() => {
|
|
138
127
|
setIsPlaying(true);
|
|
@@ -143,15 +132,8 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
143
132
|
metrika.reachGoals(play, counterName);
|
|
144
133
|
}
|
|
145
134
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
handleAnalytics(playEvents, {
|
|
149
|
-
type: 'react-player-preview',
|
|
150
|
-
block: blockName,
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents, blockName]);
|
|
135
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(playEvents);
|
|
136
|
+
}, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents]);
|
|
155
137
|
const onPause = useCallback(() => {
|
|
156
138
|
// For support correct state for youtube
|
|
157
139
|
setIsPlaying(false);
|
|
@@ -4,7 +4,8 @@ import { LocaleContext } from '../../context/localeContext';
|
|
|
4
4
|
import { MobileContext } from '../../context/mobileContext';
|
|
5
5
|
import { block } from '../../utils';
|
|
6
6
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
7
|
-
import { useAnalytics } from '
|
|
7
|
+
import { useAnalytics } from '../../hooks';
|
|
8
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
8
9
|
export const YANDEX_FORM_ORIGIN = 'https://forms.yandex.ru';
|
|
9
10
|
const CONTAINER_ID = 'pc-yandex-form-container';
|
|
10
11
|
const COMPONENT_NAME = 'yandex-form';
|
|
@@ -15,7 +16,11 @@ const YandexForm = (props) => {
|
|
|
15
16
|
const iframeRef = useRef();
|
|
16
17
|
const yaFormOrigin = customFormOrigin || YANDEX_FORM_ORIGIN;
|
|
17
18
|
const handleMetrika = useMetrika();
|
|
18
|
-
const handleAnalytics = useAnalytics(
|
|
19
|
+
const handleAnalytics = useAnalytics({
|
|
20
|
+
name: 'yndex-form-submit',
|
|
21
|
+
type: DEFAULT_EVENT_TYPE,
|
|
22
|
+
blockName: blockName,
|
|
23
|
+
});
|
|
19
24
|
const isMobile = useContext(MobileContext);
|
|
20
25
|
const locale = useContext(LocaleContext);
|
|
21
26
|
const updateFormIframe = useCallback((container) => {
|
|
@@ -56,11 +61,7 @@ const YandexForm = (props) => {
|
|
|
56
61
|
window.scrollBy(0, top - headerHeight);
|
|
57
62
|
}
|
|
58
63
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
59
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
60
|
-
name: 'default',
|
|
61
|
-
type: 'yandex-form',
|
|
62
|
-
block: blockName,
|
|
63
|
-
});
|
|
64
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
64
65
|
if (onSubmit) {
|
|
65
66
|
onSubmit();
|
|
66
67
|
}
|
|
@@ -70,7 +71,6 @@ const YandexForm = (props) => {
|
|
|
70
71
|
pixelEvents,
|
|
71
72
|
handleAnalytics,
|
|
72
73
|
analyticsEvents,
|
|
73
|
-
blockName,
|
|
74
74
|
onSubmit,
|
|
75
75
|
headerHeight,
|
|
76
76
|
]);
|
package/build/esm/constants.d.ts
CHANGED
package/build/esm/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AnalyticsEvent } from '../../models';
|
|
3
3
|
export interface AnalyticsContextProps {
|
|
4
|
-
sendEvents?: (e: AnalyticsEvent | AnalyticsEvent[]
|
|
4
|
+
sendEvents?: (e: AnalyticsEvent | AnalyticsEvent[]) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare const AnalyticsContext: React.Context<AnalyticsContextProps>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AnalyticsEvent
|
|
2
|
-
export declare const useAnalytics: () => ((e?: AnalyticsEvent | AnalyticsEvent[]
|
|
1
|
+
import { AnalyticsEvent } from '../models';
|
|
2
|
+
export declare const useAnalytics: (defaultEvent?: AnalyticsEvent) => ((e?: AnalyticsEvent | AnalyticsEvent[]) => void) | undefined;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import { AnalyticsContext } from '../context/analyticsContext';
|
|
3
|
-
export const useAnalytics = () => {
|
|
3
|
+
export const useAnalytics = (defaultEvent) => {
|
|
4
4
|
const { sendEvents } = useContext(AnalyticsContext);
|
|
5
5
|
if (!sendEvents) {
|
|
6
6
|
return undefined;
|
|
7
7
|
}
|
|
8
|
-
return (e
|
|
9
|
-
|
|
8
|
+
return (e) => {
|
|
9
|
+
let events = [];
|
|
10
|
+
if (defaultEvent && e) {
|
|
11
|
+
events = Array.isArray(e) ? [...e, defaultEvent] : [e, defaultEvent];
|
|
12
|
+
}
|
|
13
|
+
else if (e) {
|
|
14
|
+
events = e;
|
|
15
|
+
}
|
|
16
|
+
if (!events) {
|
|
10
17
|
return;
|
|
11
18
|
}
|
|
12
|
-
sendEvents(
|
|
19
|
+
sendEvents(events);
|
|
13
20
|
};
|
|
14
21
|
};
|
|
@@ -538,6 +538,9 @@ export declare const ButtonProps: {
|
|
|
538
538
|
};
|
|
539
539
|
};
|
|
540
540
|
};
|
|
541
|
+
blockName: {
|
|
542
|
+
type: string;
|
|
543
|
+
};
|
|
541
544
|
};
|
|
542
545
|
} | {
|
|
543
546
|
type: string;
|
|
@@ -573,6 +576,9 @@ export declare const ButtonProps: {
|
|
|
573
576
|
};
|
|
574
577
|
};
|
|
575
578
|
};
|
|
579
|
+
blockName: {
|
|
580
|
+
type: string;
|
|
581
|
+
};
|
|
576
582
|
};
|
|
577
583
|
};
|
|
578
584
|
})[];
|
|
@@ -834,6 +840,9 @@ export declare const ButtonBlock: {
|
|
|
834
840
|
};
|
|
835
841
|
};
|
|
836
842
|
};
|
|
843
|
+
blockName: {
|
|
844
|
+
type: string;
|
|
845
|
+
};
|
|
837
846
|
};
|
|
838
847
|
} | {
|
|
839
848
|
type: string;
|
|
@@ -869,6 +878,9 @@ export declare const ButtonBlock: {
|
|
|
869
878
|
};
|
|
870
879
|
};
|
|
871
880
|
};
|
|
881
|
+
blockName: {
|
|
882
|
+
type: string;
|
|
883
|
+
};
|
|
872
884
|
};
|
|
873
885
|
};
|
|
874
886
|
})[];
|
|
@@ -6,6 +6,7 @@ import { useMetrika } from '../../hooks/useMetrika';
|
|
|
6
6
|
import { SubBlockType } from '../../models';
|
|
7
7
|
import { useHandleHubspotEvents, useAnalytics } from '../../hooks';
|
|
8
8
|
import HubspotFormContainer from './HubspotFormContainer';
|
|
9
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
9
10
|
import './HubspotForm.css';
|
|
10
11
|
const b = block('hubspot-form');
|
|
11
12
|
const HubspotForm = (props) => {
|
|
@@ -13,7 +14,11 @@ const HubspotForm = (props) => {
|
|
|
13
14
|
// hubspotEvents, // TODO: decide how to handle them
|
|
14
15
|
analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, blockName = SubBlockType.HubspotForm, } = props;
|
|
15
16
|
const handleMetrika = useMetrika();
|
|
16
|
-
const handleAnalytics = useAnalytics(
|
|
17
|
+
const handleAnalytics = useAnalytics({
|
|
18
|
+
name: 'hubspot-form-submit',
|
|
19
|
+
type: DEFAULT_EVENT_TYPE,
|
|
20
|
+
blockName: blockName,
|
|
21
|
+
});
|
|
17
22
|
const { themeValue } = useContext(ThemeValueContext);
|
|
18
23
|
const isMobileValue = useContext(MobileContext);
|
|
19
24
|
const theme = themeProp !== null && themeProp !== void 0 ? themeProp : themeValue;
|
|
@@ -24,11 +29,7 @@ const HubspotForm = (props) => {
|
|
|
24
29
|
onLoad,
|
|
25
30
|
onSubmit: (e) => {
|
|
26
31
|
handleMetrika === null || handleMetrika === void 0 ? void 0 : handleMetrika({ pixelEvents });
|
|
27
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents
|
|
28
|
-
name: 'default',
|
|
29
|
-
type: 'hubspot-form',
|
|
30
|
-
block: blockName,
|
|
31
|
-
});
|
|
32
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
32
33
|
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(e);
|
|
33
34
|
},
|
|
34
35
|
}), [
|
|
@@ -39,7 +40,6 @@ const HubspotForm = (props) => {
|
|
|
39
40
|
pixelEvents,
|
|
40
41
|
handleAnalytics,
|
|
41
42
|
analyticsEvents,
|
|
42
|
-
blockName,
|
|
43
43
|
onSubmit,
|
|
44
44
|
]);
|
|
45
45
|
useHandleHubspotEvents(handlers, formId);
|
|
@@ -6,6 +6,7 @@ import { Author, Image, HTML } from '../../components';
|
|
|
6
6
|
import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
|
|
7
7
|
import { getMediaImage } from '../../components/Media/Image/utils';
|
|
8
8
|
import { useAnalytics } from '../../hooks';
|
|
9
|
+
import { DEFAULT_EVENT_TYPE } from '../../constants';
|
|
9
10
|
import './Quote.css';
|
|
10
11
|
const b = block('quote');
|
|
11
12
|
const Quote = (props) => {
|
|
@@ -13,12 +14,12 @@ const Quote = (props) => {
|
|
|
13
14
|
const { themeValue: theme } = useContext(ThemeValueContext);
|
|
14
15
|
const imageThemed = getThemedValue(image, theme);
|
|
15
16
|
const imageData = getMediaImage(imageThemed);
|
|
16
|
-
const handleAnalytics = useAnalytics(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const handleAnalytics = useAnalytics({
|
|
18
|
+
name: 'quote-button-click',
|
|
19
|
+
type: DEFAULT_EVENT_TYPE,
|
|
20
|
+
blockName: blockName,
|
|
21
|
+
});
|
|
22
|
+
const handleButtonClick = useCallback(() => handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(), [handleAnalytics]);
|
|
22
23
|
const renderFooter = Boolean(author || url) && (React.createElement("div", { className: b('author-wrapper') },
|
|
23
24
|
author && (React.createElement(Author, { className: b('author', { theme: textTheme }), author: author, type: AuthorType.Line })),
|
|
24
25
|
url && buttonText && (React.createElement(Button, { view: "outlined", size: "xl", href: url, className: b('link-button', { theme: textTheme }), onClick: handleButtonClick }, buttonText))));
|
package/package.json
CHANGED