From b5109268552d7aef412a6bdee217b76aea3fbe8e Mon Sep 17 00:00:00 2001 From: Ryan Tobin Date: Mon, 6 Jan 2025 14:25:38 -0800 Subject: [PATCH] Explicitly set _implicitlyLogged flag Summary: This diff explicitly sets the ```_implicityLogged``` flag as false for manually logged events. Reviewed By: maxalbrightmeta Differential Revision: D67878547 fbshipit-source-id: 3cd973d9dc199ac3a50cb0bca4b729cb1535bd6b --- .../FBSDKCoreKit/AppEvents/FBSDKAppEvents.m | 2 ++ .../Internal/AppEvents/AppEventsTests.swift | 26 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m b/FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m index 81201a955..0664935ff 100644 --- a/FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m +++ b/FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m @@ -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; diff --git a/FBSDKCoreKit/FBSDKCoreKitTests/Internal/AppEvents/AppEventsTests.swift b/FBSDKCoreKit/FBSDKCoreKitTests/Internal/AppEvents/AppEventsTests.swift index ecbf7647e..34c27101c 100644 --- a/FBSDKCoreKit/FBSDKCoreKitTests/Internal/AppEvents/AppEventsTests.swift +++ b/FBSDKCoreKit/FBSDKCoreKitTests/Internal/AppEvents/AppEventsTests.swift @@ -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, @@ -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, @@ -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, @@ -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,