|
| 1 | +--- |
| 2 | +title: Chrome Extensions |
| 3 | +description: "Learn how to set up the Sentry Flutter SDK for Chrome Extensions with Flutter Web." |
| 4 | +sidebar_order: 500 |
| 5 | +sdk: sentry.dart.flutter |
| 6 | +categories: |
| 7 | + - dart |
| 8 | + - flutter |
| 9 | +--- |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +Chrome Extensions enforce strict Content Security Policy (CSP) rules that prevent dynamically loaded scripts. Since the Sentry Flutter SDK typically loads the Sentry JavaScript SDK dynamically for web platforms, you need to include the Sentry JavaScript bundle as a static asset instead. |
| 14 | + |
| 15 | +## Required Setup |
| 16 | + |
| 17 | +### 1. Download the Sentry JavaScript Bundle |
| 18 | + |
| 19 | +Instead of loading the Sentry JavaScript SDK dynamically, you need to include it as a static asset: |
| 20 | + |
| 21 | +1. Download the minified Sentry JavaScript bundle from the Sentry CDN. Use the version that is compatible with the Sentry Flutter SDK: |
| 22 | + [bundle.tracing.min.js](https://browser.sentry-cdn.com/9.40.0/bundle.tracing.min.js) |
| 23 | + |
| 24 | + <Alert level="info"> |
| 25 | + |
| 26 | + Download the Sentry Javascript bundle with the appropriate version for your project. Check the [Sentry Flutter SDK releases](https://github.com/getsentry/sentry-dart/releases) to find the version of the Sentry Javascript SDK that is used in a specific Sentry Flutter SDK release. |
| 27 | + |
| 28 | + </Alert> |
| 29 | + |
| 30 | +2. Save this file to your Flutter Web project's `web/` directory. |
| 31 | + |
| 32 | +### 2. Include the Script in Your HTML |
| 33 | + |
| 34 | +Add the Sentry JavaScript bundle to your `web/index.html` file: |
| 35 | + |
| 36 | +```html {filename:web/index.html} |
| 37 | +<!DOCTYPE html> |
| 38 | +<html> |
| 39 | +<head> |
| 40 | + <!-- Other head elements --> |
| 41 | + <script src="bundle.tracing.min.js" type="application/javascript"></script> |
| 42 | +</head> |
| 43 | +<body> |
| 44 | + <!-- Your app content --> |
| 45 | +</body> |
| 46 | +</html> |
| 47 | +``` |
| 48 | + |
| 49 | +### 3. Configure Your Flutter Build |
| 50 | + |
| 51 | +Build your Flutter Web app for Chrome Extensions. |
| 52 | + |
| 53 | +Ensure that the `bundle.tracing.min.js` file is included in your `web/` directory before building. |
| 54 | + |
| 55 | +### 4. Upload Source Maps |
| 56 | + |
| 57 | +After building your application, upload the generated source maps to Sentry to enable proper symbolication of stack traces using the [sentry_dart_plugin](/platforms/dart/guides/flutter/debug-symbols/dart-plugin/). |
0 commit comments