Skip to content

Commit

Permalink
fix: fix the compatible issue with macOSSonoma (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhao900914 authored Sep 15, 2023
1 parent 94160a5 commit fd9495f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Sources/Amplitude/AMPIdentifyInterceptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ - (NSMutableDictionary *)intercept:(NSMutableDictionary *_Nonnull)event {
[self scheduleTransfer];

// Event is intercepted, return nil
return nil;
return [NSMutableDictionary dictionary];
} else if ([userPropertyOperations objectForKey:AMP_OP_CLEAR_ALL] != nil) {
// Clear all pending intercepted Identify's
[_dbHelper removeInterceptedIdentifys:[_dbHelper getLastSequenceNumber]];
Expand Down
2 changes: 1 addition & 1 deletion Sources/Amplitude/Amplitude.m
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ - (void)logEvent:(NSString *)eventType withEventProperties:(NSDictionary *)event
}

event = [self->_identifyInterceptor intercept:event];
if (event != nil) {
if ([event count] != 0) {
// convert event dictionary to JSON String
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[AMPUtils makeJSONSerializable:event] options:0 error:&error];
Expand Down
26 changes: 13 additions & 13 deletions Tests/IdentifyInterceptorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ - (void)testIdentifyWithOnlySetIsIntercepted {

event = [self->_identifyInterceptor intercept:event];

XCTAssertEqual(event, nil);
XCTAssertEqual([event count], 0);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 1);

Expand Down Expand Up @@ -141,7 +141,7 @@ - (void)testInterceptedIdentifyIsTransferredOnNextActiveIdentify {

event1 = [self->_identifyInterceptor intercept:event1];

XCTAssertNil(event1);
XCTAssertEqual([event1 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 1);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 1);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand Down Expand Up @@ -183,7 +183,7 @@ - (void)testMultipleInterceptedIdentifyIsTransferredOnNextActiveIdentify {

event1 = [self->_identifyInterceptor intercept:event1];

XCTAssertNil(event1);
XCTAssertEqual([event1 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 1);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 1);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand All @@ -195,7 +195,7 @@ - (void)testMultipleInterceptedIdentifyIsTransferredOnNextActiveIdentify {

event2 = [self->_identifyInterceptor intercept:event2];

XCTAssertNil(event2);
XCTAssertEqual([event2 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 2);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 2);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand Down Expand Up @@ -244,7 +244,7 @@ - (void)testMultipleInterceptedIdentifyIsTransferredOnNextActiveIdentifyWithSetO

event1 = [self->_identifyInterceptor intercept:event1];

XCTAssertNil(event1);
XCTAssertEqual([event1 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 1);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 1);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand All @@ -256,7 +256,7 @@ - (void)testMultipleInterceptedIdentifyIsTransferredOnNextActiveIdentifyWithSetO

event2 = [self->_identifyInterceptor intercept:event2];

XCTAssertNil(event2);
XCTAssertEqual([event2 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 2);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 2);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand Down Expand Up @@ -308,7 +308,7 @@ - (void)testInterceptedIdentifyIsTransferredOnNextActiveEvent {

event = [self->_identifyInterceptor intercept:event];

XCTAssertNil(event);
XCTAssertEqual([event count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 1);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 1);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand Down Expand Up @@ -345,7 +345,7 @@ - (void)testMultipleInterceptedIdentifyIsTransferredNextActiveEvent {

event1 = [self->_identifyInterceptor intercept:event1];

XCTAssertNil(event1);
XCTAssertEqual([event1 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 1);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 1);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand All @@ -357,7 +357,7 @@ - (void)testMultipleInterceptedIdentifyIsTransferredNextActiveEvent {

event2 = [self->_identifyInterceptor intercept:event2];

XCTAssertNil(event2);
XCTAssertEqual([event2 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 2);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 2);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand Down Expand Up @@ -396,7 +396,7 @@ - (void)testNullValuesInIdentifySetAreIgnoredOnActiveIdentify {

event1 = [self->_identifyInterceptor intercept:event1];

XCTAssertNil(event1);
XCTAssertEqual([event1 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 1);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 1);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand All @@ -409,7 +409,7 @@ - (void)testNullValuesInIdentifySetAreIgnoredOnActiveIdentify {

event2 = [self->_identifyInterceptor intercept:event2];

XCTAssertNil(event2);
XCTAssertEqual([event2 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 2);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 2);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand Down Expand Up @@ -454,7 +454,7 @@ - (void)testNullValuesInIdentifySetAreIgnoredOnActiveEvent {

event1 = [self->_identifyInterceptor intercept:event1];

XCTAssertNil(event1);
XCTAssertEqual([event1 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 1);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 1);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand All @@ -467,7 +467,7 @@ - (void)testNullValuesInIdentifySetAreIgnoredOnActiveEvent {

event2 = [self->_identifyInterceptor intercept:event2];

XCTAssertNil(event2);
XCTAssertEqual([event2 count], 0);
XCTAssertEqual(self->_dbHelper.getLastSequenceNumber, 2);
XCTAssertEqual(self->_dbHelper.getInterceptedIdentifyCount, 2);
XCTAssertEqual(self->_dbHelper.getIdentifyCount, 0);
Expand Down

0 comments on commit fd9495f

Please sign in to comment.