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

@zhaogyna/angular

v1.0.1

Published

Angular adapter for Monitor SDK

Readme

@zhaogyna/angular

Angular 适配包,重导出 @zhaogyna/browser 全部 API + Angular 专有类。

安装

npm install @zhaogyna/angular

peerDependencies: @angular/core >= 12.0.0

本包已内含 @zhaogyna/browser,无需重复安装。

快速开始

// main.ts
import { init } from '@zhaogyna/angular'

init({
  dsn: 'https://monitor.example.com/api/envelope',
  release: '1.0.0',
  environment: 'production',
})

// app.module.ts
import { ErrorHandler, NgModule } from '@angular/core'
import { MonitorErrorHandler, setupAngularRouterBreadcrumb } from '@zhaogyna/angular'

@NgModule({
  providers: [
    { provide: ErrorHandler, useClass: MonitorErrorHandler },
  ],
})
export class AppModule {}

完整配置项

@zhaogyna/browser 完全一致,参见 @zhaogyna/browser 配置项

Angular 专有 API

MonitorErrorHandler

实现 Angular ErrorHandler 接口的错误处理器类。

// app.module.ts
import { ErrorHandler, NgModule } from '@angular/core'
import { MonitorErrorHandler } from '@zhaogyna/angular'

@NgModule({
  providers: [
    { provide: ErrorHandler, useClass: MonitorErrorHandler },
  ],
})
export class AppModule {}

无构造参数。

内部行为:

  • 实现 ErrorHandler.handleError() 方法
  • 标记 mechanism = { type: 'angular_error_handler', handled: true }
  • 自动解包 error.ngOriginalError 链(Angular 常把原始错误包在 context 对象中),递归提取最原始的错误

setupAngularRouterBreadcrumb

Angular Router 导航面包屑。

// app.component.ts
import { Component, OnInit } from '@angular/core'
import { Router } from '@angular/router'
import { setupAngularRouterBreadcrumb } from '@zhaogyna/angular'

@Component({ selector: 'app-root', templateUrl: './app.component.html' })
export class AppComponent implements OnInit {
  constructor(private router: Router) {}

  ngOnInit() {
    setupAngularRouterBreadcrumb(this.router)
  }
}

| 参数 | 类型 | 说明 | |------|------|------| | router | Router | Angular Router 实例(必填) |

监听 router.events,过滤 NavigationEnd 事件,添加 type: 'navigation' 面包屑,包含 to / from 数据。

重导出的 Browser API

以下 API 从 @zhaogyna/browser 完整重导出,可直接从 @zhaogyna/angular 引入:

| API | 说明 | |-----|------| | init | 初始化 SDK | | captureException | 捕获异常 | | captureMessage | 捕获消息 | | track | 自定义埋点 | | setUser | 设置用户信息 | | setTag / setTags | 设置标签 | | setExtra / setExtras | 设置附加数据 | | setLevel | 设置级别 | | setTransaction | 设置事务名 | | setFingerprint | 设置指纹 | | addBreadcrumb / clearBreadcrumbs | 面包屑管理 | | startSpan | 开始追踪 Span | | startFunnel / trackFunnelStep / endFunnel | 漏斗分析 | | addIntegration / lazyLoadIntegration | 集成管理 | | flush / close | 刷新/关闭 SDK | | on | 生命周期监听 | | withScope / getClient | 作用域/客户端 | | createClient / getActiveClients / findClientForUrl | 多实例 | | 所有集成工厂函数 | globalErrorHandlertryCatchWrapperbreadcrumbCollectorhttpInterceptordedupetrackDedupehttpContextinboundFilterfunctionToStringbrowserSessionIntegrationperformanceVitalslongTaskObserverresourceObserverpageViewTrackerclickTrackerexposureTrackerstayTrackersessionReplay |

License

MIT