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

@itmirror/im-track-jssdk

v1.7.3

Published

前端埋点js-sdk,支持原生、Vue使用

Downloads

2

Readme

@itmirror/im-track-jssdk

前端埋点js-sdk,支持原生、Vue使用

安装

npm i @itmirror/im-track-jssdk --save

浏览器中使用

// 原生调用
<script src="./lib/index.js"></script>
imTrack.init({
    url: 'http://demo.com/api/log',
    type: 'post'
})
// 保存日志到发送队列
imTrack.addToQueue('eventName', {user: 'bob'});
// get方式提交一条日志
imTrack.get('eventName', {user: 'bob', type: 'get'});
// post方式提交一条日志
imTrack.post('eventName', {user: 'bob', type: 'post'});
// 设置附加信息
imTrack.setAttach({eid: 'eid123', shop: 'shop023'});
// 增加一条附加信息
imTrack.addAttach('user', 'bob');
// 删除一条附加信息
imTrack.removeAttach('user');
// 设置事件触发回调
imTrack.setEventCallback((data) => {
    console.log('event callback data:', data)
});

Vue中使用

import imTrack from '@itmirror/im-track-jssdk'
Vue.use(imTrack)
this.imTrack.init({
    app: 'vue-demo',
    url: '/api/common/log',
    attach: { os: 'ios' },
    eventCallback: (data) => {
        console.log('imTrack:', data)
    }
})
// 保存日志到发送队列
this.imTrack.addToQueue('vue-log', {user: 'bob'})
// get方式提交一条日志
this.imTrack.get('vue-log', {user: 'bob', type: 'get'});
// post方式提交一条日志
this.imTrack.post('vue-log', {user: 'bob', type: 'post'});
// 设置附加信息
this.imTrack.setAttach({eid: 'eid123', shop: 'shop023'});
// 增加一条附加信息
this.imTrack.addAttach('user', 'bob');
// 删除一条附加信息
this.imTrack.removeAttach('user');
// 设置事件触发回调
this.imTrack.setEventCallback((data) => {
    console.log('event callback data:', data)
});
// click事件
<div v-track:click="{commodityId: _id, name: 'commodity-click'}"></div>
// scroll事件
<div v-track:scroll="{commodityId: _id, name: 'detail-scroll'}"></div>

参数

| 字段 | 默认值 | 类型 | 描述 | | :---------: | :---------: | :---------: | :---------: |
|url|''|String|日志上传接口|
|type|'beacon'|String|请求方式: beacon、get、post,空时不会上报|
|attach|null|Any|数据上传附加的信息|
|delayTime|2000|Number|上报延迟时间,该时间内会累计事件再统一上报,单位毫秒|
|history|true|Boolean|是否监听 history 变更事件|
|hashchange | true | Boolean| 是否监听 hash 变更事件 |
|http | true | Boolean| 是否监听 http 请求错误事件,包含 >= 400 的响应 |
|error | true | Boolean| 是否监听错误事件 |
|errorMaxDuplicate | 1 | Number| 重复上报错误的次数 |
|click | true | Boolean| 是否监听 click 事件 |
|scroll | true | Boolean| 是否监听 window.scroll 事件,只记录scroll停止时的值,300ms未滚动即认为滚动停止 |
|eventCallback | null | Function| 事件触发回调 |

上报数据

结构: {event: 'eventName', data: {}}

  • app@TP: 页面停留时间统计
  • app@Click: click事件
  • app@Scroll: scroll事件
  • app@Error: 错误事件
  • app@$Click: vue钩子绑定的click事件
  • app@$Scroll: vue钩子绑定的scroll事件