Skip to content

Commit

Permalink
Add Braze property observer and log custom event
Browse files Browse the repository at this point in the history
Need a callback on Braze update to customize Braze implementation. 

Also the SDK is not calling custom events like the Obj-C sdk does on `track`
  • Loading branch information
Aaron Satterfield committed Dec 1, 2022
1 parent f09a377 commit d392b0a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Sources/SegmentBraze/BrazeDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ public class BrazeDestination: DestinationPlugin {
public let type = PluginType.destination
public let key = "Appboy"
public var analytics: Analytics? = nil
var braze: Braze? = nil
public var onBrazeUpdate: ((_: Braze?) -> Void)?
var braze: Braze? = nil {
didSet {
onBrazeUpdate?(braze)
}
}

private var brazeSettings: BrazeSettings?

Expand All @@ -59,11 +64,14 @@ public class BrazeDestination: DestinationPlugin {
guard let tempSettings: BrazeSettings = settings.integrationSettings(forPlugin: self) else { return }
brazeSettings = tempSettings

var configuration = Braze.Configuration(
let configuration = Braze.Configuration(
apiKey: brazeSettings?.apiKey ?? "",
endpoint: brazeSettings?.customEndpoint ?? ""
)
configuration.api.addSdkMetadata([Braze.Configuration.Api.SdkMetadata.segment])

configuration.location.automaticLocationCollection = true

configuration.api.addSDKMetadata([Braze.Configuration.Api.SDKMetadata.segment])

braze = Braze(configuration: configuration)
}
Expand Down Expand Up @@ -198,6 +206,9 @@ public class BrazeDestination: DestinationPlugin {
quantity: 1)
}
}

braze?.logCustomEvent(name: event.event, properties: event.properties?.dictionaryValue)

return event
}
}
Expand Down

0 comments on commit d392b0a

Please sign in to comment.