1.0.8 • Published 4 years ago

v-stat v1.0.8

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

v-stat

A vue directive for front-end user behaviour tracking.

Install

npm install v-stat -S

Docs

Directive Format

v-stat:event="{target:my_target, page:my_page, info:my_info}"

Supported Events

eventfired whenhtml tag examples
readydirective is boundeddiv
clickdom click eventel-button
enterENTER key is downel-input
selectvnode is changedel-select
typingvnode is changedel-input
checkvnode is changedel-table selection
exitdirective is unboundeddiv

Modifiers

modifierexamplemeaning
target'submit_button'the name of html element that produces events
page'home_page'the name of current page
info'current_title'the name of data from VueComponent, accessible by this.current_title

Usage

declare v-stat directive in main.js

// import module
import stat from 'v-stat'

// consumer function
const send = msg => $http.post('/stat', msg).then(res => res.data)

// auxiliary values that are carried with msg
const aux = {userid:'wzy816'}

// register custom directive
Vue.directive('stat', stat(send,aux))

examples

  1. capture page reload
<template>
  <div
    v-stat:ready="{target:'my_page', page:'my_page'}">
    ...
  </div>
</template>
  1. capture simple button click event
<el-button
  v-stat:click="{target:'my_button', page: 'my_btn_page'}"
  @click="my_click()">
</el-button>
  1. capture dropdown list selection and its value
<!--
After selection is done, will call like
  send({
    event: 'select'
    target: 'my_select',
    info: this.my_select_page
    page: 'my_select_page',
    timestamp: Date.now(),
    userid:'wzy816'
  })
-->
<el-select
  v-stat:select="{target:'my_select', info:'current_selection', page: 'my_select_page'}"
  v-model="current_selection"
  @change="onChangeHandler">
  ...
</el-select>
  1. capture input value when hit ENTER key
<el-input
  v-stat:enter="{target:'my_input', info:'my_input_value', page: 'my_input_page'}"
  v-model="my_input_value"
  @change="onChangeHandler"
  placeholder="DEFAULT">
  ...
</el-input>
  1. capture input change and its value while typing
<el-input
  v-stat:typing="{target:'my_input', info:'current_input', page: 'my_input_page'}"
  v-model="current_input"
  @change="onChangeHandler"
  placeholder="DEFAULT">
  ...
</el-input>
  1. capture page exit
<template>
  <div v-stat:exit="{target:'my_page', page:'my_page'}">
    ...
  </div>
</template>
  1. capture both ready and exit events
<template>
  <div v-stat:ready&exit="{target:'my_page', page:'my_page'}">
    ...
  </div>
</template>
1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.0

5 years ago