Skip to content

Commit

Permalink
feat: add Mixpanel events
Browse files Browse the repository at this point in the history
  • Loading branch information
bonustrack committed Nov 14, 2023
1 parent b66e9ff commit 4403e30
Showing 1 changed file with 64 additions and 9 deletions.
73 changes: 64 additions & 9 deletions src/composables/useClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export function useClient() {
const { notify } = useFlashNotification();
const { notifyModal } = useModalNotification();
const { isGnosisSafe } = useGnosis();
const { mixpanel } = useMixpanel();
const { web3 } = useWeb3();
const auth = getInstance();
const route = useRoute();
Expand Down Expand Up @@ -36,14 +37,16 @@ export function useClient() {

async function sendEIP712(space: { id: string }, type: string, payload: any) {
let plugins = {};
const client = clientEIP712;

if (
payload.metadata?.plugins &&
Object.keys(payload.metadata?.plugins).length !== 0
)
plugins = payload.metadata.plugins;
const client = clientEIP712;

if (type === 'create-proposal') {
return client.proposal(auth.web3, web3.value.account, {
const receipt = await client.proposal(auth.web3, web3.value.account, {
space: space.id,
type: payload.type,
title: payload.name,
Expand All @@ -56,8 +59,14 @@ export function useClient() {
plugins: JSON.stringify(plugins),
app: DEFINED_APP
});

mixpanel.track('Propose', {
space: space.id
});

return receipt;
} else if (type === 'update-proposal') {
return client.updateProposal(auth.web3, web3.value.account, {
const receipt = await client.updateProposal(auth.web3, web3.value.account, {
proposal: payload.id,
space: space.id,
type: payload.type,
Expand All @@ -67,8 +76,15 @@ export function useClient() {
choices: payload.choices,
plugins: JSON.stringify(plugins)
});

mixpanel.track('Update proposal', {
space: space.id,
proposalId: payload.proposal.id
});

return receipt;
} else if (type === 'vote') {
return client.vote(auth.web3, web3.value.account, {
const receipt = await client.vote(auth.web3, web3.value.account, {
space: space.id,
proposal: payload.proposal.id,
type: payload.proposal.type,
Expand All @@ -77,31 +93,70 @@ export function useClient() {
app: DEFINED_APP,
reason: payload.reason
});

mixpanel.track('Vote', {
space: space.id,
proposalId: payload.proposal.id
});

return receipt;
} else if (type === 'delete-proposal') {
return client.cancelProposal(auth.web3, web3.value.account, {
const receipt = await client.cancelProposal(auth.web3, web3.value.account, {
space: space.id,
proposal: payload.proposal.id
});

mixpanel.track('Delete proposal', {
space: space.id,
proposalId: payload.proposal.id
});

return receipt;
} else if (type === 'settings') {
return client.space(auth.web3, web3.value.account, {
const receipt = await client.space(auth.web3, web3.value.account, {
space: space.id,
settings: JSON.stringify(payload)
});

mixpanel.track('Update space settings', {
space: space.id
});

return receipt;
} else if (type === 'delete-space') {
return client.deleteSpace(auth.web3, web3.value.account, {
const receipt = await client.deleteSpace(auth.web3, web3.value.account, {
space: space.id
});

mixpanel.track('Delete space', {
space: space.id
});

return receipt;
} else if (type === 'set-statement') {
return client.statement(auth.web3, web3.value.account, {
const receipt = await client.statement(auth.web3, web3.value.account, {
space: space.id,
about: payload.about,
statement: payload.statement
});

mixpanel.track('Set statement', {
space: space.id
});

return receipt;
} else if (type === 'flag-proposal') {
return client.flagProposal(auth.web3, web3.value.account, {
const receipt = await client.flagProposal(auth.web3, web3.value.account, {
space: space.id,
proposal: payload.proposal.id
});

mixpanel.track('Flag proposal', {
space: space.id,
proposalId: payload.proposal.id
});

return receipt;
}
}

Expand Down

1 comment on commit 4403e30

@vercel
Copy link

@vercel vercel bot commented on 4403e30 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.