-
Notifications
You must be signed in to change notification settings - Fork 2
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
dApp: PostHog integration #871
Conversation
✅ Deploy Preview for acre-dapp ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for acre-dapp-testnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
dapp/src/components/TransactionModal/ActiveStakingStep/DepositBTCModal.tsx
Outdated
Show resolved
Hide resolved
Reused `handleCapture` function
Do you have any ideas about payload we could attach to the capture there? I mean something useful and available in the scope so can be used. |
@kpyszkowski we should probably hash the Bitcoin address and then use it as ID, please see #904 |
Maybe we can add |
It's not that straight forward. I need to play around with mutation function to pass these parameters to callbacks. I prepared POC which looks fine for further investigation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remember to set up correct env variables on testnet and production. I belive we should disable the posthog support on testnet.
@@ -26,5 +30,6 @@ VITE_FEATURE_FLAG_XVERSE_WALLET_ENABLED="false" | |||
VITE_FEATURE_FLAG_ACRE_POINTS_ENABLED="true" | |||
VITE_FEATURE_FLAG_TVL_ENABLED="true" | |||
VITE_FEATURE_GATING_DAPP_ENABLED="true" | |||
VITE_FEATURE_POSTHOG_ENABLED="true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's disable by default.
VITE_FEATURE_POSTHOG_ENABLED="true" | |
VITE_FEATURE_POSTHOG_ENABLED="false" |
Closes: #747
Closes: AENG-30
Overview
This PR integrates dApp with PostHog service to track users activities and analyze it. The PostHog project was created. All dApp activity is now accessible through the dashboard.
The API key and endpoint are available in the project settings.
Features
$pageview
capture event: autocapture for page view event was disabled to prevent false positive captures. It is triggered manually as user visits the dApp.deposit_success
- payload:{ transactionHash }
deposit_failure
- payload:{ cause }
withdrawal_success
- wasn't able to easily get any reasonable payload here, can be done laterwithdrawal_failure
- payload:{ cause }
points_claim_success
- payload:{ claimedAmount, totalAmount }
points_claim_failure
- payload:{ cause }
Changes
PostHogProvider
to inject the service into applicationusePostHogCapture
,usePostHogIdentity
,usePostHogPageViewCapture
Caveats
To ensure the
$pageview
event is captured properly it's needed to call it as a side effect as thelocation
value changes. To access this value (viauseLocation
hook) the router's context needs to be in scope of PostHog's context.The only way to achieve it was to do it in the
Layout
component where both contexts are available.Note
It's impossible to exclude captures for development environment. To keep data logs clean and ensure it contains only user's data I suggest to keep the feature flag disabled while using development environment.