Skip to content

Commit

Permalink
chore: add events for collect form (#1453)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Dec 25, 2022
1 parent c8edba7 commit c2afc4e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const BasicSettings: FC<Props> = ({ setShowModal }) => {
return toast.error('Enable collect first to use collect based token gating');
}
setCollectToView(!collectToView);
Analytics.track(PUBLICATION.NEW.ACCESS.TOGGLE_COLLECT_TO_VIEW);
Analytics.track(PUBLICATION.NEW.ACCESS.TOGGLE_COLLECT_TO_VIEW_ACCESS);
}}
label="People need to collect it first to be able to view it"
/>
Expand All @@ -76,7 +76,7 @@ const BasicSettings: FC<Props> = ({ setShowModal }) => {
on={followToView}
setOn={() => {
setFollowToView(!followToView);
Analytics.track(PUBLICATION.NEW.ACCESS.TOGGLE_FOLLOW_TO_VIEW);
Analytics.track(PUBLICATION.NEW.ACCESS.TOGGLE_FOLLOW_TO_VIEW_ACCESS);
}}
label="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 @@ -10,13 +10,15 @@ import {
SwitchHorizontalIcon,
UserGroupIcon
} from '@heroicons/react/outline';
import { Analytics } from '@lib/analytics';
import type { Erc20 } from 'lens';
import { CollectModules, useEnabledModulesQuery } from 'lens';
import type { Dispatch, FC } from 'react';
import { useEffect } from 'react';
import { useAccessSettingsStore } from 'src/store/access-settings';
import { useAppStore } from 'src/store/app';
import { useCollectModuleStore } from 'src/store/collect-module';
import { PUBLICATION } from 'src/tracking';

interface Props {
setShowModal: Dispatch<boolean>;
Expand Down Expand Up @@ -130,6 +132,7 @@ const CollectForm: FC<Props> = ({ setShowModal }) => {
}

const toggleCollect = () => {
Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_COLLECT_MODULE);
if (selectedCollectModule === RevertCollectModule) {
return setSelectedCollectModule(FreeCollectModule);
} else {
Expand All @@ -152,7 +155,13 @@ const CollectForm: FC<Props> = ({ setShowModal }) => {
<span>Charge for collecting</span>
</div>
<div className="flex items-center space-x-2">
<Toggle on={Boolean(amount)} setOn={() => setAmount(amount ? null : '0')} />
<Toggle
on={Boolean(amount)}
setOn={() => {
setAmount(amount ? null : '0');
Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_CHARGE_FOR_COLLECT);
}}
/>
<div className="lt-text-gray-500 text-sm font-bold">
Get paid whenever someone collects your post
</div>
Expand Down Expand Up @@ -225,7 +234,10 @@ const CollectForm: FC<Props> = ({ setShowModal }) => {
<div className="flex items-center space-x-2">
<Toggle
on={Boolean(collectLimit)}
setOn={() => setCollectLimit(collectLimit ? null : '1')}
setOn={() => {
setCollectLimit(collectLimit ? null : '1');
Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_LIMITED_EDITION_COLLECT);
}}
/>
<div className="lt-text-gray-500 text-sm font-bold">Make the collects exclusive</div>
</div>
Expand All @@ -251,7 +263,13 @@ const CollectForm: FC<Props> = ({ setShowModal }) => {
<span>Time limit</span>
</div>
<div className="flex items-center space-x-2">
<Toggle on={hasTimeLimit} setOn={() => setHasTimeLimit(!hasTimeLimit)} />
<Toggle
on={hasTimeLimit}
setOn={() => {
setHasTimeLimit(!hasTimeLimit);
Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_TIME_LIMIT_COLLECT);
}}
/>
<div className="lt-text-gray-500 text-sm font-bold">Limit collecting to the first 24h</div>
</div>
</div>
Expand All @@ -263,7 +281,13 @@ const CollectForm: FC<Props> = ({ setShowModal }) => {
<span>Who can collect</span>
</div>
<div className="flex items-center space-x-2">
<Toggle on={followerOnly} setOn={() => setFollowerOnly(!followerOnly)} />
<Toggle
on={followerOnly}
setOn={() => {
setFollowerOnly(!followerOnly);
Analytics.track(PUBLICATION.NEW.COLLECT_MODULE.TOGGLE_FOLLOWERS_ONLY_COLLECT);
}}
/>
<div className="lt-text-gray-500 text-sm font-bold">Only followers can collect</div>
</div>
</div>
Expand Down
11 changes: 8 additions & 3 deletions apps/web/src/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ export const PUBLICATION = {
UPLOAD_AUDIO: 'select_upload_audio'
},
COLLECT_MODULE: {
OPEN_COLLECT_SETTINGS: 'open_collect_module_settings'
OPEN_COLLECT_SETTINGS: 'open_collect_module_settings',
TOGGLE_COLLECT_MODULE: 'toggle_collect_module',
TOGGLE_CHARGE_FOR_COLLECT: 'toggle_charge_for_collect',
TOGGLE_LIMITED_EDITION_COLLECT: 'toggle_limited_edition_collect',
TOGGLE_TIME_LIMIT_COLLECT: 'toggle_time_limit_collect',
TOGGLE_FOLLOWERS_ONLY_COLLECT: 'toggle_followers_only_collect'
},
REFERENCE_MODULE: {
OPEN_REFERENCE_SETTINGS: 'open_reference_module_settings',
Expand All @@ -76,8 +81,8 @@ export const PUBLICATION = {
ACCESS: {
OPEN_ACCESS_SETTINGS: 'open_access_settings',
TOGGLE_RESTRICTED_ACCESS: 'toggle_restricted_access',
TOGGLE_COLLECT_TO_VIEW: 'toggle_collect_to_view',
TOGGLE_FOLLOW_TO_VIEW: 'toggle_follow_to_view'
TOGGLE_COLLECT_TO_VIEW_ACCESS: 'toggle_collect_to_view_access',
TOGGLE_FOLLOW_TO_VIEW_ACCESS: 'toggle_follow_to_view_access'
}
}
};
Expand Down

1 comment on commit c2afc4e

@vercel
Copy link

@vercel vercel bot commented on c2afc4e Dec 25, 2022

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-git-main-lenster.vercel.app
lenster.vercel.app
web-lenster.vercel.app
lenster.xyz

Please sign in to comment.