Instabug / Instabug-iOS

In-app feedback and bug reporting tool for apps.
https://instabug.com/
Other
290 stars 67 forks source link

Add support of async-await in event handlers #480

Closed ashalva closed 10 months ago

ashalva commented 11 months ago

Steps to Reproduce the Problem

Trying to use async-await inside willSendReportHandler. I have an actor which holds the information which I want to attach to the logs before user submits the report.

import Instabug

class InstabugTesting {
    private let featureProvider = SomeFeatureProvider()

    func setupWillSendReportObserver() {
        Instabug.willSendReportHandler = { [weak self] report in  // <-- Invalid conversion from 'async' function of type '(IBGReport) async -> IBGReport' to synchronous function type '(IBGReport) -> IBGReport'
            guard let self else { return report }

            let features = await self.featureProvider.features
            for feature in features {
                IBGLog.logInfo(feature)
            }

            return report
        }
    }
}

actor SomeFeatureProvider {
    var features: [String] = []

    func addFeature(_ feature: String) {
        features.append(feature)
    }
}

The error makes sense from current API standpoint, but having the async callbacks or any other ways support async-await calls would ease developers' lives.

Expected Behavior

Ideally support of async-await for event handlers 🥺

Actual Behavior

Compiler error 👇

image

Instabug integration code

Make sure to remove your app token.

SDK Version

12.2.0

iOS Version

Any

Device Model

Any

[Optional] Project That Reproduces the Issue

Reproducable with attached code snippet

stale[bot] commented 10 months ago

This issue has been automatically marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 10 months ago

This issue has been automatically closed due to inactivity.