@gravity-ui/page-constructor 2.3.2 → 2.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.4.0](https://github.com/gravity-ui/page-constructor/compare/v2.3.2...v2.4.0) (2023-04-05)
4
+
5
+
6
+ ### Features
7
+
8
+ * analytics in header block breadcrumbs ([#284](https://github.com/gravity-ui/page-constructor/issues/284)) ([a2e6bbf](https://github.com/gravity-ui/page-constructor/commit/a2e6bbf0816a86d23bcca784956f4cace6d21d5a))
9
+
3
10
  ## [2.3.2](https://github.com/gravity-ui/page-constructor/compare/v2.3.1...v2.3.2) (2023-04-05)
4
11
 
5
12
 
@@ -1,16 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const react_1 = tslib_1.__importDefault(require("react"));
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
5
  const utils_1 = require("../../utils");
6
+ const models_1 = require("../../models");
6
7
  const useMetrika_1 = require("../../hooks/useMetrika");
8
+ const hooks_1 = require("../../hooks");
7
9
  const b = (0, utils_1.block)('header-breadcrumbs');
8
10
  function HeaderBreadcrumbs(props) {
9
11
  const { items, metrikaGoals, pixelEvents, theme = 'light', className } = props;
10
12
  const handleMetrika = (0, useMetrika_1.useMetrika)();
11
- const onClick = () => {
13
+ const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.Breadcrumb);
14
+ const onClick = (0, react_1.useCallback)(() => {
15
+ handleAnalytics();
12
16
  handleMetrika({ metrikaGoals, pixelEvents });
13
- };
17
+ }, [handleAnalytics, handleMetrika, metrikaGoals, pixelEvents]);
14
18
  return (react_1.default.createElement("div", { className: b({ theme }, className) }, items.map((item) => (react_1.default.createElement("div", { className: b('item'), key: item.url },
15
19
  react_1.default.createElement("a", { href: item.url, className: b('text'), onClick: onClick }, item.text))))));
16
20
  }
@@ -78,7 +78,8 @@ export declare enum DefaultEventNames {
78
78
  YandexFormSubmit = "yandex-form-submit",
79
79
  HubspotFormSubmit = "hubspot-form-submit",
80
80
  QuoteButton = "quote-button-click",
81
- BackLink = "back-link-click"
81
+ BackLink = "back-link-click",
82
+ Breadcrumb = "breadcrumb-click"
82
83
  }
83
84
  export type AnalyticsCounters = {
84
85
  include?: string[];
@@ -47,4 +47,5 @@ var DefaultEventNames;
47
47
  DefaultEventNames["HubspotFormSubmit"] = "hubspot-form-submit";
48
48
  DefaultEventNames["QuoteButton"] = "quote-button-click";
49
49
  DefaultEventNames["BackLink"] = "back-link-click";
50
+ DefaultEventNames["Breadcrumb"] = "breadcrumb-click";
50
51
  })(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
@@ -1,14 +1,18 @@
1
- import React from 'react';
1
+ import React, { useCallback } from 'react';
2
2
  import { block } from '../../utils';
3
+ import { DefaultEventNames } from '../../models';
3
4
  import { useMetrika } from '../../hooks/useMetrika';
5
+ import { useAnalytics } from '../../hooks';
4
6
  import './HeaderBreadcrumbs.css';
5
7
  const b = block('header-breadcrumbs');
6
8
  export default function HeaderBreadcrumbs(props) {
7
9
  const { items, metrikaGoals, pixelEvents, theme = 'light', className } = props;
8
10
  const handleMetrika = useMetrika();
9
- const onClick = () => {
11
+ const handleAnalytics = useAnalytics(DefaultEventNames.Breadcrumb);
12
+ const onClick = useCallback(() => {
13
+ handleAnalytics();
10
14
  handleMetrika({ metrikaGoals, pixelEvents });
11
- };
15
+ }, [handleAnalytics, handleMetrika, metrikaGoals, pixelEvents]);
12
16
  return (React.createElement("div", { className: b({ theme }, className) }, items.map((item) => (React.createElement("div", { className: b('item'), key: item.url },
13
17
  React.createElement("a", { href: item.url, className: b('text'), onClick: onClick }, item.text))))));
14
18
  }
@@ -78,7 +78,8 @@ export declare enum DefaultEventNames {
78
78
  YandexFormSubmit = "yandex-form-submit",
79
79
  HubspotFormSubmit = "hubspot-form-submit",
80
80
  QuoteButton = "quote-button-click",
81
- BackLink = "back-link-click"
81
+ BackLink = "back-link-click",
82
+ Breadcrumb = "breadcrumb-click"
82
83
  }
83
84
  export type AnalyticsCounters = {
84
85
  include?: string[];
@@ -44,4 +44,5 @@ export var DefaultEventNames;
44
44
  DefaultEventNames["HubspotFormSubmit"] = "hubspot-form-submit";
45
45
  DefaultEventNames["QuoteButton"] = "quote-button-click";
46
46
  DefaultEventNames["BackLink"] = "back-link-click";
47
+ DefaultEventNames["Breadcrumb"] = "breadcrumb-click";
47
48
  })(DefaultEventNames || (DefaultEventNames = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -78,7 +78,8 @@ export declare enum DefaultEventNames {
78
78
  YandexFormSubmit = "yandex-form-submit",
79
79
  HubspotFormSubmit = "hubspot-form-submit",
80
80
  QuoteButton = "quote-button-click",
81
- BackLink = "back-link-click"
81
+ BackLink = "back-link-click",
82
+ Breadcrumb = "breadcrumb-click"
82
83
  }
83
84
  export type AnalyticsCounters = {
84
85
  include?: string[];
@@ -47,4 +47,5 @@ var DefaultEventNames;
47
47
  DefaultEventNames["HubspotFormSubmit"] = "hubspot-form-submit";
48
48
  DefaultEventNames["QuoteButton"] = "quote-button-click";
49
49
  DefaultEventNames["BackLink"] = "back-link-click";
50
+ DefaultEventNames["Breadcrumb"] = "breadcrumb-click";
50
51
  })(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));