@chiyou/minigame-framework 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ import { LogUtils } from "../Utils/LogUtils";
3
3
  import { ServiceLocator } from "../Utils/ServiceLocator";
4
4
  import { BaseMgr } from "./BaseMgr";
5
5
  import { EventMgr } from "./EventMgr";
6
+ import { AnalyticsMgr } from "./AnalyticsMgr";
6
7
 
7
8
  /** 生命周期管理器 */
8
9
  export class LifeCycleMgr extends BaseMgr {
@@ -121,6 +122,11 @@ export class LifeCycleMgr extends BaseMgr {
121
122
  }
122
123
 
123
124
  this.getPlatformAdapter().onGameColdStart();
125
+
126
+ // 上报 GameLaunch 事件
127
+ const info = this.getPlatformAdapter().getColdStartSceneInfo();
128
+ const launchHour = new Date().getHours();
129
+ AnalyticsMgr.Instance.trackGameLaunch(info.scene, info.category, launchHour);
124
130
  }
125
131
 
126
132
  /**
@@ -147,30 +153,6 @@ export class LifeCycleMgr extends BaseMgr {
147
153
  EventMgr.Instance.emit(FrameworkBase.Message.LifeCycle_onGameHide);
148
154
  }
149
155
 
150
- /**
151
- * 是否从最近使用启动
152
- * @return 是否从最近使用启动
153
- */
154
- public isLaunchFromRecentUse(): boolean {
155
- if (this.getPlatformAdapter() === null) {
156
- return false;
157
- }
158
-
159
- return this.getPlatformAdapter().isLaunchFromRecentUse();
160
- }
161
-
162
- /**
163
- * 是否从桌面快捷方式启动
164
- * @return 是否从桌面快捷方式启动
165
- */
166
- public isLaunchFromDesktopShortcut(): boolean {
167
- if (this.getPlatformAdapter() === null) {
168
- return false;
169
- }
170
-
171
- return this.getPlatformAdapter().isLaunchFromDesktopShortcut();
172
- }
173
-
174
156
  /**
175
157
  * 是否支持跳转至最近使用
176
158
  * @param callback 回调函数
@@ -195,15 +177,30 @@ export class LifeCycleMgr extends BaseMgr {
195
177
  this.getPlatformAdapter().navigateToRecentUse();
196
178
  }
197
179
 
198
- /**
199
- * 是否从广告启动
200
- * @return 是否从广告启动
201
- */
202
- public isLaunchFromAdvertisement(): boolean {
180
+ /** 获取冷启动场景信息 */
181
+ public getColdStartSceneInfo(): { scene: string; category: string } | null {
182
+ if (this.getPlatformAdapter() === null) {
183
+ return null;
184
+ }
185
+
186
+ return this.getPlatformAdapter().getColdStartSceneInfo();
187
+ }
188
+
189
+ /** 获取热启动场景信息 */
190
+ public getWarmStartSceneInfo(): { scene: string; category: string } | null {
191
+ if (this.getPlatformAdapter() === null) {
192
+ return null;
193
+ }
194
+
195
+ return this.getPlatformAdapter().getWarmStartSceneInfo();
196
+ }
197
+
198
+ /** 获取当前启动场景分类(兼容原 isLaunchFromXxx 逻辑) */
199
+ public getLaunchCategory(): string | null {
203
200
  if (this.getPlatformAdapter() === null) {
204
- return false;
201
+ return null;
205
202
  }
206
203
 
207
- return this.getPlatformAdapter().isLaunchFromAdvertisement();
204
+ return this.getPlatformAdapter().getLaunchCategory();
208
205
  }
209
206
  }