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

costway-tracking-v2

v2.0.13

Published

统计代码,新增vue3和vue2分别管理版本-增加多国家

Readme

Costway 统计脚本使用说明

安装方式

NPM包安装

# 使用npm
npm install costway-tracking-v2

# 使用yarn
yarn add costway-tracking-v2

框架集成指南

NUXT框架

plugins目录下创建tracking.js文件:

import Vue from 'vue';
import { initTracking, setConfig } from 'costway-tracking-v2/index.cjs'

export default ({ app }) => {  
    // 使用 app.router 访问路由实例  
    setConfig({ country: 'us' });  
    initTracking(app.router);
};

然后在nuxt.config.js中注册插件:

plugins: [
  { src: '~/plugins/tracking.js', mode: 'client' }
]

VITE框架

main.js中添加:

import { initTracking, setConfig } from 'costway-tracking-v2/trackvue3'

setConfig({ country: 'us' })  
initTracking(router);

文件说明

为兼容Vue2和Vue3,我们提供了不同的导入文件:

  • Vue2: costway-tracking-v2/index.cjs
  • Vue3: costway-tracking-v2/trackvue3

CDN方式集成 (M2相关国家)

建议文件加载尽量靠前,在jQuery后面

正式环境

<script src="https://assets.costway.com/email/css/jquery.min.js"></script>
<script src="https://cdn1.costway.com/cgs-assets/tracking.js"></script>

测试环境

<script src="https://assets.costway.com/email/css/jquery.min.js"></script>
<script src="https://cdn1.costway.com/cgs-assets/tracking-dev.js"></script>

配置与参数设置

国家注册(必须设置)

setConfig({ country: 'us' })

全局参数注册(必须设置)

window.customGlobalParams = {
    email: 'value1',
    customerId: 'value2'
};

事件类型说明

自动收集事件

  • pageView: 页面加载时触发
  • pageLeave: 页面离开时触发(跳转、刷新、tab切换等)

这两个事件会在以下情况自动触发:

  • 页面加载
  • 点击跳转
  • 刷新页面
  • Tab切换
  • 移动端回到首页

手动触发事件

customEvent 自定义事件

用于记录用户行为、手动触发内容等:

trackCustomEvent("mb_serveError", { url: window.location.href });

参数结构体

{
    userId: "用户uuid",
    timestamp: "时间戳",
    customData: "事件数据", 
    eventName: "自定义事件名称,如add_carts"
}

其他事件类型

  • click: 点击事件
  • pageLoadTime: 页面加载统计
  • resourceLoadTime: 资源加载统计
  • error: 错误日志
  • showElement: 页面新增显示元素数据
  • closeElement: 隐藏元素数据

NPM包更新发布流程

本节介绍如何更新和发布NPM包到公共或私有仓库。

前置准备

确保你已经拥有发布权限并且已经登录npm:

# 登录到npm账号
npm login

修改版本号

可以手动修改package.json中的版本号,或使用npm命令自动更新:

# 更新补丁版本号 (1.0.0 -> 1.0.1)
npm version patch

# 更新小版本号 (1.0.0 -> 1.1.0)
npm version minor

# 更新大版本号 (1.0.0 -> 2.0.0)
npm version major

构建包

如果项目需要构建,请先执行构建命令:

npm run build

发布包

发布到公共npm仓库:

npm publish

发布到私有仓库(如果有配置):

npm publish --registry=https://registry.costway.com/

发布特定标签版本

如需发布特定标签的版本(如beta版本):

npm publish --tag beta

撤销发布

如需撤销最近24小时内发布的版本:

npm unpublish costway-tracking-v2@版本号

完整发布流程示例

# 1. 确保代码已提交到git
git add .
git commit -m "准备发布新版本"

# 2. 更新版本号
npm version patch  # 或 minor, major

# 3. 构建项目 (如果需要) 
npm run build

# 4. 发布到npm
npm publish

# 5. 推送到git仓库,包括标签
git push && git push --tags