skip to Main Content

I want to upload source maps to sentry for Flutter web, but my sentry issues still appear in minified code files.

I have these errors in sentry above the actual exception:

There were 4 problems processing this event Unknown error Collapse
Source
http://localhost:50326/.pub-cache/hosted/pub.dev/dio-5.3.0/lib/src/dio_mixin.dart
Sourcemap http://localhost:50326/main.dart.js.map Symbolicator Type
missing_source_content Unknown error

Collapse Source
org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/js_helper.dart
Sourcemap http://localhost:50326/main.dart.js.map Symbolicator Type
missing_source_content Unknown error

Collapse Source
org-dartlang-sdk:///dart-sdk/lib/async/future_impl.dart Sourcemap
http://localhost:50326/main.dart.js.map Symbolicator Type
missing_source_content Unknown error

Collapse Source org-dartlang-sdk:///dart-sdk/lib/async/zone.dart
Sourcemap http://localhost:50326/main.dart.js.map Symbolicator Type
missing_source_content

Photo:

enter image description here

This is in my pubspec.yaml:

sentry:
  upload_debug_symbols: true
  upload_source_maps: true
  upload_sources: false
  project: qa
  release: [email protected]+1
  org: vepo-ut
  auth_token: my_secret_auth_token
  wait_for_processing: true
  log_level: error
  commits: auto
  ignore_missing: true

I have run these commands:

I initially just used:

dart run sentry_dart_plugin

And I got the missing_source_content error in sentry so I tried these commands, based off of this Stack Overflow answer (there is a comment saying it doesn’t work though):

sentry-cli releases new [email protected]+1 --org=vepo-ut --project=qa --auth-token=my_secret_auth_token

sentry-cli releases files $SENTRY_RELEASE upload-sourcemaps .     --ext dart 
    --rewrite --org=vepo-ut --project=qa --auth-token=my_secret_auth_token

sentry-cli releases files [email protected]+1 upload-sourcemaps build/web/main.dart.js.map --org=vepo-ut --project=qa --auth-token=my_secret_auth_token

sentry-cli releases finalize [email protected]+1 --org=vepo-ut --project=qa --auth-token=my_secret_auth_token

And I still get the same errors.

I’m passing in these environment vars to my app via a json file:

{
    "foo": "qa",
    "APP_DISPLAY_NAME": "Vepo Qa",
    "SENTRY_DSN": "https://xxx.ingest.sentry.io/4505594353287168",
    "SENTRY_ENVIRONMENT": "qa",
    "SENTRY_RELEASE": "[email protected]+1"
}

And this is running in my main_qa.dart. I have verified that the environment variables are correct:

  await SentryFlutter.init(
    (options) {
      const x = String.fromEnvironment('SENTRY_DSN', defaultValue: '');
      const y = String.fromEnvironment('SENTRY_RELEASE');
      const z = String.fromEnvironment('SENTRY_ENVIRONMENT', defaultValue: '');
      options.dsn =
          // 'https://xxx.ingest.sentry.io/4505594353287168';
          const String.fromEnvironment('SENTRY_DSN', defaultValue: '');
      options.tracesSampleRate = 1.0;
      options.release = const String.fromEnvironment('SENTRY_RELEASE');
      // options.environment =
      //     // options.environment = EnvironmentConstants.of().name;
      //     const String.fromEnvironment('SENTRY_ENVIRONMENT', defaultValue: '');
    },
    appRunner: () => runApp(
      ProviderScope(
        observers: [RiverpodLogger()],
        child: const VpMaterialApp(),
      ),
    ),
  );

How can I get rid of those errors and use source maps in sentry?

2

Answers


  1. Chosen as BEST ANSWER

    I changed upload_sources: true in pubspec.yaml. So, this is super tricky and easy to throw you off because in the sentry issues list they still all say that they are in file "minified:a1a/" AND when I click on the issue I still get those errors in sentry that are in the question, but they can be ignored because they are only for third-party packages.

    Despite those misleading signals, the source code of my own app is displayed in dart files in the issue, in between minified third party package code.

    The final config ended up being:

    sentry:
      upload_debug_symbols: true
      upload_source_maps: true
      upload_sources: true
      project: qa
      release: [email protected]+1
      org: vepo-ut
      auth_token: my_secret_auth_token
      wait_for_processing: true
      log_level: error
      commits: auto
      ignore_missing: true
    

    Then be sure to build it with the environment variables:

    flutter build web -t lib/main_qa.dart --release --no-tree-shake-icons --source-maps --dart-define=SENTRY_DSN=https://[email protected]/zzz --dart-define=SENTRY_ENVIRONMENT=qa [email protected]+1
    

    In main_qa.dart:

      await SentryFlutter.init(
        (options) {
          options.dsn =
              const String.fromEnvironment('SENTRY_DSN', defaultValue: '');
          options.tracesSampleRate = 1.0;
          options.release = const String.fromEnvironment('SENTRY_RELEASE');
        },
        appRunner: () => runApp(
          ProviderScope(
            observers: [RiverpodLogger()],
            child: const VpMaterialApp(),
          ),
        ),
      );
    

    Then once all that is saved and pushed to the repo:

    dart run sentry_dart_plugin
    

    It even works from Codemagic with this post-build script:

    #!/bin/sh
    curl -sL https://sentry.io/get-cli/ | sh
    
    echo -e "[33[92mrun33[0m] Uploading sourcemaps for $SENTRY_RELEASE"
    
    
    dart run sentry_dart_plugin
    

  2. @BeniaminoBaggins the release and dist should match.

    The configuration release: [email protected]+1 should match the const String.fromEnvironment('SENTRY_RELEASE').

    Also, the dist field, check it in the event on sentry.io and if they don’t match, you can force it when uploading and initing the SDK.

    Feel free to raise an issue on https://github.com/getsentry/sentry-dart/issues in case you cannot figure it out, a link to a sentry.io event would help so I can double-check the metadata, and even better a minimal reproducible example.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search