Track referrals, add them to settings list

This commit is contained in:
Ian Philips 2022-07-01 07:28:48 -06:00
parent a6c8a16295
commit c42493479f
3 changed files with 19 additions and 4 deletions

View File

@ -117,7 +117,7 @@ function getAppropriateNotifications(
return notifications.filter(
(n) =>
n.reason &&
// Show all contract notifications
// Show all contract notifications and any that aren't in the above list:
(n.sourceType === 'contract' || !lessPriorityReasons.includes(n.reason))
)
if (notificationPreferences === 'none') return []

View File

@ -34,6 +34,7 @@ import { filterDefined } from 'common/util/array'
import { addUserToGroupViaSlug } from 'web/lib/firebase/groups'
import { removeUndefinedProps } from 'common/util/object'
import dayjs from 'dayjs'
import { track } from '@amplitude/analytics-browser'
export type { User }
@ -154,9 +155,18 @@ async function setCachedReferralInfoForUser(user: User | null) {
? cachedReferralContractId
: undefined,
})
).catch((err) => {
console.log('error setting referral details', err)
})
)
.catch((err) => {
console.log('error setting referral details', err)
})
.then(() => {
track('Referral', {
userId: user.id,
referredByUserId: referredByUser.id,
referredByContractId: cachedReferralContractId,
referredByGroupSlug: cachedReferralGroupSlug,
})
})
})
if (cachedReferralGroupSlug)

View File

@ -280,6 +280,7 @@ function NotificationGroupItem(props: {
)
}
// TODO: where should we put referral bonus notifications?
function NotificationSettings() {
const user = useUser()
const [notificationSettings, setNotificationSettings] =
@ -429,6 +430,10 @@ function NotificationSettings() {
highlight={notificationSettings !== 'none'}
label={"Activity on questions you're betting on"}
/>
<NotificationSettingLine
highlight={notificationSettings !== 'none'}
label={"Referral bonuses you've received"}
/>
<NotificationSettingLine
label={"Activity on questions you've ever bet or commented on"}
highlight={notificationSettings === 'all'}