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

@rulaicd-lining/vue-log

v1.0.5

Published

vue logs tool

Downloads

16

Readme

vue-log

Vue log plugin

automate record page navigate info with vue-router guard(afterEach), also you can record the log manually.

How to Use

  1. Install package from npm
npm install @rulaicd-lining/vue-log

Or with yarn

yarn add @rulaicd-lining/vue-log
  1. import to vue project and use it
import logs from '@rulaicd-lining/vue-log'

// 数据埋点插件
Vue.use(logs, {
    router, // vue-router
    app: 'app_name',
    endpoint: 'request endpoint',
    secure: 'request security key',
    get userId() {
        return 'current login userId'
    },
    get orgId() {
        return 'current login user orgId'
    },
})

Configration

|field|type|required|remark| |---|---|---|---| |router|vue-router instance|true|vue-rouer for navigate info automated record | |app|string|false|app name, default: main| |endpoint|string|true|endpoint for logs submit to| |secure|string|true|server side security key| |userId|string/number|false|getter for current login user Id| |orgId|string/number|false|getter for current login user orgId| |interval|number|false|log buffer time, default: 2s| |usePath|boolean|false|use router path instead of name, default: false| |routeNameFormatter|function|false|format route name |

Log Datastruct

Logs will post to endpoint with post method use axios, like:

await axios({
  url: endpoint,
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  params: { secure, ts },
  data: { logs },
})

Query

|field|type|required|remark| |---|---|---|---| |secure|string|true|md5 hash string| |ts|number|true|timestamp with millisecond|

Post body

{ "logs": [ log ] }

log document fields: |field|type|required|default|remark| |---|---|---|---|---| |app|string|true|main|app name| |page|string|true|--|current page name| |source|string|true|--|current operate source| |action|enum|true|--|current operation| |ts|number|true|Date.now()|log timestamp| |orgId|string|false|--|login user orgId| |userId|string|false|--|login user id| |extra|any|false|--|extra data info|

action enum |field|description| |---|---| |view|page view| |new|create source| |edit|edit source| |delete|delete source| |navigate|router navigate with extra data: { to: 'navigate to name', duration: 'page stay duration' }| |click|click event| |request|server request|

Secure md5 Hash

secure field hashed by md5 with timestamp, there is the algorithm

secure = md5(secure + Date.now())

The secure field will available in next 10 seconds, so our request must finished in 10 seconds.

Methods

vue-log can automated log the navigation info by every navigate success. but we can manually do the log by action.

Every action method will return a object with a flush method to flush logs immediately.

  • in vue template
<template>
  <button name="add" @click="$log.click('AddButton')"></button>
</template>
  • in vue component
this.$log.click('AddButton')

// flush immediately
this.$log.click('AddButton').flush()

method signature

type method = 'view' | 'edit' | 'new' | 'delete' | 'navigate' | 'click' | 'request'

this.$log[method](source: string, extra: any): void