@gravity-ui/blog-constructor 2.1.0-alpha.1 → 2.1.0-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/build/cjs/components/PostInfo/components/Save.js +10 -6
- package/build/cjs/components/PostInfo/components/Sharing.js +2 -2
- package/build/cjs/models/common.d.ts +2 -1
- package/build/cjs/models/common.js +1 -0
- package/build/esm/components/PostInfo/components/Save.js +9 -5
- package/build/esm/components/PostInfo/components/Sharing.js +1 -1
- package/build/esm/models/common.d.ts +2 -1
- package/build/esm/models/common.js +1 -0
- package/package.json +1 -1
- package/server/models/common.d.ts +2 -1
- package/server/models/common.js +1 -0
@@ -27,16 +27,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.Save = void 0;
|
30
|
-
const
|
30
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
31
31
|
const uikit_1 = require("@gravity-ui/uikit");
|
32
|
-
const
|
33
|
-
const
|
32
|
+
const react_1 = __importStar(require("react"));
|
33
|
+
const UserContext_1 = require("../../../contexts/UserContext");
|
34
|
+
const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
|
34
35
|
const utils_1 = require("../../../counters/utils");
|
35
36
|
// @ts-ignore
|
36
|
-
const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
|
37
37
|
const Save_1 = require("../../../icons/Save");
|
38
38
|
const SaveFilled_1 = require("../../../icons/SaveFilled");
|
39
|
-
const
|
39
|
+
const common_1 = require("../../../models/common");
|
40
|
+
const cn_1 = require("../../../utils/cn");
|
41
|
+
const common_2 = require("../../../utils/common");
|
40
42
|
const ICON_SIZE = 16;
|
41
43
|
const b = (0, cn_1.block)('post-info');
|
42
44
|
/**
|
@@ -53,6 +55,7 @@ const b = (0, cn_1.block)('post-info');
|
|
53
55
|
*/
|
54
56
|
const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, dataQa, }) => {
|
55
57
|
const { uid } = (0, react_1.useContext)(UserContext_1.UserContext);
|
58
|
+
const handleAnalytics = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.SaveButton);
|
56
59
|
return (react_1.default.createElement("div", { className: b('item', { size }), onClick: (event) => {
|
57
60
|
// both preventDefault and stopImmediatePropagation required to work properly
|
58
61
|
// https://stackoverflow.com/questions/24415631/reactjs-syntheticevent-stoppropagation-only-works-with-react-events
|
@@ -61,9 +64,10 @@ const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, t
|
|
61
64
|
if (!uid) {
|
62
65
|
return;
|
63
66
|
}
|
64
|
-
(0,
|
67
|
+
(0, common_2.postLikeStatus)(postId, Boolean(hasUserLike));
|
65
68
|
handleUserLike();
|
66
69
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
|
70
|
+
handleAnalytics();
|
67
71
|
}, "data-qa": `${dataQa ? dataQa + '-' : ''}save` },
|
68
72
|
react_1.default.createElement("div", { className: b('content', { cursor: Boolean(uid), theme }) },
|
69
73
|
react_1.default.createElement("span", { className: b('icon') },
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.Sharing = void 0;
|
30
|
-
const
|
30
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
31
31
|
const uikit_1 = require("@gravity-ui/uikit");
|
32
32
|
const react_1 = __importStar(require("react"));
|
33
33
|
const MobileContext_1 = require("../../../contexts/MobileContext");
|
@@ -46,7 +46,7 @@ const Sharing = ({ theme, metrikaGoal }) => {
|
|
46
46
|
const router = (0, react_1.useContext)(RouterContext_1.RouterContext);
|
47
47
|
const isMobile = (0, react_1.useContext)(MobileContext_1.MobileContext);
|
48
48
|
const { shareOptions } = (0, react_1.useContext)(PostPageContext_1.PostPageContext);
|
49
|
-
const handleAnalyticsGlobal = (0,
|
49
|
+
const handleAnalyticsGlobal = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.ShareButton);
|
50
50
|
const handleMetrika = (0, react_1.useCallback)(() => {
|
51
51
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
|
52
52
|
}, [metrikaGoal]);
|
@@ -150,5 +150,6 @@ export type SetQueryType = (params: Query, options?: {
|
|
150
150
|
[y: string]: boolean;
|
151
151
|
}) => Promise<void> | void;
|
152
152
|
export declare enum DefaultEventNames {
|
153
|
-
ShareButton = "share-button-click"
|
153
|
+
ShareButton = "share-button-click",
|
154
|
+
SaveButton = "save-button-click"
|
154
155
|
}
|
@@ -23,4 +23,5 @@ var BlockType;
|
|
23
23
|
var DefaultEventNames;
|
24
24
|
(function (DefaultEventNames) {
|
25
25
|
DefaultEventNames["ShareButton"] = "share-button-click";
|
26
|
+
DefaultEventNames["SaveButton"] = "save-button-click";
|
26
27
|
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|
@@ -1,13 +1,15 @@
|
|
1
|
-
import
|
1
|
+
import { useAnalytics } from '@gravity-ui/page-constructor';
|
2
2
|
import { Icon } from '@gravity-ui/uikit';
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import React, { useContext } from 'react';
|
4
|
+
import { UserContext } from '../../../contexts/UserContext';
|
5
|
+
import metrika from '../../../counters/metrika.js';
|
5
6
|
import { MetrikaCounter } from '../../../counters/utils';
|
6
7
|
// @ts-ignore
|
7
|
-
import metrika from '../../../counters/metrika.js';
|
8
8
|
import { Save as SaveIcon } from '../../../icons/Save';
|
9
9
|
import { SaveFilled } from '../../../icons/SaveFilled';
|
10
|
-
import {
|
10
|
+
import { DefaultEventNames } from '../../../models/common';
|
11
|
+
import { block } from '../../../utils/cn';
|
12
|
+
import { postLikeStatus } from '../../../utils/common';
|
11
13
|
import '../PostInfo.css';
|
12
14
|
const ICON_SIZE = 16;
|
13
15
|
const b = block('post-info');
|
@@ -25,6 +27,7 @@ const b = block('post-info');
|
|
25
27
|
*/
|
26
28
|
export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, dataQa, }) => {
|
27
29
|
const { uid } = useContext(UserContext);
|
30
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.SaveButton);
|
28
31
|
return (React.createElement("div", { className: b('item', { size }), onClick: (event) => {
|
29
32
|
// both preventDefault and stopImmediatePropagation required to work properly
|
30
33
|
// https://stackoverflow.com/questions/24415631/reactjs-syntheticevent-stoppropagation-only-works-with-react-events
|
@@ -36,6 +39,7 @@ export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal,
|
|
36
39
|
postLikeStatus(postId, Boolean(hasUserLike));
|
37
40
|
handleUserLike();
|
38
41
|
metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
|
42
|
+
handleAnalytics();
|
39
43
|
}, "data-qa": `${dataQa ? dataQa + '-' : ''}save` },
|
40
44
|
React.createElement("div", { className: b('content', { cursor: Boolean(uid), theme }) },
|
41
45
|
React.createElement("span", { className: b('icon') },
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useAnalytics } from '@gravity-ui/page-constructor
|
1
|
+
import { useAnalytics } from '@gravity-ui/page-constructor';
|
2
2
|
import { SharePopover } from '@gravity-ui/uikit';
|
3
3
|
import React, { useCallback, useContext } from 'react';
|
4
4
|
import { MobileContext } from '../../../contexts/MobileContext';
|
@@ -150,5 +150,6 @@ export type SetQueryType = (params: Query, options?: {
|
|
150
150
|
[y: string]: boolean;
|
151
151
|
}) => Promise<void> | void;
|
152
152
|
export declare enum DefaultEventNames {
|
153
|
-
ShareButton = "share-button-click"
|
153
|
+
ShareButton = "share-button-click",
|
154
|
+
SaveButton = "save-button-click"
|
154
155
|
}
|
package/package.json
CHANGED
@@ -150,5 +150,6 @@ export type SetQueryType = (params: Query, options?: {
|
|
150
150
|
[y: string]: boolean;
|
151
151
|
}) => Promise<void> | void;
|
152
152
|
export declare enum DefaultEventNames {
|
153
|
-
ShareButton = "share-button-click"
|
153
|
+
ShareButton = "share-button-click",
|
154
|
+
SaveButton = "save-button-click"
|
154
155
|
}
|
package/server/models/common.js
CHANGED
@@ -23,4 +23,5 @@ var BlockType;
|
|
23
23
|
var DefaultEventNames;
|
24
24
|
(function (DefaultEventNames) {
|
25
25
|
DefaultEventNames["ShareButton"] = "share-button-click";
|
26
|
+
DefaultEventNames["SaveButton"] = "save-button-click";
|
26
27
|
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|