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

vue-track-plush

v2.0.2

Published

基于vue自定义指令的埋点统计

Downloads

19

Readme

vue-track-plush 一个基于 vue2 指令埋点的组件

npm npm npm vue2

安装方法

npm install vue-track-plush -S

字段类型

export type TrackPlushConfig = {
  projectName: string; // 项目名称
  baseURL: string; // 埋点接口baseURL
  url: srting; // 埋点接口url
};

使用方法 (指令埋点)

// main.js
import Vue from "vue";
import App from "./App";
Vue.config.productionTip = false;
// 植入埋点指令
import VueTrackPlush from "vue-track-plush";
Vue.use(VueTrackPlush, {
  baseURL: "<接口域名>",
  url: "<接口地址>",
  projectName: "项目名称",
});
new Vue({
  el: "#app",
  components: {
    App,
  },
  template: "<App/>",
});

使用方法 (点击埋点)

<!-- xxx.vue -->
<template>
  <div class="vue-track-plush">
    <h2 align="center">vue-track-plush 测试demo</h2>
    <div class="container">
      <div class="container-item">
        <h3 align="center">上报静态数据</h3>
        <h3>测试参数传递对象</h3>
        <div class="button-box" v-track:browse="{ pageName: '页面名称' }">
          <button v-track:click="{ buttonName: '按钮名称' }">
            指令点击上报(参数是对象)
          </button>
        </div>
        <h3>测试参数传递字符串</h3>
        <div class="button-box" v-track:browse="'页面名称'">
          <button v-track:click="'按钮名称'">指令点击上报(参数是字符串)</button>
        </div>
      </div>
      <div class="container-item">
        <h3 align="center">上报动态数据</h3>
        <h3>测试点击动态数据上报</h3>
        <div class="button-box">
          <button @click="clickParams++">动态修改上报点击数据</button> ===》{{
          clickParams }}
          <button
            v-track:click="{
              buttonName: '点击的上报数据',
              currentNumber: clickParams,
            }"
          >
            上报点击数据
          </button>
        </div>
        <h3>测试浏览动态数据上报</h3>
        <div class="button-box">
          <button @click="browseParams++">动态修改浏览上报数据</button> ===》 {{
          browseParams }}
          <button
            v-track:browse="{
              buttonName: '浏览的上报数据',
              currentNumber: browseParams,
            }"
          >
            上报浏览数据
          </button>
        </div>
      </div>
      <div class="container-item">
        <h3 align="center">自定义上报数据</h3>
        <h3>自定义点击上报</h3>
        <div class="button-box">
          <button @click="customClickReport">自定义点击上报</button>
          {{ clickNumber }}
        </div>
        <h3>自定义浏览上报</h3>
        <div class="button-box">
          <button @click="customBrowseReport">自定义浏览上报</button>
          {{ browseNumber }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  // 自定义埋点上报
  import { clickEvent, browseEvent } from "vue-track-plush";

  export default {
    data() {
      return {
        browseParams: 0,
        clickParams: 0,
        clickNumber: 0,
        browseNumber: 0,
      };
    },

    methods: {
      // 自定义点击上报
      customClickReport() {
        clickEvent({
          baseURL: "host",
          url: "/api/action/record",
          projectName: "测试开发",
          buttonName: "按钮名称",
          param1: "参数1",
          param2: "参数2",
          paramN: "参数n",
          clickNumber: this.clickNumber,
        });
        this.clickNumber++;
      },
      // 自定义浏览上报
      customBrowseReport() {
        browseEvent({
          baseURL: "host",
          url: "/api/action/record",
          projectName: "测试开发",
          pageName: "页面名称",
          param1: "参数1",
          param2: "参数2",
          paramN: "参数n",
          browseNumber: this.browseNumber,
        });
        this.browseNumber++;
      },
    },
  };
</script>

<style scoped lang="less">
  .container {
    display: flex;
    .container-item {
      padding: 10px 20px;
      flex: 1;
      margin: 0 20px;
      .button-box {
        margin-bottom: 10px;
        background-color: aqua;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        button {
          margin: 0 10px;
        }
      }
      &.container-item:nth-child(1) {
        background-color: bisque;
      }
      &.container-item:nth-child(2) {
        background-color: burlywood;
      }
      &.container-item:nth-child(3) {
        background-color: cadetblue;
      }
    }
  }
</style>