Skip to content

Commit 3f9610c

Browse files
bsneedBrandon Sneed
and
Brandon Sneed
authored
Fix metadata population (#128)
Co-authored-by: Brandon Sneed <[email protected]>
1 parent 343f98e commit 3f9610c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Sources/Segment/Plugins/SegmentDestination.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public class SegmentDestination: DestinationPlugin {
7272

7373
// MARK: - Event Handling Methods
7474
public func execute<T: RawEvent>(event: T?) -> T? {
75-
let result: T? = event
75+
guard let event = event else { return nil }
76+
let result = process(incomingEvent: event)
7677
if let r = result {
7778
queueEvent(event: r)
7879
}

Tests/Segment-Tests/Analytics_Tests.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,13 @@ final class Analytics_Tests: XCTestCase {
358358
let analytics = Analytics(configuration: Configuration(writeKey: "test"))
359359
let mixpanel = AnyDestination(key: "Mixpanel")
360360
let outputReader = OutputReaderPlugin()
361-
analytics.add(plugin: outputReader)
361+
362+
// we want the output reader on the segment plugin
363+
// cuz that's the only place the metadata is getting added.
364+
let segmentDest = analytics.find(pluginType: SegmentDestination.self)
365+
segmentDest?.add(plugin: outputReader)
366+
362367
analytics.add(plugin: mixpanel)
363-
analytics.add(plugin: DestinationMetadataPlugin())
364368
var settings = Settings(writeKey: "123")
365369
let integrations = try? JSON([
366370
"Segment.io": JSON([

0 commit comments

Comments
 (0)