@gravity-ui/page-constructor 1.19.1 → 1.20.1

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.
Files changed (147) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +79 -6
  3. package/build/cjs/blocks/Banner/schema.d.ts +234 -0
  4. package/build/cjs/blocks/CardLayout/schema.d.ts +6 -0
  5. package/build/cjs/blocks/ContentLayout/schema.d.ts +3 -0
  6. package/build/cjs/blocks/ExtendedFeatures/schema.d.ts +81 -0
  7. package/build/cjs/blocks/Header/schema.d.ts +3 -0
  8. package/build/cjs/blocks/HeaderSlider/schema.d.ts +3 -0
  9. package/build/cjs/blocks/Icons/schema.d.ts +6 -0
  10. package/build/cjs/blocks/LinkTable/schema.d.ts +3 -0
  11. package/build/cjs/blocks/Map/schema.d.ts +81 -0
  12. package/build/cjs/blocks/Media/schema.d.ts +162 -0
  13. package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
  14. package/build/cjs/blocks/Questions/schema.d.ts +3 -0
  15. package/build/cjs/blocks/Share/Share.js +5 -1
  16. package/build/cjs/blocks/Simple/schema.d.ts +3 -0
  17. package/build/cjs/blocks/Slider/schema.d.ts +3 -0
  18. package/build/cjs/blocks/Table/schema.d.ts +3 -0
  19. package/build/cjs/blocks/Tabs/schema.d.ts +81 -0
  20. package/build/cjs/components/BackLink/BackLink.js +5 -1
  21. package/build/cjs/components/Button/Button.js +6 -2
  22. package/build/cjs/components/CardBase/CardBase.d.ts +2 -1
  23. package/build/cjs/components/CardBase/CardBase.js +5 -1
  24. package/build/cjs/components/Link/Link.js +5 -1
  25. package/build/cjs/components/Media/Media.js +3 -2
  26. package/build/cjs/components/Media/Video/Video.js +3 -2
  27. package/build/cjs/components/ReactPlayer/ReactPlayer.js +16 -3
  28. package/build/cjs/components/YandexForm/YandexForm.d.ts +2 -1
  29. package/build/cjs/components/YandexForm/YandexForm.js +14 -2
  30. package/build/cjs/containers/PageConstructor/Provider.d.ts +2 -0
  31. package/build/cjs/containers/PageConstructor/Provider.js +3 -1
  32. package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +7 -4
  33. package/build/cjs/context/analyticsContext/analyticsContext.d.ts +7 -0
  34. package/build/cjs/context/analyticsContext/analyticsContext.js +6 -0
  35. package/build/cjs/context/analyticsContext/index.d.ts +1 -0
  36. package/build/cjs/context/analyticsContext/index.js +4 -0
  37. package/build/cjs/context/blockIdContext/blockIdContext.d.ts +3 -0
  38. package/build/cjs/context/blockIdContext/blockIdContext.js +6 -0
  39. package/build/cjs/context/blockIdContext/index.d.ts +1 -0
  40. package/build/cjs/context/blockIdContext/index.js +4 -0
  41. package/build/cjs/context/metrikaContext/metrikaContext.d.ts +6 -0
  42. package/build/cjs/hooks/index.d.ts +1 -0
  43. package/build/cjs/hooks/index.js +1 -0
  44. package/build/cjs/hooks/useAnalytics.d.ts +2 -0
  45. package/build/cjs/hooks/useAnalytics.js +35 -0
  46. package/build/cjs/hooks/useMetrika.d.ts +6 -0
  47. package/build/cjs/hooks/useMetrika.js +8 -0
  48. package/build/cjs/models/common.d.ts +45 -0
  49. package/build/cjs/models/common.js +22 -1
  50. package/build/cjs/models/constructor-items/common.d.ts +5 -5
  51. package/build/cjs/models/constructor-items/sub-blocks.d.ts +2 -2
  52. package/build/cjs/models/navigation.d.ts +3 -9
  53. package/build/cjs/models/navigation.js +0 -1
  54. package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +4 -3
  55. package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js +4 -2
  56. package/build/cjs/schema/validators/common.d.ts +249 -0
  57. package/build/cjs/schema/validators/common.js +14 -0
  58. package/build/cjs/schema/validators/event.d.ts +37 -0
  59. package/build/cjs/schema/validators/event.js +38 -0
  60. package/build/cjs/sub-blocks/HubspotForm/index.js +15 -2
  61. package/build/cjs/sub-blocks/LayoutItem/utils.d.ts +13 -0
  62. package/build/cjs/sub-blocks/Quote/Quote.js +4 -1
  63. package/build/cjs/utils/analytics.d.ts +2 -0
  64. package/build/cjs/utils/analytics.js +17 -0
  65. package/build/cjs/utils/index.d.ts +1 -0
  66. package/build/cjs/utils/index.js +1 -0
  67. package/build/esm/blocks/Banner/schema.d.ts +234 -0
  68. package/build/esm/blocks/CardLayout/schema.d.ts +6 -0
  69. package/build/esm/blocks/ContentLayout/schema.d.ts +3 -0
  70. package/build/esm/blocks/ExtendedFeatures/schema.d.ts +81 -0
  71. package/build/esm/blocks/Header/schema.d.ts +3 -0
  72. package/build/esm/blocks/HeaderSlider/schema.d.ts +3 -0
  73. package/build/esm/blocks/Icons/schema.d.ts +6 -0
  74. package/build/esm/blocks/LinkTable/schema.d.ts +3 -0
  75. package/build/esm/blocks/Map/schema.d.ts +81 -0
  76. package/build/esm/blocks/Media/schema.d.ts +162 -0
  77. package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
  78. package/build/esm/blocks/Questions/schema.d.ts +3 -0
  79. package/build/esm/blocks/Share/Share.js +6 -2
  80. package/build/esm/blocks/Simple/schema.d.ts +3 -0
  81. package/build/esm/blocks/Slider/schema.d.ts +3 -0
  82. package/build/esm/blocks/Table/schema.d.ts +3 -0
  83. package/build/esm/blocks/Tabs/schema.d.ts +81 -0
  84. package/build/esm/components/BackLink/BackLink.js +5 -1
  85. package/build/esm/components/Button/Button.js +6 -2
  86. package/build/esm/components/CardBase/CardBase.d.ts +2 -1
  87. package/build/esm/components/CardBase/CardBase.js +5 -1
  88. package/build/esm/components/Link/Link.js +5 -1
  89. package/build/esm/components/Media/Media.js +3 -2
  90. package/build/esm/components/Media/Video/Video.js +3 -2
  91. package/build/esm/components/ReactPlayer/ReactPlayer.js +17 -4
  92. package/build/esm/components/YandexForm/YandexForm.d.ts +2 -1
  93. package/build/esm/components/YandexForm/YandexForm.js +14 -2
  94. package/build/esm/containers/PageConstructor/Provider.d.ts +2 -0
  95. package/build/esm/containers/PageConstructor/Provider.js +3 -1
  96. package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +7 -4
  97. package/build/esm/context/analyticsContext/analyticsContext.d.ts +7 -0
  98. package/build/esm/context/analyticsContext/analyticsContext.js +2 -0
  99. package/build/esm/context/analyticsContext/index.d.ts +1 -0
  100. package/build/esm/context/analyticsContext/index.js +1 -0
  101. package/build/esm/context/blockIdContext/blockIdContext.d.ts +3 -0
  102. package/build/esm/context/blockIdContext/blockIdContext.js +2 -0
  103. package/build/esm/context/blockIdContext/index.d.ts +1 -0
  104. package/build/esm/context/blockIdContext/index.js +1 -0
  105. package/build/esm/context/metrikaContext/metrikaContext.d.ts +6 -0
  106. package/build/esm/hooks/index.d.ts +1 -0
  107. package/build/esm/hooks/index.js +1 -0
  108. package/build/esm/hooks/useAnalytics.d.ts +2 -0
  109. package/build/esm/hooks/useAnalytics.js +31 -0
  110. package/build/esm/hooks/useMetrika.d.ts +6 -0
  111. package/build/esm/hooks/useMetrika.js +8 -0
  112. package/build/esm/models/common.d.ts +45 -0
  113. package/build/esm/models/common.js +21 -0
  114. package/build/esm/models/constructor-items/common.d.ts +5 -5
  115. package/build/esm/models/constructor-items/sub-blocks.d.ts +2 -2
  116. package/build/esm/models/navigation.d.ts +3 -9
  117. package/build/esm/models/navigation.js +0 -1
  118. package/build/esm/navigation/components/NavigationItem/NavigationItem.js +4 -3
  119. package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js +4 -2
  120. package/build/esm/schema/validators/common.d.ts +249 -0
  121. package/build/esm/schema/validators/common.js +14 -0
  122. package/build/esm/schema/validators/event.d.ts +37 -0
  123. package/build/esm/schema/validators/event.js +35 -0
  124. package/build/esm/sub-blocks/HubspotForm/index.js +16 -3
  125. package/build/esm/sub-blocks/LayoutItem/utils.d.ts +13 -0
  126. package/build/esm/sub-blocks/Quote/Quote.js +6 -3
  127. package/build/esm/utils/analytics.d.ts +2 -0
  128. package/build/esm/utils/analytics.js +13 -0
  129. package/build/esm/utils/index.d.ts +1 -0
  130. package/build/esm/utils/index.js +1 -0
  131. package/package.json +1 -2
  132. package/server/models/common.d.ts +45 -0
  133. package/server/models/common.js +22 -1
  134. package/server/models/constructor-items/common.d.ts +5 -5
  135. package/server/models/constructor-items/sub-blocks.d.ts +2 -2
  136. package/server/models/navigation.d.ts +3 -9
  137. package/server/models/navigation.js +0 -1
  138. package/server/utils/analytics.d.ts +2 -0
  139. package/server/utils/analytics.js +17 -0
  140. package/server/utils/index.d.ts +1 -0
  141. package/server/utils/index.js +1 -0
  142. package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.css +0 -14
  143. package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts +0 -5
  144. package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.js +0 -11
  145. package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.css +0 -14
  146. package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts +0 -6
  147. package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.js +0 -7
