Skip to content

Commit

Permalink
Added Privacy Manifests
Browse files Browse the repository at this point in the history
Summary: Added Privacy Manifests

Reviewed By: jjiang10

Differential Revision: D53290629

fbshipit-source-id: c018ebad092402de1015f93ec2051bc70dfce4ee
  • Loading branch information
ryantobinmeta authored and facebook-github-bot committed Feb 14, 2024
1 parent 469554d commit 3183c7e
Show file tree
Hide file tree
Showing 80 changed files with 5,574 additions and 315 deletions.
55 changes: 4 additions & 51 deletions FBAEMKit/FBAEMKit/AEMReporter.swift
Expand Up @@ -129,60 +129,13 @@ public final class AEMReporter: NSObject {
}

/**
Enable AEM reporting
Enable AEM reporting. This function won't work and AEM APIs will early return.
This function should be called in application(_:open:options:) from ApplicationDelegate
This function should be called in application(_:open:options:) from ApplicationDelegate.
*/
public static func enable() {
guard
#available(iOS 14.0, *),
!isAEMReportEnabled
else {
return
}

isAEMReportEnabled = true

AEMConfiguration.configure(withRuleProvider: AEMAdvertiserRuleFactory())
reportFile = BasicUtility.persistenceFilePath(FileNames.aemReporter)
configFile = BasicUtility.persistenceFilePath(FileNames.aemConfig)
completionBlocks = []

dispatchOnQueue(serialQueue) {
minAggregationRequestTimestamp = loadMinAggregationRequestTimestamp()
configurations = loadConfigurations()
invocations = loadReportData()
}

loadConfiguration(withRefreshForced: false) { error in
if error != nil {
return
}

sendAggregationRequest()
clearCache()
}

// If developers forget to call configureWithNetworker:appID:
// or pass nil for networker,
// we use default networker in FBAEMKit
if networker == nil {
let networker = AEMNetworker()
networker.userAgentSuffix = analyticsAppID
self.networker = networker
}

// If developers forget to call configureWithNetworker:appID:,
// we will look up app Any in plist file, key is FacebookAppID
if appID == nil || appID?.isEmpty == true {
appID = AEMSettings.appID()
}

// If appID is still nil/empty, we don't enable AEM and throw warning here
if appID == nil || appID?.isEmpty == true {
// swiftlint:disable:next line_length
print("App ID is not set up correctly, please call configureWithNetworker:appID: and pass correct FB App ID OR add FacebookAppID in Info.plist")
}
// AEMKit is disabled and public APIs will always early return
isAEMReportEnabled = false
}

