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 🙏

© 2026 – Pkg Stats / Ryan Hefner

reflective

v1.0.0

Published

前端监控库

Readme

reflective-core

用于前端监控的核心库

手工代码埋点

  let reflective = new rft.Reflective();
  reflective.collect({});

声明代码埋点

目前支持的指令有rft-click,rft-input

vue目前支持的指令有v-rft-click,v-rft-input

  import { createApp } from 'vue'
  import App from './App.vue'
  import router from './router'
  import store from './store'
  import * as rft from 'reflective'
  import localforage from 'localforage'
  import { gzip } from 'pako'
  import axios from 'axios'

  // 创建Rft核心对象
  const refective = rft.Reflective.getInstance()
  // 创建vue根节点,但是别mount节点
  const app = createApp(App).use(store).use(router)

  const { ActionCollector, Vue2ActionCollector, Vue3ActionCollector } = {...rft.collecor}

  // 下面几种声明式收集器,根据平台环境选择一种即可
  // 1 基于Vue3自定义指令的声明埋点初始化 (根节点不能使用自定义指令)
  refective.inject(new Vue3ActionCollector(app))
  // 2 基于手工扫描自定义指令的声明埋点初始化
  // reflective.inject(new ActionCollector());
  // 扫描当前元素是否声明埋点,scan(true)时,会连同子节点遍历一起扫描
  // document.querySelector('.test').scan();
  // 3 基于Vue2自定义指令的声明埋点初始化
  // reflective.inject(new Vue2ActionCollector(Vue));

  const { LocalForageStore } = {...rft.store}
  // 基于LocalForage api的持久化插件
  // 参数1:localforage实例或者实现LocalForage api的自定义对象
  // 参数2:多长时间上报一次
  // 参数3:一次上报多少条埋点
  refective.inject(new LocalForageStore(localforage.createInstance({
  }), 5000, 10))

  const { StringTransformer } = {...rft.transformer}
  // 转换埋点信息为string的插件,传入一个将MonitorInfo[]转成string的方法,该方法中可用添加额外逻辑,比较对数据进行压缩
  // 如果没有改插件,则默认使用JSON.stringify对数据进行序列化
  refective.inject(new StringTransformer(function (data: MonitorInfo[]): string {
    return gzip(JSON.stringify(data), { to: 'string' })
  }))

  const { RestfulReport } = {...rft.reporter}
  // 上报组件,实现restful风格接口
  // 参数1:接口
  // 参数2:实现axios风格接口的对象
  refective.inject(new RestfulReport('http://www.baidu.com', axios))

  app.mount('#app')

web基本埋点

  import * as rft from 'reflective'

  const { WebCommonCollect } = {...rft.collecor}
  // 性能(基于performace获取当前页面加载速度), 异常(全局异常,资源加载异常,未捕获promise异常), 路由(通过拦截pushState和replaceState实现)
  const { PERFORMANCE, EXCEPTION, ROUTE } = {...rft.collector.WebCollectType}

  refective.inject(new WebCommonCollect([PERFORMANCE, EXCEPTION, ROUTE]))