Feat: Add more workspace mixpanel events (#2806)

This commit is contained in:
Mike
2024-08-29 13:14:13 +02:00
committed by GitHub
parent 419dbab36d
commit b84efcc8f2
6 changed files with 41 additions and 1 deletions
@@ -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({
@@ -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({
@@ -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
}
@@ -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) => {
@@ -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<boolean>('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,
@@ -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