tq-jczl4-bury
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

tq-jczl4-bury

基层治理4平台埋点sdk,h5和pc共用

目录

使用

安装依赖

yarn add tq-jczl4-bury@latest

使用方法

import TQ_JCZL4_BURY, { BURY_TAGS, PLAT_FORM } from 'tq-jczl4-bury'

// 初始化埋点信息
TQ_JCZL4_BURY.init({
    platForm: PLAT_FORM.MOBILE, // 1 pc端 2 APP端
    systemLogo: 'jczl',
    orgId: _user.data.organizationId,
    orgLevel: _user.data.orgLevel,
    userId: _user.data.id,
    url: '/operating/audit', // 请求接口
    needCallBack: false,
})

// 推送埋点tag
TQ_JCZL4_BURY.pushTag(BURY_TAGS.APP.NAVIGATION.SY)

// 同步推送埋点tag
TQ_JCZL4_BURY.pushTagSync(BURY_TAGS.APP.NAVIGATION.SY)

// 异步推送埋点tag
TQ_JCZL4_BURY.pushTagAsync(BURY_TAGS.PC.NAVIGATION.SY).then(res => {
    console.log(res)
}).catch(err => {
    console.log(err)
})

结构

   +-- src ----------------------------------------------> 源码目录
   |   |
   |   +-- constants ---------------------------------------> 变量定义
   |   |   |
   |   |   +-- tags.tsx ---------------------------------------> 埋点tag
   |   |   |
   |   |   +-- plat_form.tsx ---------------------------------------> 平台类型
   |   |   |
   |   |   +-- index.tsx ---------------------------------------> 变量导出集合
   |   |
   |   +-- types ---------------------------------------> 类型定义
   |   |   |
   |   |   +-- index.tsx ---------------------------------------> 类型定义集合
   |   |
   |   +-- utils ---------------------------------------> 工具方法定义
   |   |   |
   |   |   +-- http.tsx ---------------------------------------> 接口请求工具
   |   |   |
   |   |   +-- store.tsx ---------------------------------------> 存储工具
   |   |   |
   |   |   +-- index.tsx ---------------------------------------> 工具导出集合
   |   |
   |   +-- index.tsx ---------------------------------------> 项目入口,方法统一集合
   |
   +-- package.json -------------------------------------> 项目信息/版本/npm脚本/依赖
   +-- README.md ----------------------------------------> 说明文档

需求分析

一、用户点击对应模块或功能,上传信息

1、需要上传的“模块或功能”,看 src/constants/tags.tsx 文件定义;
2、上传方法看使用方法

系统设计

一、用户点击对应模块或功能,上传信息

1、src/index.tsx 里,通过 TQ_JCZL4_BURY.init 初始化埋点信息,将埋点信息通过 StoreUtil.InitData 存储到 localStorage;

2、通过 TQ_JCZL4_BURY.pushTag(BURY_TAGS.PC.NAVIGATION.SY) 上传对应的埋点信息,会将存储的信息一并上传;

上传到npmjs

1、更改 package.json 里的 version 版本号 +1 ;
2、执行 yarn build 构建新包;
3、执行 nrm use npm ,切换环境到 npm ;
4、执行 npm login ,账号:? 密码: ? 邮箱:? ;
5、需要输入邮箱验证码;
6、执行 npm publish , 上传版本包;
7、执行 nrm use tianque 切换环境;
8、若在 yarn add tq-jczl4-bury@latest,安装最新版本时没有新版本包时,可以到淘宝镜像地址 https://npmmirror.com/,搜索包名,点击 sync 同步;

更新

2022-09-01

1、提供同步 pushTagSync 和异步 pushTagAsync 埋点方法;
2、获取存储 StoreUtil.get() 方法里,对于 storeInfo 设置默认值 {},防止未初始化进行埋点时报错;
3、版本更新 1.0.4 ;

Readme

Keywords

Package Sidebar

Install

npm i tq-jczl4-bury

Weekly Downloads

2

Version

1.0.5

License

ISC

Unpacked Size

32.2 kB

Total Files

28

Last publish

Collaborators

  • starxqqqq