{"id":30048349,"url":"https://github.com/segmentio/segment-braze-mobile-middleware","last_synced_at":"2025-08-07T10:10:18.764Z","repository":{"id":53964812,"uuid":"216915162","full_name":"segmentio/segment-braze-mobile-middleware","owner":"segmentio","description":"Segment\u003c\u003eBraze: mobile sdk middleware examples to debounce identify() calls ","archived":false,"fork":false,"pushed_at":"2023-04-09T21:38:30.000Z","size":360,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T05:35:23.687Z","etag":null,"topics":["analytics-android","analytics-ios","braze","debounce","middleware","segmentio"],"latest_commit_sha":null,"homepage":"https://segment.com/docs/connections/","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/segmentio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-22T21:44:00.000Z","updated_at":"2024-09-02T17:04:56.000Z","dependencies_parsed_at":"2022-08-13T05:20:47.391Z","dependency_job_id":null,"html_url":"https://github.com/segmentio/segment-braze-mobile-middleware","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/segmentio/segment-braze-mobile-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fsegment-braze-mobile-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fsegment-braze-mobile-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fsegment-braze-mobile-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fsegment-braze-mobile-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/segmentio","download_url":"https://codeload.github.com/segmentio/segment-braze-mobile-middleware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segmentio%2Fsegment-braze-mobile-middleware/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269238324,"owners_count":24383516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics-android","analytics-ios","braze","debounce","middleware","segmentio"],"created_at":"2025-08-07T10:10:15.375Z","updated_at":"2025-08-07T10:10:18.733Z","avatar_url":"https://github.com/segmentio.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Segment\u003c\u003eBraze Middleware\n\nOfficial 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](https://app.segment.com) as explained [here](https://www.segment.com/docs/connections/sources/catalog/libraries/website/javascript/#middleware). This contains example code to enable Braze Debounce Identify on mobile client in addition to sample apps to help get you started on [iOS](/iOS/) and [Android](/Android/).\n\n## What are middlewares?\nMiddlewares 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](https://segment.com/docs/sources/mobile/ios/#middlewares) | [android](https://segment.com/docs/sources/mobile/android/#middlewares) | [js](https://www.segment.com/docs/connections/sources/catalog/libraries/website/javascript/#middleware)}\n\n## Why was this Braze middleware built?\nSegment 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.\n\n## How does this work?\nThe core functionality that this middleware adds can be explained with the following pseudo-code:\n```\nif payload is IdentityPayload {\n    if payload.userId != lastUserID or\n       payload.anonymousId != lastAnonymousID or\n       payload.traits != lastTraits {\n            // do nothing, it'll get sent like normal.\n       } else {\n            removeBrazeFromDestinationList()\n       }\n}\n\n```\n\nThe illustration below further elaborates upon this logic:\n![BrazeScenarios](braze-scenarios.png)\n\n\n## Does this work under both cloud and device mode?\nYes. This middleware works under both [cloud and device modes](https://segment.com/docs/destinations/#connection-modes) for the Segment\u003c\u003eBraze [integration](https://segment.com/docs/sources/cloud-apps/braze/). There is not confguration or implementation burden on you and the Segment libraries take care of this internally.\n\n## How do I add this?\nYou can follow our platform specific guides to help you add this middleware to your native mobile projects:\n1. [Android: Java](/Android/README.md)\n2. [iOS: Objective-C](/iOS/Objective-C/README.md)\n3. [iOS: Swift](/iOS/Swift/README.md)\n\nFor your Website sources of type Javascript or Project under Segment please follow directions [here](https://www.segment.com/docs/connections/sources/catalog/libraries/website/javascript/#middleware).\n\n## More information\nPlease [contact us](https://segment.com/help/) for more information on this middleware, or if you have further questions.\n\n![Analytics](https://api.segment.io/v1/pixel/page?data=eyJ3cml0ZUtleSI6IkEyUVM0cVFoWWZ3cldhTHYzZWhRWXhncXQzSWU0T2lwIiwiYW5vbnltb3VzSWQiOiIwMjVwaWthY2h1MDI1IiwiZXZlbnQiOiJSZXBvIFZpc2l0ZWQifQ)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsegmentio%2Fsegment-braze-mobile-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsegmentio%2Fsegment-braze-mobile-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsegmentio%2Fsegment-braze-mobile-middleware/lists"}