Skip to content

Commit

Permalink
feat(app): group amplitude user by accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
hbriese committed Aug 20, 2024
1 parent eb39993 commit b4f2b3b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/src/components/Analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { AnalyticsQuery } from '~/api/__generated__/AnalyticsQuery.graphql';
ampli.load({
client: {
apiKey: CONFIG.amplitudeKey,
configuration: {
trackingSessionEvents: true,
},
},
});

Expand All @@ -19,6 +22,9 @@ const Query = graphql`
user {
id
}
accounts {
address
}
}
`;

Expand All @@ -29,12 +35,16 @@ export function Analytics() {

const previousPathname = useRef<string>();

const userId = useLazyQuery<AnalyticsQuery>(Query, {}).user.id;
const { user, accounts } = useLazyQuery<AnalyticsQuery>(Query, {});

useEffect(() => {
ampli.identify(userId, { device_id: approver });
Sentry.setUser({ id: approver });
}, [approver, userId]);
ampli.identify(user.id, { device_id: approver });
ampli.client.setGroup(
'account',
accounts.map((a) => a.address),
);
}, [approver, user.id, accounts]);

useEffect(() => {
ampli.screenView({
Expand Down

0 comments on commit b4f2b3b

Please sign in to comment.