Skip to content

Commit

Permalink
Revert "Revert "feat: move back to good old datadog"" (#1759)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Feb 8, 2023
1 parent 84d2092 commit ca8a237
Show file tree
Hide file tree
Showing 97 changed files with 401 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -42,7 +42,7 @@ const BasicSettings: FC<Props> = ({ 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`}
/>
Expand All @@ -63,7 +63,7 @@ const BasicSettings: FC<Props> = ({ 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`}
/>
Expand All @@ -81,7 +81,7 @@ const BasicSettings: FC<Props> = ({ 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`}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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"
>
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Composer/Actions/Attachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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}
/>
Expand All @@ -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}
/>
Expand All @@ -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}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -135,7 +135,7 @@ const CollectForm: FC<Props> = ({ 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 {
Expand Down Expand Up @@ -166,7 +166,7 @@ const CollectForm: FC<Props> = ({ 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);
}}
/>
<div className="lt-text-gray-500 text-sm font-bold">
Expand Down Expand Up @@ -249,7 +249,7 @@ const CollectForm: FC<Props> = ({ 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);
}}
/>
<div className="lt-text-gray-500 text-sm font-bold">
Expand Down Expand Up @@ -284,7 +284,7 @@ const CollectForm: FC<Props> = ({ 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);
}}
/>
<div className="lt-text-gray-500 text-sm font-bold">
Expand All @@ -306,7 +306,7 @@ const CollectForm: FC<Props> = ({ 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);
}}
/>
<div className="lt-text-gray-500 text-sm font-bold">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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"
>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Composer/Actions/Giphy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -32,7 +32,7 @@ const Giphy: FC<Props> = ({ 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}}
>
<div className="text-brand">
Expand All @@ -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);
}}
/>
<Module
Expand All @@ -90,7 +90,7 @@ const ReferenceSettings: FC = () => {
onClick={() => {
setSelectedReferenceModule(ReferenceModules.FollowerOnlyReferenceModule);
setOnlyFollowers(true);
Analytics.track(PUBLICATION.NEW.REFERENCE_MODULE.MY_FOLLOWERS);
Leafwatch.track(PUBLICATION.NEW.REFERENCE_MODULE.MY_FOLLOWERS);
}}
/>
<Module
Expand All @@ -100,7 +100,7 @@ const ReferenceSettings: FC = () => {
onClick={() => {
setSelectedReferenceModule(ReferenceModules.DegreesOfSeparationReferenceModule);
setDegreesOfSeparation(1);
Analytics.track(PUBLICATION.NEW.REFERENCE_MODULE.MY_FOLLOWS);
Leafwatch.track(PUBLICATION.NEW.REFERENCE_MODULE.MY_FOLLOWS);
}}
/>
<Module
Expand All @@ -110,7 +110,7 @@ const ReferenceSettings: FC = () => {
onClick={() => {
setSelectedReferenceModule(ReferenceModules.DegreesOfSeparationReferenceModule);
setDegreesOfSeparation(2);
Analytics.track(PUBLICATION.NEW.REFERENCE_MODULE.FRIENDS_OF_FRIENDS);
Leafwatch.track(PUBLICATION.NEW.REFERENCE_MODULE.FRIENDS_OF_FRIENDS);
}}
/>
</Menu.Items>
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/Composer/NewPublication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -148,14 +148,14 @@ const NewPublication: FC<Props> = ({ 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(() => {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Explore/FeedType.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -20,7 +20,7 @@ const FeedType: FC<Props> = ({ 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 },
Expand Down
11 changes: 8 additions & 3 deletions apps/web/src/components/Explore/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ 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';
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';
Expand All @@ -24,6 +25,10 @@ const Explore: NextPage = () => {
const [focus, setFocus] = useState<PublicationMainFocus>();
const router = useRouter();

useEffect(() => {
Leafwatch.track(PAGEVIEW, { page: 'explore' });
}, []);

const tabs = [
{ name: t`For you`, type: PublicationSortCriteria.CuratedProfiles },
{ name: t`Popular`, type: PublicationSortCriteria.TopCommented },
Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/Home/FeedType.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -24,7 +24,7 @@ const FeedType: FC<Props> = ({ setFeedType, feedType }) => {
showOnSm={false}
onClick={() => {
setFeedType('TIMELINE');
Analytics.track(MISCELLANEOUS.SWITCH_TIMELINE);
Leafwatch.track(MISCELLANEOUS.SWITCH_TIMELINE);
}}
/>
<TabButton
Expand All @@ -34,7 +34,7 @@ const FeedType: FC<Props> = ({ setFeedType, feedType }) => {
showOnSm={false}
onClick={() => {
setFeedType('HIGHLIGHTS');
Analytics.track(MISCELLANEOUS.SWITCH_HIGHLIGHTS);
Leafwatch.track(MISCELLANEOUS.SWITCH_HIGHLIGHTS);
}}
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Home/RecommendedProfiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -81,7 +81,7 @@ const RecommendedProfiles: FC = () => {
type="button"
onClick={() => {
setShowSuggestedModal(true);
Analytics.track(MISCELLANEOUS.OPEN_RECOMMENDED_PROFILES);
Leafwatch.track(MISCELLANEOUS.OPEN_RECOMMENDED_PROFILES);
}}
>
<DotsCircleHorizontalIcon className="h-4 w-4" />
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/Home/SeeThroughLens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -126,7 +126,7 @@ const SeeThroughLens: FC = () => {
className={clsx('cursor-pointer', searchText ? 'visible' : 'invisible')}
onClick={() => {
setSearchText('');
Analytics.track(SEARCH.CLEAR);
Leafwatch.track(SEARCH.CLEAR);
}}
/>
}
Expand Down Expand Up @@ -161,7 +161,7 @@ const SeeThroughLens: FC = () => {
onClick={() => {
setSeeThroughProfile(profile);
setSearchText('');
Analytics.track(MISCELLANEOUS.SELECT_USER_FEED);
Leafwatch.track(MISCELLANEOUS.SELECT_USER_FEED);
}}
>
<UserProfile linkToProfile={false} profile={profile} showUserPreview={false} />
Expand Down
Loading

2 comments on commit ca8a237

@vercel
Copy link

@vercel vercel bot commented on ca8a237 Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./apps/web

web-lenster.vercel.app
lenster.vercel.app
web-git-main-lenster.vercel.app
lenster.xyz

@vercel
Copy link

@vercel vercel bot commented on ca8a237 Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

api – ./apps/api

api-git-main-lenster.vercel.app
lenster-api.vercel.app
api-lenster.vercel.app
api.lenster.xyz

Please sign in to comment.