Skip to content

Commit

Permalink
Merge develop to master for 5.0.4 (#2500)
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitriy Kirakosyan <[email protected]>
  • Loading branch information
AnatolyPristensky and DmitriyKirakosyan authored Sep 14, 2023
1 parent 5756ddb commit 49aa89b
Show file tree
Hide file tree
Showing 50 changed files with 810 additions and 194 deletions.
2 changes: 1 addition & 1 deletion AppCenter.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.cocoapods_version = '>= 1.10'
s.name = 'AppCenter'
s.version = '5.0.3'
s.version = '5.0.4'

s.summary = 'Visual Studio App Center is your continuous integration, delivery and learning solution for iOS and macOS apps.'
s.description = <<-DESC
Expand Down
4 changes: 4 additions & 0 deletions AppCenter/AppCenter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,8 @@
D55E7082252F5A1000AB994D /* MSACTestSessionInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSACTestSessionInfo.m; sourceTree = "<group>"; };
D55E7083252F5A1000AB994D /* MSACTestSessionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSACTestSessionInfo.h; sourceTree = "<group>"; };
D5812F312423C2FA00C5F5C5 /* MSACUserDefaultsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSACUserDefaultsTests.m; sourceTree = "<group>"; };
D80EC5002AB0713B000C82D7 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
D881A6B62AAF4176009644A0 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = ../PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
DF5DA1F823A0E55500DE695C /* MSACDispatcherUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSACDispatcherUtil.h; sourceTree = "<group>"; };
DF5DA1FC23A0E57B00DE695C /* MSACDispatcherUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSACDispatcherUtil.m; sourceTree = "<group>"; };
DFCB7FFD2472C1BD0058D292 /* OCHamcrest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OCHamcrest.xcodeproj; path = ../../Vendor/OCHamcrest/Source/OCHamcrest.xcodeproj; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1588,6 +1590,8 @@
6E0400FA1D1C98220051BCFA = {
isa = PBXGroup;
children = (
D80EC5002AB0713B000C82D7 /* PrivacyInfo.xcprivacy */,
D881A6B62AAF4176009644A0 /* PrivacyInfo.xcprivacy */,
6E0401051D1C98220051BCFA /* AppCenter */,
6E2395791D22EF4F00E543C8 /* AppCenterTests */,
6E0401041D1C98220051BCFA /* Products */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ - (void)enqueueItem:(id<MSACLog>)item flags:(MSACFlags)flags {
if (item && !item.device) {
item.device = [[MSACDeviceTracker sharedInstance] device];
}
if (item && !item.dataResidencyRegion) {
item.dataResidencyRegion = [MSACAppCenter dataResidencyRegion];
}
if (!item || ![item isValid]) {
MSACLogWarning([MSACAppCenter logTag], @"Log is not valid.");
return;
Expand Down
9 changes: 9 additions & 0 deletions AppCenter/AppCenter/Internals/MSACAppCenterInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ static NSString *const kMSACTrueEnvironmentString = @"1";

@property(atomic, copy) NSString *logUrl;

@property(atomic, copy) NSString *dataResidencyRegion;

@property(nonatomic, readonly) NSUUID *installId;

@property(nonatomic) NSNumber *requestedMaxStorageSizeInBytes;
Expand Down Expand Up @@ -110,6 +112,13 @@ static NSString *const kMSACTrueEnvironmentString = @"1";
*/
- (NSString *)logUrl;

/**
* Get the data residency region.
*
* @return data residency region.
*/
- (NSString *)dataResidencyRegion;

/**
* Get the app secret.
*
Expand Down
10 changes: 9 additions & 1 deletion AppCenter/AppCenter/Internals/Model/MSACAbstractLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ @implementation MSACAbstractLog
@synthesize sid = _sid;
@synthesize distributionGroupId = _distributionGroupId;
@synthesize userId = _userId;
@synthesize dataResidencyRegion = _dataResidencyRegion;
@synthesize device = _device;
@synthesize tag = _tag;

Expand Down Expand Up @@ -62,6 +63,9 @@ - (NSMutableDictionary *)serializeToDictionary {
if (self.device) {
dict[kMSACDevice] = [self.device serializeToDictionary];
}
if (self.dataResidencyRegion) {
dict[kMSACDataResidencyRegion] = self.dataResidencyRegion;
}
return dict;
}

Expand All @@ -80,7 +84,9 @@ - (BOOL)isEqual:(id)object {
((!self.sid && !log.sid) || [self.sid isEqualToString:log.sid]) &&
((!self.distributionGroupId && !log.distributionGroupId) || [self.distributionGroupId isEqualToString:log.distributionGroupId]) &&
((!self.userId && !log.userId) || [self.userId isEqualToString:log.userId]) &&
((!self.device && !log.device) || [self.device isEqual:log.device]);
((!self.device && !log.device) || [self.device isEqual:log.device]) &&
((!self.dataResidencyRegion && !log.dataResidencyRegion) || [self.dataResidencyRegion isEqualToString:log.dataResidencyRegion]);

}

#pragma mark - NSCoding
Expand All @@ -98,6 +104,7 @@ - (instancetype)initWithCoder:(NSCoder *)coder {
_distributionGroupId = [coder decodeObjectForKey:kMSACDistributionGroupId];
_userId = [coder decodeObjectForKey:kMSACUserId];
_device = [coder decodeObjectForKey:kMSACDevice];
_dataResidencyRegion = [coder decodeObjectForKey:kMSACDataResidencyRegion];
}
return self;
}
Expand All @@ -109,6 +116,7 @@ - (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:self.distributionGroupId forKey:kMSACDistributionGroupId];
[coder encodeObject:self.userId forKey:kMSACUserId];
[coder encodeObject:self.device forKey:kMSACDevice];
[coder encodeObject:self.dataResidencyRegion forKey:kMSACDataResidencyRegion];
}

#pragma mark - Utility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#import <Foundation/Foundation.h>

static NSString *const kMSACDataResidencyRegion = @"dataResidencyRegion";
static NSString *const kMSACDevice = @"device";
static NSString *const kMSACDistributionGroupId = @"distributionGroupId";
static NSString *const kMSACSId = @"sid";
Expand Down
6 changes: 6 additions & 0 deletions AppCenter/AppCenter/MSACAppCenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ NS_SWIFT_NAME(AppCenter)
*/
@property(class, nonatomic, strong) NSString *logUrl;

/**
* Data residency region.
* Verify list of supported regions on <link>. Value outside of supported range is treated by backend as ANY.
*/
@property(class, nonatomic, strong) NSString *dataResidencyRegion;

/**
* Set log handler.
*/
Expand Down
10 changes: 10 additions & 0 deletions AppCenter/AppCenter/MSACAppCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ @implementation MSACAppCenter

@synthesize logUrl = _logUrl;

@synthesize dataResidencyRegion = _dataResidencyRegion;

+ (instancetype)sharedInstance {
dispatch_once(&onceToken, ^{
if (sharedInstance == nil) {
Expand Down Expand Up @@ -246,6 +248,10 @@ + (NSString *)groupId {
return kMSACGroupId;
}

+ (NSString *)dataResidencyRegion {
return [[MSACAppCenter sharedInstance] dataResidencyRegion];
}

+ (void)setMaxStorageSize:(long)sizeInBytes completionHandler:(void (^)(BOOL))completionHandler {
[[MSACAppCenter sharedInstance] setMaxStorageSize:sizeInBytes completionHandler:completionHandler];
}
Expand All @@ -254,6 +260,10 @@ + (void)setUserId:(NSString *)userId {
[[MSACAppCenter sharedInstance] setUserId:userId];
}

+ (void)setDataResidencyRegion:(NSString *)dataResidencyRegion {
[[MSACAppCenter sharedInstance] setDataResidencyRegion:dataResidencyRegion];
}

+ (void)setCountryCode:(NSString *)countryCode {
[[MSACDeviceTracker sharedInstance] setCountryCode:countryCode];
}
Expand Down
5 changes: 5 additions & 0 deletions AppCenter/AppCenter/Model/MSACLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ NS_SWIFT_NAME(Log)
*/
@property(nonatomic, copy) NSString *distributionGroupId;

/**
* Data residency region.
*/
@property(nonatomic, copy) NSString *dataResidencyRegion;

/**
* Optional user identifier.
*/
Expand Down
13 changes: 13 additions & 0 deletions AppCenter/AppCenterTests/MSACAbstractLogTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ - (void)setUp {
self.sut.timestamp = [NSDate dateWithTimeIntervalSince1970:0];
self.sut.sid = @"FAKE-SESSION-ID";
self.sut.distributionGroupId = @"FAKE-GROUP-ID";
self.sut.dataResidencyRegion = @"FAKE-DATA-RESIDENCY-REGION";
self.sut.userId = @"FAKE-USER-ID";
self.sut.device = OCMPartialMock([MSACDevice new]);

Expand All @@ -57,6 +58,7 @@ - (void)testSerializingToDictionaryWorks {
assertThat(actual[@"timestamp"], equalTo(@"1970-01-01T00:00:00.000Z"));
assertThat(actual[@"sid"], equalTo(@"FAKE-SESSION-ID"));
assertThat(actual[@"distributionGroupId"], equalTo(@"FAKE-GROUP-ID"));
assertThat(actual[@"dataResidencyRegion"], equalTo(@"FAKE-DATA-RESIDENCY-REGION"));
assertThat(actual[@"userId"], equalTo(@"FAKE-USER-ID"));
assertThat(actual[@"device"], equalTo(@{}));
}
Expand All @@ -76,6 +78,7 @@ - (void)testNSCodingSerializationAndDeserializationWorks {
assertThat(actualLog.timestamp, equalTo(self.sut.timestamp));
assertThat(actualLog.sid, equalTo(self.sut.sid));
assertThat(actualLog.distributionGroupId, equalTo(self.sut.distributionGroupId));
assertThat(actualLog.dataResidencyRegion, equalTo(self.sut.dataResidencyRegion));
assertThat(actualLog.userId, equalTo(self.sut.userId));
assertThat(actualLog.device, equalTo(self.sut.device));
}
Expand Down Expand Up @@ -126,6 +129,7 @@ - (void)testIsEqual {
log.timestamp = self.sut.timestamp;
log.sid = self.sut.sid;
log.distributionGroupId = self.sut.distributionGroupId;
log.dataResidencyRegion = self.sut.dataResidencyRegion;
log.userId = self.sut.userId;
log.device = self.sut.device;
log.tag = self.sut.tag;
Expand Down Expand Up @@ -159,6 +163,14 @@ - (void)testIsEqual {

// Then
XCTAssertFalse([self.sut isEqual:log]);

// When
self.sut.userId = @"FAKE-USER-ID";
self.sut.dataResidencyRegion = @"FAKE-NEW-DATA-RESIDENCY-REGION";

// Then
XCTAssertFalse([self.sut isEqual:log]);

}

- (void)testSerializingToJsonWorks {
Expand All @@ -174,6 +186,7 @@ - (void)testSerializingToJsonWorks {
assertThat([actualDict objectForKey:@"timestamp"], equalTo(@"1970-01-01T00:00:00.000Z"));
assertThat([actualDict objectForKey:@"sid"], equalTo(@"FAKE-SESSION-ID"));
assertThat([actualDict objectForKey:@"distributionGroupId"], equalTo(@"FAKE-GROUP-ID"));
assertThat([actualDict objectForKey:@"dataResidencyRegion"], equalTo(@"FAKE-DATA-RESIDENCY-REGION"));
assertThat([actualDict objectForKey:@"userId"], equalTo(@"FAKE-USER-ID"));
assertThat([actualDict objectForKey:@"device"], equalTo(@{}));
}
Expand Down
9 changes: 9 additions & 0 deletions AppCenter/AppCenterTests/MSACAppCenterTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1065,4 +1065,13 @@ - (void)testDisableNetworkRequestsAfterStart {
XCTAssertEqual(tokenObject, self.channelGroupMock);
}

- (void)testSetDataResidencyRegion {
// If
NSString *expectedDataResidencyRegion = @"rg";
[MSACAppCenter setDataResidencyRegion:expectedDataResidencyRegion];

// Then
XCTAssertEqualObjects(expectedDataResidencyRegion, [MSACAppCenter dataResidencyRegion]);
}

@end
9 changes: 7 additions & 2 deletions AppCenter/AppCenterTests/MSACChannelUnitDefaultTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1393,21 +1393,24 @@ - (void)testDelegateAfterChannelResumed {
}];
}

- (void)testDeviceAndTimestampAreAddedOnEnqueuing {
- (void)testDeviceAndTimestampAndDataResidencyRegionAreAddedOnEnqueuing {

// If
MSACChannelUnitDefault *channel = [self createChannelUnitDefault];
id<MSACLog> mockLog = [self getValidMockLog];
mockLog.device = nil;
mockLog.timestamp = nil;
mockLog.dataResidencyRegion = nil;
[self initChannelEndJobExpectation];
[MSACAppCenter setDataResidencyRegion:@"RG1"];

// When
[channel enqueueItem:mockLog flags:MSACFlagsDefault];

// Then
XCTAssertNotNil(mockLog.device);
XCTAssertNotNil(mockLog.timestamp);
XCTAssertNotNil(mockLog.dataResidencyRegion);
[self enqueueChannelEndJobExpectation];
[self waitForExpectationsWithTimeout:kMSACTestTimeout
handler:^(NSError *error) {
Expand All @@ -1417,13 +1420,14 @@ - (void)testDeviceAndTimestampAreAddedOnEnqueuing {
}];
}

- (void)testDeviceAndTimestampAreNotOverwrittenOnEnqueuing {
- (void)testDeviceAndTimestampAndDataResidencyRegionAreNotOverwrittenOnEnqueuing {

// If
MSACChannelUnitDefault *channel = [self createChannelUnitDefault];
id<MSACLog> mockLog = [self getValidMockLog];
MSACDevice *device = mockLog.device = [MSACDevice new];
NSDate *timestamp = mockLog.timestamp = [NSDate new];
NSString *dataResidencyRegion = mockLog.dataResidencyRegion = @"RG1";
[self initChannelEndJobExpectation];

// When
Expand All @@ -1432,6 +1436,7 @@ - (void)testDeviceAndTimestampAreNotOverwrittenOnEnqueuing {
// Then
XCTAssertEqual(mockLog.device, device);
XCTAssertEqual(mockLog.timestamp, timestamp);
XCTAssertEqual(mockLog.dataResidencyRegion, dataResidencyRegion);
[self enqueueChannelEndJobExpectation];
[self waitForExpectationsWithTimeout:kMSACTestTimeout
handler:^(NSError *error) {
Expand Down
86 changes: 86 additions & 0 deletions AppCenter/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?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>NSPrivacyCollectedDataTypes</key>
<array>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeDeviceID</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypePhotosorVideos</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeUserID</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeCrashData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypePerformanceData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeOtherDiagnosticData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</dict>
</array>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
</dict>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@
C9EBAB18230D724700A20F0F /* AppCenter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AppCenter.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C9EBAB28230D72F300A20F0F /* AppCenter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AppCenter.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C9EBAB2A230D72F900A20F0F /* AppCenter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AppCenter.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D80EC5092AB07A0E000C82D7 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
DFCB80232472D5D70058D292 /* OCHamcrest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OCHamcrest.xcodeproj; path = ../../Vendor/OCHamcrest/Source/OCHamcrest.xcodeproj; sourceTree = "<group>"; };
E758FA7B20FFDEE700011793 /* MSACPropertyConfigurator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSACPropertyConfigurator.h; sourceTree = "<group>"; };
E758FA7C20FFDEE700011793 /* MSACPropertyConfigurator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSACPropertyConfigurator.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -795,6 +796,7 @@
E85547B71D2D6253002DF6E2 = {
isa = PBXGroup;
children = (
D80EC5092AB07A0E000C82D7 /* PrivacyInfo.xcprivacy */,
E85547C21D2D6253002DF6E2 /* AppCenterAnalytics */,
E85547D61D2D6723002DF6E2 /* AppCenterAnalyticsTests */,
E85547C11D2D6253002DF6E2 /* Products */,
Expand Down
Loading

0 comments on commit 49aa89b

Please sign in to comment.