/**
Expand Down
21 changes: 21 additions & 0 deletions FBAEMKit/FBAEMKit/PrivacyInfo.xcprivacy
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
</array>
</dict>
</plist>
45 changes: 1 addition & 44 deletions FBAEMKit/FBAEMKitTests/AEMReporterTests.swift
Expand Up @@ -86,10 +86,9 @@ final class AEMReporterTests: XCTestCase {
}

func testEnable() {
AEMReporter.isAEMReportEnabled = false
AEMReporter.enable()

XCTAssertTrue(AEMReporter.isAEMReportEnabled, "AEM Report should be enabled")
XCTAssertFalse(AEMReporter.isAEMReportEnabled, "AEM Report should not be enabled")
}

func testConversionFilteringDefaultConfigure() {
Expand Down Expand Up @@ -187,48 +186,6 @@ final class AEMReporterTests: XCTestCase {
XCTAssertEqual(data[0].businessID, "test_advertiserid_12345")
}

func testLoadConfigurations() {
AEMReporter.addConfigurations([SampleAEMData.validConfigurationData1])
AEMReporter.addConfigurations([SampleAEMData.validConfigurationData1, SampleAEMData.validConfigurationData2])
let loadedConfigurations = AEMReporter.loadConfigurations()
XCTAssertEqual(loadedConfigurations.count, 1, "Should load the expected number of configuration")

let defaultConfigurations = loadedConfigurations[Values.defaultMode]
XCTAssertEqual(
defaultConfigurations?.count, 2, "Should load the expected number of default configuration"
)
XCTAssertEqual(
defaultConfigurations?[0].defaultCurrency, Values.USD, "Should save the expected default_currency of the "
)
XCTAssertEqual(
defaultConfigurations?[0].cutoffTime, 1, "Should save the expected cutoff_time of the "
)
XCTAssertEqual(
defaultConfigurations?[0].validFrom, 10000, "Should save the expected valid_from of the "
)
XCTAssertEqual(
defaultConfigurations?[0].mode, Values.defaultMode, "Should save the expected config_mode of the "
)
XCTAssertEqual(
defaultConfigurations?[0].conversionValueRules.count, 1, "Should save the expected conversion_value_rules of the "
)
XCTAssertEqual(
defaultConfigurations?[1].defaultCurrency, Values.USD, "Should save the expected default_currency of the "
)
XCTAssertEqual(
defaultConfigurations?[1].cutoffTime, 1, "Should save the expected cutoff_time of the "
)
XCTAssertEqual(
defaultConfigurations?[1].validFrom, 10001, "Should save the expected valid_from of the "
)
XCTAssertEqual(
defaultConfigurations?[1].mode, Values.defaultMode, "Should save the expected config_mode of the "
)
XCTAssertEqual(
defaultConfigurations?[1].conversionValueRules.count, 2, "Should save the expected conversion_value_rules of the "
)
}

func testClearCache() {
AEMReporter.addConfigurations([SampleAEMData.validConfigurationData1])
AEMReporter.addConfigurations([SampleAEMData.validConfigurationData1, SampleAEMData.validConfigurationData2])
Expand Down
Expand Up @@ -87,7 +87,8 @@ public final class FBSDKAppEventsCAPIManager: NSObject, CAPIReporter {
guard let graphRequest = self.factory?.createGraphRequest(
withGraphPath: String(format: "%@/%@", appID, FBSDKAppEventsCAPIManager.settingsPath),
parameters: [:] as [String: Any],
flags: []
flags: [],
useAlternativeDefaultDomainPrefix: false
) else {
print("Fail to create CAPI Gateway Settings API request")
self.executeBlocks(isEnabled: false)
Expand Down
20 changes: 16 additions & 4 deletions FBSDKCoreKit/FBSDKCoreKit/AppEvents/FBSDKAppEvents.m
Expand Up @@ -866,7 +866,9 @@ - (void)publishInstall
parameters:params
tokenString:nil
HTTPMethod:FBSDKHTTPMethodPOST
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery
forAppEvents:YES
useAlternativeDefaultDomainPrefix:NO];
__block id<FBSDKDataPersisting> weakStore = self.primaryDataStore;
[request startWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
if (!error) {
Expand Down Expand Up @@ -1335,7 +1337,9 @@ - (void)flushOnMainQueue:(FBSDKAppEventsState *)appEventsState
parameters:postParameters
tokenString:appEventsState.tokenString
HTTPMethod:FBSDKHTTPMethodPOST
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery
forAppEvents:YES
useAlternativeDefaultDomainPrefix:NO];
[request startWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
[self handleActivitiesPostCompletion:error
loggingEntry:loggingEntry
Expand Down Expand Up @@ -1482,7 +1486,14 @@ - (void)validateConfiguration
// so use that data here to return nil as well.
// 3) if we have a user session token, then no need to send attribution ID / advertiser ID back as the udid parameter
// 4) otherwise, send back the udid parameter.
if (self.settings.advertisingTrackingStatus == FBSDKAdvertisingTrackingDisallowed || self.settings.isEventDataUsageLimited) {
if (self.settings.isEventDataUsageLimited) {
return nil;
}
if ([[FBSDKDomainHandler sharedInstance] isDomainHandlingEnabled]) {
if (![self.settings isAdvertiserTrackingEnabled]) {
return nil;
}
} else if (self.settings.advertisingTrackingStatus == FBSDKAdvertisingTrackingDisallowed) {
return nil;
}

Expand Down Expand Up @@ -1510,7 +1521,8 @@ - (void)validateConfiguration
parameters:parameters
tokenString:tokenString
HTTPMethod:FBSDKHTTPMethodGET
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery
useAlternativeDefaultDomainPrefix:NO];
return request;
}

Expand Down
Expand Up @@ -21,7 +21,8 @@ final class AEMNetworker: NSObject, AEMNetworking {
parameters: parameters,
tokenString: tokenString,
httpMethod: method,
flags: [.skipClientToken, .disableErrorRecovery]
flags: [.skipClientToken, .disableErrorRecovery],
useAlternativeDefaultDomainPrefix: false
)

graphRequest.start { _, result, error in
Expand Down
Expand Up @@ -239,7 +239,8 @@ + (void)loadCodelessSettingWithCompletionBlock:(FBSDKCodelessSettingLoadBlock)co
parameters:parameters
tokenString:nil
HTTPMethod:nil
flags:FBSDKGraphRequestFlagSkipClientToken | FBSDKGraphRequestFlagDisableErrorRecovery];
flags:FBSDKGraphRequestFlagSkipClientToken | FBSDKGraphRequestFlagDisableErrorRecovery
useAlternativeDefaultDomainPrefix:NO];
return request;
}

Expand Down Expand Up @@ -269,6 +270,12 @@ + (void)checkCodelessIndexingSession
if (_isCheckingSession) {
return;
}

if ([[FBSDKDomainHandler sharedInstance] isDomainHandlingEnabled]) {
if (![self.settings isAdvertiserTrackingEnabled]) {
return;
}
}

_isCheckingSession = YES;
NSDictionary<NSString *, id> *parameters = @{
Expand All @@ -279,7 +286,8 @@ + (void)checkCodelessIndexingSession
[self.settings appID],
CODELESS_INDEXING_SESSION_ENDPOINT]
parameters:parameters
HTTPMethod:FBSDKHTTPMethodPOST];
HTTPMethod:FBSDKHTTPMethodPOST
useAlternativeDefaultDomainPrefix:NO];
[request startWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
_isCheckingSession = NO;
if ([result isKindOfClass:[NSDictionary<NSString *, id> class]]) {
Expand Down Expand Up @@ -406,7 +414,8 @@ + (void)uploadIndexing:(NSString *)tree
CODELESS_INDEXING_PLATFORM_KEY : @"iOS",
CODELESS_INDEXING_SESSION_ID_KEY : [self currentSessionDeviceID]
}
HTTPMethod:FBSDKHTTPMethodPOST];
HTTPMethod:FBSDKHTTPMethodPOST
useAlternativeDefaultDomainPrefix:NO];
_isCodelessIndexing = YES;
[request startWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
_isCodelessIndexing = NO;
Expand Down
Expand Up @@ -90,7 +90,9 @@ - (void)publishATE
parameters:parameters
tokenString:nil
HTTPMethod:FBSDKHTTPMethodPOST
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery
forAppEvents:YES
useAlternativeDefaultDomainPrefix:NO];
__block id<FBSDKDataPersisting> weakStore = self.store;
[request startWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
if (!error) {
Expand Down
Expand Up @@ -90,10 +90,12 @@ - (void)loadAppEventsConfigurationWithBlock:(FBSDKAppEventsConfigurationManagerB
return;
}
self.isLoadingConfiguration = true;

id<FBSDKGraphRequest> request = [self.graphRequestFactory createGraphRequestWithGraphPath:appID
parameters:@{
@"fields" : [NSString stringWithFormat:@"app_events_config.os_version(%@)", UIDevice.currentDevice.systemVersion]
}];
}
useAlternativeDefaultDomainPrefix:NO];
id<FBSDKGraphRequestConnecting> requestConnection = [self.graphRequestConnectionFactory createGraphRequestConnection];
requestConnection.timeout = kTimeout;
[requestConnection addRequest:request completion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
Expand Down
Expand Up @@ -27,9 +27,6 @@

static const u_int FB_GROUP1_RECHECK_DURATION = 30 * 60; // seconds

// Apple reports storage in binary gigabytes (1024^3) in their About menus, etc.
static const u_int FB_GIGABYTE = 1024 * 1024 * 1024; // bytes

@interface FBSDKAppEventsDeviceInfo ()

// Other state
Expand Down Expand Up @@ -121,10 +118,6 @@ - (void)_collectPersistentData
struct utsname systemInfo;
uname(&systemInfo);
self.machine = @(systemInfo.machine);

// Disk space stuff
float totalDiskSpace = [FBSDKAppEventsDeviceInfo _getTotalDiskSpace].floatValue;
self.totalDiskSpaceGB = (unsigned long long)round(totalDiskSpace / FB_GIGABYTE);
}

- (BOOL)_isGroup1Expired
Expand Down Expand Up @@ -155,14 +148,6 @@ - (void)_collectGroup1Data
}
}

// Remaining disk space
float remainingDiskSpace = [FBSDKAppEventsDeviceInfo _getRemainingDiskSpace].floatValue;
unsigned long long newRemainingDiskSpaceGB = (unsigned long long)round(remainingDiskSpace / FB_GIGABYTE);
if (self.remainingDiskSpaceGB != newRemainingDiskSpaceGB) {
self.remainingDiskSpaceGB = newRemainingDiskSpaceGB;
self.isEncodingDirty = YES;
}

self.lastGroup1CheckTime = [self unixTimeNow];
}

Expand All @@ -185,8 +170,8 @@ - (nullable NSString *)_generateEncoding
self.height ? @((unsigned long)self.height) : @"",
densityString,
@(self.coreCount) ?: @"",
@(self.totalDiskSpaceGB) ?: @"",
@(self.remainingDiskSpaceGB) ?: @"",
@-1,
@-1,
self.timeZoneName ?: @""
];

Expand All @@ -200,20 +185,6 @@ - (NSTimeInterval)unixTimeNow
return round([NSDate date].timeIntervalSince1970);
}

+ (NSNumber *)_getTotalDiskSpace
{
NSDictionary<NSString *, id> *attrs = [[NSFileManager new] attributesOfFileSystemForPath:NSHomeDirectory()
error:nil];
return attrs[NSFileSystemSize];
}

+ (NSNumber *)_getRemainingDiskSpace
{
NSDictionary<NSString *, id> *attrs = [[NSFileManager new] attributesOfFileSystemForPath:NSHomeDirectory()
error:nil];
return attrs[NSFileSystemFreeSize];
}

+ (uint)_readCoreCount
{
int mib[2] = {CTL_HW, HW_AVAILCPU};
Expand Down
Expand Up @@ -288,7 +288,6 @@ final class MACARuleMatchingManager: NSObject, MACARuleMatching {
params["_carrier"] = dependencies.deviceInformationProvider.carrierName ?? ""
params["_deviceOSTypeName"] = "IOS"
params["_deviceOSVersion"] = dependencies.deviceInformationProvider.sysVersion ?? ""
params["_remainingDiskGB"] = dependencies.deviceInformationProvider.remainingDiskSpaceGB
}

func removeGeneratedInfo(params: inout [String: Any]) {
Expand Down
Expand Up @@ -109,7 +109,8 @@ - (void)enable
if ([_modelInfo count] == 0 || ![self.featureChecker isEnabled:FBSDKFeatureModelRequest] || ![self.class isValidTimestamp:timestamp]) {
// fetch api
NSString *graphPath = [NSString stringWithFormat:@"%@/model_asset", self.getAppID()];
id<FBSDKGraphRequest> request = [self.graphRequestFactory createGraphRequestWithGraphPath:graphPath];
id<FBSDKGraphRequest> request = [self.graphRequestFactory createGraphRequestWithGraphPath:graphPath
useAlternativeDefaultDomainPrefix:NO];
__weak FBSDKModelManager *weakSelf = self;
[request startWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
if (!error) {
Expand Down
Expand Up @@ -135,9 +135,8 @@ - (void)_loadConfigurationWithBlock:(FBSDKSKAdNetworkReporterBlock)block
}
self.isRequestStarted = YES;
id<FBSDKGraphRequest> request = [self.graphRequestFactory createGraphRequestWithGraphPath:[NSString stringWithFormat:@"%@/ios_skadnetwork_conversion_config", FBSDKSettings.sharedSettings.appID]
parameters:@{
@"os_version" : UIDevice.currentDevice.systemVersion
}];
parameters:@{@"os_version" : UIDevice.currentDevice.systemVersion}
useAlternativeDefaultDomainPrefix:NO];
[request startWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
[self dispatchOnQueue:self.serialQueue block:^{
if (error) {
Expand Down

0 comments on commit 3183c7e

Please sign in to comment.