braze-inc / braze-web-sdk

Public repo for the Braze Web SDK
https://www.braze.com
Other
73 stars 26 forks source link

Question: Future of `messageReadyCallback` #59

Closed GeorgeTaveras1231 closed 4 years ago

GeorgeTaveras1231 commented 5 years ago

I see in this change log that messageReadyCallback is being deprecated.

However, we've relied on this to ensure the proper timing of events in scenario's where the user is being redirected, and we want to wait for all analytics calls to finish (specifically in our sign up flows).

Our order of events is:

  1. User submits form
  2. User is created (via async API request)
  3. Data is received from user creation, which we use to send to braze via appboy.changeUser
  4. Redirect.

If we don't have a way to wait for the asyncchangeUser call to finish, then we risk missing some of those calls, since a redirect will force ongoing requests to be canceled.

So will there be another way to wait for that call to finish? Or can you reconsider the fate of the messageReadyCallback?

froodian commented 5 years ago

Thanks for the feedback @GeorgeTaveras1231 - that's an interesting use-case! The reason we marked messageReadyCallback as deprecated is because we solved the main purpose that it had been written for internally (ensuring that available in-app messages finish syncing before events that are supposed to trigger them fire). Their presence was somewhat confusing for some integrators though and implied (incorrectly) for a lot of people that the SDK was totally unready for use after calling openSession or changeUser until those callbacks had been invoked. I follow your use-case though and the value that it is providing for you.

In the long term, I wonder if a cleaner way of ensuring that use-cases like yours function as desired would be for us to introduce a completion callback to appboy.requestImmediateDataFlush - something like that would also function for various other event-flushing-plus-navigation use-cases, even for integrators that don't conveniently have a new user id to call changeUser with like you do. And then we could ensure internally that things like

appboy.changeUser("new user id");
appboy.requestImmediateDataFlush(function() {
   document.location = "https://new-url.com"
});

work as desired

Does something like that seem like it would solve your use-case?

In the short term, rest assured that we have no immediate plans to remove the messageReadyCallback functionality, and now that you've raised this use-case we'll make sure we at least have a satisfying answer to keep that working before we consider making any changes.

GeorgeTaveras1231 commented 5 years ago

Thanks for the response @froodian! Yes, something like that should work, as long as the callback is called after the data has successfully been sent to braze. And thanks for reassuring me that messageReadyCallback won't be going away soon. But in the case it does, is there a way for me to be notified directly? Is there some sort of release notification system in place that I can subscribe to? Or what would be the best way to find out ASAP?

froodian commented 5 years ago

Sounds good - I've filed this work internally with dependencies such that any future removal of messageReadyCallback will be blocked on having a replacement solution like this present, and I've also linked back to this issue to ensure that you're proactively notified when we prioritize that work.

In terms of the larger release notification question, you could potentially use the https://github.com/Appboy/appboy-web-sdk/releases.atom feed - if you don't already use an RSS reader regularly you could potentially set up email notifications based on that - a quick google for "rss feed email notification" shows some ways of getting entries from a feed like that into an email inbox.

GeorgeTaveras1231 commented 5 years ago

@froodian thanks for thoughtfully handling this on your side. As far as getting notified. If you are planning on sharing progress via this issue, I'm happy with subscribing to the issue since GH will send me email notifications.

wesleyorbin commented 4 years ago

Hi @GeorgeTaveras1231! We just released version 2.5.0, which adds a completion callback to appboy.requestImmediateDataFlush as discussed above.

I'm going to close out this issue for now, but should you have any issues with the new callback, feel free to re-open.