@@ -287,6 +287,84 @@ export declare const MediaBlockBaseProps: {
287
287
  };
288
288
  };
289
289
  };
290
+ analyticsEvents: {
291
+ anyOf: ({
292
+ type: string;
293
+ additionalProperties: {
294
+ type: string;
295
+ };
296
+ required: string[];
297
+ properties: {
298
+ name: {
299
+ type: string;
300
+ };
301
+ type: {
302
+ type: string;
303
+ };
304
+ counters: {
305
+ type: string;
306
+ additionalProperties: boolean;
307
+ required: never[];
308
+ properties: {
309
+ include: {
310
+ type: string;
311
+ items: {
312
+ type: string;
313
+ };
314
+ };
315
+ exclude: {
316
+ type: string;
317
+ items: {
318
+ type: string;
319
+ };
320
+ };
321
+ };
322
+ };
323
+ context: {
324
+ type: string;
325
+ };
326
+ };
327
+ } | {
328
+ type: string;
329
+ items: {
330
+ type: string;
331
+ additionalProperties: {
332
+ type: string;
333
+ };
334
+ required: string[];
335
+ properties: {
336
+ name: {
337
+ type: string;
338
+ };
339
+ type: {
340
+ type: string;
341
+ };
342
+ counters: {
343
+ type: string;
344
+ additionalProperties: boolean;
345
+ required: never[];
346
+ properties: {
347
+ include: {
348
+ type: string;
349
+ items: {
350
+ type: string;
351
+ };
352
+ };
353
+ exclude: {
354
+ type: string;
355
+ items: {
356
+ type: string;
357
+ };
358
+ };
359
+ };
360
+ };
361
+ context: {
362
+ type: string;
363
+ };
364
+ };
365
+ };
366
+ })[];
367
+ };
290
368
  target: {
291
369
  type: string;
292
370
  enum: string[];
@@ -386,6 +464,9 @@ export declare const MediaBlockBaseProps: {
386
464
  resetPaddings: {
387
465
  type: string;
388
466
  };
467
+ context: {
468
+ type: string;
469
+ };
389
470
  type: {};
390
471
  when: {};
391
472
  };
@@ -682,6 +763,84 @@ export declare const MediaBlock: {
682
763
  };
683
764
  };
