在Sentry中上传源映射没有效果。

huangapple go评论135阅读模式
英文:

Uploading source maps in sentry has no effect

问题

我想要将Flutter web的源映射上传到Sentry,但我的Sentry问题仍然出现在缩小的代码文件中。

在Sentry中,我在实际异常之上有以下错误:

> 处理此事件时出现4个问题 未知错误 折叠
> 源
> 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 类型
> missing_source_content 未知错误
>
> 折叠 源
> org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/js_helper.dart
> Sourcemap http://localhost:50326/main.dart.js.map Symbolicator 类型
> missing_source_content 未知错误
>
> 折叠 源
> org-dartlang-sdk:///dart-sdk/lib/async/future_impl.dart Sourcemap
> http://localhost:50326/main.dart.js.map Symbolicator 类型
> missing_source_content 未知错误
>
> 折叠 源 org-dartlang-sdk:///dart-sdk/lib/async/zone.dart
> Sourcemap http://localhost:50326/main.dart.js.map Symbolicator 类型
> missing_source_content

图片:

在Sentry中上传源映射没有效果。

这是我的pubspec.yaml文件中的配置:

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

我运行了以下命令:

最初,我只运行了以下命令:

dart run sentry_dart_plugin

但我在Sentry中收到了missing_source_content错误,所以我尝试了以下命令,参考了这个Stack Overflow答案(其中有一个评论说它不起作用):

sentry-cli releases new vepo@0.0.2+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 vepo@0.0.2+1 upload-sourcemaps build/web/main.dart.js.map --org=vepo-ut --project=qa --auth-token=my_secret_auth_token

sentry-cli releases finalize vepo@0.0.2+1 --org=vepo-ut --project=qa --auth-token=my_secret_auth_token

但我仍然收到相同的错误。

我通过JSON文件将以下环境变量传递给我的应用程序:

{
    "foo": "qa",
    "APP_DISPLAY_NAME": "Vepo Qa",
    "SENTRY_DSN": "https://xxx.ingest.sentry.io/4505594353287168",
    "SENTRY_ENVIRONMENT": "qa",
    "SENTRY_RELEASE": "vepo@0.0.2+1"
}

这些环境变量在我的main_qa.dart文件中运行。我已经验证了环境变量的正确性:

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(),
        ),
    ),
);

如何摆脱这些错误并在Sentry中使用源映射?

英文:

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:

在Sentry中上传源映射没有效果。

This is in my pubspec.yaml:

sentry:
  upload_debug_symbols: true
  upload_source_maps: true
  upload_sources: false
  project: qa
  release: vepo@0.0.2+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 vepo@0.0.2+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 vepo@0.0.2+1 upload-sourcemaps build/web/main.dart.js.map --org=vepo-ut --project=qa --auth-token=my_secret_auth_token

sentry-cli releases finalize vepo@0.0.2+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": "vepo@0.0.2+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?

答案1

得分: 0

我在pubspec.yaml中更改了upload_sources: true。这非常棘手,容易让你感到困惑,因为在Sentry问题列表中,它们仍然都显示在文件**"minified:a1a/"**中,当我点击问题时,我仍然会在Sentry中收到与问题中的错误相同的错误,但可以忽略,因为它们只针对第三方包。

尽管这些误导性的信号,我的应用程序的源代码显示在问题中的dart文件中,在缩小的第三方包代码之间。

最终的配置如下:

sentry:
  upload_debug_symbols: true
  upload_source_maps: true
  upload_sources: true
  project: qa
  release: vepo@0.0.2+1
  org: vepo-ut
  auth_token: my_secret_auth_token
  wait_for_processing: true
  log_level: error
  commits: auto
  ignore_missing: true

然后确保使用以下环境变量构建它:

flutter build web -t lib/main_qa.dart --release --no-tree-shake-icons --source-maps --dart-define=SENTRY_DSN=https://xxx@yyy.ingest.sentry.io/zzz --dart-define=SENTRY_ENVIRONMENT=qa --dart-define=SENTRY_RELEASE=vepo@0.0.2+1

在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(),
    ),
  ),
);

然后,一旦所有这些都保存并推送到存储库:

dart run sentry_dart_plugin

甚至可以通过Codemagic使用以下后构建脚本运行:

#!/bin/sh
curl -sL https://sentry.io/get-cli/ | sh

echo -e "[3[92mrun3[0m] Uploading sourcemaps for $SENTRY_RELEASE"

dart run sentry_dart_plugin

请确保按照这些配置和脚本的步骤进行操作。

英文:

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: vepo@0.0.2+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://xxx@yyy.ingest.sentry.io/zzz --dart-define=SENTRY_ENVIRONMENT=qa --dart-define=SENTRY_RELEASE=vepo@0.0.2+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 "[3[92mrun3[0m] Uploading sourcemaps for $SENTRY_RELEASE"


dart run sentry_dart_plugin

答案2

得分: 0

@BeniaminoBaggins 的 releasedist 应该匹配。

配置 release: vepo@0.0.2+1 应该与 const String.fromEnvironment('SENTRY_RELEASE') 匹配。

此外,检查事件中的 dist 字段,如果它们不匹配,您可以在上传和初始化 SDK 时强制它匹配。

如果您无法解决问题,请随时在 https://github.com/getsentry/sentry-dart/issues 上提出问题,提供一个链接到 sentry.io 事件的链接,以便我可以双重检查元数据,甚至最好提供一个最小的可重现示例。

英文:

@BeniaminoBaggins the release and dist should match.

The configuration release: vepo@0.0.2+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.

huangapple
  • 本文由 发表于 2023年8月5日 10:34:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76839942.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定