@gravity-ui/page-constructor 1.14.0-alpha.4 → 1.14.0-alpha.6

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 (88) hide show
  1. package/CHANGELOG.md +0 -7
  2. package/build/cjs/blocks/Banner/schema.d.ts +312 -0
  3. package/build/cjs/blocks/Media/schema.d.ts +104 -0
  4. package/build/cjs/components/Button/Button.js +5 -2
  5. package/build/cjs/components/CardBase/CardBase.d.ts +2 -0
  6. package/build/cjs/components/CardBase/CardBase.js +4 -1
  7. package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +4 -1
  8. package/build/cjs/components/Link/Link.js +4 -1
  9. package/build/cjs/components/YandexForm/YandexForm.d.ts +2 -0
  10. package/build/cjs/components/YandexForm/YandexForm.js +13 -2
  11. package/build/cjs/containers/PageConstructor/Provider.d.ts +2 -0
  12. package/build/cjs/containers/PageConstructor/Provider.js +3 -1
  13. package/build/cjs/context/analyticsContext/analyticsContext.d.ts +6 -0
  14. package/build/cjs/context/analyticsContext/analyticsContext.js +6 -0
  15. package/build/cjs/context/analyticsContext/index.d.ts +1 -0
  16. package/build/cjs/{schema/validators/navigation.js → context/analyticsContext/index.js} +1 -1
  17. package/build/cjs/context/metrikaContext/metrikaContext.d.ts +6 -0
  18. package/build/cjs/hooks/useAnalytics.d.ts +2 -0
  19. package/build/cjs/hooks/useAnalytics.js +15 -0
  20. package/build/cjs/hooks/useMetrika.d.ts +6 -0
  21. package/build/cjs/hooks/useMetrika.js +8 -0
  22. package/build/cjs/models/common.d.ts +30 -0
  23. package/build/cjs/models/common.js +3 -0
  24. package/build/cjs/models/constructor-items/common.d.ts +4 -1
  25. package/build/cjs/models/constructor-items/sub-blocks.d.ts +2 -1
  26. package/build/cjs/models/navigation.d.ts +3 -1
  27. package/build/cjs/navigation/components/Header/Header.css +3 -5
  28. package/build/cjs/navigation/components/Logo/Logo.css +6 -5
  29. package/build/cjs/navigation/components/NavigationItem/NavigationItem.css +0 -1
  30. package/build/cjs/schema/index.d.ts +0 -111
  31. package/build/cjs/schema/index.js +1 -2
  32. package/build/cjs/schema/validators/common.d.ts +220 -0
  33. package/build/cjs/schema/validators/common.js +10 -0
  34. package/build/cjs/schema/validators/event.d.ts +50 -0
  35. package/build/cjs/schema/validators/event.js +53 -0
  36. package/build/cjs/schema/validators/index.d.ts +0 -2
  37. package/build/cjs/schema/validators/index.js +0 -2
  38. package/build/cjs/sub-blocks/HubspotForm/index.js +14 -2
  39. package/build/esm/blocks/Banner/schema.d.ts +312 -0
  40. package/build/esm/blocks/Media/schema.d.ts +104 -0
  41. package/build/esm/components/Button/Button.js +5 -2
  42. package/build/esm/components/CardBase/CardBase.d.ts +2 -0
  43. package/build/esm/components/CardBase/CardBase.js +4 -1
  44. package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +4 -1
  45. package/build/esm/components/Link/Link.js +4 -1
  46. package/build/esm/components/YandexForm/YandexForm.d.ts +2 -0
  47. package/build/esm/components/YandexForm/YandexForm.js +13 -2
  48. package/build/esm/containers/PageConstructor/Provider.d.ts +2 -0
  49. package/build/esm/containers/PageConstructor/Provider.js +3 -1
  50. package/build/esm/context/analyticsContext/analyticsContext.d.ts +6 -0
  51. package/build/esm/context/analyticsContext/analyticsContext.js +2 -0
  52. package/build/esm/context/analyticsContext/index.d.ts +1 -0
  53. package/build/esm/context/analyticsContext/index.js +1 -0
  54. package/build/esm/context/metrikaContext/metrikaContext.d.ts +6 -0
  55. package/build/esm/hooks/useAnalytics.d.ts +2 -0
  56. package/build/esm/hooks/useAnalytics.js +11 -0
  57. package/build/esm/hooks/useMetrika.d.ts +6 -0
  58. package/build/esm/hooks/useMetrika.js +8 -0
  59. package/build/esm/models/common.d.ts +30 -0
  60. package/build/esm/models/common.js +3 -0
  61. package/build/esm/models/constructor-items/common.d.ts +4 -1
  62. package/build/esm/models/constructor-items/sub-blocks.d.ts +2 -1
  63. package/build/esm/models/navigation.d.ts +3 -1
  64. package/build/esm/navigation/components/Header/Header.css +3 -5
  65. package/build/esm/navigation/components/Logo/Logo.css +6 -5
  66. package/build/esm/navigation/components/NavigationItem/NavigationItem.css +0 -1
  67. package/build/esm/schema/index.d.ts +0 -111
  68. package/build/esm/schema/index.js +1 -2
  69. package/build/esm/schema/validators/common.d.ts +220 -0
  70. package/build/esm/schema/validators/common.js +10 -0
  71. package/build/esm/schema/validators/event.d.ts +50 -0
  72. package/build/esm/schema/validators/event.js +50 -0
  73. package/build/esm/schema/validators/index.d.ts +0 -2
  74. package/build/esm/schema/validators/index.js +0 -2
  75. package/build/esm/sub-blocks/HubspotForm/index.js +14 -2
  76. package/package.json +1 -1
  77. package/server/models/common.d.ts +30 -0
  78. package/server/models/common.js +3 -0
  79. package/server/models/constructor-items/common.d.ts +4 -1
  80. package/server/models/constructor-items/sub-blocks.d.ts +2 -1
  81. package/server/models/navigation.d.ts +3 -1
  82. package/build/cjs/navigation/schema.d.ts +0 -104
  83. package/build/cjs/navigation/schema.js +0 -78
  84. package/build/cjs/schema/validators/navigation.d.ts +0 -1
  85. package/build/esm/navigation/schema.d.ts +0 -104
  86. package/build/esm/navigation/schema.js +0 -75
  87. package/build/esm/schema/validators/navigation.d.ts +0 -1
  88. package/build/esm/schema/validators/navigation.js +0 -1
