npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cloudcare/rum-uniapp

v2.1.23

Published

DataFlux RUM 小程序 端数据指标监控

Downloads

44

Readme

基于 uniapp 开发框架 兼容各平台小程序 DataFlux RUM 数据采集 SDK

通过引入 sdk 文件,监控小程序性能指标,错误 log,以及资源请求情况数据,上报到 DataFlux 平台 datakit

使用方法

在 uniapp 项目入口文件main.js文件头部位置以如下方式引入代码

npm 引入(可参考 uniapp 官方npm 引入方式)

//#ifndef H5 || APP-PLUS || APP-NVUE || APP-PLUS-NVUE
const { datafluxRum } = require('@cloudcare/rum-uniapp')
// 初始化 Rum
datafluxRum.init({
  datakitOrigin: 'https://datakit.xxx.com/', // 必填,Datakit域名地址 需要在微信小程序管理后台加上域名白名单
  applicationId: 'appid_xxxxxxx', // 必填,dataflux 平台生成的应用ID
  env: 'testing', // 选填,小程序的环境
  version: '1.0.0', // 选填,小程序版本
  trackInteractions: true, // 用户行为数据
})
//#endif

CDN 下载文件本地方式引入(下载地址)

//#ifndef H5 || APP-PLUS || APP-NVUE || APP-PLUS-NVUE
const { datafluxRum } = require('@cloudcare/rum-uniapp')
// 初始化 Rum
datafluxRum.init({
  datakitOrigin: 'https://datakit.xxx.com/', // 必填,Datakit域名地址 需要在微信小程序管理后台加上域名白名单
  applicationId: 'appid_xxxxxxx', // 必填,dataflux 平台生成的应用ID
  env: 'testing', // 选填,小程序的环境
  version: '1.0.0', // 选填,小程序版本
  trackInteractions: true, // 用户行为数据
})
//#endif

配置

初始化参数

| 参数 | 类型 | 是否必须 | 默认值 | 描述 | | ----------------------------------------------- | -------- | -------------------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | applicationId | String | 是 | | 从 dataflux 创建的应用 ID | | datakitOrigin | String | 是 | | datakit 数据上报 Origin;注意:需要在小程序管理后台加上request白名单 | | site | String | 是(公网dataway上报方式 必填) | | (SDK 版本要求 > 2.1.20 )公网 DataWay 对应站点的域名 注释: 协议(包括://),域名(或IP地址)[和端口号] 例如:https://www.datakit.com, http://100.20.34.3:8088 | | clientToken | String | 是 (公网dataway 必填) | | (SDK 版本要求 > 2.1.20 )公网 DataWay 上报所需的客户端 token,在观测云控制台创建应用时生成 | | env | String | 否 | | 小程序 应用当前环境, 如 prod:线上环境;gray:灰度环境;pre:预发布环境 common:日常环境;local:本地环境; | | service | String | 否 | | 小程序应用 服务名称,可 用于 apm 关联 tag | | version | String | 否 | | 小程序 应用的版本号 | | sampleRate | Number | 否 | 100 | 指标数据收集百分比: 100表示全收集,0表示不收集 | | traceType $\color{#FF0000}{新增}$ | Enum | 否 | ddtrace | 与 APM 采集工具连接的请求 header 类型,目前兼容的类型包括:ddtracezipkinskywalking_v3jaegerzipkin_single_headerw3c_traceparent注: opentelemetry 支持 zipkin_single_header,w3c_traceparent,zipkin三种类型 | | traceId128Bit $\color{#FF0000}{新增}$ | Boolean | 否 | false | 是否以 128 位的方式生成 traceID,与traceType 对应,目前支持类型 zipkinjaeger | | allowedTracingOrigins $\color{#FF0000}{新增}$ | Array | 否 | [] | 允许注入 trace 采集器所需 header 头部的所有请求列表。可以是请求的 origin,也可以是是正则,origin: 协议(包括://),域名(或IP地址)[和端口号] 例如:["https://api.example.com", /https:\/\/.*\.my-api-domain\.com/] | | trackInteractions | Boolean | 否 | false | 是否开启用户行为采集 | | isIntakeUrl | Function | 否 | function(url) {return false} | 自定义方法根据请求资源 url 判断是否需要采集对应资源数据,默认都采集。 返回:false 表示要采集,true 表示不需要采集 该参数 方法返回结果必须为 Boolean 类型, 否则认为是无效参数 |

注意事项

  1. datakitOrigin 所对应的 datakit 域名必须在小程序管理后台加上 request 白名单
  2. 目前各平台小程序在性能数据 api 暴露这块,并没有完善统一,所以导致一些性能数据并不能完善收集,比如小程序启动小程序包下载脚本注入 等一些数据除微信平台外,都有可能会存在缺失的情况。
  3. 目前各平台小程序请求资源 APIuni.requestuni.downloadFile返回数据中profile字段目前只有微信小程序 ios 系统不支持返回,所以会导致收集的资源信息中和 timing 相关的数据收集不全。目前暂无解决方案,request, downloadFile ;API 支持情况
  4. trackInteractions 用户行为采集开启后,因为微信小程序的限制,无法采集到控件的内容和结构数据,所以在小程序 SDK 里面我们采取的是声明式编程,通过在 模版 里面设置 data-name 属性,可以给 交互元素 添加名称,方便后续统计是定位操作记录, 例如:
<button bindtap="bindSetData" data-name="setData">
  setData
</button>