Skip to content
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

[Flutter Web] Unable to define SENTRY_AUTH_TOKEN via --dart-define #23

Closed
IvanDeluxe opened this issue Dec 24, 2021 · 11 comments
Closed
Labels
enhancement New feature or request Platform: Dart up-for-grabs A free for all!

Comments

@IvanDeluxe
Copy link

Environment

Flutter Web

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?
Flutter 2.8.1, sentry_dart_plugin: ^1.0.0-beta.1

Steps to Reproduce

In pubspec.yaml:

sentry:
  project: projectname
  org: orgname

In terminal:

flutter build web --dart-define SENTRY_AUTH_TOKEN=64CHARLONGSTR
flutter pub run sentry_dart_plugin

Expected Result

I expected it to work :D

Actual Result

[❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚] 0% reading config values..
sentry-cli is not available under the assets folder, using pre-installed sentry-cli
☑ reading config values
[❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚] 9% validating config values..
Auth Token is empty, check 'auth_token' at pubspec.yaml or SENTRY_AUTH_TOKEN env. var.
pub finished with exit code 1

Did I do something wrong?

Thanks!

@IvanDeluxe
Copy link
Author

I'll just add - everything works if I put auth_token: 64CHARLONGSTR in pubspec.yaml, but I don't want to commit that token.

@marandaneto
Copy link
Contributor

this plugin does not support --dart-define yet, only environmental variables

@marandaneto marandaneto added enhancement New feature or request up-for-grabs A free for all! labels Jan 10, 2022
@marandaneto
Copy link
Contributor

marandaneto commented Jan 11, 2022

We'd just need to add support for it using https://api.flutter.dev/flutter/dart-core/String/String.fromEnvironment.html on https://github.com/getsentry/sentry-dart-plugin/blob/main/lib/src/configuration.dart#L106-L114 and

project = config?['project']?.toString(); // or env. var. SENTRY_PROJECT
org = config?['org']?.toString(); // or env. var. SENTRY_ORG
waitForProcessing = config?['wait_for_processing'] ?? false;
authToken =
config?['auth_token']?.toString(); // or env. var. SENTRY_AUTH_TOKEN

@devxpy
Copy link

devxpy commented Feb 3, 2022

Shouldn't this plugin support reading the token from the .sentrycli file (mine was generated by sentry-cli)?

@marandaneto
Copy link
Contributor

Shouldn't this plugin support reading the token from the .sentrycli file (mine was generated by sentry-cli)?

This plugin uses sentry-cli underneath so it should, but the ~/.sentryclirc file is for a global configuration, and this plugin allows a configuration per-project basis.
You're free to use sentry-cli and the .sentryclirc file directly tho, the plugin just makes it easier for Dart/Flutter projects.

@devxpy
Copy link

devxpy commented Feb 4, 2022

Shouldn't this plugin support reading the token from the .sentrycli file (mine was generated by sentry-cli)?

This plugin uses sentry-cli underneath so it should, but the ~/.sentryclirc file is for a global configuration, and this plugin allows a configuration per-project basis. You're free to use sentry-cli and the .sentryclirc file directly tho, the plugin just makes it easier for Dart/Flutter projects.

Makes sense, I jut felt like it was a bit hard to specify the auth token.

Adding it in the pubspec.yaml seems like a security issue,
and adding it to my shell environment vars means I cant use it with multiple projects.

sentry-cli seems to read the .sentryclirc from the current directory, so I can set that up for every project individually without having to commit the auth token to git.

@marandaneto
Copy link
Contributor

Yes, I agree.
That's why this issue is about adding support to --dart-define which could be passed at compilation time, so it's not a global configuration.

@Overman775
Copy link

+1

@ghost
Copy link

ghost commented Aug 30, 2022

Just add the SENTRY_AUTH_TOKEN as a env variable. It's easy to setup with CI

@ben-xD
Copy link

ben-xD commented Nov 28, 2022

From my understanding, SENTRY_AUTH_TOKEN shouldn't be passed to --dart-define because it's not an environment variable for your application, but the the CLI. Your application uses different credentials, SENTRY_DSN.

@marandaneto
Copy link
Contributor

The SDK already supports SENTRY_DSN via --dart-define.
Passing SENTRY_AUTH_TOKEN to flutter build web won't make sense, because the Dart Plugin uses the token and not the SDK.
You can already set the token via pub config or env. var.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Platform: Dart up-for-grabs A free for all!
Projects
Archived in project
Development

No branches or pull requests

5 participants