Git Product home page Git Product logo

micro-sentry's Introduction

micro-sentry

npm version

@micro-sentry/core size

@micro-sentry/browser size

@micro-sentry/angular size

@micro-sentry is a tiny sentry client to monitor your applications without raising your bundle size.

Why is it better than default sentry client?

πŸ‘œ It is small. So, it is at most 2.27 kB (gzip) in size instead of default 85.1 kB (gzip), yet it retains all the the essential functionality.

πŸ›  It is easy to set up. There is a lightweight wrapper for Angular and a browser tool for other frameworks or vanilla.

Check out all the core functionality here.

Installation

Angular:

Micro-sentry version Angular version
>= 6 >= 14
>= 5 >= 13
>= 4 >= 12
>= 3 >= 11
>= 2 >= 10
npm i @micro-sentry/angular

Other:

npm i @micro-sentry/browser

Note

since version @micro-sentry/browser@7 breadcrumbs-plugin is a separate package

npm i @micro-sentry/breadcrumbs-plugin

How to set up

Angular

You can use provide api in standalone applications:

import { provideMicroSentry } from '@micro-sentry/angular';

bootstrapApplication(AppComponent, {
  providers: [
    provideMicroSentry({
      dsn: 'https://[email protected]/123',
    }),
  ],
});

Or add it into app.module.ts of your application:

import { MicroSentryModule } from '@micro-sentry/angular';

@NgModule({
  imports: [
    // options 1: via module
    MicroSentryModule.forRoot({
      dsn: 'https://[email protected]/123',
    }),
  ],
  providers: [
    // option 2: via provide
    provideMicroSentry({
      dsn: 'https://[email protected]/123',
    }),
  ],
})
export class AppModule {}

Javascript / Typescript

If you do not use Angular framework, you can install @micro-sentry/browser module to create client manually.

const client = new BrowserMicroSentryClient({
  dsn: 'https://[email protected]/123',
});

try {
  // your app code
} catch (e) {
  client.report(e);
}

Core Functionality

  • πŸ“€ Send Errors with Stack Trace
  • πŸ“© Send Messages
  • 🚫 Ignore URLs | Errors: With strings or RegExps
  • 🍞 Breadcrumbs plugin: Track and manage the sequence of events leading up to an error for comprehensive debugging
  • 🌟 Enrich Errors with Tags, User, Context: Augment error reports with additional context, user information, and tags for deeper insights

This list encapsulates the key functionalities supported by micro-sentry, emphasizing its focus on essential error tracking and management.

Core team

Igor Katsuba
Igor Katsuba
Roman Sedov
Roman Sedov

License

πŸ†“ Feel free to use our library in your commercial and private applications

All micro-sentry packages are covered by Apache 2.0

Read more about this license here

micro-sentry's People

Contributors

ikatsuba avatar sevaru avatar marsibarsi avatar ereshidov avatar mdlufy avatar zheleznyak-f avatar tom910 avatar

Stargazers

Timothy Alcaide avatar Luis M Torres avatar David Burke avatar Jordan avatar Ilya Zyablitsev avatar Jakob Norlin avatar Alexey Nagornov avatar alxpsr avatar Sergi Luque avatar Ali Mohammadi avatar Gaubee avatar AndrΓ© Wehlert avatar Lincoln Alves avatar Pascal KΓΌsgen avatar Denis avatar Andrew Chou avatar Okiki Ojo avatar  avatar SuperOleg39 avatar Sergey avatar Andrey Sakharov avatar Sam Bulatov avatar  avatar Vladimir Potekhin avatar Ilya Yaroshevich avatar

Watchers

 avatar Maksim Ivanov avatar  avatar  avatar

Forkers

mmkal ereshidov

micro-sentry's Issues

[FEATURE] Allow return null from `beforeSend`

πŸš€ Feature request

Is your feature request related to a problem?

The issue is with the current implementation of micro-sentry library. In the original sentry library for JS, we can use the beforeSend hook to filter out events that we do not want to send to sentry by simply returning null from beforeSend. However, in micro-sentry, the type defined for the return value of the beforeSend hook does not allow returning null, making it impossible to use beforeSend for event filtering.

Describe the solution you'd like

I would like to suggest adjusting the logic of the library so that it allows returning null from the beforeSend hook for event filtering purposes.

Additional context

This feature enhancement would provide more flexibility to users of micro-sentry when it comes to filtering events before sending them to the sentry service. It would align the behavior of micro-sentry with the original sentry library for JS and improve the overall usability of the library.

