mirror of
https://github.com/RealKai42/qwerty-learner.git
synced 2026-04-04 22:09:04 +08:00
fix: event properties bug
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import noop from '../../utils/noop'
|
||||
import { hasSeenEnhancedPromotionAtom } from '@/store'
|
||||
import { trackEvent } from '@/utils/trackEvent'
|
||||
import { trackPromotionEvent } from '@/utils/trackEvent'
|
||||
import { Dialog, Transition } from '@headlessui/react'
|
||||
import { useAtom } from 'jotai'
|
||||
import type React from 'react'
|
||||
@@ -24,7 +24,7 @@ const EnhancedPromotionModal: React.FC = () => {
|
||||
}, [hasSeenPromotion])
|
||||
|
||||
const handleTryNow = () => {
|
||||
trackEvent('promotion_event', {
|
||||
trackPromotionEvent('promotion_event', {
|
||||
from: 'promotion_modal',
|
||||
action: 'open',
|
||||
action_detail: 'promotion_modal_open',
|
||||
@@ -36,7 +36,7 @@ const EnhancedPromotionModal: React.FC = () => {
|
||||
}
|
||||
|
||||
const handleDismiss = () => {
|
||||
trackEvent('promotion_event', {
|
||||
trackPromotionEvent('promotion_event', {
|
||||
from: 'promotion_modal',
|
||||
action: 'close',
|
||||
action_detail: 'promotion_modal_close',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import InfoPanel from '@/components/InfoPanel'
|
||||
import { trackEvent } from '@/utils/trackEvent'
|
||||
import { trackPromotionEvent } from '@/utils/trackEvent'
|
||||
import { useCallback, useState } from 'react'
|
||||
import IconBook2 from '~icons/tabler/book-2'
|
||||
|
||||
@@ -8,7 +8,7 @@ export default function DictRequest() {
|
||||
|
||||
const onOpenPanel = useCallback(() => {
|
||||
setShowPanel(true)
|
||||
trackEvent('promotion_event', {
|
||||
trackPromotionEvent('promotion_event', {
|
||||
from: 'dict_request_button',
|
||||
action: 'open',
|
||||
action_detail: 'dict_request_button_open',
|
||||
@@ -17,7 +17,7 @@ export default function DictRequest() {
|
||||
|
||||
const onClosePanel = useCallback(() => {
|
||||
setShowPanel(false)
|
||||
trackEvent('promotion_event', {
|
||||
trackPromotionEvent('promotion_event', {
|
||||
from: 'dict_request_panel',
|
||||
action: 'close',
|
||||
action_detail: 'dict_request_panel_close',
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { track } from '@vercel/analytics'
|
||||
|
||||
export const trackEvent = (event: string, properties: Record<string, string>) => {
|
||||
export const trackPromotionEvent = (event: string, properties: Record<string, string>) => {
|
||||
track(event, properties)
|
||||
|
||||
// @ts-expect-error gtag is not defined in the window object
|
||||
if (typeof window !== 'undefined' && window?.gtag) {
|
||||
try {
|
||||
window.gtag('event', event, { ...properties })
|
||||
if (properties.action_detail) {
|
||||
window.gtag('event', properties.action_detail)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user