Skip to content

Commit c816727

Browse files
committed
Track premium modal open times
1 parent d6bd26e commit c816727

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/app/components/Premium/Modal.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ import FeatureList, { FeatureId } from './FeatureList'
88
import PriceSection from './PriceSection'
99
import Testimonials from './Testimonials'
1010
import DiscountBadge from './DiscountBadge'
11+
import Browser from 'webextension-polyfill'
12+
13+
async function incrOpenTimes() {
14+
const { premiumModalOpenTimes = 0 } = await Browser.storage.sync.get('premiumModalOpenTimes')
15+
Browser.storage.sync.set({ premiumModalOpenTimes: premiumModalOpenTimes + 1 })
16+
return premiumModalOpenTimes + 1
17+
}
1118

1219
interface Props {
1320
open: boolean
@@ -21,7 +28,9 @@ const PremiumModal: FC<Props> = (props) => {
2128

2229
useEffect(() => {
2330
if (props.open) {
24-
trackEvent('show_premium_modal', { source: props.feature })
31+
incrOpenTimes().then((openTimes) => {
32+
trackEvent('show_premium_modal', { source: props.feature, openTimes })
33+
})
2534
}
2635
}, [props.open, props.feature])
2736

0 commit comments

Comments
 (0)