sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Allow attaching screenshots to other event types

Open heiyl opened this issue 3 years ago • 10 comments

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平台没有相关截图

heiyl avatar Aug 05 '22 11:08 heiyl

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" />

adinauer avatar Aug 05 '22 11:08 adinauer

我用的如下配置,您看下,我是手动初始化

    <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" />

heiyl avatar Aug 05 '22 12:08 heiyl

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" />

我是按文档配置手动初始化的https://docs.sentry.io/platforms/android/configuration/manual-init/

heiyl avatar Aug 05 '22 12:08 heiyl

@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?

adinauer avatar Aug 05 '22 12:08 adinauer

@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?

是的,我也是这么设置的,我用的sdk版本为6.3.1,并且我是通过如下上传的事件,这种可以有截图吗? Sentry.captureMessage(msg, parseSentryLevel(level), new ScopeCallback()

heiyl avatar Aug 05 '22 13:08 heiyl

@heiyl screenshots are only attached for errored events. Messages do not have screenshots attached.

adinauer avatar Aug 05 '22 14:08 adinauer

@heiyl screenshots are only attached for errored events. Messages do not have screenshots attached.

您好,除了error级别,其它类型消息我可以支持上报截图吗?我们确实有这方面需要,以排查视图问题。

heiyl avatar Aug 08 '22 02:08 heiyl

您好,除了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.

bruno-garcia avatar Aug 09 '22 19:08 bruno-garcia

谢谢,期待该功能!

heiyl avatar Aug 22 '22 02:08 heiyl

Possible solution: send a hint in capture and then have an EventProcessor act on the hint and attach a screenshot.

adinauer avatar Aug 31 '22 14:08 adinauer

非常感谢,问题已解决

heiyl avatar Nov 17 '22 06:11 heiyl