Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash when user attribute is empty #71

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions IntegrationTest/devicefarm/logcat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 = ''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ClickstreamTests/Clickstream/EventRecorderTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
}
Expand Down
1 change: 1 addition & 0 deletions Tests/ClickstreamTests/IntegrationTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading