Skip to content

Commit

Permalink
Fix posthog initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Dec 16, 2024
1 parent 798868c commit c8a89f7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/keychain/src/hooks/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,12 @@ export function useConnectionValue() {
}, [context, parent]);

const setController = useCallback((controller?: Controller) => {
if (controller && controller.cartridge && origin) {
posthog.identify(controller.cartridge.username(), {
if (controller) {
posthog.identify(controller.username(), {
address: controller.address,
class: controller.cartridge.classHash,
chainId: controller.chainId,
appId: origin,
});

posthog.group("company", origin);
} else {
posthog.reset();
}
Expand All @@ -101,6 +98,12 @@ export function useConnectionValue() {
setIsSignedUp();
}, []);

useEffect(() => {
if (origin) {
posthog.group("company", origin);
}
}, [origin]);

useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);

Expand Down

0 comments on commit c8a89f7

Please sign in to comment.