@bufferapp/buffer-tracking-browser-ts

中文文档
1.0.248发布于 2024/09/25ISCTypeScriptCommonJS近 30 天下载 5803

Segment tracking library for browser based Buffer Typescript projects

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

原始使用文档
文档目录3 节
  1. Product / Client Typings
  2. Gotchas
  3. Latest plan changes not reflected in the library

npm version

Buffer Tracker - Browser (Typescript)

A Strongly-typed segment tracking companion for use in Browser Typescript projects. Under the hood this uses the Buffer segment tracking plan, acting as a type-safe wrapper for clients. With this, there is no need to pull in or reference the tracking plan!

You will need to have configured segment as per these instructions before using this package.

You can install this by running:

npm install @bufferapp/buffer-tracking-browser-ts

Before using, you'll need to ensure that your project is configured to access to segment. You can follow this guide here.

Next you'll need to add the typewriter import to the desired file:

import {BufferTracker} from '@bufferapp/buffer-tracking-browser-ts'

With the dependency added, you can use the typewriter reference to call the desired tracking functions:

typewriter.draftSubmitted({
  product: 'publish',
  channel: 'instagram',
  channelType: 'business',
  postId: '58edaj782102dff',
  channelId: '12345679',
  channelServiceId: '987654567898'
})

When calling these functions, any violations or errors will be logged as warnings to your console. if you wish for these to throw errors (maybe during development), then you can configure options on the typewriter reference to enable this:

typewriter.setTypewriterOptions({
  onViolation: (msg, violations) => {
    const issues = violations.map(v => v.keyword === 'type' ? `${v.message}: '${v.dataPath}'` : `${v.message}`)
    throw new Error(
      `"${msg.event}" Fired with Tracking Plan Violation\n    ${issues.join('\n    ')}`
    )
  }
})

Product / Client Typings

If you need access to Product or Client typings, you can import them like so:

import {Product, Client} from '@bufferapp/buffer-tracking-node-ts' If there is a Product or Client that is not included, let us know in the #data-governance slack channel and it can be added :)


Gotchas

There is currently no Type support for the requirement of a userId or anonymous ID when triggering a tracking event. We are working on adding support for this in the near future, but for now it's important to note that either one of these must be added when tracking!

Latest plan changes not reflected in the library

If the library does not reflect the latest tracking changes then you can trigger a rebuild manually. Head over to this URL and select the Run Workflow option. After a few minutes, the latest release should be pushed to NPM.

Screenshot 2021-06-01 at 14 25 51

版本与发布记录

@bufferapp/buffer-tracking-browser-ts 共发布 371 个版本,首次发布于 2021/01/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.248latest2024/09/252 年前
1.0.2472024/09/252 年前
1.0.2462024/09/252 年前
1.0.2452024/09/252 年前
1.0.2442024/09/252 年前
1.0.2432024/09/242 年前

关于 @bufferapp/buffer-tracking-browser-ts 的常见问题

@bufferapp/buffer-tracking-browser-ts 是什么?

Segment tracking library for browser based Buffer Typescript projects注意:该包已被作者标记为弃用——Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

如何安装 @bufferapp/buffer-tracking-browser-ts?

在项目目录运行 npm install @bufferapp/buffer-tracking-browser-ts,或使用 pnpm add / yarn add / bun add。

@bufferapp/buffer-tracking-browser-ts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bufferapp/buffer-tracking-browser-ts 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@bufferapp/buffer-tracking-browser-ts 可以商用吗?

@bufferapp/buffer-tracking-browser-ts 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bufferapp/buffer-tracking-browser-ts 的下载量有多少?

根据 npm 官方下载统计,@bufferapp/buffer-tracking-browser-ts 在 2026/10/09 – 2026/11/07 这 30 天内被下载 5,803 次,日均约 193 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bufferapp/buffer-tracking-browser-ts 还在维护吗?

最新版本 1.0.248 发布于 2024/09/25(2 年前);至今共发布 371 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/01/14。作者已将其标记为弃用,新项目建议寻找替代方案。