@@ -4,6 +4,7 @@ import { Button } from '@aragon/ui'
4
4
import {
5
5
fetchApmArtifact ,
6
6
getRecommendedGasLimit ,
7
+ resolveEnsDomain ,
7
8
} from '../../aragonjs-wrapper'
8
9
import { EthereumAddressType } from '../../prop-types'
9
10
import {
@@ -27,6 +28,9 @@ import {
27
28
STATUS_TEMPLATE_SCREENS ,
28
29
STATUS_DEPLOYMENT ,
29
30
} from './create-statuses'
31
+ import { useWallet } from '../../wallet'
32
+ import { trackEvent , events } from '../../analytics'
33
+ import { completeDomain } from '../../check-domain'
30
34
31
35
// Used during the template selection phase, since we don’t know yet what are
32
36
// going to be the configuration steps.
@@ -225,6 +229,8 @@ function useDeploymentState(
225
229
templateData ,
226
230
walletWeb3
227
231
) {
232
+ const { networkName } = useWallet ( )
233
+
228
234
const [ transactionProgress , setTransactionProgress ] = useState ( {
229
235
signing : 0 ,
230
236
error : - 1 ,
@@ -276,13 +282,45 @@ function useDeploymentState(
276
282
await walletWeb3 . eth . sendTransaction ( transaction )
277
283
278
284
if ( ! cancelled ) {
285
+ // analytics
286
+ // we are only interested in the first tx of creating a DAO
287
+ if (
288
+ transaction ?. data ===
289
+ deployTransactions [ 0 ] ?. transaction ?. data &&
290
+ transactionProgress . signed === 0
291
+ ) {
292
+ const daoEns = completeDomain ( templateData . domain )
293
+ const daoAddress = ( await resolveEnsDomain ( daoEns ) ) || daoEns
294
+
295
+ trackEvent ( events . DAO_CREATED , {
296
+ network : networkName ,
297
+ template : template . name ,
298
+ dao_identifier : templateData . domain ,
299
+ dao_address : daoAddress ,
300
+ } )
301
+ }
302
+
279
303
setTransactionProgress ( ( { signed, errored } ) => ( {
280
304
signed : signed + 1 ,
281
305
errored,
282
306
} ) )
283
307
}
284
308
} catch ( err ) {
285
309
log ( 'Failed onboarding transaction' , err )
310
+
311
+ if (
312
+ transaction ?. data ===
313
+ deployTransactions [ 0 ] ?. transaction ?. data &&
314
+ transactionProgress . signed === 0
315
+ ) {
316
+ // analytics
317
+ trackEvent ( events . DAO_CREATIONFAILED , {
318
+ network : networkName ,
319
+ template : template . name ,
320
+ error : err . message || err . reason ,
321
+ } )
322
+ }
323
+
286
324
if ( ! cancelled ) {
287
325
setTransactionProgress ( ( { signed, errored } ) => ( {
288
326
errored : signed ,
@@ -426,6 +464,12 @@ const Create = React.memo(function Create({
426
464
walletWeb3
427
465
)
428
466
467
+ // useEffect(() => {
468
+ // if (condition) {
469
+
470
+ // }
471
+ // }, [transactionsStatus])
472
+
429
473
const handleUseTemplate = useCallback (
430
474
( id , optionalApps ) => {
431
475
selectTemplate ( id , optionalApps )
0 commit comments