Skip to content

Commit

Permalink
feat(flutter): Add Flutter support (#735)
Browse files Browse the repository at this point in the history
* add test to find last import line

* add basic wizzard and patch import in main.dart

* patch pubspec.yaml

* add sentry dart plugin options and propeties to pubspec file

* patch main with sentry init, fetch sentry_flutter version

* update template, check already added to pubspec

* order flutter behind reactNative

* cleanup

* update order

* add cl entry

* fix typos

* remove comment

* introduce options in flutter templates

* options in setup, dont upload sources, upload debug symbols

* setup flutter e2e test

* add flutter test app

* fix Flutter e2e test

* update docs/readme

* Disable replay option for now

* run prettier

* fix tests

* run prettier

* don’t add profiling if ios/macos is not configured

* run prettier

* update snippet

* fix telemetey name

* return if pubspec.yaml could not be found in project dir

* check if main exists

* show paste instructions if main could not be found

* sow snippt for pubspec file

* use chalk.cyan for file references

* wrap file reads in try/catch

* update text

* update debug flags

* run prettier

* run flutter commands in test app dir

* add SentryWidget

* fix cl

* add sentry widget in sample snippet

* fix typo
  • Loading branch information
denrase authored Feb 3, 2025
1 parent 083731b commit e50def3
Show file tree
Hide file tree
Showing 104 changed files with 5,024 additions and 8 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,29 @@ jobs:
timeout-minutes: 10
strategy:
matrix:
wizard: [Nuxt-3, Nuxt-4, NextJS, Remix, Sveltekit]
wizard: [Flutter, Nuxt-3, Nuxt-4, NextJS, Remix, Sveltekit]
env:
SENTRY_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_SENTRY_AUTH_TOKEN }}
SENTRY_TEST_ORG: 'sentry-javascript-sdks'
SENTRY_TEST_PROJECT: 'sentry-wizard-e2e-tests'
steps:
- uses: actions/checkout@v3
- name: Set up Node
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'yarn'
- name: Setup Flutter
if: matrix.wizard == 'Flutter'
uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # [email protected]
with:
channel: 'stable'
- name: Build Flutter
if: matrix.wizard == 'Flutter'
working-directory: e2e-tests/test-applications/flutter-test-app
run: |
flutter upgrade
flutter pub get
- name: Install dependencies with yarn
run: yarn install --frozen-lockfile
- name: Run End-to-End Tests
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- feat(flutter): Add Flutter support ([#735](https://github.com/getsentry/sentry-wizard/pull/735))

## 3.39.0

- Always send platform query param to auth page ([#757](https://github.com/getsentry/sentry-wizard/pull/757))
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</p>

<h1>Sentry Wizard</h1>
<h4>The Sentry Wizard helps you set up your React Native, Cordova, Electron or Next.js projects with Sentry.</h4>
<h4>The Sentry Wizard helps you set up your React Native, Flutter, Cordova, Electron or Next.js projects with Sentry.</h4>

[![npm version](https://img.shields.io/npm/v/@sentry/wizard.svg)](https://www.npmjs.com/package/@sentry/wizard)
[![npm dm](https://img.shields.io/npm/dm/@sentry/wizard.svg)](https://www.npmjs.com/package/@sentry/wizard)
Expand Down Expand Up @@ -49,7 +49,7 @@ yarn sentry-wizard
npx @sentry/wizard
```

At the current moment, the wizard can be used for Next.js, react-native, iOS, Nuxt, Remix, Sveltekit, Android, Electron, Cordova, and for sourcemaps setup. If you have other platforms you would like the wizard to support, please open a [GitHub issue](https://github.com/getsentry/sentry-wizard/issues)!
At the current moment, the wizard can be used for Next.js, react-native, iOS, Flutter, Nuxt, Remix, Sveltekit, Android, Electron, Cordova, and for sourcemaps setup. If you have other platforms you would like the wizard to support, please open a [GitHub issue](https://github.com/getsentry/sentry-wizard/issues)!

# Options

Expand All @@ -63,7 +63,7 @@ The following CLI arguments are available:
| `--uninstall` | Revert project setup process. Not available for all integrations. | boolean | `false` | | `SENTRY_WIZARD_UNINSTALL` |
| `--skip-connect` | Skips the connection to the server | boolean | `false` | | `SENTRY_WIZARD_SKIP_CONNECT` |
| `--quiet` | Do not fallback to prompting user asking questions | boolean | `false` | | `SENTRY_WIZARD_QUIET` |
| `-i, --integration` | Choose the integration to setup | choices | Select integration during setup | "reactNative", "ios", "android", "cordova", "electron", "nextjs", "nuxt", "remix", "sveltekit", "sourcemaps" | `SENTRY_WIZARD_INTEGRATION` |
| `-i, --integration` | Choose the integration to setup | choices | Select integration during setup | "reactNative", "flutter", ios", "android", "cordova", "electron", "nextjs", "nuxt", "remix", "sveltekit", "sourcemaps" | `SENTRY_WIZARD_INTEGRATION` |
| `-p, --platform` | Choose platform(s) | array | Select platform(s) during setup | "ios", "android" | `SENTRY_WIZARD_PLATFORM` |
| `-u, --url` | The URL to your Sentry installation | string | `https://sentry.io` | | `SENTRY_WIZARD_URL` |
| `--project` | The Sentry project slug to use | string | Select project during setup | | |
Expand Down
6 changes: 5 additions & 1 deletion e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

```
test-applications/
|---- flutter-test-app/
|---- nextjs-test-app/
|---- remix-test-app/
|---- sveltekit-test-app/
tests/
|---- flutter.test.ts
|---- nextjs.test.ts
|---- remix.test.ts
|---- sveltekit.test.ts
Expand Down Expand Up @@ -37,6 +39,8 @@ tests/
- `checkIfRunsOnDevMode` - Checks if the test project runs on dev mode successfully.
- `checkIfRunsOnProdMode` - Checks if the test project runs on prod mode successfully.

- `checkIfFlutterBuilds` - Checks if the Flutter (Web) test project builds successfully.
- `checkSentryProperties` - Checks if the Flutter `sentry.properties` file contains the auth token

#### `WizardTestEnv`

Expand All @@ -52,7 +56,7 @@ Tests can be run locally from the root of the project with:

To run a specific test application

`yarn test:e2e [Remix | NextJS | SvelteKit]`
`yarn test:e2e [Flutter | Remix | NextJS | SvelteKit]`

## Writing Tests

Expand Down
176 changes: 176 additions & 0 deletions e2e-tests/test-applications/flutter-test-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release

# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release


# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release

# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
45 changes: 45 additions & 0 deletions e2e-tests/test-applications/flutter-test-app/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: android
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: ios
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: linux
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: macos
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: web
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: windows
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
16 changes: 16 additions & 0 deletions e2e-tests/test-applications/flutter-test-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# flutter_magic

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
28 changes: 28 additions & 0 deletions e2e-tests/test-applications/flutter-test-app/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
13 changes: 13 additions & 0 deletions e2e-tests/test-applications/flutter-test-app/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
Loading

0 comments on commit e50def3

Please sign in to comment.