braze-inc / braze-swift-sdk

https://www.braze.com
Other
48 stars 19 forks source link

[Feature]: Callback for addAlias Function in Swift SDK for Enhanced Error Handling #129

Open initishbhatt opened 1 month ago

initishbhatt commented 1 month ago

What problem are you facing?

we are currently using the Braze Swift SDK in our application and have encountered issues with the addAlias function. Specifically, we have observed instances where the alias is not being registered, but there is no callback or error handling mechanism to inform me of this failure. This lack of feedback makes it challenging to diagnose and address the issue effectively.

While using the addAlias function, there are occasions where the alias addition fails silently. Without a callback or error reporting mechanism, it's difficult to determine whether the alias was successfully added or why it failed. This hinders our ability to ensure reliable user identity management within our application.

Workarounds

no clean solution at the moment

Ideal Solution

The addAlias function in the Braze Swift SDK be updated to include a callback that provides feedback on the status of the alias addition. This callback should offer:

Use Case:

This feature is essential for scenarios where it is crucial to know if an alias has been successfully added. For example, in applications where user identity management is critical, knowing the outcome of the alias addition allows developers to take appropriate actions based on the result.

Proposed Implementation:

An example of how this might look :

Braze.sharedInstance()?.user.add(alias: "alias", label: "label") { success, error in
    if success {
        print("Alias added successfully")
    } else {
        if let error = error {
            print("Failed to add alias: \(error.localizedDescription)")
        } else {
            print("Failed to add alias for an unknown reason")
        }
    }
}

Other Information

No response

jerielng commented 1 month ago

Hi @initishbhatt, thanks for your request! At the moment, our add(alias:label:) method does check and log errors if the alias is not valid, so you should be seeing some output in your verbose logs in such cases. Let us know if that's not the behavior you're observing.

Are there other cases where you would require further functionality with a completion handler?

initishbhatt commented 1 month ago

Hi @initishbhatt, thanks for your request! At the moment, our add(alias:label:) method does check and log errors if the alias is not valid, so you should be seeing some output in your verbose logs in such cases. Let us know if that's not the behavior you're observing.

Are there other cases where you would require further functionality with a completion handler?

Hi @jerielng i see that there is an option to log error but this happens sporadically so it becomes difficult to understand the root cause of failure, since the log lives locally providing a callback gives us an option to re-trigger the addAlias call in case of failure and would allow use to log those errors in a monitoring tool like Sentry or Crashlytics for further analysis.

jerielng commented 1 month ago

@initishbhatt That makes sense - thank you for your feedback! Since this would be a feature request, could you file it here to route it to our product teams for prioritization?

jerielng commented 1 month ago

Additionally, could you also clarify what type of errors you are seeing? When you mention that it happens sporadically, are you seeing failures when you don't expect them? It would help to know the type of values you are logging for aliases in case there is something deeper that might be occurring that is outside of intended behavior.