Skip to content

Commit

Permalink
Explicitly set _implicitlyLogged flag
Browse files Browse the repository at this point in the history
Summary: This diff explicitly sets the ```_implicityLogged``` flag as false for manually logged events.

Reviewed By: maxalbrightmeta

Differential Revision: D67878547

fbshipit-source-id: 3cd973d9dc199ac3a50cb0bca4b729cb1535bd6b
  • Loading branch information
ryantobinmeta authored and facebook-github-bot committed Jan 6, 2025
1 parent 528d9e7 commit b510926
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,8 @@ - (void) doLogEvent:(FBSDKAppEventName)eventName
}
if (isImplicitlyLogged) {
[FBSDKTypeUtility dictionary:eventDictionary setObject:@"1" forKey:FBSDKAppEventParameterNameImplicitlyLogged];
} else {
[FBSDKTypeUtility dictionary:eventDictionary setObject:@"0" forKey:FBSDKAppEventParameterNameImplicitlyLogged];
}

NSString *currentViewControllerName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,26 @@ final class AppEventsTests: XCTestCase {

// MARK: - Tests for log event

func testLogInternalEventImplicit() throws {
appEvents.logInternalEvent(
eventName,
isImplicitlyLogged: true
)
let capturedParameters = try XCTUnwrap(appEventsStateProvider.state?.capturedEventDictionary)
XCTAssertEqual(capturedParameters["_eventName"] as? String, eventName.rawValue)
XCTAssertEqual(capturedParameters["_implicitlyLogged"] as? String, "1")
}

func testLogInternalEventNotImplicit() throws {
appEvents.logInternalEvent(
eventName,
isImplicitlyLogged: false
)
let capturedParameters = try XCTUnwrap(appEventsStateProvider.state?.capturedEventDictionary)
XCTAssertEqual(capturedParameters["_eventName"] as? String, eventName.rawValue)
XCTAssertEqual(capturedParameters["_implicitlyLogged"] as? String, "0")
}

func testLogEventWithValueToSum() throws {
appEvents.logEvent(
eventName,
Expand All @@ -1343,7 +1363,7 @@ final class AppEventsTests: XCTestCase {

XCTAssertEqual(capturedParameters["_eventName"] as? String, eventName.rawValue)
XCTAssertNil(capturedParameters["_valueToSum"])
XCTAssertNil(capturedParameters["_implicitlyLogged"])
XCTAssertEqual(capturedParameters["_implicitlyLogged"] as? String, "0")

validateAEMReporterCalled(
eventName: eventName,
Expand All @@ -1364,7 +1384,7 @@ final class AppEventsTests: XCTestCase {

XCTAssertEqual(capturedParameters["_eventName"] as? String, eventName.rawValue)
XCTAssertEqual(capturedParameters["_valueToSum"] as? Double, purchaseAmount)
XCTAssertNil(capturedParameters["_implicitlyLogged"])
XCTAssertEqual(capturedParameters["_implicitlyLogged"] as? String, "0")

validateAEMReporterCalled(
eventName: eventName,
Expand All @@ -1388,7 +1408,7 @@ final class AppEventsTests: XCTestCase {

XCTAssertEqual(capturedParameters["_eventName"] as? String, eventName.rawValue)
XCTAssertNil(capturedParameters["_valueToSum"])
XCTAssertNil(capturedParameters["_implicitlyLogged"])
XCTAssertEqual(capturedParameters["_implicitlyLogged"] as? String, "0")

validateAEMReporterCalled(
eventName: eventName,
Expand Down

0 comments on commit b510926

Please sign in to comment.