684
765
  };
766
+ analyticsEvents: {
767
+ anyOf: ({
768
+ type: string;
769
+ additionalProperties: {
770
+ type: string;
771
+ };
772
+ required: string[];
773
+ properties: {
774
+ name: {
775
+ type: string;
776
+ };
777
+ type: {
778
+ type: string;
779
+ };
780
+ counters: {
781
+ type: string;
782
+ additionalProperties: boolean;
783
+ required: never[];
784
+ properties: {
785
+ include: {
786
+ type: string;
787
+ items: {
788
+ type: string;
789
+ };
790
+ };
791
+ exclude: {
792
+ type: string;
793
+ items: {
794
+ type: string;
795
+ };
796
+ };
797
+ };
798
+ };
799
+ context: {
800
+ type: string;
801
+ };
802
+ };
803
+ } | {
804
+ type: string;
805
+ items: {
806
+ type: string;
807
+ additionalProperties: {
808
+ type: string;
809
+ };
810
+ required: string[];
811
+ properties: {
812
+ name: {
813
+ type: string;
814
+ };
815
+ type: {
816
+ type: string;
817
+ };
818
+ counters: {
819
+ type: string;
820
+ additionalProperties: boolean;
821
+ required: never[];
822
+ properties: {
823
+ include: {
824
+ type: string;
825
+ items: {
826
+ type: string;
827
+ };
828
+ };
829
+ exclude: {
830
+ type: string;
831
+ items: {
832
+ type: string;
833
+ };
834
+ };
835
+ };
836
+ };
837
+ context: {
838
+ type: string;
839
+ };
840
+ };
841
+ };
842
+ })[];
843
+ };
685
844
  target: {
686
845
  type: string;
687
846
  enum: string[];
@@ -781,6 +940,9 @@ export declare const MediaBlock: {
781
940
  resetPaddings: {
782
941
  type: string;
783
942
  };
943
+ context: {
944
+ type: string;
945
+ };
784
946
  type: {};
785
947
  when: {};
786
948
  };
@@ -222,6 +222,9 @@ export declare const PromoFeaturesBlock: {
222
222
  resetPaddings: {
223
223
  type: string;
224
224
  };
225
+ context: {
226
+ type: string;
227
+ };
225
228
  type: {};
226
229
  when: {};
227
230
  };
@@ -91,6 +91,9 @@ export declare const QuestionsBlock: {
91
91
  resetPaddings: {
92
92
  type: string;
93
93
  };
94
+ context: {
95
+ type: string;
96
+ };
94
97
  type: {};
95
98
  when: {};
96
99
  };
@@ -1,8 +1,10 @@
1
- import React, { useContext } from 'react';
1
+ import React, { useContext, useCallback } from 'react';
2
2
  import { Icon, Button } from '@gravity-ui/uikit';
3
3
  import { block, getAbsolutePath, getShareLink } from '../../utils';
4
+ import { DefaultEventNames } from '../../models';
4
5
  import { LocationContext } from '../../context/locationContext';
5
6
  import i18n from './i18n';
7
+ import { useAnalytics } from '../../hooks';
6
8
  import { Facebook } from '../../icons/Facebook';
7
9
  import { Twitter } from '../../icons/Twitter';
8
10
  import { Linkedin } from '../../icons/Linkedin';
@@ -19,13 +21,15 @@ const icons = {
19
21
  const b = block('share-block');
20
22
  const Share = ({ items, title }) => {
21
23
  const { pathname, hostname } = useContext(LocationContext);
24
+ const handleAnalytics = useAnalytics(DefaultEventNames.ShareButton);
25
+ const handleButtonClick = useCallback(() => handleAnalytics(), [handleAnalytics]);
22
26
  return (React.createElement("div", { className: b() },
23
27
  React.createElement("h5", { className: b('title') }, title || i18n('constructor-share')),
24
28
  React.createElement("div", { className: b('items') }, items.map((type) => {
25
29
  const url = getAbsolutePath(hostname, pathname);
26
30
  const socialUrl = getShareLink(url, type);
27
31
  const icon = icons[type];
28
- return (React.createElement(Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }) }, icon && React.createElement(Icon, { data: icon, size: 24, className: b('icon', { type }) })));
32
+ return (React.createElement(Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }), onClick: handleButtonClick }, icon && React.createElement(Icon, { data: icon, size: 24, className: b('icon', { type }) })));
29
33
  }))));
