Skip to content

Commit 0767751

Browse files
committed
fix: fix timeline in destination plugin
1 parent 4dc18d9 commit 0767751

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

Sources/Amplitude/Plugins/AmplitudeDestinationPlugin.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
public class AmplitudeDestinationPlugin: DestinationPlugin {
9+
public let timeline = Timeline()
910
public var amplitude: Amplitude? = nil
1011
public let type: PluginType = .destination
1112
private var pipeline: EventPipeline?

Sources/Amplitude/Plugins/DestinationPlugin.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,11 @@
66
//
77

88
public protocol DestinationPlugin: EventPlugin {
9-
9+
var timeline: Timeline { get }
1010
}
1111

12-
private var _timeline: Timeline? = nil
1312
extension DestinationPlugin {
14-
var timeline: Timeline? {
15-
if _timeline == nil {
16-
_timeline = Timeline()
17-
}
18-
return _timeline
19-
}
13+
2014
var enabled: Bool {
2115
return true
2216
}
@@ -28,21 +22,21 @@ extension DestinationPlugin {
2822
@discardableResult
2923
func add(plugin: Plugin) -> Plugin {
3024
plugin.amplitude = self.amplitude
31-
timeline?.add(plugin: plugin)
25+
timeline.add(plugin: plugin)
3226
return plugin
3327
}
3428

3529
func remove(plugin: Plugin) {
36-
timeline?.remove(plugin: plugin)
30+
timeline.remove(plugin: plugin)
3731
}
3832

3933
func process(event: BaseEvent?) -> BaseEvent? {
4034
// Skip this destination if it is disabled via settings
4135
if !enabled {
4236
return nil
4337
}
44-
let beforeResult = timeline?.applyPlugin(pluginType: .before, event: event)
45-
let enrichmentResult = timeline?.applyPlugin(pluginType: .enrichment, event: beforeResult)
38+
let beforeResult = timeline.applyPlugin(pluginType: .before, event: event)
39+
let enrichmentResult = timeline.applyPlugin(pluginType: .enrichment, event: beforeResult)
4640
var destinationResult: BaseEvent? = nil
4741
switch enrichmentResult {
4842
case let e as IdentifyEvent:

0 commit comments

Comments
 (0)