Skip to content

Commit

Permalink
Basename: Fix analytics events (#997)
Browse files Browse the repository at this point in the history
* remove page events in favor of pageview

* fix invalid logging
  • Loading branch information
kirkas committed Sep 12, 2024
1 parent 8b26996 commit b993bf1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
7 changes: 0 additions & 7 deletions apps/web/src/components/Basenames/RegistrationFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import dynamic from 'next/dynamic';
import { useLocalStorage } from 'usehooks-ts';
import { Transition } from '@headlessui/react';
import { useAnalytics } from 'apps/web/contexts/Analytics';
import RegistrationBackground from 'apps/web/src/components/Basenames/RegistrationBackground';
import RegistrationBrand from 'apps/web/src/components/Basenames/RegistrationBrand';
import {
Expand All @@ -24,7 +23,6 @@ import {
USERNAME_DOMAINS,
} from 'apps/web/src/utils/usernames';
import classNames from 'classnames';
import { ActionType } from 'libs/base-ui/utils/logEvent';
import { useSearchParams } from 'next/navigation';
import { useCallback, useEffect, useMemo } from 'react';
import { useAccount, useSwitchChain } from 'wagmi';
Expand All @@ -44,7 +42,6 @@ export const claimQueryKey = 'claim';

export function RegistrationFlow() {
const { chain } = useAccount();
const { logEventWithContext } = useAnalytics();
const searchParams = useSearchParams();
const [, setIsModalOpen] = useLocalStorage('BasenamesLaunchModalVisible', true);
const [, setIsBannerVisible] = useLocalStorage('basenamesLaunchBannerVisible', true);
Expand Down Expand Up @@ -110,10 +107,6 @@ export function RegistrationFlow() {
setRegistrationStep(RegistrationSteps.Search);
}, [setRegistrationStep]);

useEffect(() => {
logEventWithContext('initial_render', ActionType.render);
}, [logEventWithContext]);

useEffect(() => {
const claimQuery = searchParams?.get(claimQueryKey);
if (claimQuery) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,17 @@ export default function RegistrationSearchInput({
}, [resetBackground, setSearchInputFocused]);

useEffect(() => {
if (!invalidWithMessage) return;

// Log invalid
logEventWithContext('search_available_name_invalid', ActionType.error, { error: message });
}, [invalidWithMessage, logEventWithContext, message, setSearchInputFocused]);
if (debouncedSearch.length > 2 && invalidWithMessage) {
// Log invalid
logEventWithContext('search_available_name_invalid', ActionType.error, { error: message });
}
}, [
debouncedSearch.length,
invalidWithMessage,
logEventWithContext,
message,
setSearchInputFocused,
]);

const selectName = useCallback(() => {
handleSelectName(debouncedSearch);
Expand Down
6 changes: 0 additions & 6 deletions apps/web/src/components/Basenames/UsernameProfile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@

import UsernameProfileContent from 'apps/web/src/components/Basenames/UsernameProfileContent';
import UsernameProfileSidebar from 'apps/web/src/components/Basenames/UsernameProfileSidebar';
import { useAnalytics } from 'apps/web/contexts/Analytics';
import { ActionType } from 'libs/base-ui/utils/logEvent';
import UsernameProfileSettings from 'apps/web/src/components/Basenames/UsernameProfileSettings';
import { useUsernameProfile } from 'apps/web/src/components/Basenames/UsernameProfileContext';
import UsernameProfileSettingsProvider from 'apps/web/src/components/Basenames/UsernameProfileSettingsContext';

export default function UsernameProfile() {
const { logEventWithContext } = useAnalytics();

const { showProfileSettings } = useUsernameProfile();

logEventWithContext('page_loaded', ActionType.render);

if (showProfileSettings)
return (
<UsernameProfileSettingsProvider>
Expand Down

0 comments on commit b993bf1

Please sign in to comment.