30
34
  };
31
35
  export default Share;
@@ -33,6 +33,9 @@ export declare const SimpleBlock: {
33
33
  resetPaddings: {
34
34
  type: string;
35
35
  };
36
+ context: {
37
+ type: string;
38
+ };
36
39
  type: {};
37
40
  when: {};
38
41
  title: {
@@ -211,6 +211,9 @@ export declare const SliderBlock: {
211
211
  resetPaddings: {
212
212
  type: string;
213
213
  };
214
+ context: {
215
+ type: string;
216
+ };
214
217
  type: {};
215
218
  when: {};
216
219
  };
@@ -64,6 +64,9 @@ export declare const TableBlock: {
64
64
  resetPaddings: {
65
65
  type: string;
66
66
  };
67
+ context: {
68
+ type: string;
69
+ };
67
70
  type: {};
68
71
  when: {};
69
72
  };
@@ -177,6 +177,84 @@ export declare const tabsItem: {
177
177
  type: string;
178
178
  enum: string[];
179
179
  };
180
+ analyticsEvents: {
181
+ anyOf: ({
182
+ type: string;
183
+ additionalProperties: {
184
+ type: string;
185
+ };
186
+ required: string[];
187
+ properties: {
188
+ name: {
189
+ type: string;
190
+ };
191
+ type: {
192
+ type: string;
193
+ };
194
+ counters: {
195
+ type: string;
196
+ additionalProperties: boolean;
197
+ required: never[];
198
+ properties: {
199
+ include: {
200
+ type: string;
201
+ items: {
202
+ type: string;
203
+ };
204
+ };
205
+ exclude: {
206
+ type: string;
207
+ items: {
208
+ type: string;
209
+ };
210
+ };
211
+ };
212
+ };
213
+ context: {
214
+ type: string;
215
+ };
216
+ };
217
+ } | {
218
+ type: string;
219
+ items: {
220
+ type: string;
221
+ additionalProperties: {
222
+ type: string;
223
+ };
224
+ required: string[];
225
+ properties: {
226
+ name: {
227
+ type: string;
228
+ };
229
+ type: {
230
+ type: string;
231
+ };
232
+ counters: {
233
+ type: string;
234
+ additionalProperties: boolean;
235
+ required: never[];
236
+ properties: {
237
+ include: {
238
+ type: string;
239
+ items: {
240
+ type: string;
241
+ };
242
+ };
243
+ exclude: {
244
+ type: string;
245
+ items: {
246
+ type: string;
247
+ };
248
+ };
249
+ };
250
+ };
251
+ context: {
252
+ type: string;
253
+ };
254
+ };
255
+ };
256
+ })[];
257
+ };
180
258
  type: {};
181
259
  when: {};
182
260
  };
@@ -341,6 +419,9 @@ export declare const TabsBlock: {
341
419
  resetPaddings: {
342
420
  type: string;
343
421
  };
422
+ context: {
423
+ type: string;
424
+ };
344
425
  type: {};
345
426
  when: {};
346
427
  };
@@ -2,10 +2,14 @@ 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 } from '../../hooks';
6
+ import { DefaultEventNames } from '../../models';
5
7
  export default function BackLink(props) {
6
8
  const { history } = useContext(LocationContext);
7
9
  const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
10
+ const handleAnalytics = useAnalytics(DefaultEventNames.ShareButton, url);
8
11
  const backActionHandler = useCallback(async () => {
12
+ handleAnalytics();
9
13
  if (!history) {
10
14
  return;
11
15
  }
@@ -18,7 +22,7 @@ export default function BackLink(props) {
18
22
  else {
19
23
  history.push({ pathname: url });
20
24
  }
21
- }, [history, onClick, url]);
25
+ }, [handleAnalytics, history, onClick, url]);
22
26
  return (React.createElement(Button, { className: className, view: theme === 'special' ? 'flat-contrast' : 'flat-secondary', size: size, href: shouldHandleBackAction ? undefined : url, onClick: shouldHandleBackAction ? backActionHandler : undefined },
23
27
  React.createElement(Icon, { data: ArrowSidebar, size: 24 }),
24
28
  React.createElement("span", null, title)));
