xugenyuan

ref |> Revert "ref |> Revert "ref |> 新增友盟统计""

This reverts commit b233489b.
{
"appKey": "662f39fecac2a664de284236",
"channel": "rmrb_china_0000"
}
\ No newline at end of file
... ...
... ... @@ -51,3 +51,5 @@ export { NetworkManager } from './src/main/ets/network/NetworkManager'
export { NetworkType } from './src/main/ets/network/NetworkType'
export { CustomToast } from './src/main/ets/reusable/CustomToast'
export { UmengStats } from "./src/main/ets/umeng/UmengStats"
... ...
... ... @@ -6,5 +6,8 @@
"description": "Please describe the basic information.",
"main": "Index.ets",
"version": "1.0.0",
"dependencies": {}
"dependencies": {
"@umeng/common": "^1.0.21",
"@umeng/analytics": "^1.0.19"
}
}
... ...
import { preInit, InternalPlugin, setLogEnabled, init, onEventObject, onProfileSignOff,
onProfileSignIn } from '@umeng/analytics';
import { common } from '@kit.AbilityKit';
import { AccountManagerUtils } from '../utils/AccountManagerUtils';
import { UserDataLocal } from '../utils/UserDataLocal';
import { EmitterUtils } from '../utils/EmitterUtils';
export class UmengStats {
private static _inited = false
// 启动时调用
static preInit(context: common.UIAbilityContext) {
// 需在 AppScope/resources/rawfile/umconfig.json 配置key和channel
preInit({
context: context.getApplicationContext(),
plugins: [new InternalPlugin()],
enableLog: true
});
}
// 在用户同意隐私政策后再调用此方法
static initAfterAgreeProtocol() {
init();
UmengStats._inited = true
UmengStats.onLogin()
UmengStats.event("testHarmony", {"key1": "value1"})
}
// TODO: 登录成功调用
static onLogin() {
AccountManagerUtils.isLogin().then((login) => {
if (!login) { return }
let userId = UserDataLocal.getUserId()
if (userId.length > 0) {
onProfileSignIn("USER", userId)
}
})
}
// TODO: 退出登录调用
static onLogout() {
onProfileSignOff()
}
// 属性key,128位以内的非空字符串,value为256位以内的数值或字符串
static event(eventId: string, param?: Record<string, string | number>) {
if (!UmengStats._inited) {
return
}
onEventObject(eventId, param);
}
}
\ No newline at end of file
... ...
... ... @@ -12,6 +12,7 @@ import {
NetworkType,
SPHelper,
StringUtils,
UmengStats,
WindowModel
} from 'wdKit';
import { HostEnum, HostManager, WDHttp } from 'wdNetwork';
... ... @@ -21,6 +22,7 @@ import { WDPushNotificationManager } from 'wdHwAbility/Index';
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
UmengStats.preInit(this.context)
SPHelper.init(this.context);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
registerRouter();
... ...
... ... @@ -11,7 +11,7 @@ import { WDRouterPage } from 'wdRouter';
import { LaunchModel } from '../viewModel/LaunchModel'
import { LaunchPageModel } from '../viewModel/LaunchPageModel'
import LaunchDataModel from '../viewModel/LaunchDataModel'
import { Logger, SPHelper } from 'wdKit/Index';
import { Logger, SPHelper, UmengStats } from 'wdKit/Index';
import { SpConstants } from 'wdConstant/Index';
@Entry
... ... @@ -44,6 +44,7 @@ struct LaunchPage {
}
onConfirm() {
UmengStats.initAfterAgreeProtocol()
// Save privacy agreement status.
this.saveIsPrivacy();
//跳转引导页
... ... @@ -94,6 +95,9 @@ struct LaunchPage {
this.dialogController.open();
// }
} else {
UmengStats.initAfterAgreeProtocol()
//需要根据请求数据判断是否需要进入广告页,广告数据为nil则直接跳转到首页
//获取本地存储的启动页数据
... ...