Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add events for algorithms #3477

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/web/src/components/Home/Algorithms/List.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { algorithms } from '@lenster/data/algorithms';
import { HOME } from '@lenster/data/tracking';
import { Toggle } from '@lenster/ui';
import { Leafwatch } from '@lib/leafwatch';
import { type FC } from 'react';
import { useEnabledAlgorithmsPersistStore } from 'src/store/enabled-algorithms';

Expand Down Expand Up @@ -40,11 +42,16 @@ const List: FC = () => {
<Toggle
on={enabledAlgorithms.includes(algorithm.feedType)}
setOn={() => {
if (!enabledAlgorithms.includes(algorithm.feedType)) {
const enabled = enabledAlgorithms.includes(algorithm.feedType);
if (!enabled) {
enableAlgorithm(algorithm.feedType);
} else {
disableAlgorithm(algorithm.feedType);
}
Leafwatch.track(HOME.ALGORITHMS.TOGGLE_ALGORITHM, {
algorithm: algorithm.feedType,
enabled: !enabled
});
}}
/>
</div>
Expand Down
6 changes: 4 additions & 2 deletions apps/web/src/components/Home/Algorithms/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { algorithms } from '@lenster/data/algorithms';
import type { HomeFeedType } from '@lenster/data/enums';
import { MISCELLANEOUS } from '@lenster/data/tracking';
import { HOME } from '@lenster/data/tracking';
import { TabButton } from '@lenster/ui';
import { Leafwatch } from '@lib/leafwatch';
import type { Dispatch, FC } from 'react';
Expand Down Expand Up @@ -41,7 +41,9 @@ const Tabs: FC<FeedTypeProps> = ({ setFeedType, feedType }) => {
showOnSm
onClick={() => {
setFeedType(algorithm.feedType as HomeFeedType);
Leafwatch.track(MISCELLANEOUS.SWITCH_HIGHLIGHTS_FEED);
Leafwatch.track(HOME.ALGORITHMS.SWITCH_ALGORITHMIC_FEED, {
algorithm: algorithm.feedType
});
}}
/>
);
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/components/Home/Algorithms/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { SparklesIcon } from '@heroicons/react/outline';
import { HOME } from '@lenster/data/tracking';
import { Modal, Tooltip } from '@lenster/ui';
import { Leafwatch } from '@lib/leafwatch';
import { t } from '@lingui/macro';
import { type FC, useState } from 'react';

Expand All @@ -14,7 +16,7 @@ const Algorithms: FC = () => {
className="rounded-md p-1 hover:bg-gray-300/20"
onClick={() => {
setShowAlgorithmsModal(true);
// Leafwatch.track(MISCELLANEOUS.SWITCH_HIGHLIGHTS_FEED);
Leafwatch.track(HOME.ALGORITHMS.OPEN_ALGORITHMS);
}}
>
<Tooltip placement="top" content={t`Algorithms`}>
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Home/FeedType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { IS_MAINNET } from '@lenster/data/constants';
import { HomeFeedType } from '@lenster/data/enums';
import { FeatureFlag } from '@lenster/data/feature-flags';
import { MISCELLANEOUS } from '@lenster/data/tracking';
import { HOME } from '@lenster/data/tracking';
import isFeatureEnabled from '@lenster/lib/isFeatureEnabled';
import { TabButton } from '@lenster/ui';
import { Leafwatch } from '@lib/leafwatch';
Expand Down Expand Up @@ -37,7 +37,7 @@ const FeedType: FC<FeedTypeProps> = ({ setFeedType, feedType }) => {
active={feedType === HomeFeedType.FOLLOWING}
onClick={() => {
setFeedType(HomeFeedType.FOLLOWING);
Leafwatch.track(MISCELLANEOUS.SWITCH_FOLLOWING_FEED);
Leafwatch.track(HOME.SWITCH_FOLLOWING_FEED);
}}
/>
{isForYouEnabled && (
Expand All @@ -47,7 +47,7 @@ const FeedType: FC<FeedTypeProps> = ({ setFeedType, feedType }) => {
active={feedType === HomeFeedType.FOR_YOU}
onClick={() => {
setFeedType(HomeFeedType.FOR_YOU);
Leafwatch.track(MISCELLANEOUS.SWITCH_FOR_YOU_FEED);
Leafwatch.track(HOME.SWITCH_FOR_YOU_FEED);
}}
/>
)}
Expand All @@ -57,7 +57,7 @@ const FeedType: FC<FeedTypeProps> = ({ setFeedType, feedType }) => {
active={feedType === HomeFeedType.HIGHLIGHTS}
onClick={() => {
setFeedType(HomeFeedType.HIGHLIGHTS);
Leafwatch.track(MISCELLANEOUS.SWITCH_HIGHLIGHTS_FEED);
Leafwatch.track(HOME.SWITCH_HIGHLIGHTS_FEED);
}}
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Home/SeeThroughLens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UserProfile from '@components/Shared/UserProfile';
import { Menu } from '@headlessui/react';
import { XIcon } from '@heroicons/react/outline';
import { ChevronDownIcon } from '@heroicons/react/solid';
import { MISCELLANEOUS } from '@lenster/data/tracking';
import { HOME } from '@lenster/data/tracking';
import type {
FeedItem,
FeedRequest,
Expand Down Expand Up @@ -181,7 +181,7 @@ const SeeThroughLens: FC = () => {
onClick={() => {
setSeeThroughProfile(profile);
setSearchText('');
Leafwatch.track(MISCELLANEOUS.SELECT_USER_FEED, {
Leafwatch.track(HOME.SELECT_USER_FEED, {
see_through_profile: profile.id
});
}}
Expand Down
17 changes: 13 additions & 4 deletions packages/data/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ export const NOTIFICATION = {
SWITCH_NOTIFICATION_TAB: 'Switch notifications tab'
};

export const HOME = {
SWITCH_FOR_YOU_FEED: 'Switch to for you feed',
SWITCH_FOLLOWING_FEED: 'Switch to following feed',
SWITCH_HIGHLIGHTS_FEED: 'Switch to highlights feed',
SELECT_USER_FEED: 'Select user feed',
ALGORITHMS: {
OPEN_ALGORITHMS: 'Open algorithms modal',
TOGGLE_ALGORITHM: 'Toggle algorithm',
SWITCH_ALGORITHMIC_FEED: 'Switch to algorithmic feed'
}
};

export const EXPLORE = {
SWITCH_EXPLORE_FEED_TAB: 'Switch explore feed tab',
SWITCH_EXPLORE_FEED_FOCUS: 'Switch explore feed focus'
Expand Down Expand Up @@ -148,10 +160,6 @@ export const SYSTEM = {
export const MISCELLANEOUS = {
OPEN_RECOMMENDED_PROFILES: 'Open recommended profiles modal',
OPEN_TRENDING_TAG: 'Open trending tag',
SWITCH_FOR_YOU_FEED: 'Switch to for you feed',
SWITCH_FOLLOWING_FEED: 'Switch to following feed',
SWITCH_HIGHLIGHTS_FEED: 'Switch to highlights feed',
SELECT_USER_FEED: 'Select user feed',
SELECT_LOCALE: 'Select locale',
OPEN_LENS_WAITLIST: 'Open Lens waitlist',
FOOTER: {
Expand Down Expand Up @@ -193,6 +201,7 @@ export const ALL_EVENTS = {
...PROFILE,
...PUBLICATION,
...NOTIFICATION,
...HOME,
...EXPLORE,
...MESSAGES,
...SETTINGS,
Expand Down
Loading