Add posthog tracking for key backup toasts (#31195)
* Add tracking for setting up key backups. * fix lint * Update @matrix-org/analytics-events to 0.30.0
This commit is contained in:
@@ -8,6 +8,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import KeyIcon from "@vector-im/compound-design-tokens/assets/web/icons/key";
|
||||
import { type ComponentType } from "react";
|
||||
import { type Interaction as InteractionEvent } from "@matrix-org/analytics-events/types/typescript/Interaction";
|
||||
|
||||
import type React from "react";
|
||||
import Modal from "../Modal";
|
||||
@@ -25,6 +26,7 @@ import { Action } from "../dispatcher/actions";
|
||||
import { UserTab } from "../components/views/dialogs/UserTab";
|
||||
import defaultDispatcher from "../dispatcher/dispatcher";
|
||||
import ConfirmKeyStorageOffDialog from "../components/views/dialogs/ConfirmKeyStorageOffDialog";
|
||||
import { PosthogAnalytics } from "../PosthogAnalytics";
|
||||
|
||||
const TOAST_KEY = "setupencryption";
|
||||
|
||||
@@ -156,6 +158,11 @@ export const showToast = (kind: Kind): void => {
|
||||
switch (kind) {
|
||||
case Kind.SET_UP_RECOVERY:
|
||||
case Kind.TURN_ON_KEY_STORAGE: {
|
||||
PosthogAnalytics.instance.trackEvent<InteractionEvent>({
|
||||
eventName: "Interaction",
|
||||
interactionType: "Pointer",
|
||||
name: kind === Kind.SET_UP_RECOVERY ? "ToastSetUpRecoveryClick" : "ToastTurnOnKeyStorageClick",
|
||||
});
|
||||
// Open the user settings dialog to the encryption tab
|
||||
const payload: OpenToTabPayload = {
|
||||
action: Action.ViewUserSettings,
|
||||
@@ -191,6 +198,11 @@ export const showToast = (kind: Kind): void => {
|
||||
const onSecondaryClick = async (): Promise<void> => {
|
||||
switch (kind) {
|
||||
case Kind.SET_UP_RECOVERY: {
|
||||
PosthogAnalytics.instance.trackEvent<InteractionEvent>({
|
||||
eventName: "Interaction",
|
||||
interactionType: "Pointer",
|
||||
name: "ToastSetUpRecoveryDismiss",
|
||||
});
|
||||
// Record that the user doesn't want to set up recovery
|
||||
const deviceListener = DeviceListener.sharedInstance();
|
||||
await deviceListener.recordRecoveryDisabled();
|
||||
@@ -209,6 +221,11 @@ export const showToast = (kind: Kind): void => {
|
||||
break;
|
||||
}
|
||||
case Kind.TURN_ON_KEY_STORAGE: {
|
||||
PosthogAnalytics.instance.trackEvent<InteractionEvent>({
|
||||
eventName: "Interaction",
|
||||
interactionType: "Pointer",
|
||||
name: "ToastTurnOnKeyStorageDismiss",
|
||||
});
|
||||
// The user clicked "Dismiss": offer them "Are you sure?"
|
||||
const modal = Modal.createDialog(
|
||||
ConfirmKeyStorageOffDialog,
|
||||
|
||||
Reference in New Issue
Block a user