Skip to content
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
2 changes: 2 additions & 0 deletions src/lib/auth/siweStore.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import posthog from 'posthog-js'
import { create } from 'zustand'
import { persist } from 'zustand/middleware'
import { immer } from 'zustand/middleware/immer'
Expand Down Expand Up @@ -95,6 +96,7 @@ export const useSiweStore = create<SiweState>()(
* Note: Zustand persist middleware handles localStorage cleanup automatically
*/
signOut: () => {
posthog.reset()
set(state => {
state.jwtToken = null
state.error = null
Expand Down
7 changes: 6 additions & 1 deletion src/shared/walletConnection/PostHogWalletSync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ export const PostHogWalletSync = ({ children }: Props) => {

useEffect(() => {
if (address) {
posthog.register({ wallet_address: address.toLowerCase() })
posthog.identify(address.toLowerCase(), {
wallet_address: address.toLowerCase(),
$set_once: { first_seen: new Date().toISOString() },
})
posthog.register({ wallet_address: address.toLowerCase(), user_type: 'wallet' })

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if we will manage this way the identity of the users, what should we do with the Super Property added in the file src/shared/walletConnection/PostHogWalletSync.tsx and the correspondent logout src/shared/walletConnection/connection/DisconnectWorkflowContainer.tsx

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think we should keep it and add it specifically so we can join it with the sessions already tracked in PostHog.

If we don't identify the user when they connect their wallet, we'll end up with a number of visits/sessions on one side and wallet-related events on the other, without a reliable way to connect them. That would make it difficult to answer questions such as how many visitors actually connected their wallet or what actions they took before doing so.

At the moment, we're mainly tracking events when a user performs an action (e.g., vote, delegate), not necessarily when they are only browsing or viewing content. Having this super property tied to the user's identity allows us to connect those anonymous sessions with their wallet activity later and get a much clearer view of the user journey and conversion funnel.

} else {
posthog.unregister('wallet_address')
posthog.register({ user_type: 'anonymous' })
}
}, [address])

Expand Down
Loading