Instabug / Instabug-iOS

In-app feedback and bug reporting tool for apps.

Home Page:https://instabug.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support of async-await in event handlers

ashalva opened this issue · comments

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

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.

This issue has been automatically closed due to inactivity.