From a72c241324eb87e1967a868bf9ffd6861ff3af2a Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 16 Mar 2023 17:12:36 +0000 Subject: [PATCH] Release 4.6.1 --- .../Metric/UADSSCARHeaderBiddingMetric.h | 12 +++++----- .../Metric/UADSSCARHeaderBiddingMetric.m | 24 +++++++++---------- ...ngTokenReaderWithSCARSignalsBaseStrategy.m | 4 ++-- ...gTokenReaderWithSCARSignalsEagerStrategy.m | 4 ++-- ...TokenReaderWithSCARSignalsHybridStrategy.m | 4 ++-- ...ngTokenReaderWithSCARSignalsLazyStrategy.m | 4 ++-- .../UADSSCARRawSignalsReader.m | 8 +++---- .../ScarHeaderBidding/UADSSCARSignalReader.h | 2 +- .../ScarHeaderBidding/UADSSCARSignalSender.h | 2 +- .../UADSSCARWebRequestSignalSender.m | 12 +++++----- .../UADSHeaderBiddingTokenReaderBase.h | 4 +++- .../UADSHeaderBiddingTokenReaderBase.m | 9 +++++-- .../UADSHeaderBiddingTokenReaderBuilder.m | 3 ++- .../Core/Properties/USRVSdkProperties.m | 4 ++-- .../Mocks/UADSSCARSignalReaderMock.m | 2 +- .../Mocks/UADSSCARSignalSenderMock.m | 2 +- ...nReaderWithSCARSignalsEagerStrategyTests.m | 9 ++++--- .../UADSSCARWebRequestSignalSenderTests.m | 6 ++--- ...ADSAsyncTokenWithPrivacyIntegrationTests.m | 1 - ...ADSHeaderBiddingTokenIntegrationTestCase.m | 4 ++-- .../Mocks/UADSConfigurationReaderMock.h | 1 + .../Mocks/UADSConfigurationReaderMock.m | 13 ++++++++++ UnityAds.podspec | 4 ++-- 23 files changed, 81 insertions(+), 57 deletions(-) diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/Metric/UADSSCARHeaderBiddingMetric.h b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/Metric/UADSSCARHeaderBiddingMetric.h index 803e7d5b..e4a8be6e 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/Metric/UADSSCARHeaderBiddingMetric.h +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/Metric/UADSSCARHeaderBiddingMetric.h @@ -4,13 +4,13 @@ NS_ASSUME_NONNULL_BEGIN @interface UADSSCARHeaderBiddingMetric : UADSMetric -+ (instancetype)newScarFetchStarted; -+ (instancetype)newScarFetchTimeSuccess: (nullable NSNumber *)value; -+ (instancetype)newScarFetchTimeFailure: (nullable NSNumber *)value tags: (NSDictionary *)tags; ++ (instancetype)newScarFetchStartedWithIsAsync:(BOOL)isAsync; ++ (instancetype)newScarFetchTimeSuccess: (nullable NSNumber *)value isAsync:(BOOL)isAsync; ++ (instancetype)newScarFetchTimeFailure: (nullable NSNumber *)value tags: (NSDictionary *)tags isAsync:(BOOL)isAsync; -+ (instancetype)newScarSendStarted; -+ (instancetype)newScarSendTimeSuccess: (nullable NSNumber *)value; -+ (instancetype)newScarSendTimeFailure: (nullable NSNumber *)value tags: (NSDictionary *)tags; ++ (instancetype)newScarSendStartedWithIsAsync:(BOOL)isAsync; ++ (instancetype)newScarSendTimeSuccess: (nullable NSNumber *)value isAsync:(BOOL)isAsync; ++ (instancetype)newScarSendTimeFailure: (nullable NSNumber *)value tags: (NSDictionary *)tags isAsync:(BOOL)isAsync; @end diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/Metric/UADSSCARHeaderBiddingMetric.m b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/Metric/UADSSCARHeaderBiddingMetric.m index 40cc487d..1a17e1f1 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/Metric/UADSSCARHeaderBiddingMetric.m +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/Metric/UADSSCARHeaderBiddingMetric.m @@ -2,38 +2,38 @@ @implementation UADSSCARHeaderBiddingMetric -+ (instancetype)newScarFetchStarted { - return [self newWithName: @"native_hb_signals_fetch_start" ++ (instancetype)newScarFetchStartedWithIsAsync:(BOOL)isAsync { + return [self newWithName: isAsync ? @"native_hb_signals_async_fetch_start" : @"native_hb_signals_sync_fetch_start" value: nil tags: nil]; } -+ (instancetype)newScarFetchTimeSuccess: (NSNumber *)value { - return [self newWithName: @"native_hb_signals_fetch_success" ++ (instancetype)newScarFetchTimeSuccess: (NSNumber *)value isAsync:(BOOL)isAsync { + return [self newWithName: isAsync ? @"native_hb_signals_async_fetch_success" : @"native_hb_signals_sync_fetch_success" value: value tags: nil]; } -+ (instancetype)newScarFetchTimeFailure: (NSNumber *)value tags: (NSDictionary *)tags { - return [self newWithName: @"native_hb_signals_fetch_failure" ++ (instancetype)newScarFetchTimeFailure: (NSNumber *)value tags: (NSDictionary *)tags isAsync:(BOOL)isAsync { + return [self newWithName: isAsync ? @"native_hb_signals_async_fetch_failure" : @"native_hb_signals_sync_fetch_failure" value: value tags: tags]; } -+ (instancetype)newScarSendStarted { - return [self newWithName: @"native_hb_signals_upload_start" ++ (instancetype)newScarSendStartedWithIsAsync:(BOOL)isAsync { + return [self newWithName: isAsync ? @"native_hb_signals_async_upload_start" : @"native_hb_signals_sync_upload_start" value: nil tags: nil]; } -+ (instancetype)newScarSendTimeSuccess: (NSNumber *)value { - return [self newWithName: @"native_hb_signals_upload_success" ++ (instancetype)newScarSendTimeSuccess: (NSNumber *)value isAsync:(BOOL)isAsync { + return [self newWithName: isAsync ? @"native_hb_signals_async_upload_success" : @"native_hb_signals_sync_upload_success" value: value tags: nil]; } -+ (instancetype)newScarSendTimeFailure: (NSNumber *)value tags: (NSDictionary *)tags { - return [self newWithName: @"native_hb_signals_upload_failure" ++ (instancetype)newScarSendTimeFailure: (NSNumber *)value tags: (NSDictionary *)tags isAsync:(BOOL)isAsync { + return [self newWithName: isAsync ? @"native_hb_signals_async_upload_failure" : @"native_hb_signals_sync_upload_success" value: value tags: tags]; } diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsBaseStrategy.m b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsBaseStrategy.m index df6a9396..a54536d0 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsBaseStrategy.m +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsBaseStrategy.m @@ -41,10 +41,10 @@ - (nonnull NSString *)getToken { NSString* uuidString = [NSUUID new].UUIDString; tokenValue = [self uuidPrefixedTokenValueWithUUIDString:uuidString forTokenValue:tokenValue]; id signalCompletion = ^(UADSSCARSignals *_Nullable signals) { - [self.scarSignalSender sendSCARSignalsWithUUIDString:uuidString signals:signals]; + [self.scarSignalSender sendSCARSignalsWithUUIDString:uuidString signals:signals isAsync:false]; }; - [self.scarSignalReader requestSCARSignalsWithCompletion:signalCompletion]; + [self.scarSignalReader requestSCARSignalsWithIsAsync:false completion:signalCompletion]; return tokenValue; } diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategy.m b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategy.m index 22dc63aa..7c4fca32 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategy.m +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategy.m @@ -19,10 +19,10 @@ - (void)getToken:(UADSHeaderBiddingTokenCompletion)completion { @synchronized (nonChangingValue) { blockSignals = signals; } - [self.scarSignalSender sendSCARSignalsWithUUIDString:uuidString signals:blockSignals]; + [self.scarSignalSender sendSCARSignalsWithUUIDString:uuidString signals:blockSignals isAsync:true]; }; - [self.scarSignalReader requestSCARSignalsWithCompletion:signalCompletion]; + [self.scarSignalReader requestSCARSignalsWithIsAsync:true completion:signalCompletion]; UADSHeaderBiddingTokenCompletion injectedCompletion = ^(UADSHeaderBiddingToken *_Nullable token) { if (token.isValid) { diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsHybridStrategy.m b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsHybridStrategy.m index a30fbe9d..bc1dd8f3 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsHybridStrategy.m +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsHybridStrategy.m @@ -22,7 +22,7 @@ - (void)getToken:(UADSHeaderBiddingTokenCompletion)completion { dispatch_group_notify(group, queue, ^{ if (blockToken) { - [self.scarSignalSender sendSCARSignalsWithUUIDString:blockToken.uuidString signals:blockSignals]; + [self.scarSignalSender sendSCARSignalsWithUUIDString:blockToken.uuidString signals:blockSignals isAsync:true]; } }); @@ -32,7 +32,7 @@ - (void)getToken:(UADSHeaderBiddingTokenCompletion)completion { dispatch_group_leave(group); }; - [self.scarSignalReader requestSCARSignalsWithCompletion:signalCompletion]; + [self.scarSignalReader requestSCARSignalsWithIsAsync:true completion:signalCompletion]; UADSHeaderBiddingTokenCompletion injectedCompletion = ^(UADSHeaderBiddingToken *_Nullable token) { token = [self setUUIDString:token.uuidString ifRemoteToken:token]; diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsLazyStrategy.m b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsLazyStrategy.m index c3aae783..3ef72b8d 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsLazyStrategy.m +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSHeaderBiddingTokenReaderWithSCARSignalsLazyStrategy.m @@ -8,13 +8,13 @@ - (void)getToken:(UADSHeaderBiddingTokenCompletion)completion { __block NSString* uuidString; id signalCompletion = ^(UADSSCARSignals *_Nullable signals) { - [self.scarSignalSender sendSCARSignalsWithUUIDString:uuidString signals:signals]; + [self.scarSignalSender sendSCARSignalsWithUUIDString:uuidString signals:signals isAsync:true]; }; UADSHeaderBiddingTokenCompletion injectedCompletion = ^(UADSHeaderBiddingToken *_Nullable token) { if (token.isValid) { uuidString = token.uuidString; - [self.scarSignalReader requestSCARSignalsWithCompletion:signalCompletion]; + [self.scarSignalReader requestSCARSignalsWithIsAsync:true completion:signalCompletion]; token = [self setUUIDString:uuidString ifRemoteToken:token]; } completion(token); diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARRawSignalsReader.m b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARRawSignalsReader.m index a5971556..1259d001 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARRawSignalsReader.m +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARRawSignalsReader.m @@ -4,13 +4,13 @@ @implementation UADSSCARRawSignalsReader -- (void) requestSCARSignalsWithCompletion: (_Nullable UADSSuccessCompletion) completion { +- (void) requestSCARSignalsWithIsAsync:(BOOL)isAsync completion: (_Nullable UADSSuccessCompletion) completion { CFTimeInterval startTime = self.config.timestampReader.currentTimestamp; - [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarFetchStarted]]; + [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarFetchStartedWithIsAsync:isAsync]]; id success = ^(UADSSCARSignals *_Nullable signals) { - [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarFetchTimeSuccess:[self durationFromStartTime:startTime]]]; + [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarFetchTimeSuccess:[self durationFromStartTime:startTime] isAsync:isAsync]]; completion(signals); }; @@ -19,7 +19,7 @@ - (void) requestSCARSignalsWithCompletion: (_Nullable UADSSuccessCompletion) com NSMutableDictionary *tags = [NSMutableDictionary dictionaryWithDictionary: @{ @"reason": error.errorCode }]; - [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarFetchTimeFailure:[self durationFromStartTime:startTime] tags:tags]]; + [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarFetchTimeFailure:[self durationFromStartTime:startTime] tags:tags isAsync:isAsync]]; completion(nil); }; diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARSignalReader.h b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARSignalReader.h index 268b4f4f..24026be3 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARSignalReader.h +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARSignalReader.h @@ -5,7 +5,7 @@ @protocol UADSSCARSignalReader -- (void) requestSCARSignalsWithCompletion: (_Nullable UADSSuccessCompletion) completion; +- (void) requestSCARSignalsWithIsAsync:(BOOL)isAsync completion: (_Nullable UADSSuccessCompletion) completion; @end diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARSignalSender.h b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARSignalSender.h index f7ce9457..58d66848 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARSignalSender.h +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARSignalSender.h @@ -5,7 +5,7 @@ @protocol UADSSCARSignalSender -- (void)sendSCARSignalsWithUUIDString:(NSString* _Nonnull)uuidString signals:(UADSSCARSignals * _Nonnull) signals; +- (void)sendSCARSignalsWithUUIDString:(NSString* _Nonnull)uuidString signals:(UADSSCARSignals * _Nonnull) signals isAsync:(BOOL)isAsync; @end diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARWebRequestSignalSender.m b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARWebRequestSignalSender.m index 34c416c1..3e287040 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARWebRequestSignalSender.m +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/ScarHeaderBidding/UADSSCARWebRequestSignalSender.m @@ -14,12 +14,12 @@ - (instancetype)init { return self; } -- (void)sendSCARSignalsWithUUIDString:(NSString*)uuidString signals:(UADSSCARSignals *) signals { +- (void)sendSCARSignalsWithUUIDString:(NSString* _Nonnull)uuidString signals:(UADSSCARSignals * _Nonnull) signals isAsync:(BOOL)isAsync { if (![signals objectForKey:UADSScarRewardedSignal] && ![signals objectForKey:UADSScarInterstitialSignal]) { NSMutableDictionary *tags = [NSMutableDictionary dictionaryWithDictionary: @{ @"reason": @"No SCAR Signals passed along" }]; - [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarSendTimeFailure:0 tags:tags]]; + [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarSendTimeFailure:0 tags:tags isAsync:isAsync]]; return; } @@ -27,10 +27,10 @@ - (void)sendSCARSignalsWithUUIDString:(NSString*)uuidString signals:(UADSSCARSig NSMutableDictionary *tags = [NSMutableDictionary dictionaryWithDictionary: @{ @"reason": @"Invalid UUID string" }]; - [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarSendTimeFailure:0 tags:tags]]; + [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarSendTimeFailure:0 tags:tags isAsync:isAsync]]; return; } - [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarSendStarted]]; + [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarSendStartedWithIsAsync:isAsync]]; CFTimeInterval startTime = self.config.timestampReader.currentTimestamp; NSString* scarHbUrl = [self.config.configurationReader getCurrentScarHBURL]; @@ -55,7 +55,7 @@ - (void)sendSCARSignalsWithUUIDString:(NSString*)uuidString signals:(UADSSCARSig NSMutableDictionary *tags = [NSMutableDictionary dictionaryWithDictionary: @{ @"reason": uads_errorStateString(error.code) }]; - [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarSendTimeFailure:[self durationFromStartTime:startTime] tags:tags]]; + [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarSendTimeFailure:[self durationFromStartTime:startTime] tags:tags isAsync:isAsync]]; return; } NSString *jsonString = [[NSString alloc] initWithData:jsonData @@ -64,7 +64,7 @@ - (void)sendSCARSignalsWithUUIDString:(NSString*)uuidString signals:(UADSSCARSig dispatch_async(queue, ^{ NSData* data = [request makeRequest]; - [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarSendTimeSuccess:[self durationFromStartTime:startTime]]]; + [self.config.metricsSender sendMetric: [UADSSCARHeaderBiddingMetric newScarSendTimeSuccess:[self durationFromStartTime:startTime] isAsync:isAsync]]; }); } diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBase.h b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBase.h index 7c295ada..6ef83463 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBase.h +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBase.h @@ -3,6 +3,7 @@ #import "USRVBodyBase64GzipCompressor.h" #import "UADSTokenType.h" #import "UADSHeaderBiddingToken.h" +#import "UADSConfigurationCRUDBase.h" NS_ASSUME_NONNULL_BEGIN @@ -19,7 +20,8 @@ typedef void (^UADSHeaderBiddingTokenCompletion)(UADSHeaderBiddingToken *_Nullab + (instancetype)newWithDeviceInfoReader: (id)deviceInfoReader andCompressor: (id)compressor withTokenPrefix: (NSString *)prefix - withUniqueIdGenerator: (id) uniqueIdGenerator; + withUniqueIdGenerator: (id) uniqueIdGenerator + withConfigurationReader: (id) configurationReader; @end diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBase.m b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBase.m index 18109478..e1396511 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBase.m +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBase.m @@ -5,6 +5,7 @@ @interface UADSHeaderBiddingTokenReaderBase () @property (nonatomic, strong) id compressor; @property (nonnull, copy) NSString *customPrefix; @property (nonatomic) id uniqueIdGenerator; +@property (nonatomic, strong) idconfigurationReader; @end @implementation UADSHeaderBiddingTokenReaderBase @@ -12,20 +13,24 @@ @implementation UADSHeaderBiddingTokenReaderBase + (instancetype)newWithDeviceInfoReader: (id)deviceInfoReader andCompressor: (id)compressor withTokenPrefix: (NSString *)prefix - withUniqueIdGenerator: (id) uniqueIdGenerator { + withUniqueIdGenerator: (id) uniqueIdGenerator + withConfigurationReader: (id) configurationReader { UADSHeaderBiddingTokenReaderBase *base = [self new]; base.deviceInfoReader = deviceInfoReader; base.compressor = compressor; base.customPrefix = prefix; base.uniqueIdGenerator = uniqueIdGenerator; + base.configurationReader = configurationReader; return base; } - (void)getToken:(UADSHeaderBiddingTokenCompletion)completion { NSMutableDictionary *info = [NSMutableDictionary dictionaryWithDictionary:[_deviceInfoReader getDeviceInfoForGameMode: UADSGameModeMix]]; NSString* uniqueId = [self.uniqueIdGenerator generateId]; - info[@"tid"] = uniqueId; + if (self.configurationReader.selectedSCARHBStrategyType != UADSSCARHeaderBiddingStrategyTypeDisabled) { + info[@"tid"] = uniqueId; + } NSString *tokenValue = [_compressor compressedIntoString: info]; NSString *prefixedTokenValue = [self.customPrefix stringByAppendingString: tokenValue]; UADSHeaderBiddingToken *hbToken = [UADSHeaderBiddingToken newNative:prefixedTokenValue]; diff --git a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBuilder.m b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBuilder.m index 0b623623..523d5798 100644 --- a/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBuilder.m +++ b/SourceCode/Private/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenReaderBuilder.m @@ -94,7 +94,8 @@ @implementation UADSHeaderBiddingTokenReaderBuilder _tokenGenerator = [UADSHeaderBiddingTokenReaderBase newWithDeviceInfoReader: self.deviceInfoReader andCompressor: self.bodyCompressor withTokenPrefix: self.nativeTokenPrefix - withUniqueIdGenerator:self.uniqueIdGenerator ?: [UADSUUIDStringGenerator new]]; + withUniqueIdGenerator: self.uniqueIdGenerator ?: [UADSUUIDStringGenerator new] + withConfigurationReader: self.sdkConfigReader]; } if (self.experiments.isPrivacyWaitEnabled) { diff --git a/SourceCode/Private/Core/Properties/USRVSdkProperties.m b/SourceCode/Private/Core/Properties/USRVSdkProperties.m index 092d9db6..bf8512fb 100644 --- a/SourceCode/Private/Core/Properties/USRVSdkProperties.m +++ b/SourceCode/Private/Core/Properties/USRVSdkProperties.m @@ -11,12 +11,12 @@ NSString *const kUnityServicesLocalStorageFilePrefix = @"UnityAdsStorage-"; NSString *const kUnityServicesWebviewBranchInfoDictionaryKey = @"UADSWebviewBranch"; NSString *const kUnityServicesWebviewConfigInfoDictionaryKey = @"UADSWebviewConfig"; -NSString *const kUnityServicesVersionName = @"4.6.0"; +NSString *const kUnityServicesVersionName = @"4.6.1"; NSString *const kUnityServicesFlavorDebug = @"debug"; NSString *const kUnityServicesFlavorRelease = @"release"; NSString *const kChinaIsoAlpha2Code = @"CN"; NSString *const kChinaIsoAlpha3Code = @"CHN"; -int const kUnityServicesVersionCode = 4600; +int const kUnityServicesVersionCode = 4610; @implementation USRVSdkProperties diff --git a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Mocks/UADSSCARSignalReaderMock.m b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Mocks/UADSSCARSignalReaderMock.m index e9b9d715..2e9d3407 100644 --- a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Mocks/UADSSCARSignalReaderMock.m +++ b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Mocks/UADSSCARSignalReaderMock.m @@ -14,7 +14,7 @@ - (instancetype)init { return self; } -- (void)requestSCARSignalsWithCompletion:(UADSSuccessCompletion _Nullable)completion { +- (void)requestSCARSignalsWithIsAsync:(BOOL)async completion:(UADSSuccessCompletion _Nullable)completion { _callHistoryCount += 1; if (_shouldAutoComplete) { completion([self.signals copy]); diff --git a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Mocks/UADSSCARSignalSenderMock.m b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Mocks/UADSSCARSignalSenderMock.m index 5d5553ec..f952818f 100644 --- a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Mocks/UADSSCARSignalSenderMock.m +++ b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Mocks/UADSSCARSignalSenderMock.m @@ -20,7 +20,7 @@ -(instancetype)init { return self; } -- (void)sendSCARSignalsWithUUIDString:(NSString * _Nonnull)uuidString signals:(UADSSCARSignals * _Nonnull)signals { +- (void)sendSCARSignalsWithUUIDString:(NSString * _Nonnull)uuidString signals:(UADSSCARSignals * _Nonnull)signals isAsync:(BOOL)isAsync { @synchronized (self) { [self.callHistory addObject:[[UADSSCARSignalSenderMockData alloc] initWithUUIDString:uuidString signals:signals]]; [self.callExpectation fulfill]; diff --git a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Strategies/UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategyTests.m b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Strategies/UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategyTests.m index 814deef2..86cde65c 100644 --- a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Strategies/UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategyTests.m +++ b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Strategies/UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategyTests.m @@ -11,6 +11,7 @@ #import "XCTestCase+SCARHBStrategies.h" #import "UADSDeviceReaderMock.h" #import "USRVDataGzipCompressor.h" +#import "UADSConfigurationReaderMock.h" @interface UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategyTests : XCTestCase @property (nonatomic, strong) UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategy *strategyToTest; @@ -22,8 +23,7 @@ @interface UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategyTests : XCTes @property (nonatomic, strong) UADSUniqueIdGeneratorMock* idGeneratorMock; @property (nonatomic, strong) UADSUniqueIdGeneratorMock* baseIdGeneratorMock; @property (nonatomic, strong) UADSDeviceReaderMock *readerMock; - - +@property (strong, nonatomic) UADSConfigurationReaderMock *configurationReaderMock; @end @implementation UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategyTests @@ -35,6 +35,8 @@ - (void)setUp { _signalSenderMock = [UADSSCARSignalSenderMock new]; _idGeneratorMock = [UADSUniqueIdGeneratorMock new]; _baseIdGeneratorMock = [UADSUniqueIdGeneratorMock new]; + _configurationReaderMock = [UADSConfigurationReaderMock new]; + _configurationReaderMock.expectedStrategyType = UADSSCARHeaderBiddingStrategyTypeEager; _configMock = [UADSHeaderBiddingTokenReaderSCARSignalsConfig new]; _configMock.compressor = _compressor; @@ -48,7 +50,8 @@ - (void)setUp { UADSHeaderBiddingTokenReaderBase *base = [UADSHeaderBiddingTokenReaderBase newWithDeviceInfoReader: _readerMock andCompressor: _compressor withTokenPrefix: @"" - withUniqueIdGenerator: _baseIdGeneratorMock]; + withUniqueIdGenerator: _baseIdGeneratorMock + withConfigurationReader: _configurationReaderMock]; _originalMock.original = base; _strategyToTest = [UADSHeaderBiddingTokenReaderWithSCARSignalsEagerStrategy decorateOriginal:_originalMock config:_configMock]; _strategyToTest.scarSignalReader = _signalReaderMock; diff --git a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Strategies/UADSSCARWebRequestSignalSenderTests.m b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Strategies/UADSSCARWebRequestSignalSenderTests.m index 0efbbe66..5afec0bd 100644 --- a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Strategies/UADSSCARWebRequestSignalSenderTests.m +++ b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/GMASCARHeaderBidding/Strategies/UADSSCARWebRequestSignalSenderTests.m @@ -59,7 +59,7 @@ - (void)test_send_valid_signals_and_empty_uuid { } - (void)test_send_nil_signal_reference_and_valid_uuid { - [self.signalSender sendSCARSignalsWithUUIDString:@"uuid" signals:nil]; + [self.signalSender sendSCARSignalsWithUUIDString:@"uuid" signals:nil isAsync:true]; XCTAssertEqual(self.requestFactoryMock.createdRequests.count, 0); } @@ -68,7 +68,7 @@ - (void)checkSentRequestValuesWithRewardedValue:(NSString*)rewardedValue interst [signals uads_setValueIfNotNil:rewardedValue forKey:UADSScarRewardedSignal]; [signals uads_setValueIfNotNil:interstitialValue forKey:UADSScarInterstitialSignal]; - [self.signalSender sendSCARSignalsWithUUIDString:uuidValue signals:signals]; + [self.signalSender sendSCARSignalsWithUUIDString:uuidValue signals:signals isAsync:true]; XCTAssertEqual(self.requestFactoryMock.createdRequests.count, 1); id mockRequest = self.requestFactoryMock.createdRequests[0]; @@ -85,7 +85,7 @@ - (void)checkNoSentRequestValuesWithRewardedValue:(NSString*)rewardedValue inter [signals uads_setValueIfNotNil:rewardedValue forKey:UADSScarRewardedSignal]; [signals uads_setValueIfNotNil:interstitialValue forKey:UADSScarInterstitialSignal]; - [self.signalSender sendSCARSignalsWithUUIDString:uuidValue signals:signals]; + [self.signalSender sendSCARSignalsWithUUIDString:uuidValue signals:signals isAsync:true]; XCTAssertEqual(self.requestFactoryMock.createdRequests.count, 0); } diff --git a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/UADSAsyncTokenWithPrivacyIntegrationTests.m b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/UADSAsyncTokenWithPrivacyIntegrationTests.m index f64fe890..c882584c 100644 --- a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/UADSAsyncTokenWithPrivacyIntegrationTests.m +++ b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/UADSAsyncTokenWithPrivacyIntegrationTests.m @@ -124,7 +124,6 @@ - (void)validateIfTokenContextual: (UADSHeaderBiddingToken *)token isContextual: XCTAssertTrue(token.isValid); NSArray *expectedKeys = isContextual ? self.contextualTokenKeys : self.behavioralTokenKeys; NSMutableArray *fullExpectedKeys = [NSMutableArray arrayWithArray:expectedKeys]; - [fullExpectedKeys addObject:@"tid"]; [_infoTester validateDataContains: token.tokenDictionary allKeys: fullExpectedKeys]; diff --git a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenIntegrationTestCase.m b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenIntegrationTestCase.m index cfe76511..b2fd7773 100644 --- a/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenIntegrationTestCase.m +++ b/Tests/UnityAdsTests/Core/Device/HeaderBiddingTokenReader/UADSHeaderBiddingTokenIntegrationTestCase.m @@ -97,8 +97,8 @@ - (void)test_if_state_is_not_initialized_return_null_token_even_if_queue_is_not_ - (void)test_adds_prefix_to_native_generated_token { self.nativeGeneratorMock = nil; self.builder.deviceInfoReader = self.readerMock; - // encoded device info: @{ @"test": @"info", @"tid": @"uuid" }; - NSString *tokenString = @"1:H4sIAAAAAAAAE6tWKslMUbJSKi0FUjpKJanFJUBeZl5avlItAPQMbt8cAAAA"; + // encoded device info: @{ @"test": @"info" }; + NSString *tokenString = @"1:H4sIAAAAAAAAE6tWKkktLlGyUsrMS8tXqgUAIuq+TA8AAAA="; UADSUniqueIdGeneratorMock *idGeneratorMock = [UADSUniqueIdGeneratorMock new]; idGeneratorMock.expectedValue = @"uuid"; _builder.uniqueIdGenerator = idGeneratorMock; diff --git a/Tests/UnityAdsTests/Mocks/UADSConfigurationReaderMock.h b/Tests/UnityAdsTests/Mocks/UADSConfigurationReaderMock.h index 466d9889..3ef723d4 100644 --- a/Tests/UnityAdsTests/Mocks/UADSConfigurationReaderMock.h +++ b/Tests/UnityAdsTests/Mocks/UADSConfigurationReaderMock.h @@ -12,5 +12,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong) NSDictionary *experiments; @property (nonatomic, strong) NSString *metricURL; @property (nonatomic, strong) NSDictionary *expectedMetricInfo; +@property (nonatomic) UADSSCARHBStrategyType expectedStrategyType; @end NS_ASSUME_NONNULL_END diff --git a/Tests/UnityAdsTests/Mocks/UADSConfigurationReaderMock.m b/Tests/UnityAdsTests/Mocks/UADSConfigurationReaderMock.m index 1cc4c534..dd612319 100644 --- a/Tests/UnityAdsTests/Mocks/UADSConfigurationReaderMock.m +++ b/Tests/UnityAdsTests/Mocks/UADSConfigurationReaderMock.m @@ -40,6 +40,11 @@ - (UADSConfigurationExperiments *)currentSessionExperiments { return [UADSConfigurationExperiments newWithJSON: self.currentSessionExperimentsAsDictionary]; } +- (nonnull NSString *)getCurrentMetricsUrl { + return @""; +} + + - (NSDictionary *)metricTags { return self.experiments; @@ -50,4 +55,12 @@ - (NSDictionary *)metricContainerConfigurationInfo { } +- (NSString *)getCurrentScarHBURL { + return @""; +} + +- (UADSSCARHBStrategyType)selectedSCARHBStrategyType { + return self.expectedStrategyType ?: UADSSCARHeaderBiddingStrategyTypeDisabled; +} + @end diff --git a/UnityAds.podspec b/UnityAds.podspec index e5983a95..2ac916b7 100644 --- a/UnityAds.podspec +++ b/UnityAds.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |s| s.name = 'UnityAds' - s.version = '4.6.0' + s.version = '4.6.1' s.license = { :type => 'Unity License', :file => 'LICENSE' } s.author = { 'UnityAds' => 'itunes@unity3d.com' } s.homepage = 'https://unity3d.com/services/ads' s.summary = 'Monetize your entire player base and reach new audiences with video ads.' s.platform = :ios - s.source = { :http => 'https://github.com/Unity-Technologies/unity-ads-ios/releases/download/4.6.0/UnityAds.zip' } + s.source = { :http => 'https://github.com/Unity-Technologies/unity-ads-ios/releases/download/4.6.1/UnityAds.zip' } s.ios.deployment_target = '9.0' s.ios.vendored_frameworks = 'UnityAds.xcframework' s.swift_version = '5.0'