Add analytics event for pinned messages

This commit is contained in:
Florian Duros 2024-09-05 16:11:55 +02:00
parent bce710e34e
commit 08d1b6ceae
No known key found for this signature in database
GPG key ID: A5BBB4041B493F15
8 changed files with 48 additions and 8 deletions

View file

@ -32,6 +32,7 @@ import dis from "../../../dispatcher/dispatcher";
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
import { Action } from "../../../dispatcher/actions";
import MessageEvent from "../messages/MessageEvent";
import PosthogTrackers from "../../../PosthogTrackers.ts";
/**
* The props for the {@link PinnedMessageBanner} component.
@ -68,6 +69,8 @@ export function PinnedMessageBanner({ room, permalinkCreator }: PinnedMessageBan
const shouldUseMessageEvent = pinnedEvent.isRedacted() || pinnedEvent.isDecryptionFailure();
const onBannerClick = (): void => {
PosthogTrackers.trackInteraction("PinnedMessageBannerClick");
// Scroll to the pinned message
dis.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
@ -309,6 +312,9 @@ function BannerButton({ room }: BannerButtonProps): JSX.Element {
className="mx_PinnedMessageBanner_actions"
kind="tertiary"
onClick={() => {
if (isPinnedMessagesPhase) PosthogTrackers.trackInteraction("PinnedMessageBannerCloseListButton");
else PosthogTrackers.trackInteraction("PinnedMessageBannerViewAllButton");
RightPanelStore.instance.showOrHidePhase(RightPanelPhases.PinnedMessages);
}}
>