Add missing events to CM

Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
soupette 2021-11-15 11:57:29 +01:00
parent 610d5976bc
commit c262c84f83
2 changed files with 11 additions and 19 deletions

View File

@ -141,7 +141,11 @@ const TableRows = ({
{canDelete && ( {canDelete && (
<Box paddingLeft={1}> <Box paddingLeft={1}>
<IconButton <IconButton
onClick={() => onClickDelete(data.id)} onClick={() => {
trackUsage('willDeleteEntryFromList');
onClickDelete(data.id);
}}
label={formatMessage( label={formatMessage(
{ id: 'app.component.table.delete', defaultMessage: 'Delete {target}' }, { id: 'app.component.table.delete', defaultMessage: 'Delete {target}' },
{ target: itemLineText } { target: itemLineText }

View File

@ -7,7 +7,6 @@ import { bindActionCreators, compose } from 'redux';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { useHistory, useLocation } from 'react-router-dom'; import { useHistory, useLocation } from 'react-router-dom';
import get from 'lodash/get'; import get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
import { stringify } from 'qs'; import { stringify } from 'qs';
import { import {
NoPermissions, NoPermissions,
@ -171,18 +170,6 @@ function ListView({
const handleConfirmDeleteData = useCallback( const handleConfirmDeleteData = useCallback(
async idToDelete => { async idToDelete => {
try { try {
let trackerProperty = {};
if (hasDraftAndPublish) {
const dataToDelete = data.find(obj => obj.id.toString() === idToDelete.toString());
const isDraftEntry = isEmpty(dataToDelete.publishedAt);
const status = isDraftEntry ? 'draft' : 'published';
trackerProperty = { status };
}
trackUsageRef.current('willDeleteEntry', trackerProperty);
await axiosInstance.delete(getRequestUrl(`collection-types/${slug}/${idToDelete}`)); await axiosInstance.delete(getRequestUrl(`collection-types/${slug}/${idToDelete}`));
const requestUrl = getRequestUrl(`collection-types/${slug}${params}`); const requestUrl = getRequestUrl(`collection-types/${slug}${params}`);
@ -192,8 +179,6 @@ function ListView({
type: 'success', type: 'success',
message: { id: getTrad('success.record.delete') }, message: { id: getTrad('success.record.delete') },
}); });
trackUsageRef.current('didDeleteEntry', trackerProperty);
} catch (err) { } catch (err) {
const errorMessage = get( const errorMessage = get(
err, err,
@ -207,7 +192,7 @@ function ListView({
}); });
} }
}, },
[hasDraftAndPublish, slug, params, fetchData, toggleNotification, data, formatMessage] [slug, params, fetchData, toggleNotification, formatMessage]
); );
useEffect(() => { useEffect(() => {
@ -282,8 +267,11 @@ function ListView({
<FieldPicker layout={layout} /> <FieldPicker layout={layout} />
<CheckPermissions permissions={cmPermissions.collectionTypesConfigurations}> <CheckPermissions permissions={cmPermissions.collectionTypesConfigurations}>
<IconButtonCustom <IconButtonCustom
onClick={() => onClick={() => {
push({ pathname: `${slug}/configurations/list`, search: pluginsQueryParams })} trackUsage('willEditListLayout');
push({ pathname: `${slug}/configurations/list`, search: pluginsQueryParams });
}}
icon={<Cog />} icon={<Cog />}
label={formatMessage({ label={formatMessage({
id: 'app.links.configure-view', id: 'app.links.configure-view',