@@ -173,6 +173,110 @@ export declare const BannerCardProps: {
173
173
  };
174
174
  };
175
175
  };
176
+ events: {
177
+ anyOf: ({
178
+ type: string;
179
+ additionalProperties: boolean;
180
+ required: string[];
181
+ properties: {
182
+ name: {
183
+ type: string;
184
+ };
185
+ type: {
186
+ type: string;
187
+ };
188
+ counters: {
189
+ type: string;
190
+ additionalProperties: boolean;
191
+ required: never[];
192
+ properties: {
193
+ include: {
194
+ type: string;
195
+ items: string;
196
+ };
197
+ exclude: {
198
+ type: string;
199
+ items: string;
200
+ };
201
+ };
202
+ };
203
+ category: {
204
+ type: string;
205
+ };
206
+ label: {
207
+ type: string;
208
+ };
209
+ params: {
210
+ type: string;
211
+ items: {
212
+ type: string;
213
+ additionalProperties: boolean;
214
+ required: string[];
215
+ properties: {
216
+ key: {
217
+ type: string;
218
+ };
219
+ value: {
220
+ type: string;
221
+ };
222
+ };
223
+ };
224
+ };
225
+ };
226
+ } | {
227
+ type: string;
228
+ items: {
229
+ type: string;
230
+ additionalProperties: boolean;
231
+ required: string[];
232
+ properties: {
233
+ name: {
234
+ type: string;
235
+ };
236
+ type: {
237
+ type: string;
238
+ };
239
+ counters: {
240
+ type: string;
241
+ additionalProperties: boolean;
242
+ required: never[];
243
+ properties: {
244
+ include: {
245
+ type: string;
246
+ items: string;
247
+ };
248
+ exclude: {
249
+ type: string;
250
+ items: string;
251
+ };
252
+ };
253
+ };
254
+ category: {
255
+ type: string;
256
+ };
257
+ label: {
258
+ type: string;
259
+ };
260
+ params: {
261
+ type: string;
262
+ items: {
263
+ type: string;
264
+ additionalProperties: boolean;
265
+ required: string[];
266
+ properties: {
267
+ key: {
268
+ type: string;
269
+ };
270
+ value: {
271
+ type: string;
272
+ };
273
+ };
274
+ };
275
+ };
276
+ };
277
+ };
278
+ })[];
279
+ };
176
280
  target: {
177
281
  type: string;
178
282
  enum: string[];
@@ -375,6 +479,110 @@ export declare const BannerBlock: {
375
479
  };
376
480
  };
