xugenyuan

ref |> 完善埋点统计

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
  1 +{
  2 + "meta": {
  3 + "stableOrder": true
  4 + },
  5 + "lockfileVersion": 3,
  6 + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
  7 + "specifiers": {
  8 + "@umeng/analytics@^1.0.19": "@umeng/analytics@1.0.19",
  9 + "@umeng/common@^1.0.21": "@umeng/common@1.0.21",
  10 + "libcommon.so@../../oh_modules/.ohpm/@umeng+common@1.0.21/oh_modules/@umeng/common/src/main/cpp/types/libcommon": "libcommon.so@../../oh_modules/.ohpm/@umeng+common@1.0.21/oh_modules/@umeng/common/src/main/cpp/types/libcommon"
  11 + },
  12 + "packages": {
  13 + "@umeng/analytics@1.0.19": {
  14 + "name": "@umeng/analytics",
  15 + "integrity": "sha512-0m9z5l8to+POjDl9UkCQC8s4P+e2E1OILwUglC7ME4QwqfH44e59GLJtQdwF0h6kwpsy3YBft4SoWK8MYbuP7g==",
  16 + "resolved": "https://ohpm.openharmony.cn/ohpm/@umeng/analytics/-/analytics-1.0.19.har",
  17 + "registryType": "ohpm"
  18 + },
  19 + "@umeng/common@1.0.21": {
  20 + "name": "@umeng/common",
  21 + "integrity": "sha512-EbXsd4OoRisTQf5egNY/+z1D2bvrYw9VwC2xu3EJA9TiDPSbnaJZ5+yltA/Se6yZ4oCcFvq6e5/AAfPuumunbw==",
  22 + "resolved": "https://ohpm.openharmony.cn/ohpm/@umeng/common/-/common-1.0.21.har",
  23 + "registryType": "ohpm",
  24 + "dependencies": {
  25 + "libcommon.so": "./src/main/cpp/types/libcommon"
  26 + }
  27 + },
  28 + "libcommon.so@../../oh_modules/.ohpm/@umeng+common@1.0.21/oh_modules/@umeng/common/src/main/cpp/types/libcommon": {
  29 + "name": "libcommon.so",
  30 + "resolved": "../../oh_modules/.ohpm/@umeng+common@1.0.21/oh_modules/@umeng/common/src/main/cpp/types/libcommon",
  31 + "registryType": "local"
  32 + }
  33 + }
  34 +}
1 -export { TrackingModule } from "./src/main/ets/TrackingModule"  
  1 +export { TrackingModule } from "./src/main/ets/TrackingModule"
  2 +
  3 +export { ParamType } from "./src/main/ets/common/PublicParams"
  4 +export { TrackConstants } from "./src/main/ets/common/TrackConstants"
  5 +export { TrackParamConvert } from "./src/main/ets/common/TrackParamConvert"
  6 +
  7 +export { Tracking } from "./src/main/ets/tracking/Tracking"
  8 +export { TrackingButton } from "./src/main/ets/tracking/TrackingButton"
  9 +export { TrackingContent } from "./src/main/ets/tracking/TrackingContent"
  10 +export { TrackingPageBrowse } from "./src/main/ets/tracking/TrackingPageBrowse"
  11 +export { TrackingPlay } from "./src/main/ets/tracking/TrackingPlay"
