diff --git a/IntegrationTest/devicefarm/logcat_test.py b/IntegrationTest/devicefarm/logcat_test.py index fc0c9cf..4dd7f92 100644 --- a/IntegrationTest/devicefarm/logcat_test.py +++ b/IntegrationTest/devicefarm/logcat_test.py @@ -196,7 +196,7 @@ def test_app_end(self, path): def get_submitted_events(path): submitted_events = [] with open(path, 'r') as file: - pattern = re.compile(r' Send (\d+) events') + pattern = re.compile(r'^Send (\d+) events') for line in file: match = pattern.search(line) if match: @@ -209,7 +209,7 @@ def get_recorded_events(path): log_lines = file.readlines() events = [] first_event_pattern = re.compile(r'app_event_log:Saved event (\w+):(.*)$') - event_pattern = re.compile(r' Saved event (\w+):(.*)$') + event_pattern = re.compile(r'^Saved event (\w+):(.*)$') current_event_name = '' diff --git a/Sources/Clickstream/Dependency/Clickstream/Event/ClickstreamEvent.swift b/Sources/Clickstream/Dependency/Clickstream/Event/ClickstreamEvent.swift index c05ac56..301d9c7 100644 --- a/Sources/Clickstream/Dependency/Clickstream/Event/ClickstreamEvent.swift +++ b/Sources/Clickstream/Dependency/Clickstream/Event/ClickstreamEvent.swift @@ -109,7 +109,9 @@ class ClickstreamEvent: AnalyticsPropertiesModel { if !items.isEmpty { event["items"] = items } - event["user"] = userAttributes + if !userAttributes.isEmpty { + event["user"] = userAttributes + } event["attributes"] = getAttributeObject(from: attributes) return event } diff --git a/Tests/ClickstreamTests/Clickstream/EventRecorderTest.swift b/Tests/ClickstreamTests/Clickstream/EventRecorderTest.swift index 73c9fe4..4b74edf 100644 --- a/Tests/ClickstreamTests/Clickstream/EventRecorderTest.swift +++ b/Tests/ClickstreamTests/Clickstream/EventRecorderTest.swift @@ -132,7 +132,7 @@ class EventRecorderTest: XCTestCase { XCTAssertNotNil(event["app_version"]) XCTAssertNotNil(event["app_package_name"]) XCTAssertNotNil(event["app_title"]) - XCTAssertNotNil(event["user"]) + XCTAssertNil(event["user"]) XCTAssertNotNil(event["attributes"]) XCTAssertNil(event["noneExistAttribute"]) } diff --git a/Tests/ClickstreamTests/IntegrationTest.swift b/Tests/ClickstreamTests/IntegrationTest.swift index 25a305c..22c3e87 100644 --- a/Tests/ClickstreamTests/IntegrationTest.swift +++ b/Tests/ClickstreamTests/IntegrationTest.swift @@ -256,6 +256,7 @@ class IntegrationTest: XCTestCase { XCTAssertEqual((user["score"] as! JsonObject)["value"] as! Double, 85.2) XCTAssertEqual((user["_user_name"] as! JsonObject)["value"] as! String, "carl") XCTAssertNotNil(user[Event.ReservedAttribute.USER_FIRST_TOUCH_TIMESTAMP]) + XCTAssertNotNil((user[Event.ReservedAttribute.USER_FIRST_TOUCH_TIMESTAMP] as! JsonObject)["value"]) } func testProfileSetTimestamp() throws {