File tree Expand file tree Collapse file tree 5 files changed +26
-6
lines changed
components/EnhancedPromotionModal Expand file tree Collapse file tree 5 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 9595 "@types/canvas-confetti" : " ^1.6.0" ,
9696 "@types/echarts" : " ^4.9.18" ,
9797 "@types/file-saver" : " ^2.0.5" ,
98+ "@types/gtag.js" : " ^0.0.20" ,
9899 "@types/howler" : " ^2.2.3" ,
99100 "@types/mixpanel-browser" : " ^2.38.1" ,
100101 "@types/node" : " 18.14.6" ,
Original file line number Diff line number Diff line change 11import noop from '../../utils/noop'
22import { hasSeenEnhancedPromotionAtom } from '@/store'
3+ import { trackEvent } from '@/utils/trackEvent'
34import { Dialog , Transition } from '@headlessui/react'
4- import { track } from '@vercel/analytics'
55import { useAtom } from 'jotai'
66import type React from 'react'
77import { Fragment , useEffect , useState } from 'react'
@@ -24,7 +24,7 @@ const EnhancedPromotionModal: React.FC = () => {
2424 } , [ hasSeenPromotion ] )
2525
2626 const handleTryNow = ( ) => {
27- track ( 'promotion_event' , {
27+ trackEvent ( 'promotion_event' , {
2828 from : 'promotion_modal' ,
2929 action : 'open' ,
3030 action_detail : 'promotion_modal_open' ,
@@ -36,7 +36,7 @@ const EnhancedPromotionModal: React.FC = () => {
3636 }
3737
3838 const handleDismiss = ( ) => {
39- track ( 'promotion_event' , {
39+ trackEvent ( 'promotion_event' , {
4040 from : 'promotion_modal' ,
4141 action : 'close' ,
4242 action_detail : 'promotion_modal_close' ,
Original file line number Diff line number Diff line change 11import InfoPanel from '@/components/InfoPanel'
2- import { track } from '@vercel/analytics '
2+ import { trackEvent } from '@/utils/trackEvent '
33import { useCallback , useState } from 'react'
44import IconBook2 from '~icons/tabler/book-2'
55
@@ -8,7 +8,7 @@ export default function DictRequest() {
88
99 const onOpenPanel = useCallback ( ( ) => {
1010 setShowPanel ( true )
11- track ( 'promotion_event' , {
11+ trackEvent ( 'promotion_event' , {
1212 from : 'dict_request_button' ,
1313 action : 'open' ,
1414 action_detail : 'dict_request_button_open' ,
@@ -17,7 +17,7 @@ export default function DictRequest() {
1717
1818 const onClosePanel = useCallback ( ( ) => {
1919 setShowPanel ( false )
20- track ( 'promotion_event' , {
20+ trackEvent ( 'promotion_event' , {
2121 from : 'dict_request_panel' ,
2222 action : 'close' ,
2323 action_detail : 'dict_request_panel_close' ,
Original file line number Diff line number Diff line change 1+ import { track } from '@vercel/analytics'
2+
3+ export const trackEvent = ( event : string , properties : Record < string , string > ) => {
4+ track ( event , properties )
5+
6+ // @ts -expect-error gtag is not defined in the window object
7+ if ( typeof window !== 'undefined' && window ?. gtag ) {
8+ try {
9+ window . gtag ( 'event' , event , { ...properties } )
10+ } catch ( error ) {
11+ console . error ( error )
12+ }
13+ }
14+ }
Original file line number Diff line number Diff line change 23682368 resolved "https://registry.npmmirror.com/@types/file-saver/-/file-saver-2.0.5.tgz"
23692369 integrity sha512-zv9kNf3keYegP5oThGLaPk8E081DFDuwfqjtiTzm6PoxChdJ1raSuADf2YGCVIyrSynLrgc8JWv296s7Q7pQSQ==
23702370
2371+ " @types/gtag.js@^0.0.20 " :
2372+ version "0.0.20"
2373+ resolved "https://registry.npmjs.org/@types/gtag.js/-/gtag.js-0.0.20.tgz#e47edabb4ed5ecac90a079275958e6c929d7c08a"
2374+ integrity sha512-wwAbk3SA2QeU67unN7zPxjEHmPmlXwZXZvQEpbEUQuMCRGgKyE1m6XDuTUA9b6pCGb/GqJmdfMOY5LuDjJSbbg==
2375+
23712376" @types/history@^4.7.11 " :
23722377 version "4.7.11"
23732378 resolved "https://registry.npmmirror.com/@types/history/-/history-4.7.11.tgz"
You can’t perform that action at this time.
0 commit comments