mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-04 22:02:16 +02:00
Merge pull request #677 from MODSetter/dev
feat: add tracking for users viewed in search space
This commit is contained in:
commit
fc8b9036a6
2 changed files with 22 additions and 2 deletions
|
|
@ -28,7 +28,7 @@ import {
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { motion } from "motion/react";
|
import { motion } from "motion/react";
|
||||||
import { useParams, useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import {
|
import {
|
||||||
createInviteMutationAtom,
|
createInviteMutationAtom,
|
||||||
|
|
@ -116,7 +116,7 @@ import type {
|
||||||
} from "@/contracts/types/roles.types";
|
} from "@/contracts/types/roles.types";
|
||||||
import { invitesApiService } from "@/lib/apis/invites-api.service";
|
import { invitesApiService } from "@/lib/apis/invites-api.service";
|
||||||
import { rolesApiService } from "@/lib/apis/roles-api.service";
|
import { rolesApiService } from "@/lib/apis/roles-api.service";
|
||||||
import { trackSearchSpaceInviteSent } from "@/lib/posthog/events";
|
import { trackSearchSpaceInviteSent, trackSearchSpaceUsersViewed } from "@/lib/posthog/events";
|
||||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
|
@ -298,6 +298,14 @@ export default function TeamManagementPage() {
|
||||||
toast.success("Team data refreshed");
|
toast.success("Team data refreshed");
|
||||||
}, [fetchMembers, fetchRoles, fetchInvites]);
|
}, [fetchMembers, fetchRoles, fetchInvites]);
|
||||||
|
|
||||||
|
// Track users per search space when team page is viewed
|
||||||
|
useEffect(() => {
|
||||||
|
if (members.length > 0 && !membersLoading) {
|
||||||
|
const ownerCount = members.filter((m) => m.is_owner).length;
|
||||||
|
trackSearchSpaceUsersViewed(searchSpaceId, members.length, ownerCount);
|
||||||
|
}
|
||||||
|
}, [members, membersLoading, searchSpaceId]);
|
||||||
|
|
||||||
if (accessLoading) {
|
if (accessLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center min-h-[60vh]">
|
<div className="flex items-center justify-center min-h-[60vh]">
|
||||||
|
|
|
||||||
|
|
@ -321,6 +321,18 @@ export function trackSearchSpaceUserAdded(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function trackSearchSpaceUsersViewed(
|
||||||
|
searchSpaceId: number,
|
||||||
|
userCount: number,
|
||||||
|
ownerCount: number
|
||||||
|
) {
|
||||||
|
posthog.capture("search_space_users_viewed", {
|
||||||
|
search_space_id: searchSpaceId,
|
||||||
|
user_count: userCount,
|
||||||
|
owner_count: ownerCount,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
// CONNECTOR CONNECTION EVENTS
|
// CONNECTOR CONNECTION EVENTS
|
||||||
// ============================================
|
// ============================================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue