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

@alicloud/logger-gl

v1.4.4

Published

黄金令箭封装

Readme

@alicloud/logger-gl

封装黄金令箭,简化黄金令箭的使用。

申请黄金令箭,去这里:http://log.alibaba-inc.com/track/index.htm#/apply/gold

INSTALL

tnpm i @alicloud/logger-gl -S

APIs

log(logKey: string, mode?: EGlMode, params?: TParams, method: TMethod = 'GET')

黄金令箭页面上有个功能叫「生成埋点代码」,会给出以下代码样例,这里的 log 方法是对这些代码样例的简单封装,唯一的差别是 params 只允许传对象而不是字符串(这里会做编码)。

import {
  EGlMode,
  log
} from '@alicloud/logger-gl';

log('/....');
log('/....', EGlMode.CLICK);
log('/....', EGlMode.CLICK, {
  ...
});
log('/....', EGlMode.CLICK, {
  ...
}, 'POST');

createLogger<P>(options: IOptions)

其中 IOptions 定义如下:

interface IOptions {
  /**
   * 业务码
   */
  bizCode: string;
  /**
   * 场景码
   */
  scene: string;
  /**
   * 令箭码
   */
  glKey: string;
  /**
   * 触发方式
   */
  mode?: EGlMode;
  /**
   * HTTP 请求方式
   */
  method?: TMethod;
  /**
   * 默认参数,避免每次都要传,可以是静态数据或产生动态数据的方法
   */
  defaultParams?: TDefaultParams;
}

新建黄金令箭时,需要提供三个配置,层级如下:

业务(bizCode)
  └─ 业务场景(scene)
     └─ 黄金令箭(glKey)

创建一个针对业务场景的黄金令箭方法,调用者只关心传入什么样的参数(如果不需要额外的参数,创建时不传入泛型即可)。

import createLogger from '@alicloud/logger-gl';

interface IParams {
  p1: string;
  p2: number;
}

// 这里返回一个函数,在需要的地方引入并使用即可,不建议创建了之后马上在同一个文件中使用
const log = createLogger<IParams>({
  bizCode, // 必填,业务码
  scene, // 必填,场景码
  glKey, // 必填,令箭码
  mode, // 可选,触发方式,默认 `OTHER`
  defaultParams // 可选,对象或返回对象的方法
});

// 使用这个特定 log 方法的时候可以很明确的知道需要传哪些参数,多传少传或类型不匹配,TS 都会编译失败
log({
  p1: 'p1',
  p2: 2
});