Skip to content

Commit 5bbe69a

Browse files
Merge pull request #4950 from segmentio/niall/braze_swift_update
Update braze swift docs
2 parents c8614f5 + 0b88b61 commit 5bbe69a

File tree

1 file changed

+9
-90
lines changed
  • src/connections/sources/catalog/libraries/mobile/apple/destination-plugins

1 file changed

+9
-90
lines changed

src/connections/sources/catalog/libraries/mobile/apple/destination-plugins/braze-swift.md

Lines changed: 9 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Analytics Swift Braze Plugin
44

55
[Braze](https://www.braze.com/), formerly Appboy, is an engagement platform that empowers growth by helping marketing teams to build customer loyalty through mobile, omni-channel customer experiences.
66

7-
Braze’s destination plugin code is open source and available on GitHub. You can view it [here.](https://github.com/braze-inc/analytics-swift-braze). This destination plugin is maintained by Braze. For any issues with the destination plugin code, please reach out to Braze's support.
7+
Braze’s destination plugin code is open source and available on GitHub. You can view it [here](https://github.com/braze-inc/analytics-swift-braze). This destination plugin is maintained by Braze. For any issues with the destination plugin code, please reach out to Braze's support.
88

99
## Getting Started
1010

@@ -16,16 +16,17 @@ Braze’s destination plugin code is open source and available on GitHub. You ca
1616

1717
## Adding the dependency
1818

19-
### through Xcode
19+
### Through Xcode
2020
In the Xcode `File` menu, click `Add Packages`. You'll see a dialog where you can search for Swift packages. In the search field, enter the URL to this repository.
21+
```
22+
https://github.com/segment-integrations/analytics-swift-braze
23+
```
2124

22-
https://github.com/segment-integrations/analytics-swift-braze{:target="_blank"}
23-
24-
You'll then have the option to pin to a version, or specific branch, as well as which project in your workspace to add it to. Once you've made your selections, click the `Add Package` button.
25+
You'll then have the option to pin to a version, or specific branch, as well as which project in your workspace to add it to. Once you've made your selections, click the `Add Package` button.
2526

26-
### through Package.swift
27+
### Through Package.swift
2728

28-
Open your Package.swift file and add the following do your the `dependencies` section:
29+
Open your Package.swift file and add the following to the `dependencies` section:
2930

3031
```
3132
.package(
@@ -53,14 +54,6 @@ let analytics = Analytics(configuration: Configuration(writeKey: "<YOUR WRITE KE
5354
.trackApplicationLifecycleEvents(true))
5455
analytics.add(plugin: BrazeDestination())
5556
```
56-
## Screen
57-
If you're not familiar with the Segment Specs, take a look to understand what the [Page method](/docs/connections/spec/page/) does. An example call would look like:
58-
59-
```swift
60-
analytics.screen(title: "SomeScreen")
61-
```
62-
63-
Segment sends Page calls to Braze as custom events if you have enabled either **Track All Pages** or **Track Only Named Pages** in the Segment Settings.
6457

6558
## Identify
6659

@@ -135,81 +128,7 @@ Segment sends all other traits (except Braze's [reserved user profile fields](ht
135128
> info "Tip"
136129
> To lower [Data Point](https://www.braze.com/docs/user_guide/onboarding_with_braze/data_points/) use, limit the events you send to Braze to those that are relevant for campaigns and segmentation to the Braze destination. For more information, see [Schema Controls](/docs/protocols/schema/).
137130
138-
If you're not familiar with the Segment Specs, take a look to understand what the [Track method](/docs/connections/spec/track/) does. An example call looks like:
139-
140-
```swift
141-
struct TrackProperties: Codable {
142-
let someValue: String
143-
}
144-
145-
analytics.track(name: "My Event", properties: TrackProperties(someValue: "Hello"))
146-
```
147-
When you `track` an event, Segment sends that event to Braze as a custom event.
148-
149-
> note ""
150-
> Braze requires that you include a `userId` or `braze_id` for all calls made in cloud-mode. Segment sends a `braze_id` if `userId` is missing. When you use a device-mode connection, Braze automatically tracks anonymous activity using the `braze_id` if a `userId` is missing.
151-
152-
> note ""
153-
> Segment removes the following custom properties reserved by Braze:
154-
>
155-
> - `time`
156-
> - `quantity`
157-
> - `event_name`
158-
> - `price`
159-
> - `currency`
160-
161-
### Order Completed
162-
163-
When you `track` an event with the name `Order Completed` using the [e-commerce tracking API](/docs/connections/spec/ecommerce/v2/), Segment sends the products you've listed to Braze as purchases.
164-
165-
### Purchases
166-
167-
When you pass [ecommerce events](/docs/connections/spec/ecommerce/v2/), the name of the event becomes the `productId` in Braze. An example of a purchase event looks like:
168-
169-
```swift
170-
struct TrackProperties: Codable {
171-
let revenue: String
172-
let currency: String
173-
}
174-
175-
analytics.track(name: "Purchased Item", properties: TrackProperties(revenue: "2000", currency: "USD"))
176-
```
177-
178-
The example above would have "Purchased Item" as its `productId` and includes two required properties that you must pass in:
179-
180-
- `revenue`
181-
- `currency`
131+
The Braze Swift destination plugin currently only supports sending `logPurchase` events, and custom events are not supported in device mode. Please review the [plugin code](https://github.com/braze-inc/analytics-swift-braze/blob/main/Sources/SegmentBraze/BrazeDestination.swift) for more information.
182132

183133
Braze supports currency codes as specified in [their Purchase Object Specification](https://www.braze.com/docs/api/objects_filters/purchase_object/). Be aware that any currency reported other than USD displays in [the Braze UI in USD based on the exchange rate on the date it was reported](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/analytics/logging_purchases/#logging-purchases).
184134

185-
You can add more product details in the form of key-value pairs to the `properties` object. The following reserved keys are not passed to Braze if included in your Track call's `properties` object:
186-
187-
- `time`
188-
- `product_id`
189-
- `quantity`
190-
- `event_name`
191-
- `price`
192-
193-
194-
## Group
195-
196-
If you're not familiar with the Segment Specs, take a look to understand what the [Group method](/docs/connections/spec/group/) does. An example call would look like:
197-
198-
```swift
199-
struct MyTraits: Codable {
200-
let username: String
201-
let email: String
202-
let plan: String
203-
}
204-
205-
// ...
206-
207-
analytics.group(groupId: "group123", traits: MyTraits(
208-
username: "MisterWhiskers",
209-
210-
plan: "premium"))
211-
```
212-
213-
When you call `group`, Segment sends a custom attribute to Braze with the name `ab_segment_group_<groupId>`, where `<groupId>` is the group's ID in the method's parameters. For example, if the group's ID is `1234`, then the custom attribute name is `ab_segment_group_1234`. The value of the custom attribute is `true`.
214-
215-

0 commit comments

Comments
 (0)