@gravity-ui/blog-constructor 2.2.0 → 2.3.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 +12 -0
- package/build/cjs/blocks/Banner/Banner.js +3 -0
- package/build/cjs/blocks/CTA/CTA.js +3 -0
- package/build/cjs/blocks/Feed/Feed.js +16 -3
- package/build/cjs/blocks/Header/Header.js +3 -0
- package/build/cjs/blocks/Meta/Meta.js +3 -0
- package/build/cjs/blocks/Suggest/Suggest.js +3 -0
- package/build/cjs/components/FeedHeader/components/Controls/Controls.js +21 -0
- package/build/cjs/components/Paginator/Paginator.js +20 -0
- package/build/cjs/components/PostCard/PostCard.d.ts +3 -0
- package/build/cjs/components/PostInfo/PostInfo.d.ts +3 -0
- package/build/cjs/components/PostInfo/components/Save.d.ts +3 -0
- package/build/cjs/components/PostInfo/components/Save.js +6 -3
- package/build/cjs/components/PostInfo/components/Sharing.d.ts +3 -0
- package/build/cjs/components/PostInfo/components/Sharing.js +11 -5
- package/build/cjs/constructor/BlogConstructorProvider.d.ts +2 -0
- package/build/cjs/constructor/BlogConstructorProvider.js +3 -1
- package/build/cjs/containers/BlogPostPage/BlogPostPage.css +1 -1
- package/build/cjs/counters/metrika.d.ts +3 -0
- package/build/cjs/counters/metrika.js +3 -0
- package/build/cjs/models/common.d.ts +11 -0
- package/build/cjs/models/common.js +14 -2
- package/build/esm/blocks/Banner/Banner.js +3 -0
- package/build/esm/blocks/CTA/CTA.js +3 -0
- package/build/esm/blocks/Feed/Feed.js +13 -0
- package/build/esm/blocks/Header/Header.js +3 -0
- package/build/esm/blocks/Meta/Meta.js +3 -0
- package/build/esm/blocks/Suggest/Suggest.js +3 -0
- package/build/esm/components/FeedHeader/components/Controls/Controls.js +21 -0
- package/build/esm/components/Paginator/Paginator.js +20 -0
- package/build/esm/components/PostCard/PostCard.d.ts +3 -0
- package/build/esm/components/PostInfo/PostInfo.d.ts +3 -0
- package/build/esm/components/PostInfo/components/Save.d.ts +3 -0
- package/build/esm/components/PostInfo/components/Save.js +4 -1
- package/build/esm/components/PostInfo/components/Sharing.d.ts +3 -0
- package/build/esm/components/PostInfo/components/Sharing.js +11 -5
- package/build/esm/constructor/BlogConstructorProvider.d.ts +2 -0
- package/build/esm/constructor/BlogConstructorProvider.js +3 -1
- package/build/esm/containers/BlogPostPage/BlogPostPage.css +1 -1
- package/build/esm/counters/metrika.d.ts +3 -0
- package/build/esm/counters/metrika.js +3 -0
- package/build/esm/models/common.d.ts +11 -0
- package/build/esm/models/common.js +13 -1
- package/package.json +2 -2
- package/server/models/common.d.ts +11 -0
- package/server/models/common.js +14 -2
- package/styles/yfm.css +1 -1
- package/styles/yfm.scss +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.3.0](https://github.com/gravity-ui/blog-constructor/compare/v2.2.0...v2.3.0) (2023-04-10)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* analytics refactoring ([#13](https://github.com/gravity-ui/blog-constructor/issues/13)) ([a95c55b](https://github.com/gravity-ui/blog-constructor/commit/a95c55bd1ff98f86a110f33ac3275b590ee5db8e))
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* margin-top of header ([#31](https://github.com/gravity-ui/blog-constructor/issues/31)) ([97ed974](https://github.com/gravity-ui/blog-constructor/commit/97ed974ab0ce0546010d60587b21b8c0eee3279c))
|
14
|
+
|
3
15
|
## [2.2.0](https://github.com/gravity-ui/blog-constructor/compare/v2.1.0...v2.2.0) (2023-04-06)
|
4
16
|
|
5
17
|
|
@@ -31,6 +31,9 @@ const Banner = (_a) => {
|
|
31
31
|
contentStyle.backgroundColor = color;
|
32
32
|
}
|
33
33
|
const contentData = (0, common_1.updateContentSizes)(content);
|
34
|
+
/**
|
35
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
36
|
+
*/
|
34
37
|
const metrikaGoal = {
|
35
38
|
name: constants_1.BlogMetrikaGoalIds.bannerCommon,
|
36
39
|
isCrossSite: true,
|
@@ -21,6 +21,9 @@ const CTA = ({ items, paddingTop, paddingBottom }) => {
|
|
21
21
|
else if (count > MAX_COLUMN_COUNT) {
|
22
22
|
count = MAX_COLUMN_COUNT;
|
23
23
|
}
|
24
|
+
/**
|
25
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
26
|
+
*/
|
24
27
|
const metrikaGoal = {
|
25
28
|
name: constants_1.BlogMetrikaGoalIds.cta,
|
26
29
|
isCrossSite: true,
|
@@ -28,6 +28,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.Feed = void 0;
|
30
30
|
const react_1 = __importStar(require("react"));
|
31
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
32
|
+
/**
|
33
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
34
|
+
*/
|
31
35
|
const uikit_1 = require("@gravity-ui/uikit");
|
32
36
|
const FeedHeader_1 = require("../../components/FeedHeader/FeedHeader");
|
33
37
|
const Posts_1 = require("../../components/Posts/Posts");
|
@@ -36,9 +40,13 @@ const constants_1 = require("../../constants");
|
|
36
40
|
const FeedContext_1 = require("../../contexts/FeedContext");
|
37
41
|
const LocaleContext_1 = require("../../contexts/LocaleContext");
|
38
42
|
const RouterContext_1 = require("../../contexts/RouterContext");
|
43
|
+
/**
|
44
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
45
|
+
*/
|
39
46
|
const metrika_js_1 = __importDefault(require("../../counters/metrika.js"));
|
40
47
|
const utils_1 = require("../../counters/utils");
|
41
|
-
const common_1 = require("../../
|
48
|
+
const common_1 = require("../../models/common");
|
49
|
+
const common_2 = require("../../utils/common");
|
42
50
|
const constants_2 = require("../constants");
|
43
51
|
const reducer_1 = require("./reducer");
|
44
52
|
const CONTAINER_ID = 'blog-cards';
|
@@ -49,6 +57,7 @@ const Feed = ({ image }) => {
|
|
49
57
|
const { posts, totalCount, tags, services, pinnedPost, getPosts, pageCountForShowSupportButtons, } = (0, react_1.useContext)(FeedContext_1.FeedContext);
|
50
58
|
const router = (0, react_1.useContext)(RouterContext_1.RouterContext);
|
51
59
|
const { locale } = (0, react_1.useContext)(LocaleContext_1.LocaleContext);
|
60
|
+
const handleAnalytics = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.ShowMore);
|
52
61
|
const [{ errorLoad, errorShowMore, isFetching, isShowMoreFetching, isShowMoreVisible, lastLoadedCount, postCountOnPage, postsOnPage, pinnedPostOnPage, currentPage, queryParams, }, dispatch,] = (0, react_1.useReducer)(reducer_1.reducer, {
|
53
62
|
errorLoad: false,
|
54
63
|
errorShowMore: false,
|
@@ -77,7 +86,7 @@ const Feed = ({ image }) => {
|
|
77
86
|
};
|
78
87
|
const fetchData = (0, react_1.useCallback)(async (pageNumber) => {
|
79
88
|
if (queryParams && getPosts) {
|
80
|
-
const query = (0,
|
89
|
+
const query = (0, common_2.getFeedQueryParams)(queryParams, pageNumber);
|
81
90
|
const data = await getPosts(query);
|
82
91
|
return data;
|
83
92
|
}
|
@@ -107,12 +116,16 @@ const Feed = ({ image }) => {
|
|
107
116
|
catch (err) {
|
108
117
|
dispatch({ type: reducer_1.ActionTypes.SetErrorLoad, payload: true });
|
109
118
|
}
|
110
|
-
(0,
|
119
|
+
(0, common_2.scrollOnPageChange)(CONTAINER_ID);
|
111
120
|
setIsFetching(false);
|
112
121
|
}, [fetchData]);
|
113
122
|
const handleShowMore = async () => {
|
114
123
|
dispatch({ type: reducer_1.ActionTypes.SetIsShowMoreFetching, payload: true });
|
124
|
+
/**
|
125
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
126
|
+
*/
|
115
127
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, constants_1.BlogMetrikaGoalIds.showMore);
|
128
|
+
handleAnalytics();
|
116
129
|
try {
|
117
130
|
const fetchedData = await fetchData(currentPage + 1);
|
118
131
|
handleChangeQueryParams({
|
@@ -33,6 +33,9 @@ const LocaleContext_1 = require("../../contexts/LocaleContext");
|
|
33
33
|
const PostPageContext_1 = require("../../contexts/PostPageContext");
|
34
34
|
const paddings_1 = require("../../models/paddings");
|
35
35
|
const common_1 = require("../../utils/common");
|
36
|
+
/**
|
37
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
38
|
+
*/
|
36
39
|
const metrikaGoals = {
|
37
40
|
sharing: constants_1.BlogMetrikaGoalIds.shareTop,
|
38
41
|
save: constants_1.BlogMetrikaGoalIds.saveTop,
|
@@ -35,6 +35,9 @@ const paddings_1 = require("../../models/paddings");
|
|
35
35
|
const cn_1 = require("../../utils/cn");
|
36
36
|
const common_1 = require("../../utils/common");
|
37
37
|
const b = (0, cn_1.block)('meta');
|
38
|
+
/**
|
39
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
40
|
+
*/
|
38
41
|
const metrikaGoals = {
|
39
42
|
sharing: constants_1.BlogMetrikaGoalIds.shareBottom,
|
40
43
|
save: constants_1.BlogMetrikaGoalIds.saveBottom,
|
@@ -32,6 +32,9 @@ const constants_1 = require("../../constants");
|
|
32
32
|
const PostPageContext_1 = require("../../contexts/PostPageContext");
|
33
33
|
const i18n_1 = require("../../i18n");
|
34
34
|
const paddings_1 = require("../../models/paddings");
|
35
|
+
/**
|
36
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
37
|
+
*/
|
35
38
|
const metrikaGoals = [
|
36
39
|
{
|
37
40
|
name: constants_1.BlogMetrikaGoalIds.suggest,
|
@@ -28,13 +28,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.Controls = void 0;
|
30
30
|
const react_1 = __importStar(require("react"));
|
31
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
31
32
|
const uikit_1 = require("@gravity-ui/uikit");
|
33
|
+
/**
|
34
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
35
|
+
*/
|
32
36
|
const constants_1 = require("../../../../constants");
|
33
37
|
const LikesContext_1 = require("../../../../contexts/LikesContext");
|
34
38
|
const metrika_js_1 = __importDefault(require("../../../../counters/metrika.js"));
|
35
39
|
const utils_1 = require("../../../../counters/utils");
|
36
40
|
const i18n_1 = require("../../../../i18n");
|
37
41
|
const Save_1 = require("../../../../icons/Save");
|
42
|
+
const common_1 = require("../../../../models/common");
|
38
43
|
const cn_1 = require("../../../../utils/cn");
|
39
44
|
const Search_1 = require("../../../Search/Search");
|
40
45
|
const customRenders_1 = require("./customRenders");
|
@@ -44,11 +49,15 @@ const DEFAULT_PAGE = 1;
|
|
44
49
|
const VIRTUALIZATION_THRESHOLD = 1000;
|
45
50
|
const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery, queryParams, }) => {
|
46
51
|
const { hasLikes } = (0, react_1.useContext)(LikesContext_1.LikesContext);
|
52
|
+
const handleAnalyticsTag = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.Tag);
|
53
|
+
const handleAnalyticsService = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.Service);
|
54
|
+
const handleAnalyticsSaveOnly = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.SaveOnly);
|
47
55
|
const { savedOnly: savedOnlyInitial, search: searchInitial, tags: tagInitial, services: servicesInitial, } = queryParams || {};
|
48
56
|
const [savedOnly, setSavedOnly] = (0, react_1.useState)(savedOnlyInitial === 'true');
|
49
57
|
const [search, setSearch] = (0, react_1.useState)(searchInitial);
|
50
58
|
const handleSavedOnly = () => {
|
51
59
|
handleChangeQuery({ savedOnly: savedOnly ? '' : 'true' });
|
60
|
+
handleAnalyticsSaveOnly();
|
52
61
|
setSavedOnly(!savedOnly);
|
53
62
|
setIsFetching(true);
|
54
63
|
};
|
@@ -58,9 +67,15 @@ const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery,
|
|
58
67
|
setIsFetching(true);
|
59
68
|
};
|
60
69
|
const handleTagSelect = (selectedTags) => {
|
70
|
+
/**
|
71
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
72
|
+
*/
|
61
73
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, constants_1.BlogMetrikaGoalIds.tag, {
|
62
74
|
theme: selectedTags[0],
|
63
75
|
});
|
76
|
+
handleAnalyticsTag(null, {
|
77
|
+
theme: selectedTags[0],
|
78
|
+
});
|
64
79
|
const isEmptyTag = selectedTags.some((tag) => tag === 'empty');
|
65
80
|
handleChangeQuery({
|
66
81
|
tags: isEmptyTag ? '' : selectedTags[0],
|
@@ -73,9 +88,15 @@ const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery,
|
|
73
88
|
return selectedServices.includes(service.value);
|
74
89
|
});
|
75
90
|
const metrikaAsString = forMetrikaServices.map((service) => service.content).join(',');
|
91
|
+
/**
|
92
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
93
|
+
*/
|
76
94
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, constants_1.BlogMetrikaGoalIds.service, {
|
77
95
|
service: metrikaAsString,
|
78
96
|
});
|
97
|
+
handleAnalyticsService(null, {
|
98
|
+
service: metrikaAsString,
|
99
|
+
});
|
79
100
|
const servicesAsString = selectedServices.join(',');
|
80
101
|
handleChangeQuery({ services: servicesAsString, page: DEFAULT_PAGE });
|
81
102
|
setIsFetching(true);
|
@@ -39,9 +39,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
40
40
|
exports.Paginator = void 0;
|
41
41
|
const react_1 = __importStar(require("react"));
|
42
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
42
43
|
const constants_1 = require("../../constants");
|
44
|
+
/**
|
45
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
46
|
+
*/
|
43
47
|
const metrika_js_1 = __importDefault(require("../../counters/metrika.js"));
|
44
48
|
const utils_1 = require("../../counters/utils");
|
49
|
+
const common_1 = require("../../models/common");
|
45
50
|
const cn_1 = require("../../utils/cn");
|
46
51
|
const NavigationButton_1 = require("./components/NavigationButton");
|
47
52
|
const PaginatorItem_1 = require("./components/PaginatorItem");
|
@@ -57,16 +62,27 @@ const Paginator = ({ itemsPerPage, totalItems, maxPages, page, className, loadin
|
|
57
62
|
}, [itemsPerPage, totalItems, maxPages]);
|
58
63
|
const handlePageChange = (pageIndex) => onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange(pageIndex);
|
59
64
|
const isShowSupportButtons = (0, react_1.useMemo)(() => pagesCount > pageCountForShowSupportButtons, [pageCountForShowSupportButtons, pagesCount]);
|
65
|
+
const handleAnalyticsHome = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.PaginatorHome);
|
66
|
+
const handleAnalyticsNext = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.PaginatorNext);
|
67
|
+
const handleAnalyticsPage = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.PaginatorPage);
|
60
68
|
if (pagesCount <= 1) {
|
61
69
|
return null;
|
62
70
|
}
|
63
71
|
const handleArrowClick = (type) => {
|
64
72
|
let newPage = page;
|
65
73
|
if (type === 'prev' && page > 1) {
|
74
|
+
/**
|
75
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
76
|
+
*/
|
66
77
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, constants_1.BlogMetrikaGoalIds.home);
|
78
|
+
handleAnalyticsHome();
|
67
79
|
newPage = 1;
|
68
80
|
}
|
69
81
|
else if (type === 'next' && page < pagesCount) {
|
82
|
+
/**
|
83
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
84
|
+
*/
|
85
|
+
handleAnalyticsNext();
|
70
86
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, constants_1.BlogMetrikaGoalIds.next);
|
71
87
|
newPage = page + 1;
|
72
88
|
}
|
@@ -76,7 +92,11 @@ const Paginator = ({ itemsPerPage, totalItems, maxPages, page, className, loadin
|
|
76
92
|
};
|
77
93
|
const handlePageClick = (index) => {
|
78
94
|
if (index !== page && typeof index === 'number') {
|
95
|
+
/**
|
96
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
97
|
+
*/
|
79
98
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, constants_1.BlogMetrikaGoalIds.page, { page: index });
|
99
|
+
handleAnalyticsPage(null, { page: String(index) });
|
80
100
|
handlePageChange(index);
|
81
101
|
}
|
82
102
|
};
|
@@ -6,6 +6,9 @@ type PostCardProps = {
|
|
6
6
|
fullWidth?: boolean;
|
7
7
|
showTag?: boolean;
|
8
8
|
size?: 's' | 'm';
|
9
|
+
/**
|
10
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
11
|
+
*/
|
9
12
|
metrikaGoals?: MetrikaGoal;
|
10
13
|
};
|
11
14
|
export declare const PostCard: React.FC<PostCardProps>;
|
@@ -9,6 +9,9 @@ type PostInfoProps = {
|
|
9
9
|
readingTime: PostData['readingTime'];
|
10
10
|
date: PostData['date'];
|
11
11
|
theme?: 'light' | 'dark';
|
12
|
+
/**
|
13
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
14
|
+
*/
|
12
15
|
metrikaGoals?: BlogMetrikaGoals;
|
13
16
|
dataQa?: string;
|
14
17
|
};
|
@@ -28,15 +28,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.Save = void 0;
|
30
30
|
const react_1 = __importStar(require("react"));
|
31
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
31
32
|
const uikit_1 = require("@gravity-ui/uikit");
|
32
33
|
const UserContext_1 = require("../../../contexts/UserContext");
|
33
34
|
const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
|
34
35
|
const utils_1 = require("../../../counters/utils");
|
35
36
|
const Save_1 = require("../../../icons/Save");
|
36
37
|
const SaveFilled_1 = require("../../../icons/SaveFilled");
|
38
|
+
const common_1 = require("../../../models/common");
|
37
39
|
const cn_1 = require("../../../utils/cn");
|
38
|
-
const
|
39
|
-
// @ts-ignore
|
40
|
+
const common_2 = require("../../../utils/common");
|
40
41
|
const ICON_SIZE = 16;
|
41
42
|
const b = (0, cn_1.block)('post-info');
|
42
43
|
/**
|
@@ -53,6 +54,7 @@ const b = (0, cn_1.block)('post-info');
|
|
53
54
|
*/
|
54
55
|
const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, dataQa, }) => {
|
55
56
|
const { uid } = (0, react_1.useContext)(UserContext_1.UserContext);
|
57
|
+
const handleAnalytics = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.SaveButton);
|
56
58
|
return (react_1.default.createElement("div", { className: b('item', { size }), onClick: (event) => {
|
57
59
|
// both preventDefault and stopImmediatePropagation required to work properly
|
58
60
|
// https://stackoverflow.com/questions/24415631/reactjs-syntheticevent-stoppropagation-only-works-with-react-events
|
@@ -61,9 +63,10 @@ const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, t
|
|
61
63
|
if (!uid) {
|
62
64
|
return;
|
63
65
|
}
|
64
|
-
(0,
|
66
|
+
(0, common_2.postLikeStatus)(postId, Boolean(hasUserLike));
|
65
67
|
handleUserLike();
|
66
68
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
|
69
|
+
handleAnalytics();
|
67
70
|
}, "data-qa": `${dataQa ? dataQa + '-' : ''}save` },
|
68
71
|
react_1.default.createElement("div", { className: b('content', { cursor: Boolean(uid), theme }) },
|
69
72
|
react_1.default.createElement("span", { className: b('icon') },
|
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.Sharing = void 0;
|
30
30
|
const react_1 = __importStar(require("react"));
|
31
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
31
32
|
const uikit_1 = require("@gravity-ui/uikit");
|
32
33
|
const MobileContext_1 = require("../../../contexts/MobileContext");
|
33
34
|
const PostPageContext_1 = require("../../../contexts/PostPageContext");
|
@@ -36,19 +37,24 @@ const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
|
|
36
37
|
const utils_1 = require("../../../counters/utils");
|
37
38
|
const i18n_1 = require("../../../i18n");
|
38
39
|
const ShareArrowUp_1 = require("../../../icons/ShareArrowUp");
|
40
|
+
const common_1 = require("../../../models/common");
|
39
41
|
const cn_1 = require("../../../utils/cn");
|
40
|
-
const
|
41
|
-
// @ts-ignore
|
42
|
+
const common_2 = require("../../../utils/common");
|
42
43
|
const b = (0, cn_1.block)('post-info');
|
43
44
|
const Sharing = ({ theme, metrikaGoal }) => {
|
44
45
|
const router = (0, react_1.useContext)(RouterContext_1.RouterContext);
|
45
46
|
const isMobile = (0, react_1.useContext)(MobileContext_1.MobileContext);
|
46
47
|
const { shareOptions } = (0, react_1.useContext)(PostPageContext_1.PostPageContext);
|
47
|
-
const
|
48
|
+
const handleAnalyticsGlobal = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.ShareButton);
|
49
|
+
const handleMetrika = (0, react_1.useCallback)(() => {
|
48
50
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
|
49
|
-
};
|
51
|
+
}, [metrikaGoal]);
|
52
|
+
const handleAnalytics = (0, react_1.useCallback)(() => {
|
53
|
+
handleAnalyticsGlobal();
|
54
|
+
handleMetrika();
|
55
|
+
}, [handleAnalyticsGlobal, handleMetrika]);
|
50
56
|
return (react_1.default.createElement("div", { className: b('item') },
|
51
57
|
react_1.default.createElement("span", { className: b('icon') },
|
52
|
-
react_1.default.createElement(uikit_1.SharePopover, { url: (0,
|
58
|
+
react_1.default.createElement(uikit_1.SharePopover, { url: (0, common_2.getAbsolutePath)(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: (0, i18n_1.i18)(i18n_1.Keyset.ActionShare), customIcon: ShareArrowUp_1.ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika: handleAnalytics }))));
|
53
59
|
};
|
54
60
|
exports.Sharing = Sharing;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import { AnalyticsContextProps } from '@gravity-ui/page-constructor';
|
2
3
|
import { DeviceContextProps } from '../contexts/DeviceContext';
|
3
4
|
import { RouterContextProps } from '../contexts/RouterContext';
|
4
5
|
import { UserContextProps } from '../contexts/UserContext';
|
@@ -11,6 +12,7 @@ export interface BlogConstructorProviderProps {
|
|
11
12
|
theme?: ThemeValueType;
|
12
13
|
user?: UserContextProps;
|
13
14
|
device?: DeviceContextProps;
|
15
|
+
analytics?: AnalyticsContextProps;
|
14
16
|
children?: React.ReactNode;
|
15
17
|
}
|
16
18
|
export declare const BlogConstructorProvider: React.FC<BlogConstructorProviderProps>;
|
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
26
|
exports.BlogConstructorProvider = void 0;
|
27
27
|
const react_1 = __importStar(require("react"));
|
28
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
28
29
|
const constants_1 = require("../constants");
|
29
30
|
const DeviceContext_1 = require("../contexts/DeviceContext");
|
30
31
|
const LocaleContext_1 = require("../contexts/LocaleContext");
|
@@ -32,7 +33,7 @@ const MobileContext_1 = require("../contexts/MobileContext");
|
|
32
33
|
const RouterContext_1 = require("../contexts/RouterContext");
|
33
34
|
const UserContext_1 = require("../contexts/UserContext");
|
34
35
|
const ThemeValueContext_1 = require("../contexts/theme/ThemeValueContext");
|
35
|
-
const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, user = {}, device = {}, children, }) => {
|
36
|
+
const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, user = {}, device = {}, analytics = {}, children, }) => {
|
36
37
|
const context = [
|
37
38
|
react_1.default.createElement(ThemeValueContext_1.ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
|
38
39
|
react_1.default.createElement(LocaleContext_1.LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
|
@@ -40,6 +41,7 @@ const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = c
|
|
40
41
|
react_1.default.createElement(MobileContext_1.MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
|
41
42
|
react_1.default.createElement(UserContext_1.UserContext.Provider, { value: user, key: "user-context" }),
|
42
43
|
react_1.default.createElement(DeviceContext_1.DeviceContext.Provider, { value: device, key: "device-context" }),
|
44
|
+
react_1.default.createElement(page_constructor_1.AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
|
43
45
|
].reduceRight((prev, provider) => react_1.default.cloneElement(provider, {}, prev), children);
|
44
46
|
return react_1.default.createElement(react_1.Fragment, null, context);
|
45
47
|
};
|
@@ -21,6 +21,9 @@ declare function hit(...args: any[]): void;
|
|
21
21
|
declare function params(...args: any[]): void;
|
22
22
|
declare function reachGoal(counterName: any, ...args: any[]): void;
|
23
23
|
declare function reachGoals(goals: any, counterName?: string): void;
|
24
|
+
/**
|
25
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
26
|
+
*/
|
24
27
|
declare const Goal: {
|
25
28
|
SUPPORT_OPEN_FORM: string;
|
26
29
|
SUPPORT_STEP_1_SUBMIT: string;
|
@@ -1,6 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.initCounters = void 0;
|
4
|
+
/**
|
5
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
6
|
+
*/
|
4
7
|
const Goal = {
|
5
8
|
SUPPORT_OPEN_FORM: 'SUPPORTOPENFORM',
|
6
9
|
SUPPORT_STEP_1_SUBMIT: 'SUPPORTSTEP1SUBMIT',
|
@@ -150,3 +150,14 @@ export type HandleChangeQueryParams = (params: Query) => void;
|
|
150
150
|
export type SetQueryType = (params: Query, options?: {
|
151
151
|
[y: string]: boolean;
|
152
152
|
}) => Promise<void> | void;
|
153
|
+
export declare enum DefaultEventNames {
|
154
|
+
ShareButton = "share-button-click",
|
155
|
+
SaveButton = "save-button-click",
|
156
|
+
ShowMore = "show-more-button-click",
|
157
|
+
PaginatorHome = "paginator-home-button-click",
|
158
|
+
PaginatorNext = "paginator-next-button-click",
|
159
|
+
PaginatorPage = "paginator-page-button-click",
|
160
|
+
Tag = "selector-tag-click",
|
161
|
+
Service = "selector-service-click",
|
162
|
+
SaveOnly = "save-only-button-click"
|
163
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.BlockType = exports.Theme = void 0;
|
3
|
+
exports.DefaultEventNames = exports.BlockType = exports.Theme = void 0;
|
4
4
|
var Theme;
|
5
5
|
(function (Theme) {
|
6
6
|
Theme["Light"] = "light";
|
@@ -19,4 +19,16 @@ var BlockType;
|
|
19
19
|
BlockType["Suggest"] = "blog-suggest-block";
|
20
20
|
BlockType["Meta"] = "blog-meta-block";
|
21
21
|
BlockType["Feed"] = "blog-feed-block";
|
22
|
-
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
22
|
+
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
23
|
+
var DefaultEventNames;
|
24
|
+
(function (DefaultEventNames) {
|
25
|
+
DefaultEventNames["ShareButton"] = "share-button-click";
|
26
|
+
DefaultEventNames["SaveButton"] = "save-button-click";
|
27
|
+
DefaultEventNames["ShowMore"] = "show-more-button-click";
|
28
|
+
DefaultEventNames["PaginatorHome"] = "paginator-home-button-click";
|
29
|
+
DefaultEventNames["PaginatorNext"] = "paginator-next-button-click";
|
30
|
+
DefaultEventNames["PaginatorPage"] = "paginator-page-button-click";
|
31
|
+
DefaultEventNames["Tag"] = "selector-tag-click";
|
32
|
+
DefaultEventNames["Service"] = "selector-service-click";
|
33
|
+
DefaultEventNames["SaveOnly"] = "save-only-button-click";
|
34
|
+
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|
@@ -26,6 +26,9 @@ export const Banner = (_a) => {
|
|
26
26
|
contentStyle.backgroundColor = color;
|
27
27
|
}
|
28
28
|
const contentData = updateContentSizes(content);
|
29
|
+
/**
|
30
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
31
|
+
*/
|
29
32
|
const metrikaGoal = {
|
30
33
|
name: BlogMetrikaGoalIds.bannerCommon,
|
31
34
|
isCrossSite: true,
|
@@ -16,6 +16,9 @@ export const CTA = ({ items, paddingTop, paddingBottom }) => {
|
|
16
16
|
else if (count > MAX_COLUMN_COUNT) {
|
17
17
|
count = MAX_COLUMN_COUNT;
|
18
18
|
}
|
19
|
+
/**
|
20
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
21
|
+
*/
|
19
22
|
const metrikaGoal = {
|
20
23
|
name: BlogMetrikaGoalIds.cta,
|
21
24
|
isCrossSite: true,
|
@@ -1,4 +1,8 @@
|
|
1
1
|
import React, { useCallback, useContext, useEffect, useMemo, useReducer } from 'react';
|
2
|
+
import { useAnalytics } from '@gravity-ui/page-constructor';
|
3
|
+
/**
|
4
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
5
|
+
*/
|
2
6
|
import { Icon } from '@gravity-ui/uikit';
|
3
7
|
import { FeedHeader } from '../../components/FeedHeader/FeedHeader';
|
4
8
|
import { Posts } from '../../components/Posts/Posts';
|
@@ -7,8 +11,12 @@ import { BlogMetrikaGoalIds } from '../../constants';
|
|
7
11
|
import { FeedContext } from '../../contexts/FeedContext';
|
8
12
|
import { LocaleContext } from '../../contexts/LocaleContext';
|
9
13
|
import { RouterContext } from '../../contexts/RouterContext';
|
14
|
+
/**
|
15
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
16
|
+
*/
|
10
17
|
import metrika from '../../counters/metrika.js';
|
11
18
|
import { MetrikaCounter } from '../../counters/utils';
|
19
|
+
import { DefaultEventNames } from '../../models/common';
|
12
20
|
import { getFeedQueryParams, scrollOnPageChange } from '../../utils/common';
|
13
21
|
import { DEFAULT_PAGE, DEFAULT_ROWS_PER_PAGE } from '../constants';
|
14
22
|
import { ActionTypes, reducer } from './reducer';
|
@@ -20,6 +28,7 @@ export const Feed = ({ image }) => {
|
|
20
28
|
const { posts, totalCount, tags, services, pinnedPost, getPosts, pageCountForShowSupportButtons, } = useContext(FeedContext);
|
21
29
|
const router = useContext(RouterContext);
|
22
30
|
const { locale } = useContext(LocaleContext);
|
31
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.ShowMore);
|
23
32
|
const [{ errorLoad, errorShowMore, isFetching, isShowMoreFetching, isShowMoreVisible, lastLoadedCount, postCountOnPage, postsOnPage, pinnedPostOnPage, currentPage, queryParams, }, dispatch,] = useReducer(reducer, {
|
24
33
|
errorLoad: false,
|
25
34
|
errorShowMore: false,
|
@@ -83,7 +92,11 @@ export const Feed = ({ image }) => {
|
|
83
92
|
}, [fetchData]);
|
84
93
|
const handleShowMore = async () => {
|
85
94
|
dispatch({ type: ActionTypes.SetIsShowMoreFetching, payload: true });
|
95
|
+
/**
|
96
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
97
|
+
*/
|
86
98
|
metrika.reachGoal(MetrikaCounter.CrossSite, BlogMetrikaGoalIds.showMore);
|
99
|
+
handleAnalytics();
|
87
100
|
try {
|
88
101
|
const fetchedData = await fetchData(currentPage + 1);
|
89
102
|
handleChangeQueryParams({
|
@@ -7,6 +7,9 @@ import { LocaleContext } from '../../contexts/LocaleContext';
|
|
7
7
|
import { PostPageContext } from '../../contexts/PostPageContext';
|
8
8
|
import { PaddingsDirections } from '../../models/paddings';
|
9
9
|
import { getBreadcrumbs } from '../../utils/common';
|
10
|
+
/**
|
11
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
12
|
+
*/
|
10
13
|
const metrikaGoals = {
|
11
14
|
sharing: BlogMetrikaGoalIds.shareTop,
|
12
15
|
save: BlogMetrikaGoalIds.saveTop,
|
@@ -10,6 +10,9 @@ import { block } from '../../utils/cn';
|
|
10
10
|
import { getBreadcrumbs } from '../../utils/common';
|
11
11
|
import './Meta.css';
|
12
12
|
const b = block('meta');
|
13
|
+
/**
|
14
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
15
|
+
*/
|
13
16
|
const metrikaGoals = {
|
14
17
|
sharing: BlogMetrikaGoalIds.shareBottom,
|
15
18
|
save: BlogMetrikaGoalIds.saveBottom,
|
@@ -6,6 +6,9 @@ import { BlogMetrikaGoalIds } from '../../constants';
|
|
6
6
|
import { PostPageContext } from '../../contexts/PostPageContext';
|
7
7
|
import { Keyset, i18 } from '../../i18n';
|
8
8
|
import { PaddingsDirections } from '../../models/paddings';
|
9
|
+
/**
|
10
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
11
|
+
*/
|
9
12
|
const metrikaGoals = [
|
10
13
|
{
|
11
14
|
name: BlogMetrikaGoalIds.suggest,
|
@@ -1,11 +1,16 @@
|
|
1
1
|
import React, { useContext, useMemo, useState } from 'react';
|
2
|
+
import { useAnalytics } from '@gravity-ui/page-constructor';
|
2
3
|
import { Button, Icon, Select } from '@gravity-ui/uikit';
|
4
|
+
/**
|
5
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
6
|
+
*/
|
3
7
|
import { BlogMetrikaGoalIds } from '../../../../constants';
|
4
8
|
import { LikesContext } from '../../../../contexts/LikesContext';
|
5
9
|
import metrika from '../../../../counters/metrika.js';
|
6
10
|
import { MetrikaCounter } from '../../../../counters/utils';
|
7
11
|
import { Keyset, i18 } from '../../../../i18n';
|
8
12
|
import { Save } from '../../../../icons/Save';
|
13
|
+
import { DefaultEventNames, } from '../../../../models/common';
|
9
14
|
import { block } from '../../../../utils/cn';
|
10
15
|
import { Search } from '../../../Search/Search';
|
11
16
|
import { renderFilter, renderOption, renderSwitcher } from './customRenders';
|
@@ -16,11 +21,15 @@ const DEFAULT_PAGE = 1;
|
|
16
21
|
const VIRTUALIZATION_THRESHOLD = 1000;
|
17
22
|
export const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery, queryParams, }) => {
|
18
23
|
const { hasLikes } = useContext(LikesContext);
|
24
|
+
const handleAnalyticsTag = useAnalytics(DefaultEventNames.Tag);
|
25
|
+
const handleAnalyticsService = useAnalytics(DefaultEventNames.Service);
|
26
|
+
const handleAnalyticsSaveOnly = useAnalytics(DefaultEventNames.SaveOnly);
|
19
27
|
const { savedOnly: savedOnlyInitial, search: searchInitial, tags: tagInitial, services: servicesInitial, } = queryParams || {};
|
20
28
|
const [savedOnly, setSavedOnly] = useState(savedOnlyInitial === 'true');
|
21
29
|
const [search, setSearch] = useState(searchInitial);
|
22
30
|
const handleSavedOnly = () => {
|
23
31
|
handleChangeQuery({ savedOnly: savedOnly ? '' : 'true' });
|
32
|
+
handleAnalyticsSaveOnly();
|
24
33
|
setSavedOnly(!savedOnly);
|
25
34
|
setIsFetching(true);
|
26
35
|
};
|
@@ -30,9 +39,15 @@ export const Controls = ({ setIsFetching, tags = [], services = [], handleChange
|
|
30
39
|
setIsFetching(true);
|
31
40
|
};
|
32
41
|
const handleTagSelect = (selectedTags) => {
|
42
|
+
/**
|
43
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
44
|
+
*/
|
33
45
|
metrika.reachGoal(MetrikaCounter.CrossSite, BlogMetrikaGoalIds.tag, {
|
34
46
|
theme: selectedTags[0],
|
35
47
|
});
|
48
|
+
handleAnalyticsTag(null, {
|
49
|
+
theme: selectedTags[0],
|
50
|
+
});
|
36
51
|
const isEmptyTag = selectedTags.some((tag) => tag === 'empty');
|
37
52
|
handleChangeQuery({
|
38
53
|
tags: isEmptyTag ? '' : selectedTags[0],
|
@@ -45,9 +60,15 @@ export const Controls = ({ setIsFetching, tags = [], services = [], handleChange
|
|
45
60
|
return selectedServices.includes(service.value);
|
46
61
|
});
|
47
62
|
const metrikaAsString = forMetrikaServices.map((service) => service.content).join(',');
|
63
|
+
/**
|
64
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
65
|
+
*/
|
48
66
|
metrika.reachGoal(MetrikaCounter.CrossSite, BlogMetrikaGoalIds.service, {
|
49
67
|
service: metrikaAsString,
|
50
68
|
});
|
69
|
+
handleAnalyticsService(null, {
|
70
|
+
service: metrikaAsString,
|
71
|
+
});
|
51
72
|
const servicesAsString = selectedServices.join(',');
|
52
73
|
handleChangeQuery({ services: servicesAsString, page: DEFAULT_PAGE });
|
53
74
|
setIsFetching(true);
|
@@ -10,9 +10,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
10
10
|
return t;
|
11
11
|
};
|
12
12
|
import React, { useEffect, useMemo, useState } from 'react';
|
13
|
+
import { useAnalytics } from '@gravity-ui/page-constructor';
|
13
14
|
import { BlogMetrikaGoalIds } from '../../constants';
|
15
|
+
/**
|
16
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
17
|
+
*/
|
14
18
|
import metrika from '../../counters/metrika.js';
|
15
19
|
import { MetrikaCounter } from '../../counters/utils';
|
20
|
+
import { DefaultEventNames } from '../../models/common';
|
16
21
|
import { block } from '../../utils/cn';
|
17
22
|
import { NavigationButton } from './components/NavigationButton';
|
18
23
|
import { PaginatorItem } from './components/PaginatorItem';
|
@@ -29,16 +34,27 @@ export const Paginator = ({ itemsPerPage, totalItems, maxPages, page, className,
|
|
29
34
|
}, [itemsPerPage, totalItems, maxPages]);
|
30
35
|
const handlePageChange = (pageIndex) => onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange(pageIndex);
|
31
36
|
const isShowSupportButtons = useMemo(() => pagesCount > pageCountForShowSupportButtons, [pageCountForShowSupportButtons, pagesCount]);
|
37
|
+
const handleAnalyticsHome = useAnalytics(DefaultEventNames.PaginatorHome);
|
38
|
+
const handleAnalyticsNext = useAnalytics(DefaultEventNames.PaginatorNext);
|
39
|
+
const handleAnalyticsPage = useAnalytics(DefaultEventNames.PaginatorPage);
|
32
40
|
if (pagesCount <= 1) {
|
33
41
|
return null;
|
34
42
|
}
|
35
43
|
const handleArrowClick = (type) => {
|
36
44
|
let newPage = page;
|
37
45
|
if (type === 'prev' && page > 1) {
|
46
|
+
/**
|
47
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
48
|
+
*/
|
38
49
|
metrika.reachGoal(MetrikaCounter.CrossSite, BlogMetrikaGoalIds.home);
|
50
|
+
handleAnalyticsHome();
|
39
51
|
newPage = 1;
|
40
52
|
}
|
41
53
|
else if (type === 'next' && page < pagesCount) {
|
54
|
+
/**
|
55
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
56
|
+
*/
|
57
|
+
handleAnalyticsNext();
|
42
58
|
metrika.reachGoal(MetrikaCounter.CrossSite, BlogMetrikaGoalIds.next);
|
43
59
|
newPage = page + 1;
|
44
60
|
}
|
@@ -48,7 +64,11 @@ export const Paginator = ({ itemsPerPage, totalItems, maxPages, page, className,
|
|
48
64
|
};
|
49
65
|
const handlePageClick = (index) => {
|
50
66
|
if (index !== page && typeof index === 'number') {
|
67
|
+
/**
|
68
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
69
|
+
*/
|
51
70
|
metrika.reachGoal(MetrikaCounter.CrossSite, BlogMetrikaGoalIds.page, { page: index });
|
71
|
+
handleAnalyticsPage(null, { page: String(index) });
|
52
72
|
handlePageChange(index);
|
53
73
|
}
|
54
74
|
};
|
@@ -7,6 +7,9 @@ type PostCardProps = {
|
|
7
7
|
fullWidth?: boolean;
|
8
8
|
showTag?: boolean;
|
9
9
|
size?: 's' | 'm';
|
10
|
+
/**
|
11
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
12
|
+
*/
|
10
13
|
metrikaGoals?: MetrikaGoal;
|
11
14
|
};
|
12
15
|
export declare const PostCard: React.FC<PostCardProps>;
|
@@ -10,6 +10,9 @@ type PostInfoProps = {
|
|
10
10
|
readingTime: PostData['readingTime'];
|
11
11
|
date: PostData['date'];
|
12
12
|
theme?: 'light' | 'dark';
|
13
|
+
/**
|
14
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
15
|
+
*/
|
13
16
|
metrikaGoals?: BlogMetrikaGoals;
|
14
17
|
dataQa?: string;
|
15
18
|
};
|
@@ -1,13 +1,14 @@
|
|
1
1
|
import React, { useContext } from 'react';
|
2
|
+
import { useAnalytics } from '@gravity-ui/page-constructor';
|
2
3
|
import { Icon } from '@gravity-ui/uikit';
|
3
4
|
import { UserContext } from '../../../contexts/UserContext';
|
4
5
|
import metrika from '../../../counters/metrika.js';
|
5
6
|
import { MetrikaCounter } from '../../../counters/utils';
|
6
7
|
import { Save as SaveIcon } from '../../../icons/Save';
|
7
8
|
import { SaveFilled } from '../../../icons/SaveFilled';
|
9
|
+
import { DefaultEventNames } from '../../../models/common';
|
8
10
|
import { block } from '../../../utils/cn';
|
9
11
|
import { postLikeStatus } from '../../../utils/common';
|
10
|
-
// @ts-ignore
|
11
12
|
import '../PostInfo.css';
|
12
13
|
const ICON_SIZE = 16;
|
13
14
|
const b = block('post-info');
|
@@ -25,6 +26,7 @@ const b = block('post-info');
|
|
25
26
|
*/
|
26
27
|
export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, dataQa, }) => {
|
27
28
|
const { uid } = useContext(UserContext);
|
29
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.SaveButton);
|
28
30
|
return (React.createElement("div", { className: b('item', { size }), onClick: (event) => {
|
29
31
|
// both preventDefault and stopImmediatePropagation required to work properly
|
30
32
|
// https://stackoverflow.com/questions/24415631/reactjs-syntheticevent-stoppropagation-only-works-with-react-events
|
@@ -36,6 +38,7 @@ export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal,
|
|
36
38
|
postLikeStatus(postId, Boolean(hasUserLike));
|
37
39
|
handleUserLike();
|
38
40
|
metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
|
41
|
+
handleAnalytics();
|
39
42
|
}, "data-qa": `${dataQa ? dataQa + '-' : ''}save` },
|
40
43
|
React.createElement("div", { className: b('content', { cursor: Boolean(uid), theme }) },
|
41
44
|
React.createElement("span", { className: b('icon') },
|
@@ -2,6 +2,9 @@ import React from 'react';
|
|
2
2
|
import '../PostInfo.css';
|
3
3
|
type SharingProps = {
|
4
4
|
theme?: 'light' | 'dark';
|
5
|
+
/**
|
6
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
7
|
+
*/
|
5
8
|
metrikaGoal?: string;
|
6
9
|
};
|
7
10
|
export declare const Sharing: React.FC<SharingProps>;
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import React, { useContext } from 'react';
|
1
|
+
import React, { useCallback, useContext } from 'react';
|
2
|
+
import { useAnalytics } from '@gravity-ui/page-constructor';
|
2
3
|
import { SharePopover } from '@gravity-ui/uikit';
|
3
4
|
import { MobileContext } from '../../../contexts/MobileContext';
|
4
5
|
import { PostPageContext } from '../../../contexts/PostPageContext';
|
@@ -7,19 +8,24 @@ import metrika from '../../../counters/metrika.js';
|
|
7
8
|
import { MetrikaCounter } from '../../../counters/utils';
|
8
9
|
import { Keyset, i18 } from '../../../i18n';
|
9
10
|
import { ShareArrowUp } from '../../../icons/ShareArrowUp';
|
11
|
+
import { DefaultEventNames } from '../../../models/common';
|
10
12
|
import { block } from '../../../utils/cn';
|
11
13
|
import { getAbsolutePath } from '../../../utils/common';
|
12
|
-
// @ts-ignore
|
13
14
|
import '../PostInfo.css';
|
14
15
|
const b = block('post-info');
|
15
16
|
export const Sharing = ({ theme, metrikaGoal }) => {
|
16
17
|
const router = useContext(RouterContext);
|
17
18
|
const isMobile = useContext(MobileContext);
|
18
19
|
const { shareOptions } = useContext(PostPageContext);
|
19
|
-
const
|
20
|
+
const handleAnalyticsGlobal = useAnalytics(DefaultEventNames.ShareButton);
|
21
|
+
const handleMetrika = useCallback(() => {
|
20
22
|
metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
|
21
|
-
};
|
23
|
+
}, [metrikaGoal]);
|
24
|
+
const handleAnalytics = useCallback(() => {
|
25
|
+
handleAnalyticsGlobal();
|
26
|
+
handleMetrika();
|
27
|
+
}, [handleAnalyticsGlobal, handleMetrika]);
|
22
28
|
return (React.createElement("div", { className: b('item') },
|
23
29
|
React.createElement("span", { className: b('icon') },
|
24
|
-
React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: i18(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika:
|
30
|
+
React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: i18(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika: handleAnalytics }))));
|
25
31
|
};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import { AnalyticsContextProps } from '@gravity-ui/page-constructor';
|
2
3
|
import { DeviceContextProps } from '../contexts/DeviceContext';
|
3
4
|
import { RouterContextProps } from '../contexts/RouterContext';
|
4
5
|
import { UserContextProps } from '../contexts/UserContext';
|
@@ -11,6 +12,7 @@ export interface BlogConstructorProviderProps {
|
|
11
12
|
theme?: ThemeValueType;
|
12
13
|
user?: UserContextProps;
|
13
14
|
device?: DeviceContextProps;
|
15
|
+
analytics?: AnalyticsContextProps;
|
14
16
|
children?: React.ReactNode;
|
15
17
|
}
|
16
18
|
export declare const BlogConstructorProvider: React.FC<BlogConstructorProviderProps>;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React, { Fragment } from 'react';
|
2
|
+
import { AnalyticsContext } from '@gravity-ui/page-constructor';
|
2
3
|
import { DEFAULT_THEME } from '../constants';
|
3
4
|
import { DeviceContext } from '../contexts/DeviceContext';
|
4
5
|
import { LocaleContext } from '../contexts/LocaleContext';
|
@@ -6,7 +7,7 @@ import { MobileContext } from '../contexts/MobileContext';
|
|
6
7
|
import { RouterContext } from '../contexts/RouterContext';
|
7
8
|
import { UserContext } from '../contexts/UserContext';
|
8
9
|
import { ThemeValueContext } from '../contexts/theme/ThemeValueContext';
|
9
|
-
export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, user = {}, device = {}, children, }) => {
|
10
|
+
export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, user = {}, device = {}, analytics = {}, children, }) => {
|
10
11
|
const context = [
|
11
12
|
React.createElement(ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
|
12
13
|
React.createElement(LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
|
@@ -14,6 +15,7 @@ export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, th
|
|
14
15
|
React.createElement(MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
|
15
16
|
React.createElement(UserContext.Provider, { value: user, key: "user-context" }),
|
16
17
|
React.createElement(DeviceContext.Provider, { value: device, key: "device-context" }),
|
18
|
+
React.createElement(AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
|
17
19
|
].reduceRight((prev, provider) => React.cloneElement(provider, {}, prev), children);
|
18
20
|
return React.createElement(Fragment, null, context);
|
19
21
|
};
|
@@ -21,6 +21,9 @@ declare function hit(...args: any[]): void;
|
|
21
21
|
declare function params(...args: any[]): void;
|
22
22
|
declare function reachGoal(counterName: any, ...args: any[]): void;
|
23
23
|
declare function reachGoals(goals: any, counterName?: string): void;
|
24
|
+
/**
|
25
|
+
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
26
|
+
*/
|
24
27
|
declare const Goal: {
|
25
28
|
SUPPORT_OPEN_FORM: string;
|
26
29
|
SUPPORT_STEP_1_SUBMIT: string;
|
@@ -150,3 +150,14 @@ export type HandleChangeQueryParams = (params: Query) => void;
|
|
150
150
|
export type SetQueryType = (params: Query, options?: {
|
151
151
|
[y: string]: boolean;
|
152
152
|
}) => Promise<void> | void;
|
153
|
+
export declare enum DefaultEventNames {
|
154
|
+
ShareButton = "share-button-click",
|
155
|
+
SaveButton = "save-button-click",
|
156
|
+
ShowMore = "show-more-button-click",
|
157
|
+
PaginatorHome = "paginator-home-button-click",
|
158
|
+
PaginatorNext = "paginator-next-button-click",
|
159
|
+
PaginatorPage = "paginator-page-button-click",
|
160
|
+
Tag = "selector-tag-click",
|
161
|
+
Service = "selector-service-click",
|
162
|
+
SaveOnly = "save-only-button-click"
|
163
|
+
}
|
@@ -16,4 +16,16 @@ export var BlockType;
|
|
16
16
|
BlockType["Suggest"] = "blog-suggest-block";
|
17
17
|
BlockType["Meta"] = "blog-meta-block";
|
18
18
|
BlockType["Feed"] = "blog-feed-block";
|
19
|
-
})(BlockType || (BlockType = {}));
|
19
|
+
})(BlockType || (BlockType = {}));
|
20
|
+
export var DefaultEventNames;
|
21
|
+
(function (DefaultEventNames) {
|
22
|
+
DefaultEventNames["ShareButton"] = "share-button-click";
|
23
|
+
DefaultEventNames["SaveButton"] = "save-button-click";
|
24
|
+
DefaultEventNames["ShowMore"] = "show-more-button-click";
|
25
|
+
DefaultEventNames["PaginatorHome"] = "paginator-home-button-click";
|
26
|
+
DefaultEventNames["PaginatorNext"] = "paginator-next-button-click";
|
27
|
+
DefaultEventNames["PaginatorPage"] = "paginator-page-button-click";
|
28
|
+
DefaultEventNames["Tag"] = "selector-tag-click";
|
29
|
+
DefaultEventNames["Service"] = "selector-service-click";
|
30
|
+
DefaultEventNames["SaveOnly"] = "save-only-button-click";
|
31
|
+
})(DefaultEventNames || (DefaultEventNames = {}));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gravity-ui/blog-constructor",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.3.0",
|
4
4
|
"description": "Gravity UI Blog Constructor",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": {
|
@@ -73,7 +73,7 @@
|
|
73
73
|
"@commitlint/config-conventional": "^17.4.3",
|
74
74
|
"@doc-tools/transform": "^2.9.0",
|
75
75
|
"@gravity-ui/eslint-config": "^2.0.0",
|
76
|
-
"@gravity-ui/page-constructor": "^2.
|
76
|
+
"@gravity-ui/page-constructor": "^2.6.0",
|
77
77
|
"@gravity-ui/prettier-config": "^1.0.1",
|
78
78
|
"@gravity-ui/stylelint-config": "^1.0.0",
|
79
79
|
"@gravity-ui/tsconfig": "^1.0.0",
|
@@ -150,3 +150,14 @@ export type HandleChangeQueryParams = (params: Query) => void;
|
|
150
150
|
export type SetQueryType = (params: Query, options?: {
|
151
151
|
[y: string]: boolean;
|
152
152
|
}) => Promise<void> | void;
|
153
|
+
export declare enum DefaultEventNames {
|
154
|
+
ShareButton = "share-button-click",
|
155
|
+
SaveButton = "save-button-click",
|
156
|
+
ShowMore = "show-more-button-click",
|
157
|
+
PaginatorHome = "paginator-home-button-click",
|
158
|
+
PaginatorNext = "paginator-next-button-click",
|
159
|
+
PaginatorPage = "paginator-page-button-click",
|
160
|
+
Tag = "selector-tag-click",
|
161
|
+
Service = "selector-service-click",
|
162
|
+
SaveOnly = "save-only-button-click"
|
163
|
+
}
|
package/server/models/common.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.BlockType = exports.Theme = void 0;
|
3
|
+
exports.DefaultEventNames = exports.BlockType = exports.Theme = void 0;
|
4
4
|
var Theme;
|
5
5
|
(function (Theme) {
|
6
6
|
Theme["Light"] = "light";
|
@@ -19,4 +19,16 @@ var BlockType;
|
|
19
19
|
BlockType["Suggest"] = "blog-suggest-block";
|
20
20
|
BlockType["Meta"] = "blog-meta-block";
|
21
21
|
BlockType["Feed"] = "blog-feed-block";
|
22
|
-
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
22
|
+
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
23
|
+
var DefaultEventNames;
|
24
|
+
(function (DefaultEventNames) {
|
25
|
+
DefaultEventNames["ShareButton"] = "share-button-click";
|
26
|
+
DefaultEventNames["SaveButton"] = "save-button-click";
|
27
|
+
DefaultEventNames["ShowMore"] = "show-more-button-click";
|
28
|
+
DefaultEventNames["PaginatorHome"] = "paginator-home-button-click";
|
29
|
+
DefaultEventNames["PaginatorNext"] = "paginator-next-button-click";
|
30
|
+
DefaultEventNames["PaginatorPage"] = "paginator-page-button-click";
|
31
|
+
DefaultEventNames["Tag"] = "selector-tag-click";
|
32
|
+
DefaultEventNames["Service"] = "selector-service-click";
|
33
|
+
DefaultEventNames["SaveOnly"] = "save-only-button-click";
|
34
|
+
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|
package/styles/yfm.css
CHANGED