Skip to content

Commit 4403e30

Browse files
committed
feat: add Mixpanel events
1 parent b66e9ff commit 4403e30

File tree

1 file changed

+64
-9
lines changed

1 file changed

+64
-9
lines changed

src/composables/useClient.ts

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export function useClient() {
66
const { notify } = useFlashNotification();
77
const { notifyModal } = useModalNotification();
88
const { isGnosisSafe } = useGnosis();
9+
const { mixpanel } = useMixpanel();
910
const { web3 } = useWeb3();
1011
const auth = getInstance();
1112
const route = useRoute();
@@ -36,14 +37,16 @@ export function useClient() {
3637

3738
async function sendEIP712(space: { id: string }, type: string, payload: any) {
3839
let plugins = {};
40+
const client = clientEIP712;
41+
3942
if (
4043
payload.metadata?.plugins &&
4144
Object.keys(payload.metadata?.plugins).length !== 0
4245
)
4346
plugins = payload.metadata.plugins;
44-
const client = clientEIP712;
47+
4548
if (type === 'create-proposal') {
46-
return client.proposal(auth.web3, web3.value.account, {
49+
const receipt = await client.proposal(auth.web3, web3.value.account, {
4750
space: space.id,
4851
type: payload.type,
4952
title: payload.name,
@@ -56,8 +59,14 @@ export function useClient() {
5659
plugins: JSON.stringify(plugins),
5760
app: DEFINED_APP
5861
});
62+
63+
mixpanel.track('Propose', {
64+
space: space.id
65+
});
66+
67+
return receipt;
5968
} else if (type === 'update-proposal') {
60-
return client.updateProposal(auth.web3, web3.value.account, {
69+
const receipt = await client.updateProposal(auth.web3, web3.value.account, {
6170
proposal: payload.id,
6271
space: space.id,
6372
type: payload.type,
@@ -67,8 +76,15 @@ export function useClient() {
6776
choices: payload.choices,
6877
plugins: JSON.stringify(plugins)
6978
});
79+
80+
mixpanel.track('Update proposal', {
81+
space: space.id,
82+
proposalId: payload.proposal.id
83+
});
84+
85+
return receipt;
7086
} else if (type === 'vote') {
71-
return client.vote(auth.web3, web3.value.account, {
87+
const receipt = await client.vote(auth.web3, web3.value.account, {
7288
space: space.id,
7389
proposal: payload.proposal.id,
7490
type: payload.proposal.type,
@@ -77,31 +93,70 @@ export function useClient() {
7793
app: DEFINED_APP,
7894
reason: payload.reason
7995
});
96+
97+
mixpanel.track('Vote', {
98+
space: space.id,
99+
proposalId: payload.proposal.id
100+
});
101+
102+
return receipt;
80103
} else if (type === 'delete-proposal') {
81-
return client.cancelProposal(auth.web3, web3.value.account, {
104+
const receipt = await client.cancelProposal(auth.web3, web3.value.account, {
82105
space: space.id,
83106
proposal: payload.proposal.id
84107
});
108+
109+
mixpanel.track('Delete proposal', {
110+
space: space.id,
111+
proposalId: payload.proposal.id
112+
});
113+
114+
return receipt;
85115
} else if (type === 'settings') {
86-
return client.space(auth.web3, web3.value.account, {
116+
const receipt = await client.space(auth.web3, web3.value.account, {
87117
space: space.id,
88118
settings: JSON.stringify(payload)
89119
});
120+
121+
mixpanel.track('Update space settings', {
122+
space: space.id
123+
});
124+
125+
return receipt;
90126
} else if (type === 'delete-space') {
91-
return client.deleteSpace(auth.web3, web3.value.account, {
127+
const receipt = await client.deleteSpace(auth.web3, web3.value.account, {
128+
space: space.id
129+
});
130+
131+
mixpanel.track('Delete space', {
92132
space: space.id
93133
});
134+
135+
return receipt;
94136
} else if (type === 'set-statement') {
95-
return client.statement(auth.web3, web3.value.account, {
137+
const receipt = await client.statement(auth.web3, web3.value.account, {
96138
space: space.id,
97139
about: payload.about,
98140
statement: payload.statement
99141
});
142+
143+
mixpanel.track('Set statement', {
144+
space: space.id
145+
});
146+
147+
return receipt;
100148
} else if (type === 'flag-proposal') {
101-
return client.flagProposal(auth.web3, web3.value.account, {
149+
const receipt = await client.flagProposal(auth.web3, web3.value.account, {
102150
space: space.id,
103151
proposal: payload.proposal.id
104152
});
153+
154+
mixpanel.track('Flag proposal', {
155+
space: space.id,
156+
proposalId: payload.proposal.id
157+
});
158+
159+
return receipt;
105160
}
106161
}
107162

0 commit comments

Comments
 (0)