10000 add analytics events DAO-97 by Rekard0 · Pull Request #1567 · aragon/client · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add analytics events DAO-97 #1567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const methods = {
export const events = {
TEMPLATE_SELECTED: 'template_selected',
WALLET_DISCONNECTED: 'wallet_disconnected',
DAO_CREATEBTN_CLICKED: 'dao_createBtn_clicked',
DAO_CREATED: 'dao_created',
DAO_CREATIONFAILED: 'dao_creationFailed',
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/check-domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ export {
DOMAIN_LOADING,
DOMAIN_NONE,
useCheckDomain,
completeDomain,
}
44 changes: 44 additions & 0 deletions src/onboarding/Create/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button } from '@aragon/ui'
import {
fetchApmArtifact,
getRecommendedGasLimit,
resolveEnsDomain,
} from '../../aragonjs-wrapper'
import { EthereumAddressType } from '../../prop-types'
import {
Expand All @@ -27,6 +28,9 @@ import {
STATUS_TEMPLATE_SCREENS,
STATUS_DEPLOYMENT,
} from './create-statuses'
import { useWallet } from '../../wallet'
import { trackEvent, events } from '../../analytics'
import { completeDomain } from '../../check-domain'

// Used during the template selection phase, since we don’t know yet what are
// going to be the configuration steps.
Expand Down Expand Up @@ -225,6 +229,8 @@ function useDeploymentState(
templateData,
walletWeb3
) {
const { networkName } = useWallet()

const [transactionProgress, setTransactionProgress] = useState({
signing: 0,
error: -1,
Expand Down Expand Up @@ -276,13 +282,45 @@ function useDeploymentState(
await walletWeb3.eth.sendTransaction(transaction)

if (!cancelled) {
// analytics
// we are only interested in the first tx of creating a DAO
if (
transaction?.data ===
deployTransactions[0]?.transaction?.data &&
transactionProgress.signed === 0
) {
const daoEns = completeDomain(templateData.domain)
const daoAddress = (await resolveEnsDomain(daoEns)) || daoEns

trackEvent(events.DAO_CREATED, {
network: networkName,
template: template.name,
dao_identifier: templateData.domain,
dao_address: daoAddress,
})
}

setTransactionProgress(({ signed, errored }) => ({
signed: signed + 1,
errored,
}))
}
} catch (err) {
8000 log('Failed onboarding transaction', err)

if (
transaction?.data ===
deployTransactions[0]?.transaction?.data &&
transactionProgress.signed === 0
) {
// analytics
trackEvent(events.DAO_CREATIONFAILED, {
network: networkName,
template: template.name,
error: err.message || err.reason,
})
}

if (!cancelled) {
setTransactionProgress(({ signed, errored }) => ({
errored: signed,
Expand Down Expand Up @@ -426,6 +464,12 @@ const Create = React.memo(function Create({
walletWeb3
)

// useEffect(() => {
// if (condition) {

// }
// }, [transactionsStatus])

const handleUseTemplate = useCallback(
(id, optionalApps) => {
selectTemplate(id, optionalApps)
Expand Down
11 changes: 10 additions & 1 deletion src/templates/kit/screens/ReviewScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
useTheme,
} from '@aragon/ui'
import { Header, Navigation, ScreenPropsType } from '..'
import { trackEvent, events } from '../../../analytics'
import { useWallet } from '../../../wallet'

function ReviewScreen({
items,
Expand All @@ -18,10 +20,17 @@ function ReviewScreen({
screenTitle,
}) {
const theme = useTheme()
const { networkName } = useWallet()

const handleNext = useCallback(() => {
// analytics
trackEvent(events.DAO_CREATEBTN_CLICKED, {
network: networkName,
template: items[0].fields[0][1],
})

next(data)
}, [data, next])
}, [data, next, items, networkName])

const containerRef = useRef()
const prevNextRef = useRef()
Expand Down
0