@@ -2,23 +2,27 @@ import { __rest } from "tslib";
2
2
  import React, { useCallback, useContext } from 'react';
3
3
  import { Platform, Button as CommonButton, Icon, StoreBadge } from '@gravity-ui/uikit';
4
4
  import { block, setUrlTld } from '../../utils';
5
+ import { DefaultEventNames } from '../../models';
5
6
  import { toCommonSize, toCommonView } from './utils';
6
7
  import { LocaleContext } from '../../context/localeContext/localeContext';
7
8
  import { useMetrika } from '../../hooks/useMetrika';
9
+ import { useAnalytics } from '../../hooks';
8
10
  import { Github } from '../../icons';
9
11
  import './Button.css';
10
12
  const b = block('button-block');
11
13
  const Button = (props) => {
12
14
  const handleMetrika = useMetrika();
13
15
  const { lang, tld } = useContext(LocaleContext);
14
- const { className, metrikaGoals, pixelEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "size", "theme", "url", "img", "onClick", "text"]);
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"]);
15
17
  const defaultImgPosition = 'left';
18
+ const handleAnalytics = useAnalytics(DefaultEventNames.Button, url);
16
19
  const onClick = useCallback(() => {
17
20
  handleMetrika({ metrikaGoals, pixelEvents });
21
+ handleAnalytics(analyticsEvents);
18
22
  if (onClickOrigin) {
19
23
  onClickOrigin();
20
24
  }
21
- }, [handleMetrika, metrikaGoals, pixelEvents, onClickOrigin]);
25
+ }, [handleMetrika, metrikaGoals, pixelEvents, handleAnalytics, analyticsEvents, onClickOrigin]);
22
26
  const buttonImg = img instanceof Object
