Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/getsentry/sentry-capacitor
The official Sentry SDK for Capacitor
https://github.com/getsentry/sentry-capacitor
android capacitor crash crash-reporting error error-handling hybrid-apps ionic ios javascript mobile sdk sentry tag-production
Last synced: 2 days ago
JSON representation
The official Sentry SDK for Capacitor
- Host: GitHub
- URL: https://github.com/getsentry/sentry-capacitor
- Owner: getsentry
- License: mit
- Created: 2020-10-26T14:20:09.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-18T03:08:14.000Z (3 months ago)
- Last Synced: 2024-10-19T05:35:44.135Z (3 months ago)
- Topics: android, capacitor, crash, crash-reporting, error, error-handling, hybrid-apps, ionic, ios, javascript, mobile, sdk, sentry, tag-production
- Language: TypeScript
- Homepage: https://sentry.io
- Size: 13 MB
- Stars: 119
- Watchers: 37
- Forks: 31
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-capacitor - Sentry - Add Sentry error tracking and performance monitoring for Capacitor apps. (Other plugins)
README
_Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us [**Check out our open positions**](https://sentry.io/careers/)_
## Official Sentry SDK for Capacitor
[![build](https://github.com/getsentry/sentry-capacitor/workflows/Build%20&%20Test/badge.svg?branch=main)](https://github.com/getsentry/sentry-capacitor/actions?query=branch%3Amain)
[![Discord Chat](https://img.shields.io/discord/621778831602221064?logo=discord&logoColor=ffffff&color=7389D8)](https://discord.gg/PXa5Apfe7K)## Installation
```bash
# Angular 14 and newer:
yarn add @sentry/capacitor @sentry/angular --exact# Vue
yarn add @sentry/capacitor @sentry/vue --exact# React
yarn add @sentry/capacitor @sentry/react --exact# Other
yarn add @sentry/capacitor @sentry/browser --exact
```Older versions of Angular require @sentry/capacitor V0, for more information check the page: https://docs.sentry.io/platforms/javascript/guides/capacitor/#angular-version-compatibility
## Usage
To use this SDK, call `Sentry.init` as early as possible after loading the page. This will initialize the SDK and hook into the environment. _Note that you can turn off almost all side effects using the respective options._
```typescript
// app.module.tsimport * as Sentry from "@sentry/capacitor";
import { init as sentryAngularInit, createErrorHandler } from "@sentry/angular";// Init by passing the sibling SDK's init as the second parameter.
Sentry.init({
dsn: "__DSN__",
}, sentryAngularInit);// Attach the Sentry ErrorHandler
@NgModule({
providers: [
{
provide: ErrorHandler,
useValue: createErrorHandler(),
},
],
})
```To set context information or send manual events, use the exported functions of `@sentry/capacitor`. _Note that these functions will not perform any action before you have called `Sentry.init()`:_
```javascript
import * as Sentry from '@sentry/capacitor';// Set user information, as well as tags and further extras
const scope = Sentry.getCurrentScope();
scope.setExtra('battery', 0.7);
scope.setTag('user_mode', 'admin');
scope.setUser({ id: '4711' });
// scope.clear();
});// Add a breadcrumb for future events
Sentry.addBreadcrumb({
message: 'My Breadcrumb',
// ...
});// Capture exceptions, messages or manual events
Sentry.captureMessage('Hello, world!');
Sentry.captureException(new Error('Good bye'));
Sentry.captureEvent({
message: 'Manual',
stacktrace: [
// ...
],
});
```#### Resources
* [![Documentation](https://img.shields.io/badge/documentation-sentry.io-green.svg)](https://docs.sentry.io/platforms/javascript/guides/capacitor/)
* [![Discussions](https://img.shields.io/github/discussions/getsentry/sentry-capacitor.svg)](https://github.com/getsentry/sentry-capacitor/discussions)
* [![Discord Chat](https://img.shields.io/discord/621778831602221064?logo=discord&logoColor=ffffff&color=7389D8)](https://discord.gg/PXa5Apfe7K)
* [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](https://stackoverflow.com/questions/tagged/sentry)
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)