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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@4a/sdk-action

v0.1.4

Published

事件上报

Readme

Action

事件上报SDK

Install

npm i @4a/sdk-action

Usage

const Action = require('@4a/sdk-action')

const action = new Action({
    axios: {
        url: '/logo.gif',
        method: 'POST',
        baseURL: 'http://example.com',
    },
    params: {
        app: 'app',
        from: 'wechat',
    }
})

// PV上报
// 仅前端
action.pv()

// 通用事件上报
action.event({
    app: 'AppName',
    mod: 'mode',
    uid: 'gavinning',
    tmp: 'tmpid',
    pid: 'pid',
    from: 'qq',
    action: '测试事件',
    result: 'ok',
    message: '测试事件描述',
    key: 'trade',
    value: '123',
    context: { a: 1 }
})

// 通用异常上报
action.error({
    app: 'errorapp',
    mod: 'mode',
    uid: 'gavinning',
    tmp: 'tmpid',
    pid: 'pid',
    from: 'qq',
    action: '测试错误',
    result: 'fail',
    message: '测试错误描述',
    key: 'trade',
    value: '123',
    errid: '456',
    stack: 'stack',
    context: {b:1},
})

API

/**
 * PV 仅前端可用
 * @param {Object} params 可选
 * @param {String} params.uid 关联用户id
 * @param {String} params.pid 关联PV记录id
 * @param {String} params.tmp 关联用户临时id
 * @param {String} params.url 当前PV地址
 * @param {String} params.screen 当前终端分辨率
 * @param {String} params.referrer referrer
 */
PV(params = {})


/**
 * Event上报
 * @param {Object | String} params 字符串默认处理为action
 * @param {String} params.app 项目名称
 * @param {String} params.mod 项目模块
 * @param {String} params.uid 关联用户id
 * @param {String} params.tmp 关联用户临时id
 * @param {String} params.pid 关联PV记录id
 * @param {String} params.from 关联来源
 * @param {String} params.action 上报事件简述
 * @param {String} params.result 上报事件状态
 * @param {String} params.message 上报事件详细描述
 * @param {String} params.key 关键字段
 * @param {String} params.value 关键字段值
 * @param {Object | String} params.context 上报事件上下文
 */
event(params)


/**
 * Error上报
 * @param {Object | String} params 字符串默认处理为action
 * @param {String} params.app 项目名称
 * @param {String} params.mod 项目模块
 * @param {String} params.uid 关联用户id
 * @param {String} params.tmp 关联用户临时id
 * @param {String} params.pid 关联PV记录id
 * @param {String} params.from 关联来源
 * @param {String} params.action 上报事件简述
 * @param {String} params.result 上报事件状态
 * @param {String} params.message 上报事件详细描述
 * @param {String} params.key 关键字段
 * @param {String} params.value 关键字段值
 * @param {String} params.errid 错误记录id
 * @param {String} params.stack 错误栈
 * @param {Object | String} params.context 上报事件上下文
 */
error(params)

Vue配置

兼容性考虑vue.config.js文件中应添加以下配置

module.exports = {
    transpileDependencies: [
        /[/\\]node_modules[/\\]@4a\/sdk-action[/\\]/,
    ],
}