-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat(flutter): Add Flutter support #735
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # CHANGELOG.md
@buenaflor Ready for the first review/feedback round :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have another look later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, leaving a first pass review for general wizard recommendations. This is not technical as I have very little to no context around Flutter.
- Ideally, we can make the SDK features selectable from the start as we've done recently with the JS-SDK wizards. See Make Sentry features selectable in wizard #558
- Great to see some tests for this flow! :) I recommend adding an e2e test app as well as this proved quite useful for our other wizards.
Feel free to disregard my advice as I'll happily leave the final call to the mobile team. Don't want to block you, just share some recommendations :)
…o feat/flutter-support # Conflicts: # CHANGELOG.md
@bruno-garcia We have added replay as an option, but we are not sure if we should, as it is still beta on Flutter. Do you have any guidance/thoughts? |
# Conflicts: # CHANGELOG.md
Removed the Replay option for now, as this is still considered bet on Flutter/Mobile. |
@krystofwoldrich could you also have a quick look since you already have quite some rn wizard exp :) |
# Conflicts: # CHANGELOG.md
Profiling is now only asked as an option in the flutter wizard if we have an ios/macos folder. Also added tests for this. |
appRunner: () => runApp(${runApp}), | ||
); | ||
// TODO: Remove this line after sending the first sample event to sentry. | ||
await Sentry.captureMessage('This is a sample exception.');`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await Sentry.captureMessage('This is a sample exception.');`; | |
await Sentry.captureException(Exception('This is a sample exception.'));`; |
@denrase e2e test is failing |
return withTelemetry( | ||
{ | ||
enabled: options.telemetryEnabled, | ||
integration: 'android', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the integration name reported to Sentry Telemetry.
integration: 'android', | |
integration: 'flutter', |
await getOrAskForProjectData(options, 'flutter'); | ||
|
||
const projectDir = process.cwd(); | ||
const pubspecFile = findFile(projectDir, 'pubspec.yaml'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we should not look for this file, if the user is in a directory without pubspec.yaml
, likely they are not in root of the project they want to patch.
We should handle the missing pubspecFile
and let user know they are not in Flutter project dir.
); | ||
if (!pubspecPatched) { | ||
clack.log.warn( | ||
"Could not add Sentry to your apps pubspec.yaml file. You'll have to add it manually.\nPlease follow the instructions at https://docs.sentry.io/platforms/flutter/#install", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if it's out of scope, but the other wizards show code pastable code snippets so users don't have to leave the wizard and look online for the code.
Example from RN:
sentry-wizard/src/react-native/javascript.ts
Lines 31 to 35 in fe849fe
await showCopyPasteInstructions( | |
'App.js or _layout.tsx', | |
getSentryInitColoredCodeSnippet(dsn), | |
'This ensures the Sentry SDK is ready to capture errors.', | |
); |
); | ||
if (!propertiesAdded) { | ||
clack.log.warn( | ||
`We could not add "sentry.properties" file in your project directory in order to provide an auth token for Sentry CLI. You'll have to add it manually, or you can set the SENTRY_AUTH_TOKEN environment variable instead. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually filenames are highlighted by cyan
.
Wizard Develop docs describe the use of colors.
https://develop.sentry.dev/sdk/expected-features/setup-wizards/#colors
fs.existsSync(`${projectDir}/ios`) || fs.existsSync(`${projectDir}/macos`); | ||
|
||
const mainPatched = await traceStep('Patch main.dart', () => | ||
codetools.patchMain(mainFile, dsn, canEnableProfiling), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can't patch the mainFile
we should show a copy pastable code snippet.
if (!pubspecFile || !fs.existsSync(pubspecFile)) { | ||
clack.log.warn('No pubspec.yaml source file found in filesystem.'); | ||
Sentry.captureException('No pubspec.yaml source file'); | ||
return false; | ||
} | ||
let pubspecContent = fs.readFileSync(pubspecFile, 'utf8'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better practice to try catch
the readFile
instead of checking for existence. The read
might still throw and this would crash the wizard.
chalk.greenBright( | ||
`${chalk.bold( | ||
'main.dart', | ||
)} is already patched with test error snippet.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's maybe better to call out that Sentry is already in the main.dart
instead of the test error.
const { selectedProject, selfHosted, sentryUrl, authToken } = | ||
await getOrAskForProjectData(options, 'flutter'); | ||
|
||
const projectDir = process.cwd(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it applies (if it's common users have old outdated apps), but we could check min dart and flutter versions before the wizard starts patching.
Added some comments based on my experience with RN Wizard. |
main.dart
with import, sentry setup and sample snippetpubspec.yaml
with sentry_flutter dependency and plugin to upload debug symbols and source mapsCloses getsentry/sentry-dart#2424
Relates to #558