[FEATURE] Export BrowserSentryClientOptions from micro-sentry library

πŸš€ Feature request

Is your feature request related to a problem?

At the moment you can use only MicroSentryErrorHandler class for ErrorHandler implementation without any additional preparations. And it makes sense if your app uses only 1 ErrorHandler which is good and by Angular design. I faced with situation when the App uses multiple ErrorHandler in conjunction with kind of Visitor pattern. So i could not just use your MicroSentryErrorHandler and i had to use MicroSentryService directly. But then i had to declare MICRO_SENTRY_CONFIG token which has MicroSentryModuleOptions type that you don't export from lib. Of course i could use any type but i wanted more type-safety feature.

Describe the solution you'd like

Export BrowserSentryClientOptions type from lib for more flexibility purposes

Additional context

Who faced with such issue you can use workaround:

import { MicroSentryService } from '@micro-sentry/angular';

type MicroSentryModuleOptionsParams = ConstructorParameters<typeof MicroSentryService>;
type FirstElemFromTuple<T extends unknown[]> = T extends [infer R, unknown] ? R : never;
export type MicroSentryModuleOptions = FirstElemFromTuple<MicroSentryModuleOptionsParams>;

Then you will get BrowserSentryClientOptions type

[BUG] Allow returning `null` in `beforeBreadcrumb` for breadcrumb to be ignored

🐞 Bug report

Description

When using @sentry/angular-ivy I can define a beforeBreadcrumb callback to adjust a breadcrumb before it is persisted, or I can return null for the breadcrumb to be ignored.

Unfortunately the beforeBreadcrumb method of micro-sentry does not accept null as the return type. If I work around that by doing return null as unknown as Breadcrumb unfortunately there is still a (empty) breadcrumb being sent to GlitchTip.

Reproduction

beforeBreadcrumb: (breadcrumb) => {
// ignore XHR requests for `.svg` files
  if (
    breadcrumb.category === 'xhr' &&
    breadcrumb.data?.['method'] === 'GET' &&
    (breadcrumb.data?.['url'] as string | undefined)?.endsWith('.svg')
  ) {
    // // does not work, an empty breadcrumb is still rendered in GlitchTip
    return null as unknown as Breadcrumb; 
  }

  return breadcrumb;
},

Expected behavior

Allow null as return type for beforeBreadcrumb and ignore the breadcrumb if it's null

Versions

7.0.3

[BUG] Missing method to clear the user

🐞 Bug report

Description

I call setUser on login with the user's details and would like to clear the user on logout. Unfortunately there is no method clearUser and setUser does not allow to be called with null.

In @sentry/angular-ivy what I do is get the current scope and call scope.setUser(null) on it.

image

Expected behavior

Add a new method clearUser or allow calling setUser with null.

Versions

"@micro-sentry/angular": "~7.0.2",

[BUG] Error `cause` not being respected

🐞 Bug report

Description

We are calling Sentry.report(new Error('Something bad happened'), {cause: 'Some useful context about the bad thing'}) on a micro-sentry client, but we only see the "Something bad happened" message in sentry.io. I would expect the cause to appear under the "extras" section in the Sentry UI. It's not in the JSON payload sent to sentry a all though

Reproduction

I don't know that it's possible to reproduce in stackblitz since it's about what gets sent to sentry, but it should be easy to reproduce if you have a local sentry set up. Just create a new @micro-sentry/browser client and call the code snippet above.

Expected behavior

Include cause (MDN docs)

Versions

If needed:

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Angular/React/Vue [e.g. Angular 11]

Additional context

[FEATURE] Add jsdoc for BrowserMicroSentryClient class methods

Docs improvements

Is your feature request related to a problem?

Tried to figure out purposes of all methods inside library classes and it was not obvious and quite difficult without calling them.
It's gonna be very helpful if you can add js-doc for each methods and props

Describe the solution you'd like

Add js-doc for methods

Additional context

Anyway highly appreciate your efforts to develop such library. Thank you guys

Every `extras` property seems to be stringified a second time

(not sure if bug or feature request)

I view reported issues in GlitchTip. In the Additional Data section, which I populate using setExtra every string is wrapped in quotes, and every JSON object (which I already stringified because setExtra only accepts strings) is escaped with backslashes, leading to very unreadable JSON data.

image

Request:

Either allow passing objects to setExtra or do not stringify string properties a second time

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.