Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

refactor: remove logEvent calls and related code from components to streamline functionality

yoginth.com 33711b04 a1413662

verified
+6 -137
-2
apps/web/src/components/Common/Layout.tsx
··· 12 12 import Navbar from "@/components/Shared/Navbar"; 13 13 import BottomNavigation from "@/components/Shared/Navbar/BottomNavigation"; 14 14 import { Spinner } from "@/components/Shared/UI"; 15 - import logEvent from "@/helpers/logEvent"; 16 15 import reloadAllTabs from "@/helpers/reloadAllTabs"; 17 16 import { useTheme } from "@/hooks/useTheme"; 18 17 import { useAccountStore } from "@/store/persisted/useAccountStore"; ··· 32 31 33 32 useEffect(() => { 34 33 window.scrollTo(0, 0); 35 - void logEvent(`User Event: Page View - ${pathname}`); 36 34 }, [pathname]); 37 35 38 36 const onError = useCallback(() => {
+2 -20
apps/web/src/components/Common/Providers/index.tsx
··· 1 - import { ApolloLink, ApolloProvider, from } from "@apollo/client"; 1 + import { ApolloProvider } from "@apollo/client"; 2 2 import { createApolloClient } from "@hey/indexer/apollo/client"; 3 3 import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; 4 4 import type { ReactNode } from "react"; 5 5 import { HelmetProvider } from "react-helmet-async"; 6 6 import ErrorBoundary from "@/components/Common/ErrorBoundary"; 7 7 import authLink from "@/helpers/authLink"; 8 - import logEvent from "@/helpers/logEvent"; 9 8 import { ThemeProvider } from "@/hooks/useTheme"; 10 9 import Web3Provider from "./Web3Provider"; 11 10 ··· 13 12 defaultOptions: { queries: { refetchOnWindowFocus: false } } 14 13 }); 15 14 16 - const logLink = new ApolloLink((operation, forward) => { 17 - try { 18 - const defs = operation.query.definitions as Array<{ 19 - kind?: string; 20 - operation?: string; 21 - }>; 22 - const opType = 23 - defs?.find((d) => d.kind === "OperationDefinition")?.operation || "query"; 24 - const name = operation.operationName || "anonymous"; 25 - const variables = operation.variables || {}; 26 - 27 - void logEvent(`GraphQL ${opType}: ${name} - ${JSON.stringify(variables)}`); 28 - } catch {} 29 - 30 - return forward(operation); 31 - }); 32 - 33 - const lensApolloClient = createApolloClient(from([logLink, authLink])); 15 + const lensApolloClient = createApolloClient(authLink); 34 16 35 17 interface ProvidersProps { 36 18 children: ReactNode;
-2
apps/web/src/components/Post/FullPost.tsx
··· 9 9 getBlockedByMeMessage, 10 10 getBlockedMeMessage 11 11 } from "@/helpers/getBlockedMessage"; 12 - import usePostView from "@/hooks/usePostView"; 13 12 import { useHiddenCommentFeedStore } from "."; 14 13 import PostActions from "./Actions"; 15 14 import HiddenPost from "./HiddenPost"; ··· 30 29 31 30 const targetPost = isRepost(post) ? post?.repostOf : post; 32 31 const { timestamp } = targetPost; 33 - usePostView({ slug: targetPost.slug }); 34 32 35 33 const isBlockedByMe = post.author.operations?.isBlockedByMe; 36 34 const hasBlockedMe = post.author.operations?.hasBlockedMe;
+1 -5
apps/web/src/components/Settings/Developer/Tokens.tsx
··· 7 7 import BackButton from "@/components/Shared/BackButton"; 8 8 import { Button, Card, CardHeader, H6 } from "@/components/Shared/UI"; 9 9 import errorToast from "@/helpers/errorToast"; 10 - import logEvent from "@/helpers/logEvent"; 11 10 import useCopyToClipboard from "@/hooks/useCopyToClipboard"; 12 11 import useHandleWrongNetwork from "@/hooks/useHandleWrongNetwork"; 13 12 import { hydrateAuthTokens } from "@/store/persisted/useAuthStore"; ··· 39 38 }, []); 40 39 41 40 const { signMessageAsync } = useSignMessage({ 42 - mutation: { 43 - onError, 44 - onSuccess: () => void logEvent("Viem: Token Sign Message") 45 - } 41 + mutation: { onError } 46 42 }); 47 43 const [loadChallenge] = useChallengeMutation(); 48 44 const [authenticate] = useAuthenticateMutation();
+1 -5
apps/web/src/components/Shared/Auth/Login.tsx
··· 17 17 import Loader from "@/components/Shared/Loader"; 18 18 import { Button, Card, ErrorMessage } from "@/components/Shared/UI"; 19 19 import errorToast from "@/helpers/errorToast"; 20 - import logEvent from "@/helpers/logEvent"; 21 20 import reloadAllTabs from "@/helpers/reloadAllTabs"; 22 21 import { signIn } from "@/store/persisted/useAuthStore"; 23 22 import { EXPANSION_EASE } from "@/variants"; ··· 44 43 const { disconnect } = useDisconnect(); 45 44 const { address, connector: activeConnector } = useAccount(); 46 45 const { signMessageAsync } = useSignMessage({ 47 - mutation: { 48 - onError, 49 - onSuccess: () => void logEvent("Viem: Login Sign Message") 50 - } 46 + mutation: { onError } 51 47 }); 52 48 const [loadChallenge, { error: errorChallenge }] = useChallengeMutation({ 53 49 onError
+1 -7
apps/web/src/components/Shared/Auth/Signup/ChooseUsername.tsx
··· 21 21 import AuthMessage from "@/components/Shared/Auth/AuthMessage"; 22 22 import { Button, Form, Input, useZodForm } from "@/components/Shared/UI"; 23 23 import errorToast from "@/helpers/errorToast"; 24 - import logEvent from "@/helpers/logEvent"; 25 24 import uploadMetadata from "@/helpers/uploadMetadata"; 26 25 import useHandleWrongNetwork from "@/hooks/useHandleWrongNetwork"; 27 26 import useTransactionLifecycle from "@/hooks/useTransactionLifecycle"; ··· 71 70 errorToast(error); 72 71 }, []); 73 72 74 - const { signMessageAsync } = useSignMessage({ 75 - mutation: { 76 - onError, 77 - onSuccess: () => void logEvent("Viem: Signup Sign Message") 78 - } 79 - }); 73 + const { signMessageAsync } = useSignMessage({ mutation: { onError } }); 80 74 const [loadChallenge] = useChallengeMutation({ onError }); 81 75 const [authenticate] = useAuthenticateMutation({ onError }); 82 76
+1 -28
apps/web/src/components/Shared/Post/PostWrapper.tsx
··· 1 1 import type { AnyPostFragment } from "@hey/indexer"; 2 2 import type { ReactNode } from "react"; 3 - import { memo, useEffect, useRef } from "react"; 3 + import { memo, useRef } from "react"; 4 4 import { useNavigate } from "react-router"; 5 - import { hono } from "@/helpers/fetcher"; 6 5 import { usePostLinkStore } from "@/store/non-persisted/navigation/usePostLinkStore"; 7 - import { useAccountStore } from "@/store/persisted/useAccountStore"; 8 6 9 7 interface PostWrapperProps { 10 8 children: ReactNode | ReactNode[]; ··· 15 13 const PostWrapper = ({ children, className = "", post }: PostWrapperProps) => { 16 14 const navigate = useNavigate(); 17 15 const { setCachedPost } = usePostLinkStore(); 18 - const { currentAccount } = useAccountStore(); 19 16 const rootRef = useRef<HTMLElement>(null); 20 - const hasLoggedRef = useRef(false); 21 17 22 18 const handleClick = () => { 23 19 const selection = window.getSelection(); ··· 26 22 navigate(`/posts/${post.slug}`); 27 23 } 28 24 }; 29 - 30 - useEffect(() => { 31 - if (!rootRef.current || hasLoggedRef.current) return; 32 - const el = rootRef.current; 33 - const observer = new IntersectionObserver( 34 - (entries) => { 35 - const entry = entries[0]; 36 - if (entry?.isIntersecting && !hasLoggedRef.current) { 37 - hasLoggedRef.current = true; 38 - try { 39 - void hono.impressions.create({ 40 - address: currentAccount?.address, 41 - post: post.slug 42 - }); 43 - } catch {} 44 - observer.unobserve(el); 45 - } 46 - }, 47 - { threshold: 0.5 } 48 - ); 49 - observer.observe(el); 50 - return () => observer.disconnect(); 51 - }, [currentAccount?.address, post.slug]); 52 25 53 26 return ( 54 27 <article className={className} onClick={handleClick} ref={rootRef}>
-2
apps/web/src/components/Shared/Sidebar/BetaBanner.tsx
··· 9 9 import { toast } from "sonner"; 10 10 import { Button, Card, H5 } from "@/components/Shared/UI"; 11 11 import errorToast from "@/helpers/errorToast"; 12 - import logEvent from "@/helpers/logEvent"; 13 12 import useTransactionLifecycle from "@/hooks/useTransactionLifecycle"; 14 13 import useWaitForTransactionToComplete from "@/hooks/useWaitForTransactionToComplete"; 15 14 import { useAccountStore } from "@/store/persisted/useAccountStore"; ··· 35 34 onCompleted: () => { 36 35 toast.success("Dismissed"); 37 36 setBetaBannerDismissed(true); 38 - void logEvent("Dismiss Beta Banner"); 39 37 }, 40 38 onError, 41 39 variables: { request: { post: BANNER_IDS.BETA } }
-2
apps/web/src/components/Shared/Sidebar/ProBanner.tsx
··· 6 6 import { toast } from "sonner"; 7 7 import { Button, Card, H5 } from "@/components/Shared/UI"; 8 8 import errorToast from "@/helpers/errorToast"; 9 - import logEvent from "@/helpers/logEvent"; 10 9 import { useProModalStore } from "@/store/non-persisted/modal/useProModalStore"; 11 10 import { useAccountStore } from "@/store/persisted/useAccountStore"; 12 11 import { useProStore } from "@/store/persisted/useProStore"; ··· 24 23 onCompleted: () => { 25 24 toast.success("Dismissed"); 26 25 setProBannerDismissed(true); 27 - void logEvent("Dismiss Pro Banner"); 28 26 }, 29 27 onError, 30 28 variables: { request: { post: BANNER_IDS.BETA } }
-22
apps/web/src/helpers/fetcher.ts
··· 62 62 }; 63 63 64 64 export const hono = { 65 - events: { 66 - create: async (payload: { event: string }) => 67 - fetch("https://yoginth.com/api/hey/events", { 68 - body: JSON.stringify(payload), 69 - headers: { 70 - accept: "application/json", 71 - "content-type": "application/json" 72 - }, 73 - method: "POST" 74 - }) 75 - }, 76 - impressions: { 77 - create: async (payload: { post: string; address?: string }) => 78 - fetch("https://yoginth.com/api/hey/impressions", { 79 - body: JSON.stringify(payload), 80 - headers: { 81 - accept: "application/json", 82 - "content-type": "application/json" 83 - }, 84 - method: "POST" 85 - }) 86 - }, 87 65 metadata: { 88 66 sts: (): Promise<STS> => { 89 67 return fetchApi<STS>("/metadata/sts", { method: "GET" });
-9
apps/web/src/helpers/logEvent.ts
··· 1 - import { hono } from "@/helpers/fetcher"; 2 - 3 - const logEvent = async (event: string) => { 4 - try { 5 - await hono.events.create({ event }); 6 - } catch {} 7 - }; 8 - 9 - export default logEvent;
-5
apps/web/src/helpers/tokenManager.ts
··· 3 3 import apolloClient from "@hey/indexer/apollo/client"; 4 4 import type { JwtPayload } from "@hey/types/jwt"; 5 5 import { signIn, signOut } from "@/store/persisted/useAuthStore"; 6 - import logEvent from "./logEvent"; 7 6 8 7 let refreshPromise: Promise<string> | null = null; 9 8 const MAX_RETRIES = 5; ··· 29 28 if (!newAccessToken || !newRefreshToken) { 30 29 throw new Error("Missing tokens in refresh response"); 31 30 } 32 - 33 - try { 34 - void logEvent("GraphQL mutation: Refresh"); 35 - } catch {} 36 31 37 32 signIn({ 38 33 accessToken: newAccessToken,
-28
apps/web/src/hooks/usePostView.tsx
··· 1 - import { useEffect, useMemo } from "react"; 2 - import { hono } from "@/helpers/fetcher"; 3 - import { useAccountStore } from "@/store/persisted/useAccountStore"; 4 - 5 - const sentImpressions = new Set<string>(); 6 - 7 - interface UsePostViewOptions { 8 - slug: string; 9 - } 10 - 11 - const usePostView = ({ slug }: UsePostViewOptions) => { 12 - const key = useMemo(() => `${slug}`, [slug]); 13 - const { currentAccount } = useAccountStore(); 14 - 15 - useEffect(() => { 16 - if (!slug) return; 17 - if (sentImpressions.has(key)) return; 18 - sentImpressions.add(key); 19 - try { 20 - void hono.impressions.create({ 21 - address: currentAccount?.address, 22 - post: slug 23 - }); 24 - } catch {} 25 - }, [currentAccount?.address, key, slug]); 26 - }; 27 - 28 - export default usePostView;