| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This SDK is a v2 Ember addon that provides error tracking and performance monitoring for Ember.js applications.
npm install @sentry/ember
# or
yarn add @sentry/ember
# or
pnpm add @sentry/emberInitialize Sentry early in your application, typically in app/app.ts or app/app.js:
import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from 'my-app/config/environment';
import * as Sentry from '@sentry/ember';
// Initialize Sentry before the application
Sentry.init({
dsn: '__YOUR_DSN__',
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
});
export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
}
loadInitializers(App, config.modulePrefix);For automatic performance instrumentation (page loads, navigation, runloop, components), create an instance-initializer:
// app/instance-initializers/sentry-performance.ts
import type ApplicationInstance from '@ember/application/instance';
import { instrumentAppInstancePerformance } from '@sentry/ember';
export function initialize(appInstance: ApplicationInstance): void {
instrumentAppInstancePerformance(appInstance, optionalOptions);
}
export default {
initialize,
};| Option | Type | Default | Description |
|---|---|---|---|
| appInstance | ApplicationInstance | required | The Ember application instance |
| disableRunloopPerformance | boolean | false | Disable runloop queue tracking |
| disableInstrumentComponents | boolean | false | Disable component render tracking |
| enableComponentDefinitions | boolean | false | Enable component definition tracking |
| minimumRunloopQueueDuration | number | 5 | Minimum duration (ms) for runloop spans |
| minimumComponentRenderDuration | number | 2 | Minimum duration (ms) for component spans |
| instrumentPageLoad | boolean | true | Instrument page load spans |
| instrumentNavigation | boolean | true | Instrument navigation spans |
| idleTimeout | number | 1000 | Idle timeout (ms) for tracing |
To instrument individual routes with detailed lifecycle tracking, use the instrumentRoutePerformance decorator:
// app/routes/application.ts
import Route from '@ember/routing/route';
import { instrumentRoutePerformance } from '@sentry/ember';
class ApplicationRoute extends Route {
async model() {
return this.store.findAll('post');
}
}
export default instrumentRoutePerformance(ApplicationRoute);This wraps the route's beforeModel, model, afterModel, and setupController hooks with Sentry spans.
This package re-exports everything from @sentry/browser, so you have access to the full Sentry Browser SDK API:
import * as Sentry from '@sentry/ember';
// Capture an error
Sentry.captureException(new Error('Something went wrong'));
// Capture a message
Sentry.captureMessage('Something happened');
// Set user context
Sentry.setUser({ id: '123', email: 'user@example.com' });
// Add breadcrumb
Sentry.addBreadcrumb({
category: 'ui.click',
message: 'User clicked button',
level: 'info',
});
// Create a span
Sentry.startSpan({ name: 'my-operation', op: 'task' }, () => {
// ... do work
});If you're upgrading from an older version of @sentry/ember (v1 addon format), here are the key changes:
No automatic instance initializer: You must now explicitly set up performance instrumentation by creating an instance-initializer that calls instrumentAppInstancePerformance(appInstance).
No contentFor hooks: The addon no longer injects scripts via contentFor.
No environment config via ENV['@sentry/ember']: Configure Sentry directly via Sentry.init() in your app.ts.
Simpler dependency tree: The v2 addon format has fewer dependencies and works better with modern build tools like Vite and Embroider.
Update your app/app.ts to call Sentry.init() directly with your configuration.
Create app/instance-initializers/sentry-performance.ts to set up performance monitoring using instrumentAppInstancePerformance.
Remove any @sentry/ember configuration from config/environment.js.
MIT
| Back | FazBrowse Home | New Git URL |