File tree Expand file tree Collapse file tree
Sources/GDSAnalytics/Events/Forms
Tests/GDSAnalyticsTests/Events Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,17 +5,21 @@ public struct FormCTAEvent: Event {
55 public let type = EventType . callToAction
66
77 public let text : String
8+ public let response : String
89
910 public var parameters : [ String : String ] {
1011 [
1112 EventParameter . text. rawValue: text,
12- EventParameter . type. rawValue: type. rawValue
13+ EventParameter . type. rawValue: type. rawValue,
14+ EventParameter . response. rawValue: response
1315 ] . mapValues ( \. formattedAsParameter)
1416 }
1517
1618 public init ( textKey: String ,
1719 _ variableKeys: String ... ,
20+ responseKey: String ,
1821 bundle: Bundle = . main) {
1922 self . text = textKey. englishString ( variableKeys, bundle: bundle)
23+ self . response = responseKey. englishString ( bundle: bundle)
2024 }
2125}
Original file line number Diff line number Diff line change @@ -3,19 +3,21 @@ import XCTest
33
44final class FormCTAEventTests : XCTestCase {
55 func testInitialisation( ) {
6- let event = FormCTAEvent ( textKey: " Continue " )
6+ let event = FormCTAEvent ( textKey: " Continue " , responseKey : " Yes " )
77
88 XCTAssertEqual ( event. name, . formResponse)
99 XCTAssertEqual ( event. type, . callToAction)
1010 XCTAssertEqual ( event. text, " Continue " )
11+ XCTAssertEqual ( event. response, " Yes " )
1112 }
1213
1314 func testParameters( ) {
14- let event = FormCTAEvent ( textKey: " Continue " )
15+ let event = FormCTAEvent ( textKey: " Continue " , responseKey : " Yes " )
1516
1617 XCTAssertEqual ( event. parameters, [
1718 " text " : " continue " ,
18- " type " : " call to action "
19+ " type " : " call to action " ,
20+ " response " : " yes "
1921 ] )
2022 }
2123}
You can’t perform that action at this time.
0 commit comments