@@ -5,33 +5,41 @@ import { HostEnum, HostManager } from 'wdNetwork/Index'; @@ -5,33 +5,41 @@ import { HostEnum, HostManager } from 'wdNetwork/Index';
5 /// 统计埋点模块 5 /// 统计埋点模块
6 export class TrackingModule { 6 export class TrackingModule {
7 7
  8 + private static SA_DATA_SERVER_URL_PRODUCT = "https://data.pdnews.cn/sa?project=PDChinese"
  9 + private static SA_DATA_SERVER_URL_TEST = "https://data.pdnews.cn/sa?project=PDChineseTest"
  10 +
8 private static _init = false 11 private static _init = false
9 static getHasInit() { 12 static getHasInit() {
10 return TrackingModule._init; 13 return TrackingModule._init;
11 } 14 }
12 15
13 /// 初始化 16 /// 初始化
14 - static startup(context: common.UIAbilityContext) {  
15 -  
16 - // const isOnlineEnv = HostManager.getHost() === HostEnum.HOST_PRODUCT  
17 - //  
18 - // sensors.init({  
19 - // // 服务器接收地址  
20 - // server_url: isOnlineEnv ? '正式地址' : "测试地址",  
21 - // // Ability 上下文  
22 - // context: context,  
23 - // // 是否显示日志  
24 - // show_log: true,  
25 - // // 是否开启采集位置信息,需要 app 授权,默认 false  
26 - // enable_track_location: true,  
27 - // // 是否开启批量发送,默认 false  
28 - // batch_send: true,  
29 - // // 数据发送超时时间  
30 - // datasend_timeout: 10000,  
31 - // // 开启 App 打通 H5  
32 - // app_js_bridge: false  
33 - // });  
34 - // TrackingModule._init = true 17 + static startup(context: common.UIAbilityContext) : Promise<void> {
  18 +
  19 + return new Promise((resolve) => {
  20 + const isOnlineEnv = HostManager.getHost() === HostEnum.HOST_PRODUCT
  21 +
  22 + sensors.init({
  23 + //TODO: 服务器接收地址 暂时用测试环境的
  24 + server_url: isOnlineEnv ? TrackingModule.SA_DATA_SERVER_URL_TEST : TrackingModule.SA_DATA_SERVER_URL_TEST,
  25 + // Ability 上下文
  26 + context: context,
  27 + // 是否显示日志
  28 + show_log: true,
  29 + // 是否开启采集位置信息,需要 app 授权,默认 false
  30 + enable_track_location: true,
  31 + // 是否开启批量发送,默认 false
  32 + batch_send: true,
  33 + // 数据发送超时时间
  34 + datasend_timeout: 10000,
  35 + // 开启 App 打通 H5
  36 + app_js_bridge: false
  37 + }).then((inited) => {
  38 + TrackingModule._init = inited
  39 +
  40 + resolve()
  41 + });
  42 + })
35 } 43 }
36 44
37 45
1 import { SpConstants } from 'wdConstant/Index'; 1 import { SpConstants } from 'wdConstant/Index';
2 -import { DeviceUtil, SPHelper, StringUtils } from 'wdKit/Index'; 2 +import { AccountManagerUtils, AppUtils, DeviceUtil, SPHelper, StringUtils } from 'wdKit/Index';
3 import { HostEnum, HostManager } from 'wdNetwork/Index'; 3 import { HostEnum, HostManager } from 'wdNetwork/Index';
4 4
5 export type ParamType = Record<string, string | number | boolean | Array<string>> 5 export type ParamType = Record<string, string | number | boolean | Array<string>>
@@ -10,20 +10,20 @@ export class PublicParams { @@ -10,20 +10,20 @@ export class PublicParams {
10 return new Promise((resolve) => { 10 return new Promise((resolve) => {
11 11
12 let pub: ParamType = { 12 let pub: ParamType = {
13 - "userName":"",  
14 - "pdUseId":"",  
15 - "creatorId":"",  
16 - "pdCnsBirthday":"", 13 + "userName": SPHelper.default.getSync(SpConstants.USER_NAME, '') as string,
  14 + "pdUseId": SPHelper.default.getSync(SpConstants.USER_ID, '') as string,
  15 + "creatorId": SPHelper.default.getSync(SpConstants.USER_CREATOR_ID, '') as string,
  16 + "pdCnsBirthday": SPHelper.default.getSync(SpConstants.USER_BIRTHDAY, '') as string,
17 "city": PublicParams.getLocationCity(), 17 "city": PublicParams.getLocationCity(),
18 - "sex":"",  
19 - "isSign":"0", 18 + "sex":` ${SPHelper.default.getSync(SpConstants.USER_SEX, 0) as number}`,
  19 + "isSign": AccountManagerUtils.isLoginSync() ? "1" : "0",
20 "environment": PublicParams.getEnv(), 20 "environment": PublicParams.getEnv(),
21 - "os": "harmonyos", 21 + "os": AppUtils.getOSName(),
22 "actionTime": new Date().getTime() * 0.001, 22 "actionTime": new Date().getTime() * 0.001,
23 - "channel": "rmrb_china_0000",  
24 - "version": PublicParams.getVersionName(), 23 + "channel": AppUtils.getAppChannel(),
  24 + "version": AppUtils.getAppVersionName(),
25 "deviceId": DeviceUtil.clientId(), 25 "deviceId": DeviceUtil.clientId(),
26 - "model":"", 26 + "model": DeviceUtil.getMarketName() || "未知",
27 "mpaasId": PublicParams.getMpaasId(), 27 "mpaasId": PublicParams.getMpaasId(),
28 } 28 }
29 resolve(pub) 29 resolve(pub)
@@ -53,23 +53,8 @@ export class PublicParams { @@ -53,23 +53,8 @@ export class PublicParams {
53 return "" 53 return ""
54 } 54 }
55 55
56 - private static getBuildVersion() {  
57 - // TODO  
58 - return '202401242103';  
59 - }  
60 -  
61 - private static getVersionCode() {  
62 - // TODO  
63 - return '10000';  
64 - }  
65 -  
66 - private static getVersionName() {  
67 - // TODO 读取配置  
68 - return '1.0.0';  
69 - }  
70 -  
71 private static getMpaasId() { 56 private static getMpaasId() {
72 - // TODO 57 + // TODO: 新增mpaasId utdid
73 return 'alsjdflajxaljdlfjaldjfa'; 58 return 'alsjdflajxaljdlfjaldjfa';
74 } 59 }
75 } 60 }
  1 +export namespace TrackConstants {
  2 +
  3 + export enum EventType {
  4 + Show = 0,
  5 + Click = 1
  6 + }
  7 +
  8 + // 行为类型
  9 + export enum ActionType {
  10 + Show = "show", // 曝光/展示
  11 + DetailPageShow = "detailPageShow",
  12 + Collect = "collect",
  13 + CollectTag = "collectTag",
  14 + UnCollect = "uncollect",
  15 + Follow = "follow",
  16 + UnFollow = "unfollow",
  17 + Like = "like",
  18 + DisLike = "dislike",
  19 + Share = "share",
  20 + Comment = "comment",
  21 + Browse = "browse",
  22 + Download = "download",
  23 + Subscribe = "subscribe",
  24 + UnSubscribe = "unSubscribe",
  25 + CloseInterestCard = "closeInterestCard",
  26 + SelectInterestCard = "selectInterestCard",
  27 +
  28 + }
  29 +
  30 + // 分享聚道
  31 + export enum ShareChannelType {
  32 + Poster = "poster",
  33 + Wechat = "wechat",
  34 + Moments = "moments",
  35 + Sina = "sinaweibo",
  36 + Dingtalk = "dingTalk",
  37 + QQ = "qq",
  38 + Qzone = "qzone",
  39 + CopyLink = "copyLink",
  40 +
  41 + }
  42 +
  43 + // 专题类型
  44 + export enum SummaryType {
  45 + Live = "liveTopic",
  46 + Article = "articleTopic",
  47 + Audio = "audioTopic",
  48 + Talk = "talkTopic",
  49 + MorningAndEveningNews = "morningAndEveningNewsTopic",
  50 + TimeAxis = "timeAxisTopic"
  51 + }
  52 +
  53 + // 直播类别
  54 + export enum LiveType {
  55 + Subscribe = "liveSubscribe",
  56 + Running = "livePlaying",
  57 + End = "liveEnd"
  58 + }
  59 +
  60 + // 所属区域
  61 + export enum RegionName{
  62 + KaiPing = "0",
  63 + GuaJiao = "1",
  64 + Feed = "2",
  65 + CaiDan = "3",
  66 + }
  67 +
  68 + // 页面名称或页面id。这里是不包含运营配置页面的pageid的
  69 + export enum PageName {
  70 + DynamicDetail = "dynamicDetailPage",
  71 + VideoDetail = "videoDetailPage",
  72 + Live_Detail = "liveDetailPage",
  73 + /// 音频详情页
  74 + Audio_Detail = "audioDetailPage",
  75 + /// 音频正文页
  76 + Audio_Detail_Text = "audioTextPage",
  77 +
  78 + /// 图文详情页
  79 + Article_Detail = "articleDetailPage",
  80 + /// 图集详情页
  81 + Atlas_Detail = "atlasDetailPage",
  82 +
  83 + ///电子报页面
  84 + Eletronic_Paper = "newsPaperPage",
  85 +
  86 + /// 金刚位详情
  87 + KeyPosition = "diamondDetailPage",
  88 +
  89 + /// 问政详情页
  90 + Ask_Detail = "questionAnswerPage",
  91 + /// 专题详情页
  92 + Summary_Detail = "summaryDetailPage",
  93 + /// 搜索页
  94 + Search = "searchPage",
  95 + /// 我的
  96 + My = "myPage",
  97 +
  98 + /// 设置页
  99 + Setting = "settingPage",
  100 + /// 账号管理
  101 + Account_Management = "accountManagementPage",
  102 + /// 注销账户
  103 + Cancel_Account = "cancelAccountPage",
  104 +
  105 + /// 隐私设置
  106 + Privacy_Setting = "privacySettingPage",
  107 + /// 意见反馈
  108 + Feedback = "feedbackPage",
  109 + /// 关于
  110 + About = "aboutPage",
  111 +
  112 + /// 编辑资料
  113 + Edit_Information = "editInformationPage",
  114 + /// 登录页
  115 + Login_Page = "loginPage",
  116 + /// 手机号登录
  117 + Phone_Login_Page = "phoneNumberLoginPage",
  118 + /// 我的评论
  119 + My_Comment = "myCommentPage",
  120 + ///草稿箱
  121 + My_DraftBox = "draftBoxPage",
  122 +
  123 + /// 我的关注
  124 + My_Follow = "myFollowPage",
  125 + /// 我的收藏
  126 + My_Collect = "myCollectPage",
  127 + /// 浏览历史
  128 + My_History = "myHistoryPage",
  129 +
  130 + /// 消息
  131 + My_Notification = "myNotificationPage",
  132 +
  133 + /// 我的预约
  134 + My_Saved_Live = "mySavedLivePage",
  135 +
  136 + /// 兴趣选择
  137 + Preference_Selection = "preferenceSelectionPage",
  138 + /// 升级页面
  139 + Update = "updatePage",
  140 + /// 开屏广告页
  141 + Open_Screen = "openScreenPage",
  142 +
  143 + /// 新手引导页
  144 + Guide = "guidePage",
  145 + /// 启动页
  146 + Launch = "launchPage",
  147 +
  148 + /// 个人主页(主态)
  149 + Main_Personal = "mainPersonalPage",
  150 + /// 个人主页(客态)
  151 + Customer_Personal = "customerPersonalPage",
  152 +
  153 + /// 个人资料页
  154 + Personal_Data = "personalDataPage",
  155 + /// H5下载页面
  156 + H5download = "H5DownloadPage",
  157 +
  158 + /// 找回密码
  159 + Retrieve_Password = "retrievePasswordPage",
  160 + /// 重置密码
  161 + Reset_Password = "resetPasswordPage",
  162 +
  163 + /// 一键登录
  164 + OneClick_Login = "oneClickLoginPage",
  165 + /// 二维码扫描
  166 + QR_Scan = "QRCodeLoginPage",
  167 + /// 绑定手机号
  168 + Bind_PhoneNum = "bindPhoneNumberPage",
  169 +
  170 + /// 验证当前手机号
  171 + Checking_PhoneNum = "checkingPhoneNumberPage",
  172 +
  173 + /// 更改手机号
  174 + Change_PhoneNum = "changePhoneNumberPage",
  175 +
  176 + /// 设置密码
  177 + Setup_Passwd = "setPasswordPage",
  178 +
  179 + /// 修改密码
  180 + Change_Passwd = "changePasswordPage",
  181 +
  182 + /// 第三方账号绑定手机号
  183 + Third_Part_Account_Bind_PhoneNum = "bindingThirdNumberPage",
  184 +
  185 + /// 实名认证
  186 + RealName_Authentication = "realNameAuthenticationPage",
  187 +
  188 + /// 发布文章
  189 + Publish_Article = "publishArticlePage",
  190 +
  191 + /// 发布视频
  192 + Publish_Video = "publishVideoPage",
  193 +
  194 + /// 发布动态
  195 + Publish_Dynamic = "publishDynamicPage",
  196 +
  197 + /// 发布图集
  198 + Publish_Atlas = "publishAtlasPage",
  199 +
  200 + /// 举报评论
  201 + Report_Comment = "reportCommentsPage",
  202 +
  203 + /// 优质评论
  204 + Best_Comment = "bestCommentsPage",
  205 +
  206 + /// 举报内容
  207 + Report_Content = "reportContentPage",
  208 +
  209 + ///兴趣偏好页
  210 + Interest = "preferenceSelectionPage",
  211 + }
  212 +}
  1 +import { ContentDetailDTO } from 'wdBean/Index';
  2 +import { ParamType } from './PublicParams';
  3 +
  4 +export class TrackParamConvert {
  5 +
  6 + static convertContentDetail(detail: ContentDetailDTO) : ParamType {
  7 +
  8 + let param: ParamType = {
  9 + "contentType": detail.newsType.toFixed(0),
  10 + "contentId": detail.newsId,
  11 + "contentName": detail.newsTitle
  12 +
  13 + //TODO: 添加更多参数
  14 +
  15 +
  16 + }
  17 +
  18 + TrackParamConvert.appendRecommend(detail, param)
  19 + return param
  20 + }
  21 +
  22 + private static appendRecommend(detail: ContentDetailDTO, to: ParamType) {
  23 +
  24 + to["sceneId"] = "9999"
  25 + to["subSceneId"] = ""
  26 + to["cnsTraceId"] = "selfHold"
  27 + to["itemId"] = ""
  28 + to["expIds"] = ""
  29 +
  30 + /// 这里填写默认值,后续在分享处 再重写
  31 + to["shareChannel"] = ""
  32 + /// 这里填写默认值,后续在action=browse时,再重写
  33 + to["duration"] = 0
  34 + }
  35 +}
1 import { Logger } from 'wdKit/Index'; 1 import { Logger } from 'wdKit/Index';
2 import { TrackingModule } from '../TrackingModule'; 2 import { TrackingModule } from '../TrackingModule';
3 import sensors from '@sensorsdata/analytics'; 3 import sensors from '@sensorsdata/analytics';
4 -import { ParamType, PublicParams } from './PublicParams'; 4 +import { ParamType, PublicParams } from '../common/PublicParams';
5 import { HashMap } from '@kit.ArkTS'; 5 import { HashMap } from '@kit.ArkTS';
  6 +import { TrackConstants } from '../common/TrackConstants';
6 7
7 const TAG = "WDTracking" 8 const TAG = "WDTracking"
8 9
@@ -22,11 +23,10 @@ export class Tracking { @@ -22,11 +23,10 @@ export class Tracking {
22 23
23 if (params) { 24 if (params) {
24 for (const obj of Object.entries(params)) { 25 for (const obj of Object.entries(params)) {
25 - Logger.info(TAG, ` ${obj[0]} => ` + `${obj[1]}`); 26 + // Logger.info(TAG, ` ${obj[0]} => ` + `${obj[1]}`);
26 pubParams[obj[0]] = obj[1] 27 pubParams[obj[0]] = obj[1]
27 } 28 }
28 } 29 }
29 -  
30 sensors.track(eventId, pubParams) 30 sensors.track(eventId, pubParams)
31 }) 31 })
32 } 32 }
  1 +import { ParamType } from '../common/PublicParams';
  2 +import { Tracking } from './Tracking';
  3 +
  4 +export class TrackingButton {
  5 +
  6 + static click(buttonName: string, pageId: string, pageName: string, extParams?: ParamType) {
  7 +
  8 + if (!extParams) {
  9 + extParams = {}
  10 + }
  11 + extParams["pageName"] = pageName
  12 + extParams["pageId"] = pageId
  13 + extParams["clickButtonName"] = buttonName
  14 +
  15 + Tracking.event("name_click", extParams)
  16 + }
  17 +}
  1 +import { ParamType } from '../common/PublicParams'
  2 +import { TrackConstants } from "../common/TrackConstants"
  3 +
  4 +export class TrackingContent {
  5 +
  6 + /// 内容曝光/内容点击 事件
  7 + /// eventType 曝光 / 点击类型
  8 + /// pageName 如果是统一业务值 见 TrackConstants
  9 + /// pageId
  10 + /// extParams 模型转换成字段参数传值 转换方法见 TrackParamConvert
  11 + static common(eventType: TrackConstants.EventType, pageId: string, pageName: string, extParams: ParamType) {
  12 +
  13 + }
  14 +
  15 + static commonShare(shareType: number, pageId: string, pageName: string, extParams: ParamType) {
  16 +
  17 + }
  18 +
  19 + static like(like: boolean, pageId: string, pageName: string, extParams: ParamType) {
  20 +
  21 + }
  22 +
  23 + static collect(collect: boolean, pageId: string, pageName: string, extParams: ParamType) {
  24 +
  25 + }
  26 +
  27 + static follow(follow: boolean, followUserId: string, followUserName: string, pageId: string, pageName: string, extParams: ParamType) {
  28 +
  29 + }
  30 +
  31 + static commentClick(pageId: string, pageName: string, extParams: ParamType) {
  32 +
  33 + }
  34 +
  35 + static commentShare(pageId: string, pageName: string, extParams: ParamType) {
  36 +
  37 + }
  38 +
  39 + // 内容下载点击事件 1.图片 2.音频 3.视频
  40 + static download(donwloadContentType: number, pageId: string, pageName: string, extParams: ParamType) {
  41 +
  42 + }
  43 +
  44 +
  45 +}
  1 +export class TrackingPageBrowse {
  2 +
  3 +
  4 +}
  1 +import { ParamType } from '../common/PublicParams';
  2 +
  3 +/*
  4 + * 处理音频、视频、直播 正片播放、播放结束、播放错误等
  5 + * */
  6 +export class TrackingPlay {
  7 +
  8 + // 视频
  9 + static videoPositivePlay(prepareTime: number, pageId: string, pageName: string, extParams: ParamType) {
  10 +
  11 + }
  12 +
  13 + static videoPlayEnd(currentPlayTime: number, totalTime: number, browseTime: number, pageId: string, pageName: string, extParams: ParamType) {
  14 +
  15 + }
  16 +
  17 + static videoPlayError(errorInfo: string, pageId: string, pageName: string, extParams: ParamType) {
  18 +
  19 + }
  20 +
  21 +
  22 + // 音频
  23 + static audioPositivePlay(prepareTime: number, pageId: string, pageName: string, extParams: ParamType) {
  24 +
  25 + }
  26 +
  27 + static audioPlayEnd(currentPlayTime: number, totalTime: number, browseTime: number, pageId: string, pageName: string, extParams: ParamType) {
  28 +
  29 + }
  30 +
  31 + static audioPlayError(errorInfo: string, pageId: string, pageName: string, extParams: ParamType) {
  32 +
  33 + }
  34 +
  35 +
  36 + // 直播
  37 + static liveVideoPositivePlay(prepareTime: number, pageId: string, pageName: string, extParams: ParamType) {
  38 +
  39 + }
  40 +
  41 + static liveVideoPlayEnd(currentPlayTime: number, totalTime: number, browseTime: number, pageId: string, pageName: string, extParams: ParamType) {
  42 +
  43 + }
  44 +
  45 +}