23
27
  ? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
24
28
  : { url: img, position: defaultImgPosition };
@@ -1,7 +1,8 @@
1
1
  import React, { ReactElement, HTMLAttributeAnchorTarget } from 'react';
2
2
  import { ButtonPixel, CardBaseProps as CardBaseParams, ImageProps, MetrikaGoal, WithChildren } from '../../models';
3
+ import { AnalyticsEventsBase } from '../../models/common';
3
4
  import './CardBase.css';
4
- export interface CardBaseProps extends CardBaseParams {
5
+ export interface CardBaseProps extends AnalyticsEventsBase, CardBaseParams {
5
6
  className?: string;
6
7
  bodyClassName?: string;
7
8
  contentClassName?: string;
@@ -3,14 +3,17 @@ import { block } from '../../utils';
3
3
  import BackgroundImage from '../BackgroundImage/BackgroundImage';
4
4
  import RouterLink from '../RouterLink/RouterLink';
5
5
  import { useMetrika } from '../../hooks/useMetrika';
6
+ import { DefaultEventNames } from '../../models/common';
7
+ import { useAnalytics } from '../../hooks';
6
8
  import './CardBase.css';
7
9
  const b = block('card-base-block');
8
10
  const Header = () => null;
9
11
  const Content = () => null;
10
12
  const Footer = () => null;
11
13
  export const Layout = (props) => {
12
- const { className, bodyClassName, metrikaGoals, pixelEvents, contentClassName, children, url, target, border = 'shadow', } = props;
14
+ const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', } = props;
13
15
  const handleMetrika = useMetrika();
16
+ const handleAnalytics = useAnalytics(DefaultEventNames.CardBase, url);
14
17
  let header, content, footer, image, headerClass, footerClass;
15
18
  function handleChild(child) {
16
19
  switch (child.type) {
@@ -43,6 +46,7 @@ export const Layout = (props) => {
43
46
  const fullClassName = b({ border }, className);
44
47
  const onClick = () => {
45
48
  handleMetrika({ metrikaGoals, pixelEvents });
49
+ handleAnalytics(analyticsEvents);
46
50
  };
47
51
  return url ? (React.createElement(RouterLink, { href: url },
48
52
  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));
@@ -1,12 +1,14 @@
1
1
  import React, { Fragment, useContext } from 'react';
2
2
  import { Icon } from '@gravity-ui/uikit';
3
3
  import { block, getLinkProps, setUrlTld } from '../../utils';
4
+ import { DefaultEventNames } from '../../models';
4
5
  import { Chevron } from '../../icons';
5
6
  import FileLink from '../FileLink/FileLink';
6
7
  import BackLink from '../BackLink/BackLink';
7
8
  import { LocaleContext } from '../../context/localeContext/localeContext';
8
9
  import { LocationContext } from '../../context/locationContext/locationContext';
9
10
  import { useMetrika } from '../../hooks/useMetrika';
11
+ import { useAnalytics } from '../../hooks';
10
12
  import './Link.css';
11
13
  const b = block('link-block');
12
14
  const WORD_JOINER_SYM = '\u200b';
@@ -23,14 +25,16 @@ function getArrowSize(size) {
23
25
  }
24
26
  }
25
27
  const LinkBlock = (props) => {
26
- const { text, url, arrow, metrikaGoals, pixelEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
28
+ const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
27
29
  const handleMetrika = useMetrika();
30
+ const handleAnalytics = useAnalytics(DefaultEventNames.Link, url);
28
31
  const { hostname } = useContext(LocationContext);
29
32
  const { tld } = useContext(LocaleContext);
30
33
  const href = setUrlTld(props.url, tld);
31
34
  const defaultTextSize = theme === 'back' ? 'l' : 'm';
32
35
  const onClick = () => {
33
36
  handleMetrika({ metrikaGoals, pixelEvents });
37
+ handleAnalytics(analyticsEvents);
34
38
  };
35
39
  const getLinkByType = () => {
36
40
  switch (theme) {
@@ -7,7 +7,7 @@ import YoutubeBlock from '../VideoBlock/VideoBlock';
7
7
  import './Media.css';
8
8
  const b = block('Media');
9
9
  export const Media = (props) => {
10
- const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullScreen, } = props;
10
+ const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullScreen, analyticsEvents, } = props;
11
11
  const { className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, } = props;
12
12
  const [hasVideoFallback, setHasVideoFallback] = useState(false);
13
13
  const content = useMemo(() => {
@@ -16,7 +16,7 @@ export const Media = (props) => {
16
16
  result.push(React.createElement(Image, { key: "image", parallax: parallax, image: image, height: height, imageClassName: imageClassName, isBackground: isBackground, video: video, hasVideoFallback: hasVideoFallback }));
17
17
  }
18
18
  if (video) {
19
- result.push(React.createElement(Video, { key: "video", video: video, videoClassName: videoClassName, height: height, metrika: metrika, playVideo: playVideo, previewImg: previewImg, playButton: playButton, customBarControlsClassName: customBarControlsClassName, hasVideoFallback: hasVideoFallback, setHasVideoFallback: setHasVideoFallback }));
19
+ result.push(React.createElement(Video, { key: "video", video: video, videoClassName: videoClassName, height: height, metrika: metrika, analyticsEvents: analyticsEvents, playVideo: playVideo, previewImg: previewImg, playButton: playButton, customBarControlsClassName: customBarControlsClassName, hasVideoFallback: hasVideoFallback, setHasVideoFallback: setHasVideoFallback }));
20
20
  }
21
21
  if (youtube) {
22
22
  result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullScreen: fullScreen }));
@@ -37,6 +37,7 @@ export const Media = (props) => {
37
37
  hasVideoFallback,
38
38
  videoClassName,
39
39
  metrika,
40
+ analyticsEvents,
40
41
  playVideo,
41
42
  previewImg,
42
43
  playButton,
@@ -6,7 +6,7 @@ import { block } from '../../../utils';
6
6
  import './Video.css';
7
7
  const b = block('media-component-video');
8
8
  const Video = (props) => {
9
- const { video, height, metrika, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, } = props;
9
+ const { video, height, metrika, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, } = props;
10
10
  const ref = useRef(null);
11
11
  useEffect(() => {
12
12
  if (ref && ref.current) {
@@ -29,7 +29,7 @@ const Video = (props) => {
29
29
  }, [playVideo, video, setHasVideoFallback]);
30
30
  const reactPlayerBlock = useMemo(() => {
31
31
  const { src, loop, controls, muted, autoplay = true, elapsedTime, playButton } = video;
32
- return (React.createElement(ReactPlayerBlock, { className: b('react-player', videoClassName), src: src, previewImgUrl: previewImg, loop: Boolean(loop), controls: controls, muted: muted, autoplay: autoplay && playVideo, elapsedTime: elapsedTime, playButton: playButton || commonPlayButton, customBarControlsClassName: customBarControlsClassName, metrika: metrika, height: height }));
32
+ return (React.createElement(ReactPlayerBlock, { className: b('react-player', videoClassName), src: src, previewImgUrl: previewImg, loop: Boolean(loop), controls: controls, muted: muted, autoplay: autoplay && playVideo, elapsedTime: elapsedTime, playButton: playButton || commonPlayButton, customBarControlsClassName: customBarControlsClassName, metrika: metrika, analyticsEvents: analyticsEvents, height: height }));
33
33
  }, [
34
34
  video,
35
35
  height,
@@ -39,6 +39,7 @@ const Video = (props) => {
39
39
  commonPlayButton,
40
40
  customBarControlsClassName,
41
41
  metrika,
42
+ analyticsEvents,
42
43
  ]);
43
44
  const defaultVideoBlock = useMemo(() => {
44
45
  return video.src.length && !hasVideoFallback ? (React.createElement("div", { className: b('wrap', videoClassName), style: { height } },
@@ -3,11 +3,12 @@ import ReactPlayer from 'react-player';
3
3
  import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
4
4
  import { Icon } from '@gravity-ui/uikit';
5
5
  import { block } from '../../utils';
6
- import { PlayButtonThemes, PlayButtonType, MediaVideoControlsType, } from '../../models';
6
+ import { PlayButtonThemes, PlayButtonType, MediaVideoControlsType, PredefinedEventTypes, DefaultEventNames, } from '../../models';
7
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 } from '../../hooks';
11
12
  import { PlayVideo } from '../../icons';
12
13
  import './ReactPlayer.css';
13
14
  const b = block('ReactPlayer');
@@ -16,7 +17,7 @@ const FPS = 60;
16
17
  export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
17
18
  const isMobile = useContext(MobileContext);
18
19
  const { metrika } = useContext(MetrikaContext);
19
- const { src, previewImgUrl, loop = false, controls = MediaVideoControlsType.Default, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, metrika: videoMetrika, height, } = props;
20
+ const { src, previewImgUrl, loop = false, controls = MediaVideoControlsType.Default, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, metrika: videoMetrika, analyticsEvents, height, } = props;
20
21
  const { type = PlayButtonType.Default, theme = PlayButtonThemes.Blue, text, className: buttonClassName, } = playButton || {};
21
22
  const autoPlay = Boolean(!isMobile && !previewImgUrl && props.autoplay);
22
23
  const mute = initiallyMuted || autoPlay;
@@ -31,6 +32,13 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
31
32
  const [started, setStarted] = useState(autoPlay);
32
33
  const [paused, setPaused] = useState(false);
33
34
  const [ended, setEnded] = useState(false);
35
+ const eventsArray = useMemo(() => {
36
+ if (analyticsEvents) {
37
+ return Array.isArray(analyticsEvents) ? analyticsEvents : [analyticsEvents];
38
+ }
39
+ return [];
40
+ }, [analyticsEvents]);
41
+ const handleAnalytics = useAnalytics(DefaultEventNames.ReactPlayerControls);
34
42
  useImperativeHandle(originRef, () => ({
35
43
  pause: () => setIsPlaying(false),
36
44
  }));
@@ -79,6 +87,8 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
79
87
  window.removeEventListener('resize', updateSize);
80
88
  };
81
89
  }, []);
90
+ const playEvents = useMemo(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === PredefinedEventTypes.Play), [eventsArray]);
91
+ const stopEvents = useMemo(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === PredefinedEventTypes.Stop), [eventsArray]);
82
92
  const playIcon = useMemo(() => {
83
93
  let playButtonContent;
84
94
  switch (type) {
@@ -104,12 +114,14 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
104
114
  metrika.reachGoals(goal, counterName);
105
115
  }
106
116
  }
117
+ const events = isMuted ? playEvents : stopEvents;
118
+ handleAnalytics(events);
107
119
  if (isMuted) {
108
120
  setProps({ playingVideoRef: ref.current });
109
121
  }
110
122
  // In order to the progress bar to update (equals 0) before displaying
111
123
  setTimeout(() => setMuted(!isMuted), 0);
112
- }, [playerRef, setProps, videoMetrika, metrika]);
124
+ }, [playerRef, metrika, videoMetrika, handleAnalytics, playEvents, stopEvents, setProps]);
113
125
  const handleClick = useCallback(() => changeMute(muted), [changeMute, muted]);
114
126
  const handleClickPreview = useCallback(() => {
115
127
  setIsPlaying(true);
@@ -120,7 +132,8 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
120
132
  metrika.reachGoals(play, counterName);
121
133
  }
122
134
  }
123
- }, [onClickPreview, setIsPlaying, videoMetrika, metrika]);
135
+ handleAnalytics(playEvents);
136
+ }, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents]);
124
137
  const onPause = useCallback(() => {
125
138
  // For support correct state for youtube
126
139
  setIsPlaying(false);
@@ -1,6 +1,7 @@
1
1
  import { PixelEvent } from '../../models';
2
+ import { AnalyticsEventsBase } from '../../models/common';
2
3
  export declare const YANDEX_FORM_ORIGIN = "https://forms.yandex.ru";
3
- export interface YandexFormProps {
4
+ export interface YandexFormProps extends AnalyticsEventsBase {
4
5
  id: number | string;
5
6
  containerId?: string;
6
7
  theme?: string;