From ca8a2374d342c2dc3293127df6fe22d61c3d3062 Mon Sep 17 00:00:00 2001 From: bigint <69431456+bigint@users.noreply.github.com> Date: Wed, 8 Feb 2023 19:23:44 +0530 Subject: [PATCH] Revert "Revert "feat: move back to good old datadog"" (#1759) --- .../Actions/AccessSettings/BasicSettings.tsx | 8 ++-- .../Composer/Actions/AccessSettings/index.tsx | 4 +- .../Composer/Actions/Attachment.tsx | 8 ++-- .../Actions/CollectSettings/CollectForm.tsx | 12 +++--- .../Actions/CollectSettings/index.tsx | 4 +- .../Composer/Actions/Giphy/index.tsx | 4 +- .../Actions/ReferenceSettings/index.tsx | 12 +++--- .../components/Composer/NewPublication.tsx | 6 +-- apps/web/src/components/Explore/FeedType.tsx | 4 +- apps/web/src/components/Explore/index.tsx | 11 ++++-- apps/web/src/components/Home/FeedType.tsx | 6 +-- .../components/Home/RecommendedProfiles.tsx | 4 +- .../src/components/Home/SeeThroughLens.tsx | 6 +-- apps/web/src/components/Home/SetProfile.tsx | 6 +-- apps/web/src/components/Home/Trending.tsx | 4 +- apps/web/src/components/Home/index.tsx | 8 +++- apps/web/src/components/Messages/Composer.tsx | 4 +- apps/web/src/components/Messages/Message.tsx | 8 +++- .../src/components/Messages/PreviewList.tsx | 4 +- apps/web/src/components/Messages/index.tsx | 7 ++++ apps/web/src/components/Mod/index.tsx | 7 ++++ .../src/components/Notification/FeedType.tsx | 12 +++--- .../Notification/NotificationIcon.tsx | 4 +- .../web/src/components/Notification/index.tsx | 8 +++- apps/web/src/components/Pages/Contact.tsx | 7 ++++ apps/web/src/components/Pages/Privacy.tsx | 11 +++++- apps/web/src/components/Pages/Terms.tsx | 7 ++++ apps/web/src/components/Pages/Thanks.tsx | 7 ++++ apps/web/src/components/Profile/FeedType.tsx | 12 +++--- .../src/components/Profile/Followerings.tsx | 6 +-- .../Profile/MutualFollowers/index.tsx | 4 +- apps/web/src/components/Profile/New.tsx | 7 ++++ .../Profile/NftGallery/Detail/index.tsx | 8 +++- apps/web/src/components/Profile/index.tsx | 6 +++ .../Publication/Actions/Analytics/index.tsx | 2 +- .../Actions/Collect/CollectModule.tsx | 6 +-- .../Publication/Actions/Collect/index.tsx | 4 +- .../components/Publication/Actions/Like.tsx | 6 +-- .../Publication/Actions/Menu/Delete.tsx | 4 +- .../Publication/Actions/Menu/Embed.tsx | 4 +- .../Publication/Actions/Menu/Permalink.tsx | 4 +- .../Publication/Actions/Menu/index.tsx | 4 +- .../components/Publication/Actions/Mirror.tsx | 4 +- .../Publication/Actions/ModAction.tsx | 6 +-- .../Publication/DecryptedPublicationBody.tsx | 10 ++--- .../Publication/PublicationStats.tsx | 8 ++-- .../Publication/SinglePublication.tsx | 4 +- .../src/components/Publication/ThreadBody.tsx | 4 +- apps/web/src/components/Publication/index.tsx | 8 +++- apps/web/src/components/Search/index.tsx | 7 ++++ .../components/Settings/Account/CrossPost.tsx | 6 +-- .../Settings/Account/SetProfile.tsx | 4 +- .../Settings/Account/SuperFollow.tsx | 4 +- .../Settings/Account/Verification.tsx | 4 +- .../src/components/Settings/Account/index.tsx | 7 ++++ .../components/Settings/Allowance/Button.tsx | 4 +- .../components/Settings/Allowance/index.tsx | 8 +++- .../src/components/Settings/Cleanup/index.tsx | 7 ++++ .../src/components/Settings/Delete/index.tsx | 8 +++- .../Settings/Dispatcher/ToggleDispatcher.tsx | 4 +- .../components/Settings/Dispatcher/index.tsx | 7 ++++ .../Settings/Interests/Interests.tsx | 6 +-- .../components/Settings/Interests/index.tsx | 7 ++++ .../components/Settings/Preferences/index.tsx | 7 ++++ .../Settings/Profile/NFTPicture.tsx | 4 +- .../components/Settings/Profile/Picture.tsx | 4 +- .../components/Settings/Profile/Profile.tsx | 4 +- .../src/components/Settings/Profile/index.tsx | 8 +++- .../web/src/components/Shared/Attachments.tsx | 4 +- .../web/src/components/Shared/Audio/index.tsx | 6 +-- apps/web/src/components/Shared/Follow.tsx | 4 +- apps/web/src/components/Shared/Footer.tsx | 18 ++++----- .../src/components/Shared/IFramely/Embed.tsx | 4 +- .../Shared/Login/WalletSelector.tsx | 8 ++-- .../components/Shared/Modal/Report/index.tsx | 12 ++++-- .../components/Shared/Navbar/LoginButton.tsx | 4 +- .../Shared/Navbar/NavItems/Logout.tsx | 4 +- .../Shared/Navbar/NavItems/StaffMode.tsx | 4 +- .../Shared/Navbar/NavItems/ThemeSwitch.tsx | 4 +- .../src/components/Shared/Navbar/Search.tsx | 6 +-- apps/web/src/components/Shared/Status.tsx | 6 +-- .../Shared/SuperFollow/FollowModule.tsx | 4 +- .../components/Shared/SuperFollow/index.tsx | 4 +- .../src/components/Shared/SwitchNetwork.tsx | 4 +- .../src/components/Shared/SwitchProfiles.tsx | 4 +- apps/web/src/components/Shared/Unfollow.tsx | 4 +- apps/web/src/components/Shared/Uniswap.tsx | 4 +- .../src/components/StaffTools/Stats/index.tsx | 7 ++++ .../utils/matchers/HashtagMatcher.tsx | 4 +- .../utils/matchers/MentionMatcher.tsx | 4 +- apps/web/src/lib/analytics.ts | 21 ---------- apps/web/src/lib/leafwatch.ts | 38 +++++++++++++++++++ apps/web/src/locales/en/messages.po | 4 +- apps/web/src/locales/es/messages.po | 3 +- apps/web/src/locales/ta/messages.po | 3 +- apps/web/src/tracking.ts | 1 + packages/data/constants.ts | 4 ++ 97 files changed, 401 insertions(+), 220 deletions(-) delete mode 100644 apps/web/src/lib/analytics.ts create mode 100644 apps/web/src/lib/leafwatch.ts diff --git a/apps/web/src/components/Composer/Actions/AccessSettings/BasicSettings.tsx b/apps/web/src/components/Composer/Actions/AccessSettings/BasicSettings.tsx index 206bb80db340..38cbd5368e95 100644 --- a/apps/web/src/components/Composer/Actions/AccessSettings/BasicSettings.tsx +++ b/apps/web/src/components/Composer/Actions/AccessSettings/BasicSettings.tsx @@ -2,7 +2,7 @@ import ToggleWithHelper from '@components/Shared/ToggleWithHelper'; import { Button } from '@components/UI/Button'; import { Card } from '@components/UI/Card'; import { CollectionIcon, UsersIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import { CollectModules } from 'lens'; import type { Dispatch, FC } from 'react'; @@ -42,7 +42,7 @@ const BasicSettings: FC = ({ setShowModal }) => { reset(); } setRestricted(!restricted); - Analytics.track(PUBLICATION.NEW.ACCESS.TOGGLE_RESTRICTED_ACCESS); + Leafwatch.track(PUBLICATION.NEW.ACCESS.TOGGLE_RESTRICTED_ACCESS); }} label={t`Add restrictions on who can view this post`} /> @@ -63,7 +63,7 @@ const BasicSettings: FC = ({ setShowModal }) => { return toast.error(t`Enable collect first to use collect based token gating`); } setCollectToView(!collectToView); - Analytics.track(PUBLICATION.NEW.ACCESS.TOGGLE_COLLECT_TO_VIEW_ACCESS); + Leafwatch.track(PUBLICATION.NEW.ACCESS.TOGGLE_COLLECT_TO_VIEW_ACCESS); }} label={t`People need to collect it first to be able to view it`} /> @@ -81,7 +81,7 @@ const BasicSettings: FC = ({ setShowModal }) => { on={followToView} setOn={() => { setFollowToView(!followToView); - Analytics.track(PUBLICATION.NEW.ACCESS.TOGGLE_FOLLOW_TO_VIEW_ACCESS); + Leafwatch.track(PUBLICATION.NEW.ACCESS.TOGGLE_FOLLOW_TO_VIEW_ACCESS); }} label={t`People need to follow you to be able to view it`} /> diff --git a/apps/web/src/components/Composer/Actions/AccessSettings/index.tsx b/apps/web/src/components/Composer/Actions/AccessSettings/index.tsx index c33e32dceece..88e8c0a961b4 100644 --- a/apps/web/src/components/Composer/Actions/AccessSettings/index.tsx +++ b/apps/web/src/components/Composer/Actions/AccessSettings/index.tsx @@ -2,7 +2,7 @@ import HelpTooltip from '@components/UI/HelpTooltip'; import { Modal } from '@components/UI/Modal'; import { Tooltip } from '@components/UI/Tooltip'; import { LockClosedIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import clsx from 'clsx'; import { motion } from 'framer-motion'; @@ -27,7 +27,7 @@ const AccessSettings: FC = () => { type="button" onClick={() => { setShowModal(!showModal); - Analytics.track(PUBLICATION.NEW.ACCESS.OPEN_ACCESS_SETTINGS); + Leafwatch.track(PUBLICATION.NEW.ACCESS.OPEN_ACCESS_SETTINGS); }} aria-label="Access" > diff --git a/apps/web/src/components/Composer/Actions/Attachment.tsx b/apps/web/src/components/Composer/Actions/Attachment.tsx index 2a7fa3aaee19..0d85ea425ad2 100644 --- a/apps/web/src/components/Composer/Actions/Attachment.tsx +++ b/apps/web/src/components/Composer/Actions/Attachment.tsx @@ -5,7 +5,7 @@ import useOnClickOutside from '@components/utils/hooks/useOnClickOutside'; import useUploadAttachments from '@components/utils/hooks/useUploadAttachments'; import { Menu } from '@headlessui/react'; import { MusicNoteIcon, PhotographIcon, VideoCameraIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import clsx from 'clsx'; import { @@ -135,7 +135,7 @@ const Attachment: FC = () => { multiple accept={ALLOWED_IMAGE_TYPES.join(',')} className="hidden" - onClick={() => Analytics.track(PUBLICATION.NEW.ATTACHMENT.UPLOAD_IMAGES)} + onClick={() => Leafwatch.track(PUBLICATION.NEW.ATTACHMENT.UPLOAD_IMAGES)} onChange={handleAttachment} disabled={attachments.length >= 4} /> @@ -157,7 +157,7 @@ const Attachment: FC = () => { type="file" accept={ALLOWED_VIDEO_TYPES.join(',')} className="hidden" - onClick={() => Analytics.track(PUBLICATION.NEW.ATTACHMENT.UPLOAD_VIDEO)} + onClick={() => Leafwatch.track(PUBLICATION.NEW.ATTACHMENT.UPLOAD_VIDEO)} onChange={handleAttachment} disabled={attachments.length >= 4} /> @@ -179,7 +179,7 @@ const Attachment: FC = () => { type="file" accept={ALLOWED_AUDIO_TYPES.join(',')} className="hidden" - onClick={() => Analytics.track(PUBLICATION.NEW.ATTACHMENT.UPLOAD_AUDIO)} + onClick={() => Leafwatch.track(PUBLICATION.NEW.ATTACHMENT.UPLOAD_AUDIO)} onChange={handleAttachment} disabled={attachments.length >= 4} /> diff --git a/apps/web/src/components/Composer/Actions/CollectSettings/CollectForm.tsx b/apps/web/src/components/Composer/Actions/CollectSettings/CollectForm.tsx index a384976d90c5..4d1e5278fc6c 100644 --- a/apps/web/src/components/Composer/Actions/CollectSettings/CollectForm.tsx +++ b/apps/web/src/components/Composer/Actions/CollectSettings/CollectForm.tsx @@ -10,7 +10,7 @@ import { SwitchHorizontalIcon, UserGroupIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import type { Erc20 } from 'lens'; import { CollectModules, useEnabledModulesQuery } from 'lens'; @@ -135,7 +135,7 @@ const CollectForm: FC = ({ setShowModal }) => { } const toggleCollect = () => { - Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_COLLECT_MODULE); + Leafwatch.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_COLLECT_MODULE); if (selectedCollectModule === RevertCollectModule) { return setSelectedCollectModule(FreeCollectModule); } else { @@ -166,7 +166,7 @@ const CollectForm: FC = ({ setShowModal }) => { on={Boolean(amount)} setOn={() => { setAmount(amount ? null : '0'); - Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_CHARGE_FOR_COLLECT); + Leafwatch.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_CHARGE_FOR_COLLECT); }} />
@@ -249,7 +249,7 @@ const CollectForm: FC = ({ setShowModal }) => { on={Boolean(collectLimit)} setOn={() => { setCollectLimit(collectLimit ? null : '1'); - Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_LIMITED_EDITION_COLLECT); + Leafwatch.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_LIMITED_EDITION_COLLECT); }} />
@@ -284,7 +284,7 @@ const CollectForm: FC = ({ setShowModal }) => { on={hasTimeLimit} setOn={() => { setHasTimeLimit(!hasTimeLimit); - Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_TIME_LIMIT_COLLECT); + Leafwatch.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_TIME_LIMIT_COLLECT); }} />
@@ -306,7 +306,7 @@ const CollectForm: FC = ({ setShowModal }) => { on={followerOnly} setOn={() => { setFollowerOnly(!followerOnly); - Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_FOLLOWERS_ONLY_COLLECT); + Leafwatch.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_FOLLOWERS_ONLY_COLLECT); }} />
diff --git a/apps/web/src/components/Composer/Actions/CollectSettings/index.tsx b/apps/web/src/components/Composer/Actions/CollectSettings/index.tsx index 4be49b1fd5c6..8bf42011e3e8 100644 --- a/apps/web/src/components/Composer/Actions/CollectSettings/index.tsx +++ b/apps/web/src/components/Composer/Actions/CollectSettings/index.tsx @@ -2,8 +2,8 @@ import { Modal } from '@components/UI/Modal'; import { Tooltip } from '@components/UI/Tooltip'; import GetModuleIcon from '@components/utils/GetModuleIcon'; import { CashIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; import { getModule } from '@lib/getModule'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import { motion } from 'framer-motion'; import type { FC } from 'react'; @@ -25,7 +25,7 @@ const CollectSettings: FC = () => { type="button" onClick={() => { setShowModal(!showModal); - Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.OPEN_COLLECT_SETTINGS); + Leafwatch.track(PUBLICATION.NEW.COLLECT_MODULE.OPEN_COLLECT_SETTINGS); }} aria-label="Choose Collect Module" > diff --git a/apps/web/src/components/Composer/Actions/Giphy/index.tsx b/apps/web/src/components/Composer/Actions/Giphy/index.tsx index 28279bd3c1e8..3b9ad914efb2 100644 --- a/apps/web/src/components/Composer/Actions/Giphy/index.tsx +++ b/apps/web/src/components/Composer/Actions/Giphy/index.tsx @@ -3,7 +3,7 @@ import { Modal } from '@components/UI/Modal'; import { Tooltip } from '@components/UI/Tooltip'; import type { IGif } from '@giphy/js-types'; import { PhotographIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import { motion } from 'framer-motion'; import dynamic from 'next/dynamic'; @@ -32,7 +32,7 @@ const Giphy: FC = ({ setGifAttachment }) => { type="button" onClick={() => { setShowModal(!showModal); - Analytics.track(PUBLICATION.NEW.OPEN_GIF); + Leafwatch.track(PUBLICATION.NEW.OPEN_GIF); }} disabled={attachments.length >= 4} aria-label="Choose GIFs" diff --git a/apps/web/src/components/Composer/Actions/ReferenceSettings/index.tsx b/apps/web/src/components/Composer/Actions/ReferenceSettings/index.tsx index 24195fc16b60..c4732edfbac3 100644 --- a/apps/web/src/components/Composer/Actions/ReferenceSettings/index.tsx +++ b/apps/web/src/components/Composer/Actions/ReferenceSettings/index.tsx @@ -2,7 +2,7 @@ import MenuTransition from '@components/Shared/MenuTransition'; import { Menu } from '@headlessui/react'; import { GlobeAltIcon, UserAddIcon, UserGroupIcon, UsersIcon } from '@heroicons/react/outline'; import { CheckCircleIcon } from '@heroicons/react/solid'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import clsx from 'clsx'; import { motion } from 'framer-motion'; @@ -58,7 +58,7 @@ const ReferenceSettings: FC = () => { as={motion.button} whileTap={{ scale: 0.9 }} onClick={() => { - Analytics.track(PUBLICATION.NEW.REFERENCE_MODULE.OPEN_REFERENCE_SETTINGS); + Leafwatch.track(PUBLICATION.NEW.REFERENCE_MODULE.OPEN_REFERENCE_SETTINGS); }} >
@@ -80,7 +80,7 @@ const ReferenceSettings: FC = () => { onClick={() => { setSelectedReferenceModule(ReferenceModules.FollowerOnlyReferenceModule); setOnlyFollowers(false); - Analytics.track(PUBLICATION.NEW.REFERENCE_MODULE.EVERYONE); + Leafwatch.track(PUBLICATION.NEW.REFERENCE_MODULE.EVERYONE); }} /> { onClick={() => { setSelectedReferenceModule(ReferenceModules.FollowerOnlyReferenceModule); setOnlyFollowers(true); - Analytics.track(PUBLICATION.NEW.REFERENCE_MODULE.MY_FOLLOWERS); + Leafwatch.track(PUBLICATION.NEW.REFERENCE_MODULE.MY_FOLLOWERS); }} /> { onClick={() => { setSelectedReferenceModule(ReferenceModules.DegreesOfSeparationReferenceModule); setDegreesOfSeparation(1); - Analytics.track(PUBLICATION.NEW.REFERENCE_MODULE.MY_FOLLOWS); + Leafwatch.track(PUBLICATION.NEW.REFERENCE_MODULE.MY_FOLLOWS); }} /> { onClick={() => { setSelectedReferenceModule(ReferenceModules.DegreesOfSeparationReferenceModule); setDegreesOfSeparation(2); - Analytics.track(PUBLICATION.NEW.REFERENCE_MODULE.FRIENDS_OF_FRIENDS); + Leafwatch.track(PUBLICATION.NEW.REFERENCE_MODULE.FRIENDS_OF_FRIENDS); }} /> diff --git a/apps/web/src/components/Composer/NewPublication.tsx b/apps/web/src/components/Composer/NewPublication.tsx index 57fddf480b9f..6875c40e30fb 100644 --- a/apps/web/src/components/Composer/NewPublication.tsx +++ b/apps/web/src/components/Composer/NewPublication.tsx @@ -16,11 +16,11 @@ import type { } from '@lens-protocol/sdk-gated/dist/graphql/types'; import { $convertFromMarkdownString } from '@lexical/markdown'; import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'; -import { Analytics } from '@lib/analytics'; import getSignature from '@lib/getSignature'; import getTags from '@lib/getTags'; import getTextNftUrl from '@lib/getTextNftUrl'; import getUserLocale from '@lib/getUserLocale'; +import { Leafwatch } from '@lib/leafwatch'; import onError from '@lib/onError'; import splitSignature from '@lib/splitSignature'; import uploadToArweave from '@lib/uploadToArweave'; @@ -148,14 +148,14 @@ const NewPublication: FC = ({ publication }) => { setShowNewPostModal(false); } - // Track in simple analytics + // Track in leafwatch const eventProperties = { publication_type: restricted ? 'token_gated' : 'public', publication_collect_module: selectedCollectModule, publication_reference_module: selectedReferenceModule, publication_has_attachments: attachments.length > 0 }; - Analytics.track(isComment ? COMMENT.NEW : POST.NEW, eventProperties); + Leafwatch.track(isComment ? COMMENT.NEW : POST.NEW, eventProperties); }; useEffect(() => { diff --git a/apps/web/src/components/Explore/FeedType.tsx b/apps/web/src/components/Explore/FeedType.tsx index 388ef854bde3..fd5e3a11c9b4 100644 --- a/apps/web/src/components/Explore/FeedType.tsx +++ b/apps/web/src/components/Explore/FeedType.tsx @@ -1,4 +1,4 @@ -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import clsx from 'clsx'; import { PublicationMainFocus } from 'lens'; @@ -20,7 +20,7 @@ const FeedType: FC = ({ setFocus, focus }) => { type="button" onClick={() => { setFocus(type as PublicationMainFocus); - Analytics.track(`select_${(type ?? 'all_posts')?.toLowerCase()}_filter_in_explore`); + Leafwatch.track(`select_${(type ?? 'all_posts')?.toLowerCase()}_filter_in_explore`); }} className={clsx( { '!bg-brand-500 !text-white': focus === type }, diff --git a/apps/web/src/components/Explore/index.tsx b/apps/web/src/components/Explore/index.tsx index 49da2949b9d0..84f20e78238f 100644 --- a/apps/web/src/components/Explore/index.tsx +++ b/apps/web/src/components/Explore/index.tsx @@ -4,8 +4,8 @@ import Trending from '@components/Home/Trending'; import Footer from '@components/Shared/Footer'; import { GridItemEight, GridItemFour, GridLayout } from '@components/UI/GridLayout'; import { Tab } from '@headlessui/react'; -import { Analytics } from '@lib/analytics'; import isFeatureEnabled from '@lib/isFeatureEnabled'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import clsx from 'clsx'; import { APP_NAME } from 'data/constants'; @@ -13,8 +13,9 @@ import type { PublicationMainFocus } from 'lens'; import { PublicationSortCriteria } from 'lens'; import type { NextPage } from 'next'; import { useRouter } from 'next/router'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { useAppStore } from 'src/store/app'; +import { PAGEVIEW } from 'src/tracking'; import Feed from './Feed'; import FeedType from './FeedType'; @@ -24,6 +25,10 @@ const Explore: NextPage = () => { const [focus, setFocus] = useState(); const router = useRouter(); + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'explore' }); + }, []); + const tabs = [ { name: t`For you`, type: PublicationSortCriteria.CuratedProfiles }, { name: t`Popular`, type: PublicationSortCriteria.TopCommented }, @@ -50,7 +55,7 @@ const Explore: NextPage = () => { key={index} defaultChecked={index === 1} onClick={() => { - Analytics.track(`switch_to_${tab.type?.toLowerCase()}_tab_in_explore`); + Leafwatch.track(`switch_to_${tab.type?.toLowerCase()}_tab_in_explore`); }} className={({ selected }) => clsx( diff --git a/apps/web/src/components/Home/FeedType.tsx b/apps/web/src/components/Home/FeedType.tsx index bc7eccc83cb5..c03e6e8178b1 100644 --- a/apps/web/src/components/Home/FeedType.tsx +++ b/apps/web/src/components/Home/FeedType.tsx @@ -1,6 +1,6 @@ import TabButton from '@components/UI/TabButton'; import { SparklesIcon, ViewListIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import type { Dispatch, FC } from 'react'; import { MISCELLANEOUS } from 'src/tracking'; @@ -24,7 +24,7 @@ const FeedType: FC = ({ setFeedType, feedType }) => { showOnSm={false} onClick={() => { setFeedType('TIMELINE'); - Analytics.track(MISCELLANEOUS.SWITCH_TIMELINE); + Leafwatch.track(MISCELLANEOUS.SWITCH_TIMELINE); }} /> = ({ setFeedType, feedType }) => { showOnSm={false} onClick={() => { setFeedType('HIGHLIGHTS'); - Analytics.track(MISCELLANEOUS.SWITCH_HIGHLIGHTS); + Leafwatch.track(MISCELLANEOUS.SWITCH_HIGHLIGHTS); }} />
diff --git a/apps/web/src/components/Home/RecommendedProfiles.tsx b/apps/web/src/components/Home/RecommendedProfiles.tsx index d205943cfe18..48caf3c2afa9 100644 --- a/apps/web/src/components/Home/RecommendedProfiles.tsx +++ b/apps/web/src/components/Home/RecommendedProfiles.tsx @@ -7,7 +7,7 @@ import { ErrorMessage } from '@components/UI/ErrorMessage'; import { Modal } from '@components/UI/Modal'; import { DotsCircleHorizontalIcon, UsersIcon } from '@heroicons/react/outline'; import { SparklesIcon } from '@heroicons/react/solid'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import type { Profile } from 'lens'; import { useRecommendedProfilesQuery } from 'lens'; @@ -81,7 +81,7 @@ const RecommendedProfiles: FC = () => { type="button" onClick={() => { setShowSuggestedModal(true); - Analytics.track(MISCELLANEOUS.OPEN_RECOMMENDED_PROFILES); + Leafwatch.track(MISCELLANEOUS.OPEN_RECOMMENDED_PROFILES); }} > diff --git a/apps/web/src/components/Home/SeeThroughLens.tsx b/apps/web/src/components/Home/SeeThroughLens.tsx index f6ae1ae4170a..a7b00e30162e 100644 --- a/apps/web/src/components/Home/SeeThroughLens.tsx +++ b/apps/web/src/components/Home/SeeThroughLens.tsx @@ -5,9 +5,9 @@ import { Spinner } from '@components/UI/Spinner'; import { Menu } from '@headlessui/react'; import { XIcon } from '@heroicons/react/outline'; import { ChevronDownIcon } from '@heroicons/react/solid'; -import { Analytics } from '@lib/analytics'; import formatHandle from '@lib/formatHandle'; import getAvatar from '@lib/getAvatar'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import clsx from 'clsx'; import type { FeedItem, FeedRequest, Profile, ProfileSearchResult } from 'lens'; @@ -126,7 +126,7 @@ const SeeThroughLens: FC = () => { className={clsx('cursor-pointer', searchText ? 'visible' : 'invisible')} onClick={() => { setSearchText(''); - Analytics.track(SEARCH.CLEAR); + Leafwatch.track(SEARCH.CLEAR); }} /> } @@ -161,7 +161,7 @@ const SeeThroughLens: FC = () => { onClick={() => { setSeeThroughProfile(profile); setSearchText(''); - Analytics.track(MISCELLANEOUS.SELECT_USER_FEED); + Leafwatch.track(MISCELLANEOUS.SELECT_USER_FEED); }} > diff --git a/apps/web/src/components/Home/SetProfile.tsx b/apps/web/src/components/Home/SetProfile.tsx index ff5370956e92..6248e120477a 100644 --- a/apps/web/src/components/Home/SetProfile.tsx +++ b/apps/web/src/components/Home/SetProfile.tsx @@ -2,7 +2,7 @@ import New from '@components/Shared/Badges/New'; import { Card } from '@components/UI/Card'; import { MinusCircleIcon, PencilAltIcon, PhotographIcon } from '@heroicons/react/outline'; import { CheckCircleIcon } from '@heroicons/react/solid'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import clsx from 'clsx'; import { APP_NAME } from 'data/constants'; @@ -59,7 +59,7 @@ const SetProfile: FC = () => {
Analytics.track(MISCELLANEOUS.NAVIGATE_UPDATE_PROFILE_INTERESTS)} + onClick={() => Leafwatch.track(MISCELLANEOUS.NAVIGATE_UPDATE_PROFILE_INTERESTS)} href="/settings/interests" > {
- Analytics.track(MISCELLANEOUS.NAVIGATE_UPDATE_PROFILE)} href="/settings"> + Leafwatch.track(MISCELLANEOUS.NAVIGATE_UPDATE_PROFILE)} href="/settings"> Update profile now
diff --git a/apps/web/src/components/Home/Trending.tsx b/apps/web/src/components/Home/Trending.tsx index a58927b9c1bb..e0398bfe4af0 100644 --- a/apps/web/src/components/Home/Trending.tsx +++ b/apps/web/src/components/Home/Trending.tsx @@ -2,7 +2,7 @@ import TrendingTagShimmer from '@components/Shared/Shimmer/TrendingTagShimmer'; import { Card } from '@components/UI/Card'; import { ErrorMessage } from '@components/UI/ErrorMessage'; import { TrendingUpIcon } from '@heroicons/react/solid'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import nFormatter from '@lib/nFormatter'; import { t, Trans } from '@lingui/macro'; import type { TagResult } from 'lens'; @@ -53,7 +53,7 @@ const Trending: FC = () => {
Analytics.track(MISCELLANEOUS.OPEN_TRENDING_TAG)} + onClick={() => Leafwatch.track(MISCELLANEOUS.OPEN_TRENDING_TAG)} >
{tag?.tag}
diff --git a/apps/web/src/components/Home/index.tsx b/apps/web/src/components/Home/index.tsx index b8957efd1c95..5c49528530b5 100644 --- a/apps/web/src/components/Home/index.tsx +++ b/apps/web/src/components/Home/index.tsx @@ -4,9 +4,11 @@ import ExploreFeed from '@components/Explore/Feed'; import BetaWarning from '@components/Home/BetaWarning'; import Footer from '@components/Shared/Footer'; import { GridItemEight, GridItemFour, GridLayout } from '@components/UI/GridLayout'; +import { Leafwatch } from '@lib/leafwatch'; import type { NextPage } from 'next'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { useAppStore } from 'src/store/app'; +import { PAGEVIEW } from 'src/tracking'; import EnableDispatcher from './EnableDispatcher'; import EnableMessages from './EnableMessages'; @@ -22,6 +24,10 @@ const Home: NextPage = () => { const currentProfile = useAppStore((state) => state.currentProfile); const [feedType, setFeedType] = useState<'TIMELINE' | 'HIGHLIGHTS'>('TIMELINE'); + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'home' }); + }, []); + return ( <> diff --git a/apps/web/src/components/Messages/Composer.tsx b/apps/web/src/components/Messages/Composer.tsx index 6112b1cb97da..8fcc23ae5598 100644 --- a/apps/web/src/components/Messages/Composer.tsx +++ b/apps/web/src/components/Messages/Composer.tsx @@ -3,7 +3,7 @@ import { Input } from '@components/UI/Input'; import { Spinner } from '@components/UI/Spinner'; import useWindowSize from '@components/utils/hooks/useWindowSize'; import { ArrowRightIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import { MIN_WIDTH_DESKTOP } from 'data/constants'; import type { FC } from 'react'; @@ -36,7 +36,7 @@ const Composer: FC = ({ sendMessage, conversationKey, disabledInput }) => if (sent) { setMessage(''); setUnsentMessage(conversationKey, null); - Analytics.track(MESSAGES.SEND); + Leafwatch.track(MESSAGES.SEND); } else { toast.error(t`Error sending message`); } diff --git a/apps/web/src/components/Messages/Message.tsx b/apps/web/src/components/Messages/Message.tsx index ba22740b4a4d..da76e59e3450 100644 --- a/apps/web/src/components/Messages/Message.tsx +++ b/apps/web/src/components/Messages/Message.tsx @@ -9,15 +9,17 @@ import useSendMessage from '@components/utils/hooks/useSendMessage'; import useStreamMessages from '@components/utils/hooks/useStreamMessages'; import { parseConversationKey } from '@lib/conversationKey'; import formatHandle from '@lib/formatHandle'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import { APP_NAME } from 'data/constants'; import type { NextPage } from 'next'; import { useRouter } from 'next/router'; import type { FC } from 'react'; -import { useCallback, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import Custom404 from 'src/pages/404'; import { useAppStore } from 'src/store/app'; import { useMessageStore } from 'src/store/message'; +import { PAGEVIEW } from 'src/tracking'; import Composer from './Composer'; import MessagesList from './MessagesList'; @@ -103,6 +105,10 @@ const MessagePage: NextPage = () => { query: { conversationKey } } = useRouter(); + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'conversation' }); + }, []); + // Need to have a login page for when there is no currentProfileId if (!conversationKey || !currentProfileId || !Array.isArray(conversationKey)) { return ; diff --git a/apps/web/src/components/Messages/PreviewList.tsx b/apps/web/src/components/Messages/PreviewList.tsx index 1638848f7324..dbab02e8f52a 100644 --- a/apps/web/src/components/Messages/PreviewList.tsx +++ b/apps/web/src/components/Messages/PreviewList.tsx @@ -9,9 +9,9 @@ import { GridItemFour } from '@components/UI/GridLayout'; import { Modal } from '@components/UI/Modal'; import useMessagePreviews from '@components/utils/hooks/useMessagePreviews'; import { MailIcon, PlusCircleIcon, UsersIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; import buildConversationId from '@lib/buildConversationId'; import { buildConversationKey } from '@lib/conversationKey'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import clsx from 'clsx'; import { ERROR_MESSAGE } from 'data/constants'; @@ -58,7 +58,7 @@ const PreviewList: FC = ({ className, selectedConversationKey }) => { const newMessageClick = () => { setShowSearchModal(true); - Analytics.track(MESSAGES.OPEN_NEW_CONVERSATION); + Leafwatch.track(MESSAGES.OPEN_NEW_CONVERSATION); }; const onProfileSelected = (profile: Profile) => { diff --git a/apps/web/src/components/Messages/index.tsx b/apps/web/src/components/Messages/index.tsx index 45d323d9b8df..73b8a43b51e8 100644 --- a/apps/web/src/components/Messages/index.tsx +++ b/apps/web/src/components/Messages/index.tsx @@ -1,11 +1,14 @@ import MetaTags from '@components/Common/MetaTags'; import { Card } from '@components/UI/Card'; import { GridItemEight, GridLayout } from '@components/UI/GridLayout'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import { APP_NAME } from 'data/constants'; import type { NextPage } from 'next'; +import { useEffect } from 'react'; import Custom404 from 'src/pages/404'; import { useAppStore } from 'src/store/app'; +import { PAGEVIEW } from 'src/tracking'; import PreviewList from './PreviewList'; @@ -28,6 +31,10 @@ const NoConversationSelected = () => { const Messages: NextPage = () => { const currentProfile = useAppStore((state) => state.currentProfile); + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'messages' }); + }, []); + if (!currentProfile) { return ; } diff --git a/apps/web/src/components/Mod/index.tsx b/apps/web/src/components/Mod/index.tsx index 2485033ac839..40909065f90f 100644 --- a/apps/web/src/components/Mod/index.tsx +++ b/apps/web/src/components/Mod/index.tsx @@ -3,17 +3,24 @@ import Footer from '@components/Shared/Footer'; import { Card } from '@components/UI/Card'; import { GridItemEight, GridItemFour, GridLayout } from '@components/UI/GridLayout'; import isGardener from '@lib/isGardener'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import { APP_NAME } from 'data/constants'; import type { NextPage } from 'next'; +import { useEffect } from 'react'; import Custom404 from 'src/pages/404'; import { useAppStore } from 'src/store/app'; +import { PAGEVIEW } from 'src/tracking'; import Feed from './Feed'; const Mod: NextPage = () => { const currentProfile = useAppStore((state) => state.currentProfile); + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'mod' }); + }, []); + if (!isGardener(currentProfile?.id)) { return ; } diff --git a/apps/web/src/components/Notification/FeedType.tsx b/apps/web/src/components/Notification/FeedType.tsx index 41425cefa896..ed467f3f4416 100644 --- a/apps/web/src/components/Notification/FeedType.tsx +++ b/apps/web/src/components/Notification/FeedType.tsx @@ -6,7 +6,7 @@ import { HeartIcon, LightningBoltIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import type { Dispatch, FC } from 'react'; import { NOTIFICATION } from 'src/tracking'; @@ -27,7 +27,7 @@ const FeedType: FC = ({ setFeedType, feedType }) => { type="all" onClick={() => { setFeedType('ALL'); - Analytics.track(NOTIFICATION.SWITCH_ALL); + Leafwatch.track(NOTIFICATION.SWITCH_ALL); }} /> = ({ setFeedType, feedType }) => { type="mentions" onClick={() => { setFeedType('MENTIONS'); - Analytics.track(NOTIFICATION.SWITCH_MENTIONS); + Leafwatch.track(NOTIFICATION.SWITCH_MENTIONS); }} /> = ({ setFeedType, feedType }) => { type="comments" onClick={() => { setFeedType('COMMENTS'); - Analytics.track(NOTIFICATION.SWITCH_COMMENTS); + Leafwatch.track(NOTIFICATION.SWITCH_COMMENTS); }} /> = ({ setFeedType, feedType }) => { type="likes" onClick={() => { setFeedType('LIKES'); - Analytics.track(NOTIFICATION.SWITCH_LIKES); + Leafwatch.track(NOTIFICATION.SWITCH_LIKES); }} /> = ({ setFeedType, feedType }) => { type="collects" onClick={() => { setFeedType('COLLECTS'); - Analytics.track(NOTIFICATION.SWITCH_COLLECTS); + Leafwatch.track(NOTIFICATION.SWITCH_COLLECTS); }} />
diff --git a/apps/web/src/components/Notification/NotificationIcon.tsx b/apps/web/src/components/Notification/NotificationIcon.tsx index 6d8f3d498459..6276c042de60 100644 --- a/apps/web/src/components/Notification/NotificationIcon.tsx +++ b/apps/web/src/components/Notification/NotificationIcon.tsx @@ -1,5 +1,5 @@ import { LightningBoltIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { CustomFiltersTypes, useNotificationCountQuery } from 'lens'; import Link from 'next/link'; import type { FC } from 'react'; @@ -33,7 +33,7 @@ const NotificationIcon: FC = () => { onClick={() => { setNotificationCount(data?.notifications?.pageInfo?.totalCount || 0); setShowBadge(false); - Analytics.track(NOTIFICATION.OPEN); + Leafwatch.track(NOTIFICATION.OPEN); }} > diff --git a/apps/web/src/components/Notification/index.tsx b/apps/web/src/components/Notification/index.tsx index b70bb3bf3657..2fcf8b64f8ba 100644 --- a/apps/web/src/components/Notification/index.tsx +++ b/apps/web/src/components/Notification/index.tsx @@ -1,11 +1,13 @@ import MetaTags from '@components/Common/MetaTags'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import { APP_NAME } from 'data/constants'; import { useRouter } from 'next/router'; import type { FC } from 'react'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import Custom404 from 'src/pages/404'; import { useAppStore } from 'src/store/app'; +import { PAGEVIEW } from 'src/tracking'; import FeedType from './FeedType'; import List from './List'; @@ -21,6 +23,10 @@ const Notification: FC = () => { : 'ALL' ); + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'notifications' }); + }, []); + if (!currentProfile) { return ; } diff --git a/apps/web/src/components/Pages/Contact.tsx b/apps/web/src/components/Pages/Contact.tsx index b351b7233ace..0a4c6cd9f7fc 100644 --- a/apps/web/src/components/Pages/Contact.tsx +++ b/apps/web/src/components/Pages/Contact.tsx @@ -9,10 +9,13 @@ import { Input } from '@components/UI/Input'; import { TextArea } from '@components/UI/TextArea'; import { PencilAltIcon } from '@heroicons/react/outline'; import { CheckCircleIcon } from '@heroicons/react/solid'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import { APP_NAME, CONTACT_EMAIL } from 'data/constants'; import { useRouter } from 'next/router'; import type { FC } from 'react'; +import { useEffect } from 'react'; +import { PAGEVIEW } from 'src/tracking'; import { object, string } from 'zod'; const newContactSchema = object({ @@ -31,6 +34,10 @@ const newContactSchema = object({ const Contact: FC = () => { const { push } = useRouter(); + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'contact' }); + }, []); + const form = useZodForm({ schema: newContactSchema }); diff --git a/apps/web/src/components/Pages/Privacy.tsx b/apps/web/src/components/Pages/Privacy.tsx index c7b009456170..76da3abe0c9c 100644 --- a/apps/web/src/components/Pages/Privacy.tsx +++ b/apps/web/src/components/Pages/Privacy.tsx @@ -1,10 +1,17 @@ import MetaTags from '@components/Common/MetaTags'; import Footer from '@components/Shared/Footer'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import { APP_NAME } from 'data/constants'; import type { FC } from 'react'; +import { useEffect } from 'react'; +import { PAGEVIEW } from 'src/tracking'; const Privacy: FC = () => { + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'privacy' }); + }, []); + const updatedAt = 'December 11, 2022'; return ( @@ -138,8 +145,8 @@ const Privacy: FC = () => {

- We use Simple Analytics to collect various events from user actions to analyse and - make decisions for Site improvements. + We use Datadog to collect various events from user actions to analyse and make + decisions for Site improvements.

diff --git a/apps/web/src/components/Pages/Terms.tsx b/apps/web/src/components/Pages/Terms.tsx index 95325fbf0201..77c0d6f55a52 100644 --- a/apps/web/src/components/Pages/Terms.tsx +++ b/apps/web/src/components/Pages/Terms.tsx @@ -1,11 +1,18 @@ import MetaTags from '@components/Common/MetaTags'; import Footer from '@components/Shared/Footer'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import { APP_NAME } from 'data/constants'; import Link from 'next/link'; import type { FC } from 'react'; +import { useEffect } from 'react'; +import { PAGEVIEW } from 'src/tracking'; const Terms: FC = () => { + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'terms' }); + }, []); + const updatedAt = 'December 11, 2022'; return ( diff --git a/apps/web/src/components/Pages/Thanks.tsx b/apps/web/src/components/Pages/Thanks.tsx index f71684e4ebee..6193bd87b3b3 100644 --- a/apps/web/src/components/Pages/Thanks.tsx +++ b/apps/web/src/components/Pages/Thanks.tsx @@ -1,10 +1,13 @@ import MetaTags from '@components/Common/MetaTags'; import Footer from '@components/Shared/Footer'; import { HeartIcon } from '@heroicons/react/outline'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import { APP_NAME, STATIC_IMAGES_URL } from 'data/constants'; import { useTheme } from 'next-themes'; import type { FC, ReactNode } from 'react'; +import { useEffect } from 'react'; +import { PAGEVIEW } from 'src/tracking'; interface Props { name: string; @@ -37,6 +40,10 @@ const Brand: FC = ({ name, logo, url, size, type, children }) => { }; const Thanks: FC = () => { + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'thanks' }); + }, []); + return ( <> diff --git a/apps/web/src/components/Profile/FeedType.tsx b/apps/web/src/components/Profile/FeedType.tsx index e0e71706e2a8..79392446e8ec 100644 --- a/apps/web/src/components/Profile/FeedType.tsx +++ b/apps/web/src/components/Profile/FeedType.tsx @@ -6,7 +6,7 @@ import { PencilAltIcon, PhotographIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import type { Dispatch, FC } from 'react'; import { PROFILE } from 'src/tracking'; @@ -30,7 +30,7 @@ const FeedType: FC = ({ setFeedType, feedType }) => { type="feed" onClick={() => { setFeedType(ProfileFeedType.Feed); - Analytics.track(PROFILE.SWITCH_FEED); + Leafwatch.track(PROFILE.SWITCH_FEED); }} /> = ({ setFeedType, feedType }) => { type="replies" onClick={() => { setFeedType(ProfileFeedType.Replies); - Analytics.track(PROFILE.SWITCH_REPLIES); + Leafwatch.track(PROFILE.SWITCH_REPLIES); }} /> = ({ setFeedType, feedType }) => { type="media" onClick={() => { setFeedType(ProfileFeedType.Media); - Analytics.track(PROFILE.SWITCH_MEDIA); + Leafwatch.track(PROFILE.SWITCH_MEDIA); }} /> = ({ setFeedType, feedType }) => { type="collects" onClick={() => { setFeedType(ProfileFeedType.Collects); - Analytics.track(PROFILE.SWITCH_MEDIA); + Leafwatch.track(PROFILE.SWITCH_MEDIA); }} /> = ({ setFeedType, feedType }) => { type="nft" onClick={() => { setFeedType(ProfileFeedType.Nft); - Analytics.track(PROFILE.SWITCH_NFTS); + Leafwatch.track(PROFILE.SWITCH_NFTS); }} />

diff --git a/apps/web/src/components/Profile/Followerings.tsx b/apps/web/src/components/Profile/Followerings.tsx index bbf452feeb98..c5ba6da0f0f2 100644 --- a/apps/web/src/components/Profile/Followerings.tsx +++ b/apps/web/src/components/Profile/Followerings.tsx @@ -1,7 +1,7 @@ import { Modal } from '@components/UI/Modal'; import { UsersIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; import humanize from '@lib/humanize'; +import { Leafwatch } from '@lib/leafwatch'; import { t, Trans } from '@lingui/macro'; import type { Profile } from 'lens'; import type { FC } from 'react'; @@ -26,7 +26,7 @@ const Followerings: FC = ({ profile }) => { className="text-left" onClick={() => { setShowFollowingModal(!showFollowingModal); - Analytics.track(PROFILE.OPEN_FOLLOWING); + Leafwatch.track(PROFILE.OPEN_FOLLOWING); }} >
{humanize(profile?.stats?.totalFollowing)}
@@ -39,7 +39,7 @@ const Followerings: FC = ({ profile }) => { className="text-left" onClick={() => { setShowFollowersModal(!showFollowersModal); - Analytics.track(PROFILE.OPEN_FOLLOWERS); + Leafwatch.track(PROFILE.OPEN_FOLLOWERS); }} >
{humanize(profile?.stats?.totalFollowers)}
diff --git a/apps/web/src/components/Profile/MutualFollowers/index.tsx b/apps/web/src/components/Profile/MutualFollowers/index.tsx index 4c097b7aafa3..601caae932db 100644 --- a/apps/web/src/components/Profile/MutualFollowers/index.tsx +++ b/apps/web/src/components/Profile/MutualFollowers/index.tsx @@ -1,6 +1,6 @@ -import { Analytics } from '@lib/analytics'; import formatHandle from '@lib/formatHandle'; import getAvatar from '@lib/getAvatar'; +import { Leafwatch } from '@lib/leafwatch'; import { Trans } from '@lingui/macro'; import clsx from 'clsx'; import type { Profile } from 'lens'; @@ -40,7 +40,7 @@ const MutualFollowers: FC = ({ setShowMutualFollowersModal, profile, vari })} onClick={() => { setShowMutualFollowersModal?.(true); - Analytics.track(PROFILE.OPEN_MUTUAL_FOLLOWERS); + Leafwatch.track(PROFILE.OPEN_MUTUAL_FOLLOWERS); }} >
diff --git a/apps/web/src/components/Profile/New.tsx b/apps/web/src/components/Profile/New.tsx index 48f50568c891..c4fe2b01a385 100644 --- a/apps/web/src/components/Profile/New.tsx +++ b/apps/web/src/components/Profile/New.tsx @@ -3,15 +3,22 @@ import Signup from '@components/Shared/Login/New'; import SettingsHelper from '@components/Shared/SettingsHelper'; import { Card } from '@components/UI/Card'; import { GridItemEight, GridItemFour, GridLayout } from '@components/UI/GridLayout'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import { APP_NAME } from 'data/constants'; import type { NextPage } from 'next'; +import { useEffect } from 'react'; import Custom404 from 'src/pages/404'; import { useAppStore } from 'src/store/app'; +import { PAGEVIEW } from 'src/tracking'; const NewProfile: NextPage = () => { const currentProfile = useAppStore((state) => state.currentProfile); + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'new-profile' }); + }, []); + if (!currentProfile) { return ; } diff --git a/apps/web/src/components/Profile/NftGallery/Detail/index.tsx b/apps/web/src/components/Profile/NftGallery/Detail/index.tsx index 8ef056cdf173..08c7c17ce9bc 100644 --- a/apps/web/src/components/Profile/NftGallery/Detail/index.tsx +++ b/apps/web/src/components/Profile/NftGallery/Detail/index.tsx @@ -6,17 +6,23 @@ import { GridItemEight, GridItemFour, GridLayout } from '@components/UI/GridLayo import formatHandle from '@lib/formatHandle'; import getAvatar from '@lib/getAvatar'; import isFeatureEnabled from '@lib/isFeatureEnabled'; +import { Leafwatch } from '@lib/leafwatch'; import type { Profile } from 'lens'; import Link from 'next/link'; import type { FC } from 'react'; -import React from 'react'; +import React, { useEffect } from 'react'; import Custom404 from 'src/pages/404'; import { useAppStore } from 'src/store/app'; +import { PAGEVIEW } from 'src/tracking'; const NFTDetail: FC = () => { const currentProfile = useAppStore((state) => state.currentProfile); const profiles = useAppStore((state) => state.profiles); + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'nft' }); + }, []); + if (!isFeatureEnabled('nft-detail', currentProfile?.id) || !currentProfile) { return ; } diff --git a/apps/web/src/components/Profile/index.tsx b/apps/web/src/components/Profile/index.tsx index 174d89e3f095..ac9b78bc24a7 100644 --- a/apps/web/src/components/Profile/index.tsx +++ b/apps/web/src/components/Profile/index.tsx @@ -4,6 +4,7 @@ import { GridItemEight, GridItemFour, GridLayout } from '@components/UI/GridLayo import { Modal } from '@components/UI/Modal'; import formatHandle from '@lib/formatHandle'; import isFeatureEnabled from '@lib/isFeatureEnabled'; +import { Leafwatch } from '@lib/leafwatch'; import { APP_NAME, STATIC_IMAGES_URL } from 'data/constants'; import type { Profile } from 'lens'; import { useProfileQuery } from 'lens'; @@ -13,6 +14,7 @@ import { useEffect, useState } from 'react'; import Custom404 from 'src/pages/404'; import Custom500 from 'src/pages/500'; import { useAppStore } from 'src/store/app'; +import { PAGEVIEW } from 'src/tracking'; import Cover from './Cover'; import Details from './Details'; @@ -33,6 +35,10 @@ const ViewProfile: NextPage = () => { : ProfileFeedType.Feed ); + useEffect(() => { + Leafwatch.track(PAGEVIEW, { page: 'profile' }); + }, []); + const handle = formatHandle(username as string, true); const { data, loading, error } = useProfileQuery({ variables: { request: { handle }, who: currentProfile?.id ?? null }, diff --git a/apps/web/src/components/Publication/Actions/Analytics/index.tsx b/apps/web/src/components/Publication/Actions/Analytics/index.tsx index a8de1f1b3288..bb6b375940e0 100644 --- a/apps/web/src/components/Publication/Actions/Analytics/index.tsx +++ b/apps/web/src/components/Publication/Actions/Analytics/index.tsx @@ -43,7 +43,7 @@ const Analytics: FC = ({ publication }) => { whileTap={{ scale: 0.9 }} onClick={() => { setShowCollectModal(true); - // Analytics.track(PUBLICATION.COLLECT_MODULE.OPEN_COLLECT); + // Leafwatch.track(PUBLICATION.COLLECT_MODULE.OPEN_COLLECT); }} aria-label="Analytics" > diff --git a/apps/web/src/components/Publication/Actions/Collect/CollectModule.tsx b/apps/web/src/components/Publication/Actions/Collect/CollectModule.tsx index 9b8847df477f..637c69b231fa 100644 --- a/apps/web/src/components/Publication/Actions/Collect/CollectModule.tsx +++ b/apps/web/src/components/Publication/Actions/Collect/CollectModule.tsx @@ -19,7 +19,6 @@ import { UsersIcon } from '@heroicons/react/outline'; import { CheckCircleIcon } from '@heroicons/react/solid'; -import { Analytics } from '@lib/analytics'; import formatAddress from '@lib/formatAddress'; import formatHandle from '@lib/formatHandle'; import formatTime from '@lib/formatTime'; @@ -28,6 +27,7 @@ import getCoingeckoPrice from '@lib/getCoingeckoPrice'; import getSignature from '@lib/getSignature'; import getTokenImage from '@lib/getTokenImage'; import humanize from '@lib/humanize'; +import { Leafwatch } from '@lib/leafwatch'; import onError from '@lib/onError'; import splitSignature from '@lib/splitSignature'; import { t, Trans } from '@lingui/macro'; @@ -84,7 +84,7 @@ const CollectModule: FC = ({ count, setCount, publication, electedMirror setCount(count + 1); setHasCollectedByMe(true); toast.success(t`Collected successfully!`); - Analytics.track(PUBLICATION.COLLECT_MODULE.COLLECT); + Leafwatch.track(PUBLICATION.COLLECT_MODULE.COLLECT); }; const { isFetching, refetch } = useContractRead({ @@ -307,7 +307,7 @@ const CollectModule: FC = ({ count, setCount, publication, electedMirror type="button" onClick={() => { setShowCollectorsModal(!showCollectorsModal); - Analytics.track(PUBLICATION.COLLECT_MODULE.OPEN_COLLECTORS); + Leafwatch.track(PUBLICATION.COLLECT_MODULE.OPEN_COLLECTORS); }} > {humanize(count)} collectors diff --git a/apps/web/src/components/Publication/Actions/Collect/index.tsx b/apps/web/src/components/Publication/Actions/Collect/index.tsx index 391307c28ba3..fa46daf423fb 100644 --- a/apps/web/src/components/Publication/Actions/Collect/index.tsx +++ b/apps/web/src/components/Publication/Actions/Collect/index.tsx @@ -4,9 +4,9 @@ import { Tooltip } from '@components/UI/Tooltip'; import GetModuleIcon from '@components/utils/GetModuleIcon'; import { CollectionIcon } from '@heroicons/react/outline'; import { CollectionIcon as CollectionIconSolid } from '@heroicons/react/solid'; -import { Analytics } from '@lib/analytics'; import { getModule } from '@lib/getModule'; import humanize from '@lib/humanize'; +import { Leafwatch } from '@lib/leafwatch'; import nFormatter from '@lib/nFormatter'; import { t } from '@lingui/macro'; import { motion } from 'framer-motion'; @@ -59,7 +59,7 @@ const Collect: FC = ({ publication, electedMirror, showCount }) => { whileTap={{ scale: 0.9 }} onClick={() => { setShowCollectModal(true); - Analytics.track(PUBLICATION.COLLECT_MODULE.OPEN_COLLECT); + Leafwatch.track(PUBLICATION.COLLECT_MODULE.OPEN_COLLECT); }} aria-label="Collect" > diff --git a/apps/web/src/components/Publication/Actions/Like.tsx b/apps/web/src/components/Publication/Actions/Like.tsx index 5b9d5cee872f..59c4dd2a2359 100644 --- a/apps/web/src/components/Publication/Actions/Like.tsx +++ b/apps/web/src/components/Publication/Actions/Like.tsx @@ -2,9 +2,9 @@ import type { ApolloCache } from '@apollo/client'; import { Tooltip } from '@components/UI/Tooltip'; import { HeartIcon, SunIcon } from '@heroicons/react/outline'; import { HeartIcon as HeartIconSolid, SunIcon as SunIconSolid } from '@heroicons/react/solid'; -import { Analytics } from '@lib/analytics'; import hasGm from '@lib/hasGm'; import { publicationKeyFields } from '@lib/keyFields'; +import { Leafwatch } from '@lib/leafwatch'; import nFormatter from '@lib/nFormatter'; import onError from '@lib/onError'; import { t } from '@lingui/macro'; @@ -76,7 +76,7 @@ const Like: FC = ({ publication, showCount }) => { const [addReaction] = useAddReactionMutation({ onCompleted: () => { - Analytics.track(PUBLICATION.LIKE, getEventProperties('like')); + Leafwatch.track(PUBLICATION.LIKE, getEventProperties('like')); }, onError: (error) => { setLiked(!liked); @@ -88,7 +88,7 @@ const Like: FC = ({ publication, showCount }) => { const [removeReaction] = useRemoveReactionMutation({ onCompleted: () => { - Analytics.track(PUBLICATION.DISLIKE, getEventProperties('dislike')); + Leafwatch.track(PUBLICATION.DISLIKE, getEventProperties('dislike')); }, onError: (error) => { setLiked(!liked); diff --git a/apps/web/src/components/Publication/Actions/Menu/Delete.tsx b/apps/web/src/components/Publication/Actions/Menu/Delete.tsx index 08f45daeebb5..05a996c6ac3a 100644 --- a/apps/web/src/components/Publication/Actions/Menu/Delete.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/Delete.tsx @@ -1,6 +1,6 @@ import { Menu } from '@headlessui/react'; import { TrashIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import clsx from 'clsx'; import type { Publication } from 'lens'; import { useHidePublicationMutation } from 'lens'; @@ -16,7 +16,7 @@ const Delete: FC = ({ publication }) => { const { pathname, push } = useRouter(); const [hidePost] = useHidePublicationMutation({ onCompleted: () => { - Analytics.track(PUBLICATION.DELETE); + Leafwatch.track(PUBLICATION.DELETE); pathname === '/posts/[id]' ? push('/') : location.reload(); } }); diff --git a/apps/web/src/components/Publication/Actions/Menu/Embed.tsx b/apps/web/src/components/Publication/Actions/Menu/Embed.tsx index 35f3749b3c30..41ec6eec4197 100644 --- a/apps/web/src/components/Publication/Actions/Menu/Embed.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/Embed.tsx @@ -1,6 +1,6 @@ import { Menu } from '@headlessui/react'; import { CodeIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import clsx from 'clsx'; import type { Publication } from 'lens'; import type { FC, MouseEvent } from 'react'; @@ -19,7 +19,7 @@ const Embed: FC = ({ publication }) => { } onClick={(event: MouseEvent) => { event.stopPropagation(); - Analytics.track(PUBLICATION.EMBED); + Leafwatch.track(PUBLICATION.EMBED); }} href={`https://embed.withlens.app/?url=${publication?.id}`} target="_blank" diff --git a/apps/web/src/components/Publication/Actions/Menu/Permalink.tsx b/apps/web/src/components/Publication/Actions/Menu/Permalink.tsx index d81109add923..5f2ffe2479f0 100644 --- a/apps/web/src/components/Publication/Actions/Menu/Permalink.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/Permalink.tsx @@ -1,6 +1,6 @@ import { Menu } from '@headlessui/react'; import { ClipboardCopyIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { t } from '@lingui/macro'; import clsx from 'clsx'; import type { Publication } from 'lens'; @@ -19,7 +19,7 @@ const Permalink: FC = ({ publication }) => { text={`${location.origin}/posts/${publication?.id}`} onCopy={() => { toast.success(t`Copied to clipboard!`); - Analytics.track(PUBLICATION.PERMALINK); + Leafwatch.track(PUBLICATION.PERMALINK); }} > = ({ publication }) => { className="rounded-full p-1.5 hover:bg-gray-300 hover:bg-opacity-20" onClick={(event: MouseEvent) => { event.stopPropagation(); - Analytics.track(PUBLICATION.MORE); + Leafwatch.track(PUBLICATION.MORE); }} aria-label="More" > diff --git a/apps/web/src/components/Publication/Actions/Mirror.tsx b/apps/web/src/components/Publication/Actions/Mirror.tsx index 360e71362400..cf0ad97e5809 100644 --- a/apps/web/src/components/Publication/Actions/Mirror.tsx +++ b/apps/web/src/components/Publication/Actions/Mirror.tsx @@ -2,10 +2,10 @@ import type { ApolloCache } from '@apollo/client'; import { Spinner } from '@components/UI/Spinner'; import { Tooltip } from '@components/UI/Tooltip'; import { SwitchHorizontalIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; import getSignature from '@lib/getSignature'; import humanize from '@lib/humanize'; import { publicationKeyFields } from '@lib/keyFields'; +import { Leafwatch } from '@lib/leafwatch'; import nFormatter from '@lib/nFormatter'; import onError from '@lib/onError'; import splitSignature from '@lib/splitSignature'; @@ -62,7 +62,7 @@ const Mirror: FC = ({ publication, showCount }) => { const onCompleted = () => { setMirrored(true); toast.success(t`Post has been mirrored!`); - Analytics.track(PUBLICATION.MIRROR); + Leafwatch.track(PUBLICATION.MIRROR); }; const { isLoading: writeLoading, write } = useContractWrite({ diff --git a/apps/web/src/components/Publication/Actions/ModAction.tsx b/apps/web/src/components/Publication/Actions/ModAction.tsx index 4e355c1b5b32..a4dc390d977a 100644 --- a/apps/web/src/components/Publication/Actions/ModAction.tsx +++ b/apps/web/src/components/Publication/Actions/ModAction.tsx @@ -1,6 +1,6 @@ import { Button } from '@components/UI/Button'; import { ExclamationCircleIcon, ExternalLinkIcon, ShieldCheckIcon } from '@heroicons/react/outline'; -import { Analytics } from '@lib/analytics'; +import { Leafwatch } from '@lib/leafwatch'; import { Trans } from '@lingui/macro'; import type { Publication } from 'lens'; import type { FC } from 'react'; @@ -19,7 +19,7 @@ const ModAction: FC = ({ publication }) => {