braze-inc / braze-web-sdk

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

[Feature]: `logInAppMissageDismissal` #136

Closed psimk closed 1 year ago

psimk commented 1 year ago

What problem are you facing?

When using my own custom in-app-message UI, I am unable to log "close message" events.

Workarounds

N/A

Ideal Solution

A separately importable function that would let me pass an in app message, and send out a "close message" event for it:

/**
 * Logs that the user dismissed the given inAppMessage.
 *
 * @param inAppMessage - the `InAppMessage` object that received a dismissal
 *
 * @returns Whether or not the event was successfully logged (to be flushed later).
 */
export function logInAppMessageDismissal(inAppMessage: InAppMessage): boolean;

This would be mimicking the content card utility - logCardDismissal.

Other Information

As I understand, there exists inAppMessage.closeMessage(), but it only works when we are using the Braze UI.

davidbielik commented 1 year ago

Hi @psimk depending on the In-app message type (Modal, Fullscreen, HTML, etc.) you can log clicks accordingly.

Since you're using your own UI, you're correct there's no dismiss method. So in addition to hiding/removing your message UI yourself, it sounds like you're looking for one of the following methods to log a click for analytics purposes:

logInAppMessageButtonClick will log button 1 or 2.

logInAppMessageClick logs a "body" click.

For HTML in-app messages, you can use logInAppMessageHtmlClick which lets you log any arbitrary button name (i.e. "closed message" or "clicked some button")

Let me know if that helps answer your question.

psimk commented 1 year ago

I understand that we can log button clicks with logInAppMessageButtonClick, log body clicks with logInAppMessageClick and handle HTML in-app-message clicks with logInAppMessageHtmlClick.

However, there still is no function that we can call to log in-app-message dismissals. Is this something that the Braze SDK could implement? I understand the functionality already exists internally, it is just not exposed to us.

wesleyorbin commented 1 year ago

Hi @psimk. Are you trying to log dismissal events to the backend? If so, in-app message dismissal events are not actually logged to the backend (unlike content cards). They exist so that users of the built-in UI can be notified through subscribeToDismissedEvent that the user has closed the message.

psimk commented 1 year ago

Are you trying to log dismissal events to the backend?

Yes, that's what we're trying to do. We want to see how many users have dismissed the message.

wesleyorbin commented 1 year ago

@psimk Unfortunately the backend does not support this as a built-in event. You can log it as a custom event and create your own analytics or you can submit product feedback that you would like this functionality to be added. I'm going to close out the issue since this is a more general product request rather than an SDK request.