Track when task list sections are closed (#32625)

* Track when task list sections are closed

* Add tracks for when task list section is opened
This commit is contained in:
Joshua T Flowers 2022-04-14 12:21:56 -04:00 committed by GitHub
parent 4b7eb80d3f
commit 3561b87f83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 3 deletions

View File

@ -35,7 +35,7 @@ const PanelBodyWithUpdatedType = PanelBody as React.ComponentType< PanelBodyProp
export const SectionedTaskList: React.FC< TaskListProps > = ( {
query,
id,
eventName,
eventPrefix,
tasks,
keepCompletedTaskList,
isComplete,
@ -66,7 +66,7 @@ export const SectionedTaskList: React.FC< TaskListProps > = ( {
return;
}
recordEvent( `${ eventName }_view`, {
recordEvent( `${ eventPrefix }view`, {
number_tasks: visibleTasks.length,
store_connected: profileItems.wccom_connected,
} );
@ -122,7 +122,7 @@ export const SectionedTaskList: React.FC< TaskListProps > = ( {
}
const trackClick = ( task: TaskType ) => {
recordEvent( `${ eventName }_click`, {
recordEvent( `${ eventPrefix }_click`, {
task_name: task.id,
} );
};
@ -182,10 +182,34 @@ export const SectionedTaskList: React.FC< TaskListProps > = ( {
opened={ openPanel === section.id }
onToggle={ ( isOpen: boolean ) => {
if ( ! isOpen && openPanel === section.id ) {
recordEvent(
`${ eventPrefix }section_closed`,
{
id: section.id,
all: true,
}
);
setOpenPanel( null );
} else {
if ( openPanel ) {
recordEvent(
`${ eventPrefix }section_closed`,
{
id: openPanel,
all: false,
}
);
}
setOpenPanel( section.id );
}
if ( isOpen ) {
recordEvent(
`${ eventPrefix }section_opened`,
{
id: section.id,
}
);
}
} }
initialOpen={ false }
>