377
481
  };
482
+ events: {
483
+ anyOf: ({
484
+ type: string;
485
+ additionalProperties: boolean;
486
+ required: string[];
487
+ properties: {
488
+ name: {
489
+ type: string;
490
+ };
491
+ type: {
492
+ type: string;
493
+ };
494
+ counters: {
495
+ type: string;
496
+ additionalProperties: boolean;
497
+ required: never[];
498
+ properties: {
499
+ include: {
500
+ type: string;
501
+ items: string;
502
+ };
503
+ exclude: {
504
+ type: string;
505
+ items: string;
506
+ };
507
+ };
508
+ };
509
+ category: {
510
+ type: string;
511
+ };
512
+ label: {
513
+ type: string;
514
+ };
515
+ params: {
516
+ type: string;
517
+ items: {
518
+ type: string;
519
+ additionalProperties: boolean;
520
+ required: string[];
521
+ properties: {
522
+ key: {
523
+ type: string;
524
+ };
525
+ value: {
526
+ type: string;
527
+ };
528
+ };
529
+ };
530
+ };
531
+ };
532
+ } | {
533
+ type: string;
534
+ items: {
535
+ type: string;
536
+ additionalProperties: boolean;
537
+ required: string[];
538
+ properties: {
539
+ name: {
540
+ type: string;
541
+ };
542
+ type: {
543
+ type: string;
544
+ };
545
+ counters: {
546
+ type: string;
547
+ additionalProperties: boolean;
548
+ required: never[];
549
+ properties: {
550
+ include: {
551
+ type: string;
552
+ items: string;
553
+ };
554
+ exclude: {
555
+ type: string;
556
+ items: string;
557
+ };
558
+ };
559
+ };
560
+ category: {
561
+ type: string;
562
+ };
563
+ label: {
564
+ type: string;
565
+ };
566
+ params: {
567
+ type: string;
568
+ items: {
569
+ type: string;
570
+ additionalProperties: boolean;
571
+ required: string[];
572
+ properties: {
573
+ key: {
574
+ type: string;
575
+ };
576
+ value: {
577
+ type: string;
578
+ };
579
+ };
580
+ };
581
+ };
582
+ };
583
+ };
584
+ })[];
585
+ };
378
586
  target: {
379
587
  type: string;
380
588
  enum: string[];
@@ -578,6 +786,110 @@ export declare const BannerCard: {
578
786
  };
579
787
  };
580
788
  };
