refiner-io / mobile-sdk-ios

iOS SDK for Refiner in-app surveys
https://refiner.io
0 stars 0 forks source link

[Enhancement] Log error instead of crashing if Refiner has not been initialized #1

Closed jeremiahk closed 11 months ago

jeremiahk commented 1 year ago

Hello, I would categorize this request as a nice to have. Its not a blocker.

If Refiner.instance.trackScreen is called before Refiner.instance.initialize it causes the following crash:

Function doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError.
It is considered unexpected and unhandled instead. Program will be terminated.
Uncaught Kotlin exception: org.koin.core.error.NoBeanDefFoundException: |- No definition found for class:'co.touchlab.kermit.Logger'. Check your definitions!
    at 0   RefinerInternalSDK                  0x10bcf9457        kfun:org.koin.core.scope.Scope.throwDefinitionNotFound#internal + 511 
    at 1   RefinerInternalSDK                  0x10bcf912b        kfun:org.koin.core.scope.Scope.resolveInstance#internal + 2491 
    at 2   RefinerInternalSDK                  0x10bcf801b        kfun:org.koin.core.scope.Scope#get(kotlin.reflect.KClass<*>;org.koin.core.qualifier.Qualifier?;kotlin.Function0<org.koin.core.parameter.ParametersHolder>?){0§<kotlin.Any?>}0:0 + 471 
    at 3   RefinerInternalSDK                  0x10bd2483b        kfun:io.refiner.shared.$injectLogger$lambda-8$FUNCTION_REFERENCE$6.invoke#internal + 815 
    at 4   RefinerInternalSDK                  0x10babe47f        kfun:kotlin.native.concurrent.SafePublicationLazyImpl#<get-value>(){}1:0 + 983 
    at 5   RefinerInternalSDK                  0x10bd67043        kfun:io.refiner.shared.NativeViewModel.<get-log>#internal + 235 
    at 6   RefinerInternalSDK                  0x10bda591f        objc2kotlin.1713 + 987 
    at 7   Driver                              0x104cb3857        $s10RefinerSDK0A0C9viewModel33_7D1C7512F44F37760770E716D9FBAA8CLLSo015RISDKNativeViewD0Cvg + 63 
    at 8   Driver                              0x104cb649b        $s10RefinerSDK0A0C10trackEvent4nameySS_tFTm + 51 
    at 9   Driver                              0x104cb65bf        $s10RefinerSDK0A0C10trackEvent4nameySS_tFToTm + 91 
    at 10  Driver                              0x104958ba7        $s6Driver21RefinerViewControllerC13viewDidAppearyySbF + 479 
    at 11  Driver                              0x104958c47        $s6Driver21RefinerViewControllerC13viewDidAppearyySbFTo + 55 
    at 12  UIKitCore                           0x1bc05527b        <redacted> + 1147 
    at 13  UIKitCore                           0x1bc26d6d3        <redacted> + 163 
    at 14  UIKitCore                           0x1bc26d54f        <redacted> + 215 
    at 15  UIKitCore                           0x1bc198443        <redacted> + 1195 
    at 16  UIKit                               0x24104fa63        <redacted> + 103 
    at 17  UIKitCore                           0x1bc197f5b        <redacted> + 295 
    at 18  UIKitCore                           0x1bc19751b        <redacted> + 535 
    at 19  UIKitCore                           0x1bc19726b        <redacted> + 135 
    at 20  UIKitCore                           0x1bc1f0787        <redacted> + 1611 
    at 21  UIKitCore                           0x1bc1efdeb        <redacted> + 2103 
    at 22  UIKitCore                           0x1bc1eeb2f        <redacted> + 607 
    at 23  UIKitCore                           0x1bc1ee17f        <redacted> + 95 
    at 24  UIKitCore                           0x1bc1ee0e3        <redacted> + 171 
    at 25  UIKit                               0x241048c2b        <redacted> + 51 
    at 26  UIKitCore                           0x1bc04c84f        <redacted> + 1979 
    at 27  QuartzCore                          0x1bb51fb0b        <redacted> + 499 
    at 28  QuartzCore                          0x1bb5331bf        <redacted> + 147 
    at 29  QuartzCore                          0x1bb544533        <redacted> + 443 
    at 30  QuartzCore                          0x1bb57992f        <redacted> + 651 
    at 31  UIKitCore                           0x1bc54c0af        <redacted> + 83 
    at 32  UIKitCore                           0x1bc69a48f        <redacted> + 83 
    at 33  UIKitCore                           0x1bcce640f        <redacted> + 171 
    at 34  UIKitCore                           0x1bcce55db        <redacted> + 91 
    at 35  CoreFoundation                      0x1b9f3cf33        <redacted> + 27 
    at 36  CoreFoundation                      0x1b9f4930b        <redacted> + 175 
    at 37  CoreFoundation                      0x1b9ecd22f        <redacted> + 339 
    at 38  CoreFoundation                      0x1b9ee2b8b        <redacted> + 835 
    at 39  CoreFoundation                      0x1b9ee7ebf        CFRunLoopRunSpecific + 611 
    at 40  GraphicsServices                    0x1f4733367        GSEventRunModal + 163 
    at 41  UIKitCore                           0x1bc3e985b        <redacted> + 887 
    at 42  UIKitCore                           0x1bc3e94bf        UIApplicationMain + 339 
    at 43  Driver                              0x1049a8b57        main + 63 
    at 44  dyld                                0x1d8ec795f        <redacted> + 2527 

Because of our current feature switch logic we can sometimes end up in a state where the application does not in initialize Refiner, but it does try to track a screen. I don't think the function needs to be throwing. Logging an error would be fine. Again, this is not a high priority request.

tekinalper commented 11 months ago

Resolved, thank you.