File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -159,4 +159,8 @@ extension Analytics {
159159 public func find< T: Plugin > ( pluginType: T . Type ) -> T ? {
160160 return timeline. find ( pluginType: pluginType)
161161 }
162+
163+ public func find( key: String ) -> DestinationPlugin ? {
164+ return timeline. find ( key: key)
165+ }
162166}
Original file line number Diff line number Diff line change @@ -135,6 +135,17 @@ extension Timeline {
135135 }
136136 return found. first as? T
137137 }
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+ }
138149}
139150
140151// MARK: - Plugin Timeline Execution
Original file line number Diff line number Diff line change @@ -76,6 +76,10 @@ final class Analytics_Tests: XCTestCase {
7676
7777 analytics. track ( name: " testDestinationEnabled " )
7878
79+ let dest = analytics. find ( key: myDestination. key)
80+ XCTAssertNotNil ( dest)
81+ XCTAssertTrue ( dest is MyDestination )
82+
7983 wait ( for: [ expectation] , timeout: 1.0 )
8084 }
8185
You can’t perform that action at this time.
0 commit comments