789
+ events: {
790
+ anyOf: ({
791
+ type: string;
792
+ additionalProperties: boolean;
793
+ required: string[];
794
+ properties: {
795
+ name: {
796
+ type: string;
797
+ };
798
+ type: {
799
+ type: string;
800
+ };
801
+ counters: {
802
+ type: string;
803
+ additionalProperties: boolean;
804
+ required: never[];
805
+ properties: {
806
+ include: {
807
+ type: string;
808
+ items: string;
809
+ };
810
+ exclude: {
811
+ type: string;
812
+ items: string;
813
+ };
814
+ };
815
+ };
816
+ category: {
817
+ type: string;
818
+ };
819
+ label: {
820
+ type: string;
821
+ };
822
+ params: {
823
+ type: string;
824
+ items: {
825
+ type: string;
826
+ additionalProperties: boolean;
827
+ required: string[];
828
+ properties: {
829
+ key: {
830
+ type: string;
831
+ };
832
+ value: {
833
+ type: string;
834
+ };
835
+ };
836
+ };
837
+ };
838
+ };
839
+ } | {
840
+ type: string;
841
+ items: {
842
+ type: string;
843
+ additionalProperties: boolean;
844
+ required: string[];
845
+ properties: {
846
+ name: {
847
+ type: string;
848
+ };
849
+ type: {
850
+ type: string;
851
+ };
852
+ counters: {
853
+ type: string;
854
+ additionalProperties: boolean;
855
+ required: never[];
856
+ properties: {
857
+ include: {
858
+ type: string;
859
+ items: string;
860
+ };
861
+ exclude: {
862
+ type: string;
863
+ items: string;
864
+ };
865
+ };
866
+ };
867
+ category: {
868
+ type: string;
869
+ };
870
+ label: {
871
+ type: string;
872
+ };
873
+ params: {
874
+ type: string;
875
+ items: {
876
+ type: string;
877
+ additionalProperties: boolean;
878
+ required: string[];
879
+ properties: {
880
+ key: {
881
+ type: string;
882
+ };
883
+ value: {
884
+ type: string;
885
+ };
886
+ };
887
+ };
888
+ };
889
+ };
890
+ };
891
+ })[];
892
+ };
581
893
  target: {
582
894
  type: string;
583
895
  enum: string[];
@@ -426,6 +426,110 @@ export declare const MediaBlock: {
426
426
  };
427
427
  };
428
428
  };
429
+ events: {
430
+ anyOf: ({
431
+ type: string;
432
+ additionalProperties: boolean;
433
+ required: string[];
434
+ properties: {
435
+ name: {
436
+ type: string;
437
+ };
438
+ type: {
439
+ type: string;
440
+ };
441
+ counters: {
442
+ type: string;
443
+ additionalProperties: boolean;
444
+ required: never[];
445
+ properties: {
446
+ include: {
447
+ type: string;
448
+ items: string;
449
+ };
450
+ exclude: {
451
+ type: string;
452
+ items: string;
453
+ };
454
+ };
455
+ };
456
+ category: {
457
+ type: string;
458
+ };
459
+ label: {
460
+ type: string;
461
+ };
462
+ params: {
463
+ type: string;
464
+ items: {
465
+ type: string;
466
+ additionalProperties: boolean;
467
+ required: string[];
468
+ properties: {
469
+ key: {
470
+ type: string;
471
+ };
472
+ value: {
473
+ type: string;
474
+ };
475
+ };
476
+ };
477
+ };
478
+ };
479
+ } | {
480
+ type: string;
481
+ items: {
482
+ type: string;
483
+ additionalProperties: boolean;
484
+ required: string[];
485
+ properties: {
486
+ name: {
487
+ type: string;
488
+ };
489
+ type: {
490
+ type: string;
491
+ };
492
+ counters: {
493
+ type: string;
494
+ additionalProperties: boolean;
495
+ required: never[];
496
+ properties: {
497
+ include: {
498
+ type: string;
499
+ items: string;
500
+ };
501
+ exclude: {
502
+ type: string;
503
+ items: string;
504
+ };
505
+ };
506
+ };
507
+ category: {
508
+ type: string;
509
+ };
510
+ label: {
511
+ type: string;
512
+ };
513
+ params: {
514
+ type: string;
515
+ items: {
516
+ type: string;
517
+ additionalProperties: boolean;
518
+ required: string[];
519
+ properties: {
520
+ key: {
521
+ type: string;
522
+ };
523
+ value: {
524
+ type: string;
525
+ };
526
+ };
527
+ };
528
+ };
529
+ };
530
+ };
531
+ })[];
532
+ };
429
533
  target: {
430
534
  type: string;
431
535
  enum: string[];
@@ -5,20 +5,23 @@ import { block, setUrlTld } from '../../utils';
5
5
  import { toCommonSize, toCommonView } from './utils';
6
6
  import { LocaleContext } from '../../context/localeContext/localeContext';
7
7
  import { useMetrika } from '../../hooks/useMetrika';
8
+ import { useAnalytics } from '../../hooks/useAnalytics';
8
9
  import { Github } from '../../icons';
9
10
  import './Button.css';
10
11
  const b = block('button-block');
11
12
  const Button = (props) => {
12
13
  const handleMetrika = useMetrika();
14
+ const handleAnalytics = useAnalytics();
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';
16
18
  const onClick = useCallback(() => {
17
19
  handleMetrika({ metrikaGoals, pixelEvents });
20
+ handleAnalytics(analyticsEvents);
18
21
  if (onClickOrigin) {
19
22
  onClickOrigin();
20
23
  }
21
- }, [handleMetrika, metrikaGoals, pixelEvents, onClickOrigin]);
24
+ }, [handleMetrika, metrikaGoals, pixelEvents, handleAnalytics, analyticsEvents, onClickOrigin]);
22
25
  const buttonImg = img instanceof Object
