Repository: raychenfj/vue-uweb Branch: master Commit: 579605e9a6ed Files: 79 Total size: 1.7 MB Directory structure: gitextract_yj9gbp5a/ ├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── .stylelintrc ├── .travis.yml ├── .vscode/ │ └── settings.json ├── LICENSE ├── README.md ├── README_EN.md ├── build/ │ ├── build.js │ ├── utils/ │ │ ├── index.js │ │ ├── log.js │ │ ├── style.js │ │ └── write.js │ ├── webpack.config.base.js │ ├── webpack.config.dev.js │ └── webpack.config.dll.js ├── dist/ │ ├── vue-uweb.common.js │ ├── vue-uweb.esm.js │ └── vue-uweb.js ├── examples/ │ ├── simple/ │ │ ├── index.html │ │ ├── prism.css │ │ ├── prism.js │ │ ├── script.js │ │ └── styles.css │ └── webpack/ │ ├── .babelrc │ ├── .editorconfig │ ├── .eslintignore │ ├── .eslintrc.js │ ├── .gitignore │ ├── .postcssrc.js │ ├── .vscode/ │ │ └── settings.json │ ├── README.md │ ├── build/ │ │ ├── build.js │ │ ├── check-versions.js │ │ ├── dev-client.js │ │ ├── dev-server.js │ │ ├── utils.js │ │ ├── vue-loader.conf.js │ │ ├── webpack.base.conf.js │ │ ├── webpack.dev.conf.js │ │ └── webpack.prod.conf.js │ ├── config/ │ │ ├── dev.env.js │ │ ├── index.js │ │ └── prod.env.js │ ├── index.html │ ├── package.json │ ├── src/ │ │ ├── app.css │ │ ├── app.js │ │ ├── app.vue │ │ ├── main.js │ │ └── uweb.js │ └── static/ │ └── .gitkeep ├── package.json ├── src/ │ ├── directives/ │ │ ├── auto-pageview.js │ │ ├── track-event.js │ │ ├── track-pageview.js │ │ └── util.js │ ├── index.js │ └── install.js └── test/ ├── .eslintrc ├── dist/ │ ├── vuePluginTemplateDeps.dll.js │ └── vuePluginTemplateDeps.json ├── helpers/ │ ├── Test.vue │ ├── index.js │ ├── utils.js │ └── wait-for-update.js ├── index.js ├── karma.conf.js ├── mocks.js ├── specs/ │ ├── directives/ │ │ ├── auto-pageview.spec.js │ │ ├── track-event.spec.js │ │ ├── track-pageview.spec.js │ │ └── util.spec.js │ └── index.spec.js └── visual.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .babelrc ================================================ { "presets": [ [ "env", { "targets": { "browsers": [ "last 2 versions" ] } } ] ], "plugins": [ "transform-vue-jsx", "transform-object-rest-spread", "transform-runtime" ], "env": { "test": { "plugins": [ "istanbul" ] } } } ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 indent_style = space indent_size = 2 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true ================================================ FILE: .eslintignore ================================================ dist/*.js build/* ================================================ FILE: .eslintrc.js ================================================ module.exports = { root: true, parser: 'babel-eslint', parserOptions: { sourceType: 'module' }, extends: 'vue', // add your custom rules here 'rules': { // allow async-await 'generator-star-spacing': 0, // allow debugger during development 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 }, globals: { requestAnimationFrame: true, performance: true } } ================================================ FILE: .gitignore ================================================ .DS_Store node_modules/ npm-debug.log yarn-error.log test/coverage *.tgz package ================================================ FILE: .postcssrc.js ================================================ // https://github.com/michael-ciniawsky/postcss-load-config module.exports = { "plugins": { // to edit target browsers: use "browserlist" field in package.json "autoprefixer": {} } } ================================================ FILE: .stylelintrc ================================================ { "processors": ["stylelint-processor-html"], "extends": "stylelint-config-standard", "rules": { "no-empty-source": null } } ================================================ FILE: .travis.yml ================================================ language: node_js node_js: "node" ================================================ FILE: .vscode/settings.json ================================================ { "vsicons.presets.angular": false } ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2017 Ray Chen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # vue-uweb [](https://travis-ci.org/raychenfj/vue-uweb) > vuejs 友盟统计埋点插件 ## 1. 安装 ```shell npm install vue-uweb --save ``` 直接在页面中引用 ```html
npm install vue-uweb --save
<script src="../node_modules/vue-uweb/dist/index.js"></script>
import uweb from 'vue-uweb'
Vue.use(uweb,'YOUR_SITEID_HERE')
Vue.use(uweb,options)
this.$uweb.ready().then(() => {
...
}).catch(() => {
... // error handling here
})
// 使用 async await, 建议使用 try/catch 避免加载失败影响主程序
async SOME_METHOD () {
try {
await this.$uweb.ready()
...
} catch (e){
... // error handling here
}
}
this.$uweb.trackPageview(content_url[, referer_url])
this.$uweb.trackEvent(category, action[, label, value, nodeid])
this.$uweb.setCustomVar(name, value[, time])
this.$uweb.setAccount(siteid)
this.$uweb.setAutoPageview(autopageview)
this.$uweb.deleteCustomVar(name)
<button v-track-event.click="'event, click''"></button>
<button v-track-event="'event, shortcut'"></button>
<input v-track-event.keypress="'event, keypress'">
关于参数和顺序
<button v-track-event="'event, click'"></button>
<button v-track-event="{category:'event', action:'click'}"></button>
<div v-show="vshow" v-track-pageview="'/bar'"></div>
<div v-if="vif" v-track-pageview="'/foo'"></div>
<div v-track-pageview="'/tar, https://github.com/raychenfj'"></div>
<div v-track-pageview="{content_url:'/zoo', referer_url:'https://github.com/raychenfj'}"></div>
<div v-auto-pageview=true></div>
<div v-auto-pageview=false></div>
import uweb from 'vue-uweb'
let trackEvent = uweb.trackEvent
uweb.trackEvent = (action, category='default'') => {
trackEvent.call(uweb, category, action, '', '', '')
}
Vue.use(uweb)