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

ic-vue-track

v1.1.0

Published

A Vue directive for statistics

Downloads

1

Readme

v-track

Aim of this plugin: in some scenarios, we want to track user's action with the third statistics code, these codes polluted our business code. If we placed these code in a individual place that is pretty good, so this plugin is borned.

Install

$ npm i ic-vue-track || yarn add ic-vue-track

Usage

Assuming you are using cnzz then you can use it as below:

import Vue from 'vue'
import IcVueTrack from 'ic-vue-track'

Vue.use(IcVueTrack, options)

The options is an object with your statistics code:

export default {
    shareButton () {
        _czc.push([
          '_trackEvent',
          '用户在该页面分享的意愿',
          `职位首页_点击分享图标_按钮点击`,
          '用户在该页面分享的意愿'
        ])
    },
    'search-button' () {
        _czc.push([
          '_trackEvent',
          '搜索功能使用的频次',
          `职位首页_点击搜索图标_按钮点击`,
          '搜索功能使用的频次'
        ])
    },
    'filter' (headerTitle, name) {
        _czc.push([
          '_trackEvent',
          '用户对不同筛选项的使用频次',
          `职位首页_职位列表页筛选项_${headerTitle}_${name}_按钮点击`,
          '用户对不同筛选项的使用频次'
        ])
    }
}

The example above, the key of options is a indentifier for directive's arg, so the directive in template like this:

<div v-track:search-button>
    
</div>

If the statistics code receive some params, you can pass an array to it:

<div v-track:filter="[headerTitle, name]">
    
</div>

If you use it on a component and triggered element is not the el of this directive but it's children, thats you can pass an object to this directive with triggers and params props and the arg is a string separate by pipes('|'):

<component
    v-track:search-button|filter="{
        triggers: ['.class-name', '#id'],
        params: [[], [headerTitle, name]]
    }">
</component>

::: warning In this case, the order of arg、triggers and params must be one-to-one matched. Internally, we find target node by a selector .class-name in triggers and execute search-button statistics code and passed [] to it in a handler. The order of rest is similar. :::

Also, you can pass a router instance and a global guard to options to track action of page-level:

main.js

import Vue from 'vue'
import IcVueTrack from 'ic-vue-track'
import router from '/some/path/router'
import trackConfig from '/some/path/track'

Vue.use(IcVueTrack, { router, ...trackConfig })
export default {
    afterEach (to, from) {
        _czc.push(['_trackPageview', to.fullPath, from.fullPath])
    },
    shareButton () {
        _czc.push([
          '_trackEvent',
          '用户在该页面分享的意愿',
          `职位首页_点击分享图标_按钮点击`,
          '用户在该页面分享的意愿'
        ])
    },
    // ...
}