From 039fc604f5a19ef49ce130b6cd3e1c2aee27eadc Mon Sep 17 00:00:00 2001 From: xu_yanfeng Date: Fri, 7 Feb 2025 14:23:05 +0800 Subject: [PATCH] game url --- src/ga/type.ts | 1 + src/scripts/inject/event.ts | 5 +++++ src/scripts/inject/inspector.ts | 1 + 3 files changed, 7 insertions(+) diff --git a/src/ga/type.ts b/src/ga/type.ts index a3a2ade..18c0d1a 100644 --- a/src/ga/type.ts +++ b/src/ga/type.ts @@ -79,6 +79,7 @@ export enum GA_EventName { Inspector = "Inspector", EngineVersion = "engine_version", AppVersion = "app_version", + GameUrl = "game_url", GamePlayer = "game_player", GamePause = "game_pause", GameStep = "game_step", diff --git a/src/scripts/inject/event.ts b/src/scripts/inject/event.ts index 47c8580..f4be7fd 100644 --- a/src/scripts/inject/event.ts +++ b/src/scripts/inject/event.ts @@ -29,4 +29,9 @@ export class InjectEvent { const event = new CustomEvent(DocumentEvent.GoogleAnalytics, { detail }); document.dispatchEvent(event); } + sendUrl(url: string) { + const detail = { event: GA_EventName.GameUrl, params: url } as GoogleAnalyticsData; + const event = new CustomEvent(DocumentEvent.GoogleAnalytics, { detail }); + document.dispatchEvent(event); + } } diff --git a/src/scripts/inject/inspector.ts b/src/scripts/inject/inspector.ts index 8e0caf7..b16aa80 100644 --- a/src/scripts/inject/inspector.ts +++ b/src/scripts/inject/inspector.ts @@ -214,6 +214,7 @@ export class Inspector extends InjectEvent { if (version) { this.hasUploadEngineVersion = true; this.sendEngineVersion(version); + this.sendUrl(window.location.href); } } forEachNode(cb: (node: any) => void) {