sentry-java
sentry-java copied to clipboard
Allow attaching screenshots to other event types
Integration
sentry-android
Build System
Gradle
AGP Version
6.8
Proguard
Enabled
Version
6.3.1
Steps to Reproduce
上报截屏配置如下,但是sentry平台没有相关截图,未生效 Sentry.OptionsConfiguration<SentryAndroidOptions> configuration = new Sentry.OptionsConfiguration<SentryAndroidOptions>() { @Override public void configure(@NotNull SentryAndroidOptions options) { options.setAttachScreenshot(true); } }
Expected Result
Sentry平台有相关截图
Actual Result
是sentry平台没有相关截图
Hello @heiyl, are you using the Sentry.OptionsConfiguration for manual init?
In case you're using auto init, have you tried adding the following to your manifest?
<meta-data android:name="io.sentry.attach-screenshot" android:value="true" />
我用的如下配置,您看下,我是手动初始化
<provider
android:name="io.sentry.android.core.SentryInitProvider"
android:authorities="${applicationId}.SentryInitProvider"
tools:node="remove" />
<provider
android:name="io.sentry.android.core.SentryPerformanceProvider"
android:authorities="${applicationId}.SentryPerformanceProvider"
tools:node="remove" />
<meta-data android:name="io.sentry.ndk.scope-sync.enable" android:value="true" />
Hello @heiyl, are you using the
Sentry.OptionsConfigurationfor manual init?In case you're using auto init, have you tried adding the following to your manifest?
<meta-data android:name="io.sentry.attach-screenshot" android:value="true" />
我是按文档配置手动初始化的https://docs.sentry.io/platforms/android/configuration/manual-init/
@heiyl I just tested with our sample App and it worked as expected. Screenshots were uploaded when I enabled the option during init in the Application. https://github.com/getsentry/sentry-java/blob/eba572ac900ca2c58111c6b0db9730a64ac58533/sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/MyApplication.java#L16-L26
This is what I put in MyApplication.java:
SentryAndroid.init(
this,
options -> {
options.setAttachScreenshot(true);
...
When removing the options.setAttachScreenshot(true); the screenshot is not uploaded, with this line it is.
Are you sure you passed your Sentry.OptionsConfiguration which you assigned to configuration when you called SentryAndroid.init?
@heiyl I just tested with our sample App and it worked as expected. Screenshots were uploaded when I enabled the option during init in the
Application.https://github.com/getsentry/sentry-java/blob/eba572ac900ca2c58111c6b0db9730a64ac58533/sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/MyApplication.java#L16-L26
This is what I put in
MyApplication.java:SentryAndroid.init( this, options -> { options.setAttachScreenshot(true); ...When removing the
options.setAttachScreenshot(true);the screenshot is not uploaded, with this line it is.Are you sure you passed your
Sentry.OptionsConfigurationwhich you assigned toconfigurationwhen you calledSentryAndroid.init?
是的,我也是这么设置的,我用的sdk版本为6.3.1,并且我是通过如下上传的事件,这种可以有截图吗? Sentry.captureMessage(msg, parseSentryLevel(level), new ScopeCallback()
@heiyl screenshots are only attached for errored events. Messages do not have screenshots attached.
@heiyl screenshots are only attached for errored events. Messages do not have screenshots attached.
您好,除了error级别,其它类型消息我可以支持上报截图吗?我们确实有这方面需要,以排查视图问题。
您好,除了error级别,其它类型消息我可以支持上报截图吗?我们确实有这方面需要,以排查视图问题。
I think this is a fair request. We decided the default behavior would make more sense for errors only, but we could discuss adding an additional config to include it in other types of events.
谢谢,期待该功能!
Possible solution: send a hint in capture and then have an EventProcessor act on the hint and attach a screenshot.
非常感谢,问题已解决