Skip to content

ref(angular): Update Replay lazy load instructions #11291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
```javascript {filename: main.ts} {3, 7-8}
```javascript {filename: main.ts} {3, 6-7, 11-15}
Sentry.init({
// Note, replayIntegration is NOT instantiated below:
integrations: [],

// Replay sample rates still have to be set in `Sentry.init`:
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});

// Sometime later
import("@sentry/angular").then(lazyLoadedSentry => {
Sentry.addIntegration(lazyLoadedSentry.replayIntegration());
Sentry.lazyLoadIntegration("replayIntegration").then((replayIntegration) => {
Sentry.addIntegration(replayIntegration());
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ To learn more about Session Replay privacy, [read our docs.](/platforms/javascri

### Lazy-loading Replay

Once you've added the integration, Replay will start automatically. If you don't want to start it immediately (lazy-load it), you can use `addIntegration`:
Once you've added the integration, Replay will start automatically. If you don't want to start it immediately (lazy-load it), you can use `lazyLoadIntegration`:

<PlatformContent includePath="configuration/integrations/lazy-loading-replay" />

You can lazy-load the `replayIntegration` directly in `main.ts` (as shown in the example) but also in other parts of your application, for example a lazy-loaded module or component.
Loading