xugenyuan

Revert "ref |> 新增埋点封装"

This reverts commit c7efaeda.

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
... ... @@ -268,18 +268,6 @@
]
}
]
},
{
"name": "wdTracking",
"srcPath": "./features/wdTracking",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}
\ No newline at end of file
... ...
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
\ No newline at end of file
export { TrackingModule } from "./src/main/ets/TrackingModule"
\ No newline at end of file
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
}
}
},
},
],
"targets": [
{
"name": "default"
}
]
}
\ No newline at end of file
import { hspTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
\ No newline at end of file
../../../../oh_modules/.ohpm/@sensorsdata+analytics@0.0.2/oh_modules/@sensorsdata/analytics
\ No newline at end of file
... ...
../../wdBean
\ No newline at end of file
... ...
../../../commons/wdConstant
\ No newline at end of file
... ...
../../../commons/wdKit
\ No newline at end of file
... ...
../../../commons/wdNetwork
\ No newline at end of file
... ...
import sensors from '@sensorsdata/analytics';
import { common } from '@kit.AbilityKit';
import { HostEnum, HostManager } from 'wdNetwork/Index';
/// 统计埋点模块
export class TrackingModule {
private static _init = false
static getHasInit() {
return TrackingModule._init;
}
/// 初始化
static startup(context: common.UIAbilityContext) {
// const isOnlineEnv = HostManager.getHost() === HostEnum.HOST_PRODUCT
//
// sensors.init({
// // 服务器接收地址
// server_url: isOnlineEnv ? '正式地址' : "测试地址",
// // Ability 上下文
// context: context,
// // 是否显示日志
// show_log: true,
// // 是否开启采集位置信息,需要 app 授权,默认 false
// enable_track_location: true,
// // 是否开启批量发送,默认 false
// batch_send: true,
// // 数据发送超时时间
// datasend_timeout: 10000,
// // 开启 App 打通 H5
// app_js_bridge: false
// });
// TrackingModule._init = true
}
}
\ No newline at end of file
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
import { SpConstants } from 'wdConstant/Index';
import { DeviceUtil, SPHelper, StringUtils } from 'wdKit/Index';
import { HostEnum, HostManager } from 'wdNetwork/Index';
export type ParamType = Record<string, string | number | boolean | Array<string>>
export class PublicParams {
getPublicParams() : Promise<ParamType> {
return new Promise((resolve) => {
let pub: ParamType = {
"userName":"",
"pdUseId":"",
"creatorId":"",
"pdCnsBirthday":"",
"city": PublicParams.getLocationCity(),
"sex":"",
"isSign":"0",
"environment": PublicParams.getEnv(),
"os": "harmonyos",
"actionTime": new Date().getTime() * 0.001,
"channel": "rmrb_china_0000",
"version": PublicParams.getVersionName(),
"deviceId": DeviceUtil.clientId(),
"model":"",
"mpaasId": PublicParams.getMpaasId(),
}
resolve(pub)
})
}
private static getEnv() {
switch (HostManager.getHost()) {
case HostEnum.HOST_UAT:
return "uat"
case HostEnum.HOST_SIT:
return "sit"
case HostEnum.HOST_PRODUCT:
return "prod"
case HostEnum.HOST_DEV:
return "dev"
default:
return "prod"
}
}
private static getLocationCity() {
let cityName = SPHelper.default.getSync(SpConstants.LOCATION_CITY_NAME, '') as string
if (StringUtils.isNotEmpty(cityName)) {
return encodeURI(cityName)
}
return ""
}
private static getBuildVersion() {
// TODO
return '202401242103';
}
private static getVersionCode() {
// TODO
return '10000';
}
private static getVersionName() {
// TODO 读取配置
return '1.0.0';
}
private static getMpaasId() {
// TODO
return 'alsjdflajxaljdlfjaldjfa';
}
}
import { Logger } from 'wdKit/Index';
import { TrackingModule } from '../TrackingModule';
import sensors from '@sensorsdata/analytics';
import { ParamType, PublicParams } from './PublicParams';
import { HashMap } from '@kit.ArkTS';
const TAG = "WDTracking"
export class Tracking {
static event(eventId: string, params?: ParamType) {
if (!TrackingModule.getHasInit()) {
Logger.warn(TAG, "还没有初始化 " + eventId + " " + JSON.stringify(params))
return
}
//TODO: 添加运行单独线程?
let publicParams = new PublicParams()
publicParams.getPublicParams().then((pubParams) => {
if (params) {
for (const obj of Object.entries(params)) {
Logger.info(TAG, ` ${obj[0]} => ` + `${obj[1]}`);
pubParams[obj[0]] = obj[1]
}
}
sensors.track(eventId, pubParams)
})
}
}
\ No newline at end of file
{
"module": {
"name": "wdTracking",
"type": "shared",
"description": "$string:shared_desc",
"deviceTypes": [
"phone",
"tablet",
"2in1"
],
"deliveryWithInstall": true,
"pages": "$profile:main_pages"
}
}
\ No newline at end of file
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "shared_desc",
"value": "埋点封装库"
}
]
}
\ No newline at end of file
import localUnitTest from './LocalUnit.test';
export default function testsuite() {
localUnitTest();
}
\ No newline at end of file
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function localUnitTest() {
describe('localUnitTest',() => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
});
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
});
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
});
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
});
it('assertContain', 0, () => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let a = 'abc';
let b = 'b';
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b);
expect(a).assertEqual(a);
});
});
}
\ No newline at end of file
... ... @@ -17,7 +17,6 @@
"wdNetwork": "file:../../commons/wdNetwork",
"wdHwAbility": "file:../../features/wdHwAbility",
"wdJsBridge": "file:../../commons/wdJsBridge",
"wdLogin": "file:../../features/wdLogin",
"wdTracking": "file:../../features/wdTracking"
"wdLogin": "file:../../features/wdLogin"
}
}
... ...
... ... @@ -13,7 +13,6 @@ import { LaunchPageModel } from '../viewModel/LaunchPageModel'
import LaunchDataModel from '../viewModel/LaunchDataModel'
import { Logger, SPHelper, UmengStats } from 'wdKit/Index';
import { SpConstants } from 'wdConstant/Index';
import { TrackingModule } from 'wdTracking/Index'
@Entry
@Component
... ... @@ -46,7 +45,6 @@ struct LaunchPage {
onConfirm() {
UmengStats.initAfterAgreeProtocol()
TrackingModule.startup(getContext(this) as common.UIAbilityContext)
// Save privacy agreement status.
this.saveIsPrivacy();
//跳转引导页
... ... @@ -99,7 +97,6 @@ struct LaunchPage {
} else {
UmengStats.initAfterAgreeProtocol()
TrackingModule.startup(getContext(this) as common.UIAbilityContext)
//需要根据请求数据判断是否需要进入广告页,广告数据为nil则直接跳转到首页
//获取本地存储的启动页数据
... ...