From b84efcc8f2d8ddfddebee5f3a61a3fd357d6c538 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 29 Aug 2024 13:14:13 +0200 Subject: [PATCH] Feat: Add more workspace mixpanel events (#2806) --- .../settings/workspaces/General/DeleteDialog.vue | 7 +++++++ .../settings/workspaces/General/LeaveDialog.vue | 7 +++++++ .../components/settings/workspaces/Security.vue | 4 ++++ .../settings/workspaces/members/MembersTable.vue | 13 +++++++++++++ .../workspaces/security/DomainRemoveDialog.vue | 7 +++++++ .../components/workspace/InviteDialog.vue | 4 +++- 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/frontend-2/components/settings/workspaces/General/DeleteDialog.vue b/packages/frontend-2/components/settings/workspaces/General/DeleteDialog.vue index d69b28998..0de876968 100644 --- a/packages/frontend-2/components/settings/workspaces/General/DeleteDialog.vue +++ b/packages/frontend-2/components/settings/workspaces/General/DeleteDialog.vue @@ -41,6 +41,7 @@ import { import { ToastNotificationType, useGlobalToast } from '~~/lib/common/composables/toast' import { useActiveUser } from '~~/lib/auth/composables/activeUser' import { isUndefined } from 'lodash-es' +import { useMixpanel } from '~/lib/core/composables/mp' graphql(` fragment SettingsWorkspaceGeneralDeleteDialog_Workspace on Workspace { @@ -59,6 +60,7 @@ const { mutate: deleteWorkspace } = useMutation(deleteWorkspaceMutation) const { triggerNotification } = useGlobalToast() const { activeUser } = useActiveUser() const apollo = useApolloClient().client +const mixpanel = useMixpanel() const onDelete = async () => { isOpen.value = false @@ -98,6 +100,11 @@ const onDelete = async () => { title: 'Workspace deleted', description: `The ${props.workspace.name} workspace has been deleted` }) + + mixpanel.track('Workspace Deleted', { + // eslint-disable-next-line camelcase + workspace_id: props.workspace.id + }) } else { const errorMessage = getFirstErrorMessage(result?.errors) triggerNotification({ diff --git a/packages/frontend-2/components/settings/workspaces/General/LeaveDialog.vue b/packages/frontend-2/components/settings/workspaces/General/LeaveDialog.vue index fca4e144a..5e017486f 100644 --- a/packages/frontend-2/components/settings/workspaces/General/LeaveDialog.vue +++ b/packages/frontend-2/components/settings/workspaces/General/LeaveDialog.vue @@ -31,6 +31,7 @@ import { import { ToastNotificationType, useGlobalToast } from '~~/lib/common/composables/toast' import { useActiveUser } from '~~/lib/auth/composables/activeUser' import { isUndefined } from 'lodash-es' +import { useMixpanel } from '~/lib/core/composables/mp' graphql(` fragment SettingsWorkspaceGeneralDeleteDialog_Workspace on Workspace { @@ -49,6 +50,7 @@ const { mutate: leaveWorkspace } = useMutation(settingsLeaveWorkspaceMutation) const { triggerNotification } = useGlobalToast() const { activeUser } = useActiveUser() const apollo = useApolloClient().client +const mixpanel = useMixpanel() const onLeave = async () => { isOpen.value = false @@ -88,6 +90,11 @@ const onLeave = async () => { title: 'Workspace left', description: `You have left the ${props.workspace.name} workspace` }) + + mixpanel.track('Workspace User Left', { + // eslint-disable-next-line camelcase + workspace_id: props.workspace.id + }) } else { const errorMessage = getFirstErrorMessage(result?.errors) triggerNotification({ diff --git a/packages/frontend-2/components/settings/workspaces/Security.vue b/packages/frontend-2/components/settings/workspaces/Security.vue index 4b90c9609..fdba1ef39 100644 --- a/packages/frontend-2/components/settings/workspaces/Security.vue +++ b/packages/frontend-2/components/settings/workspaces/Security.vue @@ -297,6 +297,10 @@ const addDomain = async () => { result.value?.workspace.domainBasedMembershipProtectionEnabled ) + mixpanel.track('Workspace Domain Added', { + // eslint-disable-next-line camelcase + workspace_id: props.workspaceId + }) selectedDomain.value = undefined } diff --git a/packages/frontend-2/components/settings/workspaces/members/MembersTable.vue b/packages/frontend-2/components/settings/workspaces/members/MembersTable.vue index bdbf37c15..b45367a0a 100644 --- a/packages/frontend-2/components/settings/workspaces/members/MembersTable.vue +++ b/packages/frontend-2/components/settings/workspaces/members/MembersTable.vue @@ -89,6 +89,7 @@ import { useWorkspaceUpdateRole } from '~/lib/workspaces/composables/management' import type { LayoutMenuItem } from '~~/lib/layout/helpers/components' import { HorizontalDirection } from '~~/lib/common/composables/window' import { Roles } from '@speckle/shared' +import { useMixpanel } from '~/lib/core/composables/mp' type UserItem = (typeof members)['value'][0] @@ -127,6 +128,7 @@ const props = defineProps<{ }>() const updateUserRole = useWorkspaceUpdateRole() +const mixpanel = useMixpanel() const showChangeUserRoleDialog = ref(false) const showDeleteUserRoleDialog = ref(false) @@ -172,6 +174,12 @@ const onUpdateRole = async () => { role: newRole.value, workspaceId: props.workspaceId }) + + mixpanel.track('Workspace User Role Updated', { + newRole: newRole.value, + // eslint-disable-next-line camelcase + workspace_id: props.workspaceId + }) } const onRemoveUser = async () => { @@ -182,6 +190,11 @@ const onRemoveUser = async () => { role: null, workspaceId: props.workspaceId }) + + mixpanel.track('Workspace User Removed', { + // eslint-disable-next-line camelcase + workspace_id: props.workspaceId + }) } const onActionChosen = (actionItem: LayoutMenuItem, user: UserItem) => { diff --git a/packages/frontend-2/components/settings/workspaces/security/DomainRemoveDialog.vue b/packages/frontend-2/components/settings/workspaces/security/DomainRemoveDialog.vue index 7a7fc5f09..1e914b0e2 100644 --- a/packages/frontend-2/components/settings/workspaces/security/DomainRemoveDialog.vue +++ b/packages/frontend-2/components/settings/workspaces/security/DomainRemoveDialog.vue @@ -23,6 +23,7 @@ import { } from '~/lib/common/generated/gql/graphql' import { getCacheId, getFirstErrorMessage } from '~/lib/common/helpers/graphql' import { settingsDeleteWorkspaceDomainMutation } from '~/lib/settings/graphql/mutations' +import { useMixpanel } from '~/lib/core/composables/mp' graphql(` fragment SettingsWorkspacesSecurityDomainRemoveDialog_WorkspaceDomain on WorkspaceDomain { @@ -49,6 +50,7 @@ const isOpen = defineModel('open', { required: true }) const apollo = useApolloClient().client const { triggerNotification } = useGlobalToast() +const mixpanel = useMixpanel() const handleRemove = async () => { const result = await apollo @@ -85,6 +87,11 @@ const handleRemove = async () => { title: 'Domain removed', description: `Removed domain successfully` }) + + mixpanel.track('Workspace Domain Removed', { + // eslint-disable-next-line camelcase + workspace_id: props.workspaceId + }) } else { triggerNotification({ type: ToastNotificationType.Danger, diff --git a/packages/frontend-2/components/workspace/InviteDialog.vue b/packages/frontend-2/components/workspace/InviteDialog.vue index 8a21e98fa..6e89dc563 100644 --- a/packages/frontend-2/components/workspace/InviteDialog.vue +++ b/packages/frontend-2/components/workspace/InviteDialog.vue @@ -167,7 +167,9 @@ const onInviteUser = async ( multiple: inputs.length !== 1, count: inputs.length, hasProject: true, - to: isEmail ? 'email' : 'existing user' + to: isEmail ? 'email' : 'existing user', + // eslint-disable-next-line camelcase + workspace_id: props.workspaceId }) disabled.value = false