File tree 3 files changed +19
-0
lines changed
3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -159,4 +159,8 @@ extension Analytics {
159
159
public func find< T: Plugin > ( pluginType: T . Type ) -> T ? {
160
160
return timeline. find ( pluginType: pluginType)
161
161
}
162
+
163
+ public func find( key: String ) -> DestinationPlugin ? {
164
+ return timeline. find ( key: key)
165
+ }
162
166
}
Original file line number Diff line number Diff line change @@ -135,6 +135,17 @@ extension Timeline {
135
135
}
136
136
return found. first as? T
137
137
}
138
+
139
+ internal func find( key: String ) -> DestinationPlugin ? {
140
+ var found = [ Plugin] ( )
141
+ if let mediator = plugins [ . destination] {
142
+ found. append ( contentsOf: mediator. plugins. filter { plugin in
143
+ guard let p = plugin as? DestinationPlugin else { return false }
144
+ return p. key == key
145
+ } )
146
+ }
147
+ return found. first as? DestinationPlugin
148
+ }
138
149
}
139
150
140
151
// MARK: - Plugin Timeline Execution
Original file line number Diff line number Diff line change @@ -76,6 +76,10 @@ final class Analytics_Tests: XCTestCase {
76
76
77
77
analytics. track ( name: " testDestinationEnabled " )
78
78
79
+ let dest = analytics. find ( key: myDestination. key)
80
+ XCTAssertNotNil ( dest)
81
+ XCTAssertTrue ( dest is MyDestination )
82
+
79
83
wait ( for: [ expectation] , timeout: 1.0 )
80
84
}
81
85
You can’t perform that action at this time.
0 commit comments