23
26
  ? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
24
27
  : { url: img, position: defaultImgPosition };
@@ -1,5 +1,6 @@
1
1
  import React, { ReactElement, HTMLAttributeAnchorTarget } from 'react';
2
2
  import { ButtonPixel, CardBaseProps as CardBaseParams, ImageProps, MetrikaGoal, WithChildren } from '../../models';
3
+ import { AnalyticsEvent } from '../../models/common';
3
4
  import './CardBase.css';
4
5
  export interface CardBaseProps extends CardBaseParams {
5
6
  className?: string;
@@ -10,6 +11,7 @@ export interface CardBaseProps extends CardBaseParams {
10
11
  target?: HTMLAttributeAnchorTarget;
11
12
  metrikaGoals?: MetrikaGoal;
12
13
  pixelEvents?: ButtonPixel;
14
+ analyticsEvents?: AnalyticsEvent | AnalyticsEvent[];
13
15
  }
14
16
  export interface CardHeaderBaseProps {
15
17
  className?: string;
@@ -3,14 +3,16 @@ 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 { useAnalytics } from '../../hooks/useAnalytics';
6
7
  import './CardBase.css';
7
8
  const b = block('card-base-block');
8
9
  const Header = () => null;
9
10
  const Content = () => null;
10
11
  const Footer = () => null;
11
12
  export const Layout = (props) => {
12
- const { className, bodyClassName, metrikaGoals, pixelEvents, contentClassName, children, url, target, border = 'shadow', } = props;
13
+ const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', } = props;
13
14
  const handleMetrika = useMetrika();
15
+ const handleAnalytics = useAnalytics();
14
16
  let header, content, footer, image, headerClass, footerClass;
15
17
  function handleChild(child) {
16
18
  switch (child.type) {
@@ -43,6 +45,7 @@ export const Layout = (props) => {
43
45
  const fullClassName = b({ border }, className);
44
46
  const onClick = () => {
45
47
  handleMetrika({ metrikaGoals, pixelEvents });
48
+ handleAnalytics(analyticsEvents);
46
49
  };
47
50
  return url ? (React.createElement(RouterLink, { href: url },
48
51
  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,13 +1,16 @@
1
1
  import React from 'react';
2
2
  import { block } from '../../utils';
3
3
  import { useMetrika } from '../../hooks/useMetrika';
4
+ import { useAnalytics } from '../../hooks/useAnalytics';
4
5
  import './HeaderBreadcrumbs.css';
5
6
  const b = block('header-breadcrumbs');
6
7
  export default function HeaderBreadcrumbs(props) {
7
- const { items, metrikaGoals, pixelEvents, theme = 'light', className } = props;
8
+ const { items, metrikaGoals, pixelEvents, analyticsEvents, theme = 'light', className } = props;
8
9
  const handleMetrika = useMetrika();
10
+ const handleAnalytics = useAnalytics();
9
11
  const onClick = () => {
10
12
  handleMetrika({ metrikaGoals, pixelEvents });
13
+ handleAnalytics(analyticsEvents);
11
14
  };
12
15
  return (React.createElement("div", { className: b({ theme }, className) }, items.map((item) => (React.createElement("div", { className: b('item'), key: item.url },
13
16
  React.createElement("a", { href: item.url, className: b('text'), onClick: onClick }, item.text))))));
@@ -7,6 +7,7 @@ import BackLink from '../BackLink/BackLink';
7
7
  import { LocaleContext } from '../../context/localeContext/localeContext';
8
8
  import { LocationContext } from '../../context/locationContext/locationContext';
9
9
  import { useMetrika } from '../../hooks/useMetrika';
10
+ import { useAnalytics } from '../../hooks/useAnalytics';
10
11
  import './Link.css';
11
12
  const b = block('link-block');
12
13
  const WORD_JOINER_SYM = '\u200b';
@@ -23,14 +24,16 @@ function getArrowSize(size) {
23
24
  }
24
25
  }
25
26
  const LinkBlock = (props) => {
26
- const { text, url, arrow, metrikaGoals, pixelEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
27
+ const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
27
28
  const handleMetrika = useMetrika();
29
+ const handleAnalytics = useAnalytics();
28
30
  const { hostname } = useContext(LocationContext);
29
31
  const { tld } = useContext(LocaleContext);
30
32
  const href = setUrlTld(props.url, tld);
31
33
  const defaultTextSize = theme === 'back' ? 'l' : 'm';
32
34
  const onClick = () => {
33
35
  handleMetrika({ metrikaGoals, pixelEvents });
36
+ handleAnalytics(analyticsEvents);
34
37
  };
35
38
  const getLinkByType = () => {
36
39
  switch (theme) {
@@ -1,4 +1,5 @@
1
1
  import { PixelEvent } from '../../models';
2
+ import { AnalyticsEvent } from '../../models/common';
2
3
  export declare const YANDEX_FORM_ORIGIN = "https://forms.yandex.ru";
3
4
  export interface YandexFormProps {
4
5
  id: number | string;
@@ -14,6 +15,7 @@ export interface YandexFormProps {
14
15
  onLoad?: () => void;
15
16
  metrikaGoals?: string | string[];
16
17
  pixelEvents?: string | string[] | PixelEvent | PixelEvent[];
18
+ analyticsEvents?: AnalyticsEvent | AnalyticsEvent[];
17
19
  }
18
20
  declare const YandexForm: (props: YandexFormProps) => JSX.Element;
19
21
  export default YandexForm;
@@ -4,15 +4,17 @@ 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 '../..//hooks/useAnalytics';
7
8
  export const YANDEX_FORM_ORIGIN = 'https://forms.yandex.ru';
8
9
  const CONTAINER_ID = 'pc-yandex-form-container';
9
10
  const b = block('yandex-form');
10
11
  const YandexForm = (props) => {
11
- const { onLoad, id, params, className, theme, containerId = CONTAINER_ID, headerHeight = HEADER_HEIGHT, onSubmit, metrikaGoals, pixelEvents, customFormOrigin, } = props;
12
+ const { onLoad, id, params, className, theme, containerId = CONTAINER_ID, headerHeight = HEADER_HEIGHT, onSubmit, metrikaGoals, pixelEvents, analyticsEvents, customFormOrigin, } = props;
12
13
  const formContainerRef = useRef(null);
13
14
  const iframeRef = useRef();
14
15
  const yaFormOrigin = customFormOrigin || YANDEX_FORM_ORIGIN;
15
16
  const handleMetrika = useMetrika();
17
+ const handleAnalytics = useAnalytics();
16
18
  const isMobile = useContext(MobileContext);
17
19
  const locale = useContext(LocaleContext);
18
20
  const updateFormIframe = useCallback((container) => {
@@ -53,10 +55,19 @@ const YandexForm = (props) => {
53
55
  window.scrollBy(0, top - headerHeight);
54
56
  }
55
57
  handleMetrika({ metrikaGoals, pixelEvents });
58
+ handleAnalytics(analyticsEvents);
56
59
  if (onSubmit) {
57
60
  onSubmit();
58
61
  }
59
- }, [handleMetrika, metrikaGoals, pixelEvents, onSubmit, headerHeight]);
62
+ }, [
63
+ handleMetrika,
64
+ metrikaGoals,
65
+ pixelEvents,
66
+ handleAnalytics,
67
+ analyticsEvents,
68
+ onSubmit,
69
+ headerHeight,
70
+ ]);
60
71
  const handleMessage = useCallback(({ origin, data }) => {
61
72
  if (origin !== yaFormOrigin) {
62
73
  return;
@@ -1,4 +1,5 @@
1
1
  import { MetrikaContextProps } from '../../context/metrikaContext';
2
+ import { AnalyticsContextProps } from '../../context/analyticsContext';
2
3
  import { ProjectSettingsContextProps } from '../../context/projectSettingsContext';
3
4
  import { SSRContextProps } from '../../context/ssrContext';
4
5
  import { LocaleContextProps } from '../../context/localeContext';
@@ -13,5 +14,6 @@ export interface PageConstructorProviderProps {
13
14
  ssrConfig?: SSRContextProps;
14
15
  theme?: ConstructorTheme;
15
16
  projectSettings?: ProjectSettingsContextProps;
17
+ analytics?: AnalyticsContextProps;
16
18
  }
17
19
  export declare const PageConstructorProvider: (props: WithChildren<PageConstructorProviderProps>) => JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import React, { Fragment } from 'react';
2
2
  import { MetrikaContext } from '../../context/metrikaContext';
3
+ import { AnalyticsContext } from '../../context/analyticsContext';
3
4
  import { MobileContext } from '../../context/mobileContext';
4
5
  import { ProjectSettingsContext, } from '../../context/projectSettingsContext';
5
6
  import { SSRContext } from '../../context/ssrContext';
@@ -8,7 +9,7 @@ import { LocationContext } from '../../context/locationContext';
8
9
  import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
9
10
  import { DEFAULT_THEME } from '../../components/constants';
10
11
  export const PageConstructorProvider = (props) => {
11
- const { isMobile, locale = {}, location = {}, metrika = {}, ssrConfig = {}, projectSettings = {}, theme = DEFAULT_THEME, children, } = props;
12
+ const { isMobile, locale = {}, location = {}, metrika = {}, analytics = {}, ssrConfig = {}, projectSettings = {}, theme = DEFAULT_THEME, children, } = props;
12
13
  /* eslint-disable react/jsx-key */
13
14
  const context = [
14
15
  React.createElement(ThemeValueContext.Provider, { value: { themeValue: theme } }),
@@ -17,6 +18,7 @@ export const PageConstructorProvider = (props) => {
17
18
  React.createElement(LocationContext.Provider, { value: location }),
18
19
  React.createElement(MobileContext.Provider, { value: Boolean(isMobile) }),
19
20
  React.createElement(MetrikaContext.Provider, { value: metrika }),
21
+ React.createElement(AnalyticsContext.Provider, { value: analytics }),
20
22
  React.createElement(SSRContext.Provider, { value: { isServer: ssrConfig === null || ssrConfig === void 0 ? void 0 : ssrConfig.isServer } }),
21
23
  ].reduceRight((prev, provider) => React.cloneElement(provider, {}, prev), children);
22
24
  /* eslint-enable react/jsx-key */
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { AnalyticsEvent } from '../../models';
3
+ export interface AnalyticsContextProps {
4
+ sendEvents?: (e: AnalyticsEvent | AnalyticsEvent[]) => void;
5
+ }
6
+ export declare const AnalyticsContext: React.Context<AnalyticsContextProps>;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export const AnalyticsContext = React.createContext({});
@@ -0,0 +1 @@
1
+ export * from './analyticsContext';