Skip to content

segmentio/segment-braze-mobile-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Segment<>Braze Middleware

Official repository explaining the Braze Debounce Identify() functionality for customers using both products via direct Segment integration. This codebase is only an example for iOS and Android. For analytics.js you can directly access similar functionality via source settings as explained here. This contains example code to enable Braze Debounce Identify on mobile client in addition to sample apps to help get you started on iOS and Android.

What are middlewares?

Middlewares are a powerful mechanism that can augment the events collected by the SDK. A middleware is a simple function that is invoked by the Segment SDK and can be used to monitor, modify or reject events. They are available across all analytics-{ ios | android | js}

Why was this Braze middleware built?

Segment customers are not charged for duplicate identify() calls hence default client app and Segment SDK behavior is to aggresively call this endpoint. Braze on the other hand is priced such that customers are charged per data point stored (incuding duplicates). To help customers avoid overage, this middleware was built to avoid sending duplicate user traits to Braze on every identify() call inside Segment.

How does this work?

The core functionality that this middleware adds can be explained with the following pseudo-code:

if payload is IdentityPayload {
    if payload.userId != lastUserID or
       payload.anonymousId != lastAnonymousID or
       payload.traits != lastTraits {
            // do nothing, it'll get sent like normal.
       } else {
            removeBrazeFromDestinationList()
       }
}

The illustration below further elaborates upon this logic: BrazeScenarios

Does this work under both cloud and device mode?

Yes. This middleware works under both cloud and device modes for the Segment<>Braze integration. There is not confguration or implementation burden on you and the Segment libraries take care of this internally.

How do I add this?

You can follow our platform specific guides to help you add this middleware to your native mobile projects:

  1. Android: Java
  2. iOS: Objective-C
  3. iOS: Swift

For your Website sources of type Javascript or Project under Segment please follow directions here.

More information

Please contact us for more information on this middleware, or if you have further questions.

Analytics