Skip to content

Commit

Permalink
Lay foundation for passing operational parameters
Browse files Browse the repository at this point in the history
Summary: This diff lays the foundation for passing operational parameters.

Reviewed By: jjiang10

Differential Revision:
D66025393

Privacy Context Container: L1285343

fbshipit-source-id: 099ca70dfff5ce4f6204779a8032d3e944f394ce
  • Loading branch information
ryantobinmeta authored and facebook-github-bot committed Nov 27, 2024
1 parent 52e5f3f commit 54b34d5
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 7 deletions.
4 changes: 3 additions & 1 deletion FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,8 @@ - (void) logEvent:(FBSDKAppEventName)eventName
valueToSum:valueToSum
parameters:parameters
isImplicitlyLogged:isImplicitlyLogged
accessToken:accessToken];
accessToken:accessToken
operationalParameters:nil];
// Unless the behavior is set to only allow explicit flushing, we go ahead and flush, since purchase events
// are relatively rare and relatively high value and worth getting across on wire right away.
if (eventName == FBSDKAppEventNamePurchased && self.flushBehavior != FBSDKAppEventsFlushBehaviorExplicitOnly) {
Expand All @@ -1148,6 +1149,7 @@ - (void) doLogEvent:(FBSDKAppEventName)eventName
parameters:(nullable NSDictionary<FBSDKAppEventParameterName, id> *)parameters
isImplicitlyLogged:(BOOL)isImplicitlyLogged
accessToken:(nullable FBSDKAccessToken *)accessToken
operationalParameters:(nullable NSDictionary<FBSDKAppOperationalDataType, NSDictionary<NSString *, id> *> *)operationalParameters
{
[self validateConfiguration];

Expand Down
11 changes: 11 additions & 0 deletions FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppOperationalDataType.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

#import "FBSDKAppOperationalDataType.h"

FBSDKAppOperationalDataType const FBSDKAppOperationalDataTypeIAPParameters = @"iap_parameters";
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ extension IAPDedupeProcessor {
valueToSum: implicitEvent.valueToSum,
parameters: implicitEvent.parameters?.appEventParameterKeys,
isImplicitlyLogged: implicitEvent.isImplicitEvent,
accessToken: implicitEvent.accessToken
accessToken: implicitEvent.accessToken,
operationalParameters: nil
)
}
for manualEvent in manualEvents {
Expand All @@ -256,7 +257,8 @@ extension IAPDedupeProcessor {
valueToSum: manualEvent.valueToSum,
parameters: manualEvent.parameters?.appEventParameterKeys,
isImplicitlyLogged: manualEvent.isImplicitEvent,
accessToken: manualEvent.accessToken
accessToken: manualEvent.accessToken,
operationalParameters: nil
)
}
if dependencies.eventLogger.flushBehavior != .explicitOnly {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ extension IAPTransactionLogger {
valueToSum: valueToSum.currencyNumber,
parameters: parameters,
isImplicitlyLogged: true,
accessToken: nil
accessToken: nil,
operationalParameters: nil
)
if dependencies.eventLogger.flushBehavior != .explicitOnly {
dependencies.eventLogger.flush(for: .eagerlyFlushingEvent)
Expand Down
20 changes: 20 additions & 0 deletions FBSDKCoreKit/FBSDKCoreKit/include/FBSDKAppOperationalDataType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

#import <Foundation/Foundation.h>

/**
Internal Type exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/

typedef NSString *FBSDKAppOperationalDataType NS_TYPED_EXTENSIBLE_ENUM NS_SWIFT_NAME(AppOperationalDataType);

FOUNDATION_EXPORT FBSDKAppOperationalDataType const FBSDKAppOperationalDataTypeIAPParameters;
4 changes: 3 additions & 1 deletion FBSDKCoreKit/FBSDKCoreKit/include/FBSDKEventLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#import <FBSDKCoreKit/FBSDKAppEventName.h>
#import <FBSDKCoreKit/FBSDKAppEventParameterName.h>
#import <FBSDKCoreKit/FBSDKAppOperationalDataType.h>
#import <FBSDKCoreKit/FBSDKAppEventsFlushReason.h>
#import <FBSDKCoreKit/FBSDKAppEventsFlushBehavior.h>

Expand Down Expand Up @@ -64,7 +65,8 @@ NS_SWIFT_NAME(EventLogging)
valueToSum:(nullable NSNumber *)valueToSum
parameters:(nullable NSDictionary<FBSDKAppEventParameterName, id> *)parameters
isImplicitlyLogged:(BOOL)isImplicitlyLogged
accessToken:(nullable FBSDKAccessToken *)accessToken;
accessToken:(nullable FBSDKAccessToken *)accessToken
operationalParameters:(nullable NSDictionary<FBSDKAppOperationalDataType, NSDictionary<NSString *, id> *> *)operationalParameters;

@end

Expand Down
9 changes: 7 additions & 2 deletions TestTools/TestTools/TestEventLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import FBSDKCoreKit
import Foundation

@objcMembers
open class TestEventLogger: NSObject, EventLogging { // swiftlint:disable:this prefer_final_classes
open class TestEventLogger: NSObject, EventLogging {
// swiftlint:disable:this prefer_final_classes
public var flushCallCount = 0
public var flushBehavior: AppEvents.FlushBehavior = .auto
public var capturedEventName: AppEvents.Name?
Expand All @@ -20,6 +21,7 @@ open class TestEventLogger: NSObject, EventLogging { // swiftlint:disable:this p
public var capturedValueToSum: Double?
public var capturedFlushReason: AppEvents.FlushReason?
public var capturedEvents: [EventStructForTests] = []
public var capturedOperationalParameters: [AppOperationalDataType: [String: Any]]?

public func flush(for flushReason: AppEvents.FlushReason) {
flushCallCount += 1
Expand Down Expand Up @@ -87,18 +89,21 @@ open class TestEventLogger: NSObject, EventLogging { // swiftlint:disable:this p
capturedParameters = parameters
}

// swiftlint:disable:next function_parameter_count
public func doLogEvent(
_ eventName: AppEvents.Name,
valueToSum: NSNumber?,
parameters: [AppEvents.ParameterName: Any]?,
isImplicitlyLogged: Bool,
accessToken: AccessToken?
accessToken: AccessToken?,
operationalParameters: [AppOperationalDataType: [String: Any]]?
) {
capturedEventName = eventName
capturedValueToSum = valueToSum?.doubleValue
capturedParameters = parameters
capturedIsImplicitlyLogged = isImplicitlyLogged
capturedAccessToken = accessToken
capturedOperationalParameters = operationalParameters
let event = EventStructForTests(
eventName: eventName,
valueToSum: valueToSum,
Expand Down

0 comments on commit 54b34d5

Please sign in to comment.