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

@kbapp/tmuyun-tracker

v1.1.1-alpha.0

Published

开吧天目云埋点

Downloads

867

Readme

开吧天目云埋点 SDK

⚠️ 重要提示:本 SDK 基于 TypeScript 开发,所有 API 参数均带有明确的必填 / 选填类型标注。使用时请务必开启 TS 类型检查或在 IDE 中查看参数提示,必填项缺失会直接提示错误,选填项可按需传入,请勿忽略类型提示以避免使用异常。

简介

@kbapp/tmuyun-tracker 是开吧天目云埋点 SDK,用于将稿件浏览数据上报至天目云平台。包括稿件 ID、标题、发布时间、频道、类型、来源、作者等信息的上报。

安装方式 1:npm

npm i @kbapp/tmuyun-tracker
import { TmuyunTracker, TmuyunDocModel } from '@kbapp/tmuyun-tracker'

const tmuyunTracker = new TmuyunTracker({
    enableLog: true,
    onAfterTracker(data) {
        console.log('埋点上报回调')
    },
})

tmuyunTracker.report({
    docId: 'ACTIVITY_HUB-fifa_world_cup_2026-index',
    title: '活动页-FIFA世界杯2026-首页',
    pubTime: '2023-04-01 12:00:00',
    tmuyunModel: TmuyunDocModel.ACTIVITY_HUB,
})

安装方式 2:通过 script 标签引入

使用 unpkg CDN:

<script src="https://unpkg.com/@kbapp/tmuyun-tracker@latest/dist/umd/index.js"></script>

使用 jsdelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/@kbapp/tmuyun-tracker@latest/dist/umd/index.js"></script>

通过 script 标签引入后,SDK 将作为全局变量 kbTmuyunTracker 挂载在 window 对象上

<script src="https://unpkg.com/@kbapp/tmuyun-tracker@latest/dist/umd/index.js"></script>
<script>
const { TmuyunTracker, TmuyunDocModel } = kbTmuyunTracker

const tmuyunTracker = new TmuyunTracker({
    enableLog: true,
})

tmuyunTracker.report({
    docId: 'ACTIVITY_HUB-fifa_world_cup_2026-index',
    title: '活动页-FIFA世界杯2026-首页',
    pubTime: '2023-04-01 12:00:00',
    tmuyunModel: TmuyunDocModel.ACTIVITY_HUB,
})
</script>

API

总览

| 方法 / 函数 | 说明 | | --------------------------- | ------------------------------ | | TmuyunTracker | 初始化天目云埋点实例 | | TmuyunDocModel | 省宣稿件频道模型(含预置常量) | | getTmuyunSDKSessionId | 获取天目云 SessionId | | getTmuyunSDKDistinctId | 获取天目云 DistinctId |

TmuyunTracker

天目云埋点实例类,实例化后包含 report 方法

配置参数

| 参数 | 类型 | 必填 | 说明 | | ---------------- | ------------------------------------------------------------------------------------------------------------ | ---- | -------------------------------- | | enableLog | boolean | 否 | 是否启用日志,默认不开启 | | onAfterTracker | (params: { params: object; tmuyunPayload: object }) => void | 否 | 触发埋点上报后的回调 |

返回值

{
    report: (params: {
        /** 稿件id */
        docId: string
        /** 稿件标题 */
        title: string
        /** 稿件发布时间,毫秒时间戳或 YYYY-MM-DD HH:mm:ss 格式 */
        pubTime: string | number
        /** 稿件频道模型,参考 TmuyunDocModel */
        tmuyunModel?: TmuyunDocModel
        /** 稿件来源 */
        source?: string
        /** 作者 */
        author?: string
        /** 原始稿件id,一般用于伴随埋点 */
        ref1Id?: string
    }) => void
}

示例代码

import { TmuyunTracker, TmuyunDocModel } from '@kbapp/tmuyun-tracker'

const tmuyunTracker = new TmuyunTracker({
    enableLog: true,
    onAfterTracker(data) {
        console.log('埋点上报回调', data)
    },
})

tmuyunTracker.report({
    docId: 'ACTIVITY_HUB-fifa_world_cup_2026-index',
    title: '活动页-FIFA世界杯2026-首页',
    pubTime: '2023-04-01 12:00:00',
    tmuyunModel: TmuyunDocModel.ACTIVITY_HUB,
})

getTmuyunSDKSessionId

获取天目云 SessionId

import { getTmuyunSDKSessionId } from '@kbapp/tmuyun-tracker'

const sessionId = getTmuyunSDKSessionId()
console.log('SessionId:', sessionId)

getTmuyunSDKDistinctId

获取天目云 DistinctId

import { getTmuyunSDKDistinctId } from '@kbapp/tmuyun-tracker'

const distinctId = getTmuyunSDKDistinctId()
console.log('DistinctId:', distinctId)

数据模型

TmuyunDocModel

省宣稿件频道模型,用于定义稿件所属频道。提供以下预置常量:

| 常量 | 说明 | | ----------------------------- | -------------- | | TmuyunDocModel.NEWS | 新闻 | | TmuyunDocModel.NEWS_NEO | 新资讯 | | TmuyunDocModel.PROGRAM | 电台广播 | | TmuyunDocModel.HOT_TOPIC | 热门专题 | | TmuyunDocModel.VIDEO_LIVE | 视频直播 | | TmuyunDocModel.HOOLO | 葫芦网 | | TmuyunDocModel.ACTIVITY | 临时活动 | | TmuyunDocModel.CIRCLE | 圈子话题 | | TmuyunDocModel.EXT | 外部稿件 | | TmuyunDocModel.REVEAL_NODE | 爆料台话题节点 | | TmuyunDocModel.REVEAL_MAIN | 爆料台首页 | | TmuyunDocModel.ACT_MIX | 混合活动 | | TmuyunDocModel.APP_MAIN_PAGE| App 主页 | | TmuyunDocModel.AUDIO_LIVE | 广播页面 | | TmuyunDocModel.NEWS_NEO_GROUP_TOPIC | 资讯专题 | | TmuyunDocModel.MALL | 商城 | | TmuyunDocModel.MINI_THEATRE | 微短剧 | | TmuyunDocModel.PLAYBACK | 节目回放 | | TmuyunDocModel.NEWS_NEO_PROGRAMME | 栏目主页 | | TmuyunDocModel.WORK_ORDER | 工单 | | TmuyunDocModel.ACTIVITY_HUB | 临时活动 | | TmuyunDocModel.ART_MAP | 艺术地图 | | TmuyunDocModel.ENROLL | 报名征集 |

也可以自定义频道模型:

import { TmuyunDocModel } from '@kbapp/tmuyun-tracker'

const customModel = new TmuyunDocModel({
    editionNumber: '10086',
    editionName: '自定义频道',
    docType: '新闻',
})