Skip to content

Commit 906257a

Browse files
feat!: updated FormEventCTA to require responseKey parameter (#97)
1 parent 7b92893 commit 906257a

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

Sources/GDSAnalytics/Events/Forms/FormCTAEvent.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

Tests/GDSAnalyticsTests/Events/FormCTAEvents.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ import XCTest
33

44
final 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
}

0 commit comments

Comments
 (0)