Skip to content

Commit

Permalink
Gate operational parameters by SK2 Feature GK
Browse files Browse the repository at this point in the history
Summary: As an additional safeguard, let's gate the operational parameter API argument by the Store Kit 2 GK feature so we can turn it off if necessary.

Reviewed By: jjiang10

Differential Revision: D66313929

fbshipit-source-id: e3dfa5e2c028c92839a9c40c8a5c0e8633a43836
  • Loading branch information
ryantobinmeta authored and facebook-github-bot committed Dec 9, 2024
1 parent 232533d commit d26ce60
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ - (void)fetchServerConfiguration:(FBSDKCodeBlock)callback
}
}];
} else {
[self.iapTransactionCache setHasRestoredPurchases:YES];
[self.iapTransactionCache setNewCandidatesDate:[NSDate date]];
[self.iapDedupeProcessor disable];
[self.paymentObserver stopObservingTransactions];
Expand Down Expand Up @@ -1452,7 +1453,7 @@ - (void)flushOnMainQueue:(FBSDKAppEventsState *)appEventsState
}

[FBSDKTypeUtility dictionary:postParameters setObject:encodedEvents forKey:@"custom_events"];
if (encodedOperationalData != nil) {
if ([self.featureChecker isEnabled:FBSDKFeatureIAPLoggingSK2] && encodedOperationalData != nil) {
[FBSDKTypeUtility dictionary:postParameters setObject:encodedOperationalData forKey:@"operational_parameters"];
}
if (appEventsState.numSkipped > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ extension IAPTransactionObserver {
for transactionResult in newTransactions {
await handleNewTransaction(transaction: transactionResult.iapTransaction)
}
IAPTransactionCache.shared.newCandidatesDate = newTransactions.last?.iapTransaction.transaction.purchaseDate ??
Date()
if let latest = newTransactions.last {
IAPTransactionCache.shared.newCandidatesDate = latest.iapTransaction.transaction.purchaseDate
}
}

private func handleRestoredTransaction(transaction: IAPTransaction) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ final class AppEventsTests: XCTestCase {
// MARK: - Test for operational parameters

func testLogEventWithOperationalParameters() {
featureManager.enable(feature: .iapLoggingSK2)
let operationalParameters: [AppOperationalDataType: [String: Any]] = [
.iapParameters: [
AppEvents.ParameterName.transactionID.rawValue: "1",
Expand Down Expand Up @@ -294,6 +295,7 @@ final class AppEventsTests: XCTestCase {
}

func testLogEventWithNoOperationalParameters() {
featureManager.enable(feature: .iapLoggingSK2)
appEvents.doLogEvent(
.purchased,
valueToSum: 2.99,
Expand Down

0 comments on commit d26ce60

Please sign in to comment.