MM-60331 - Scheduled post telemetry (#29132)
* Added scheduled posts telemetry * Tracking scheudled post creation via webapp to filter by platform * Fixed keys * Lint fix
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
65ed87bda0
Коммит
f812104a92
@@ -2,11 +2,18 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import moment from 'moment';
|
||||
import React, {memo, useCallback} from 'react';
|
||||
import React, {memo, useCallback, useEffect} from 'react';
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
import {useSelector} from 'react-redux';
|
||||
|
||||
import {
|
||||
TrackPropertyUser, TrackPropertyUserAgent,
|
||||
TrackScheduledPostsFeature,
|
||||
} from 'mattermost-redux/constants/telemetry';
|
||||
import {getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone';
|
||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
|
||||
import {trackFeatureEvent} from 'actions/telemetry_actions';
|
||||
|
||||
import * as Menu from 'components/menu';
|
||||
import Timestamp from 'components/timestamp';
|
||||
@@ -17,6 +24,21 @@ type Props = {
|
||||
|
||||
function CoreMenuOptions({handleOnSelect}: Props) {
|
||||
const userTimezone = useSelector(getCurrentTimezone);
|
||||
const currentUserId = useSelector(getCurrentUserId);
|
||||
|
||||
useEffect(() => {
|
||||
// tracking opening of scheduled posts option menu.
|
||||
// Since MUI menu has no `onOpen` event, we are tracking it here.
|
||||
// useEffect ensures that it is tracked only once.
|
||||
trackFeatureEvent(
|
||||
TrackScheduledPostsFeature,
|
||||
'scheduled_posts_menu_opened',
|
||||
{
|
||||
[TrackPropertyUser]: currentUserId,
|
||||
[TrackPropertyUserAgent]: 'webapp',
|
||||
},
|
||||
);
|
||||
}, [currentUserId]);
|
||||
|
||||
const today = moment().tz(userTimezone);
|
||||
const tomorrow9amTime = moment().
|
||||
|
||||
@@ -181,7 +181,8 @@ function DraftRow({
|
||||
|
||||
// if scheduled posts was being sent, delete the scheduled post after it's been sent
|
||||
if (isScheduledPostBeingSent.current && response.created && !response.error) {
|
||||
dispatch(deleteScheduledPost((item as ScheduledPost).id, connectionId));
|
||||
const scheduledPost = item as ScheduledPost;
|
||||
dispatch(deleteScheduledPost(scheduledPost.user_id, scheduledPost.id, connectionId));
|
||||
isScheduledPostBeingSent.current = false;
|
||||
}
|
||||
}, [connectionId, dispatch, handleOnDelete, item]);
|
||||
@@ -262,8 +263,8 @@ function DraftRow({
|
||||
const handleSchedulePostOnDelete = useCallback(async () => {
|
||||
handleCancelEdit();
|
||||
|
||||
const scheduledPostId = (item as ScheduledPost).id;
|
||||
const result = await dispatch(deleteScheduledPost(scheduledPostId, connectionId));
|
||||
const scheduledPost = item as ScheduledPost;
|
||||
const result = await dispatch(deleteScheduledPost(scheduledPost.user_id, scheduledPost.id, connectionId));
|
||||
return {
|
||||
error: result.error?.message,
|
||||
};
|
||||
|
||||
@@ -74,10 +74,10 @@ export function updateScheduledPost(scheduledPost: ScheduledPost, connectionId:
|
||||
};
|
||||
}
|
||||
|
||||
export function deleteScheduledPost(scheduledPostId: string, connectionId: string) {
|
||||
export function deleteScheduledPost(userId: string, scheduledPostId: string, connectionId: string) {
|
||||
return async (dispatch: DispatchFunc) => {
|
||||
try {
|
||||
const deletedScheduledPost = await Client4.deleteScheduledPost(scheduledPostId, connectionId);
|
||||
const deletedScheduledPost = await Client4.deleteScheduledPost(userId, scheduledPostId, connectionId);
|
||||
|
||||
dispatch({
|
||||
type: ScheduledPostTypes.SCHEDULED_POST_DELETED,
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as rudderAnalytics from 'rudder-sdk-js';
|
||||
|
||||
import type {TelemetryHandler} from '@mattermost/client';
|
||||
|
||||
import {TrackMiscCategory, eventCategory, eventSKUs} from 'mattermost-redux/constants/telemetry';
|
||||
import {TrackMiscCategory, eventCategory, eventSKUs, TrackPropertyUser} from 'mattermost-redux/constants/telemetry';
|
||||
import {isSystemAdmin} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
export {rudderAnalytics};
|
||||
@@ -18,7 +18,7 @@ export class RudderTelemetryHandler implements TelemetryHandler {
|
||||
category,
|
||||
type: event,
|
||||
user_actual_role: getActualRoles(userRoles),
|
||||
user_actual_id: userId,
|
||||
[TrackPropertyUser]: userId,
|
||||
}, props);
|
||||
const options = {
|
||||
context: {
|
||||
@@ -41,7 +41,7 @@ export class RudderTelemetryHandler implements TelemetryHandler {
|
||||
const properties = Object.assign({
|
||||
category: getEventCategory(event),
|
||||
type: event,
|
||||
user_actual_id: userId,
|
||||
[TrackPropertyUser]: userId,
|
||||
user_actual_role: getActualRoles(userRoles),
|
||||
}, props);
|
||||
|
||||
@@ -68,7 +68,7 @@ export class RudderTelemetryHandler implements TelemetryHandler {
|
||||
title: '',
|
||||
url: '',
|
||||
user_actual_role: getActualRoles(userRoles),
|
||||
user_actual_id: userId,
|
||||
[TrackPropertyUser]: userId,
|
||||
},
|
||||
{
|
||||
context: {
|
||||
|
||||
@@ -8,6 +8,7 @@ export const TrackEnterpriseSKU = 'enterprise';
|
||||
// Features
|
||||
export const TrackGroupsFeature = 'custom_groups';
|
||||
export const TrackPassiveKeywordsFeature = 'passive_keywords';
|
||||
export const TrackScheduledPostsFeature = 'scheduled_posts';
|
||||
|
||||
// Events
|
||||
export const TrackInviteGroupEvent = 'invite_group_to_channel__add_member';
|
||||
@@ -17,6 +18,10 @@ export const TrackPassiveKeywordsEvent = 'update_passive_keywords';
|
||||
export const TrackActionCategory = 'action';
|
||||
export const TrackMiscCategory = 'miscellaneous';
|
||||
|
||||
// Properties
|
||||
export const TrackPropertyUser = 'user_actual_id';
|
||||
export const TrackPropertyUserAgent = 'user_agent';
|
||||
|
||||
export const eventSKUs: {[event: string]: string[]} = {
|
||||
[TrackInviteGroupEvent]: [TrackProfessionalSKU, TrackEnterpriseSKU],
|
||||
[TrackPassiveKeywordsEvent]: [TrackProfessionalSKU, TrackEnterpriseSKU],
|
||||
|
||||
Ссылка в новой задаче
Block a user