diff --git a/src/scripts/inject-view/ad.vue b/src/scripts/inject-view/ad.vue index 95ccfe4..56dbf48 100644 --- a/src/scripts/inject-view/ad.vue +++ b/src/scripts/inject-view/ad.vue @@ -14,7 +14,7 @@ import { GA_EventName } from "../../ga/type"; import Banner from "./banner.vue"; import { emitter, Msg } from "./const"; import { AdItem, getAdData } from "./loader"; -import { ga } from "./util"; +import { sendGaEvent } from "./util"; const { CCButton } = ccui.components; export default defineComponent({ name: "ad", @@ -37,7 +37,7 @@ export default defineComponent({ ads.value = data.data.filter((item) => item.valid); console.log("get ads ", toRaw(ads.value)); - ga(GA_EventName.ShowAd); + sendGaEvent(GA_EventName.ShowAd); }); onUnmounted(() => {}); function testBanner() { diff --git a/src/scripts/inject-view/app.vue b/src/scripts/inject-view/app.vue index 323f9e2..3308b8c 100644 --- a/src/scripts/inject-view/app.vue +++ b/src/scripts/inject-view/app.vue @@ -26,7 +26,7 @@ import Ad from "./ad.vue"; import Banner from "./banner.vue"; import Memory from "./memory.vue"; import { appStore } from "./store"; -import { ga } from "./util"; +import { sendGaEvent } from "./util"; declare const cc: any; const { CCDialog, CCMenu } = ccui.components; interface ListItem { @@ -58,7 +58,7 @@ export default defineComponent({ const { config } = storeToRefs(appStore()); function doInspector() { unregisterPickShortKey(); - ga(GA_EventName.GameInspector); + sendGaEvent(GA_EventName.GameInspector); if (config.value.autoHide) { showBtns.value = false; } @@ -83,7 +83,7 @@ export default defineComponent({ width: 310, height: 500, closeCB: () => { - ga(GA_EventName.CloseAd); + sendGaEvent(GA_EventName.CloseAd); }, }); }, @@ -91,7 +91,7 @@ export default defineComponent({ { icon: "icon_do_play", click: (event: MouseEvent, item: ListItem) => { - ga(GA_EventName.GamePlayer); + sendGaEvent(GA_EventName.GamePlayer); if (typeof cc !== "undefined") { cc.game.resume(); } @@ -105,7 +105,7 @@ export default defineComponent({ visible: true, txt: "game pause", click: () => { - ga(GA_EventName.GamePause); + sendGaEvent(GA_EventName.GamePause); if (typeof cc !== "undefined") { cc.game.pause(); } @@ -117,7 +117,7 @@ export default defineComponent({ visible: true, txt: "game step", click: () => { - ga(GA_EventName.GameStep); + sendGaEvent(GA_EventName.GameStep); if (typeof cc !== "undefined") { cc.game.step(); } @@ -144,7 +144,7 @@ export default defineComponent({ enabled: inspectTarget.enabled, selected: inspectTarget.isContainInspectType(item.type), callback: (menu: IUiMenuItem) => { - ga(GA_EventName.MouseMenu, menu.name); + sendGaEvent(GA_EventName.MouseMenu, menu.name); if (menu.selected) { inspectTarget.removeInspectType(item.type); } else { @@ -159,7 +159,7 @@ export default defineComponent({ callback: (menu: IUiMenuItem) => { const event = new CustomEvent(DocumentEvent.InspectorClear); document.dispatchEvent(event); - ga(GA_EventName.MouseMenu, menu.name); + sendGaEvent(GA_EventName.MouseMenu, menu.name); }, }, { @@ -168,7 +168,7 @@ export default defineComponent({ callback: (menu: IUiMenuItem) => { config.value.pickTop = !config.value.pickTop; appStore().save(); - ga(GA_EventName.MouseMenu, menu.name); + sendGaEvent(GA_EventName.MouseMenu, menu.name); }, }, { type: ccui.menu.MenuType.Separator }, @@ -176,7 +176,7 @@ export default defineComponent({ name: "Filter Enabled", selected: inspectTarget.enabled, callback: (menu: IUiMenuItem) => { - ga(GA_EventName.MouseMenu, menu.name); + sendGaEvent(GA_EventName.MouseMenu, menu.name); inspectTarget.enabled = !inspectTarget.enabled; }, }, @@ -277,7 +277,7 @@ export default defineComponent({ callback: (item) => { config.value.autoHide = !config.value.autoHide; appStore().save(); - ga(GA_EventName.MouseMenu, item.name); + sendGaEvent(GA_EventName.MouseMenu, item.name); if (!config.value.autoHide) { clearTimeout(autoHideTimer); showBtns.value = true; diff --git a/src/scripts/inject-view/banner.vue b/src/scripts/inject-view/banner.vue index 4f67b69..cac65ea 100644 --- a/src/scripts/inject-view/banner.vue +++ b/src/scripts/inject-view/banner.vue @@ -12,7 +12,7 @@ import { defineComponent, onMounted, onUnmounted, PropType, ref, toRaw } from "v import { GA_EventName } from "../../ga/type"; import { emitter, Msg } from "./const"; import { AdItem } from "./loader"; -import { ga } from "./util"; +import { sendGaEvent } from "./util"; export default defineComponent({ name: "banner", props: { @@ -47,7 +47,7 @@ export default defineComponent({ const url = toRaw(props.data.store); if (url) { window.open(url); - ga(GA_EventName.ClickPluginLink, url); + sendGaEvent(GA_EventName.ClickPluginLink, url); } }, }; diff --git a/src/scripts/inject-view/util.ts b/src/scripts/inject-view/util.ts index 83d438c..d44b9d0 100644 --- a/src/scripts/inject-view/util.ts +++ b/src/scripts/inject-view/util.ts @@ -1,7 +1,7 @@ import { GA_EventName } from "../../ga/type"; import { DocumentEvent, GoogleAnalyticsData } from "../const"; -export function ga(event: GA_EventName, params: string = "") { +export function sendGaEvent(event: GA_EventName, params: string = "") { const detail = { event, params } as GoogleAnalyticsData; const e = new CustomEvent(DocumentEvent.GoogleAnalytics, { detail }); document.dispatchEvent(e);