Skip to content

Commit

Permalink
Introduce Server Side SDK configuration properties for Creative Facto…
Browse files Browse the repository at this point in the history
…ry Timeout (#903)

* feat: implement server-side creative factory timeout

* feat: assign server-side ctf values only if they are not nil
  • Loading branch information
OlenaPostindustria authored Aug 16, 2023
1 parent 4ee7509 commit b377074
Show file tree
Hide file tree
Showing 21 changed files with 451 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,28 @@ struct TestCaseManager {
setupCustomParams(for: bannerController.prebidConfigId)
}),

TestCase(title: "Banner 320x50 Server-Side Creative Factory Timeout (In-App)",
tags: [.banner, .inapp, .server],
exampleVCStoryboardID: "AdapterViewController",
configurationClosure: { vc in
guard let adapterVC = vc as? AdapterViewController else {
return
}

Prebid.shared.prebidServerAccountId = "prebid-stored-request-sdk-config"

let bannerController = PrebidBannerController(rootController: adapterVC)
bannerController.adSizes = [CGSize(width: 320, height: 50)]

bannerController.prebidConfigId = "prebid-ita-banner-320-50"

bannerController.testPBSSDKConfig = true

adapterVC.setup(adapter: bannerController)

setupCustomParams(for: bannerController.prebidConfigId)
}),

TestCase(title: "Banner Events 320x50 (In-App)",
tags: [.banner, .inapp, .server],
exampleVCStoryboardID: "AdapterViewController",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class PrebidBannerController: NSObject, AdaptedController, PrebidConfigurableBan

var adBannerView: BannerView?

var testPBSSDKConfig = false

weak var rootController: AdapterViewController?

private let adViewDidReceiveAdButton = EventReportContainer()
Expand Down Expand Up @@ -162,6 +164,19 @@ class PrebidBannerController: NSObject, AdaptedController, PrebidConfigurableBan
rootController?.bannerView.constraints.first { $0.firstAttribute == .height }?.constant = adSize.height
lastLoadedAdSizeLabel.isHidden = false
lastLoadedAdSizeLabel.text = "Ad Size: \(adSize.width)x\(adSize.height)"

// Creative Factory Timeout Check

if testPBSSDKConfig {
let pbsSDKConfig = bannerView.lastBidResponse?.ext?.extPrebid?.passthrough?.filter({
$0.type == "prebidmobilesdk"
}).first?.sdkConfiguration

if pbsSDKConfig?.cftBanner?.doubleValue != Prebid.shared.creativeFactoryTimeout || pbsSDKConfig?.cftPreRender?.doubleValue != Prebid.shared.creativeFactoryTimeoutPreRenderContent {
resetEvents()
adViewDidFailToLoadAdButton.isEnabled = true
}
}
}

func bannerView(_ bannerView: BannerView, didFailToReceiveAdWith error: Error) {
Expand Down
36 changes: 26 additions & 10 deletions PrebidMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
539D4C7229B5E23600B6B30E /* MockPBMAbstractCreative.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539D4C7129B5E23600B6B30E /* MockPBMAbstractCreative.swift */; };
53A6579E2A860F5800AE0B4F /* CacheExpiryDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A6579D2A860F5800AE0B4F /* CacheExpiryDelegate.swift */; };
53A657A02A860F7200AE0B4F /* CacheExpiryDelegateWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A6579F2A860F7200AE0B4F /* CacheExpiryDelegateWrapper.swift */; };
53A657B02A8B64C200AE0B4F /* PBMORTBSDKConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 53A657AF2A8B64C200AE0B4F /* PBMORTBSDKConfiguration.m */; };
53A657B12A8B650900AE0B4F /* PBMORTBSDKConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 53A657AE2A8B64B300AE0B4F /* PBMORTBSDKConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
53A657B52A8B8B0500AE0B4F /* PBMORTBBidResponseExtPrebid.h in Headers */ = {isa = PBXBuildFile; fileRef = 53A657B42A8B8B0500AE0B4F /* PBMORTBBidResponseExtPrebid.h */; settings = {ATTRIBUTES = (Public, ); }; };
53A657B72A8B8B6400AE0B4F /* PBMORTBBidResponseExtPrebid.m in Sources */ = {isa = PBXBuildFile; fileRef = 53A657B62A8B8B6400AE0B4F /* PBMORTBBidResponseExtPrebid.m */; };
53B221CF2A0E3D2800C91CCB /* PrebidJSLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53B221CE2A0E3D2800C91CCB /* PrebidJSLibrary.swift */; };
53B221D12A0E3D3D00C91CCB /* PrebidJSLibraryManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53B221D02A0E3D3D00C91CCB /* PrebidJSLibraryManager.swift */; };
53B221D32A0E3DA900C91CCB /* PrebidJSLibraryManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53B221D22A0E3DA900C91CCB /* PrebidJSLibraryManagerTests.swift */; };
Expand Down Expand Up @@ -928,6 +932,10 @@
539D4C7129B5E23600B6B30E /* MockPBMAbstractCreative.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPBMAbstractCreative.swift; sourceTree = "<group>"; };
53A6579D2A860F5800AE0B4F /* CacheExpiryDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CacheExpiryDelegate.swift; sourceTree = "<group>"; };
53A6579F2A860F7200AE0B4F /* CacheExpiryDelegateWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CacheExpiryDelegateWrapper.swift; sourceTree = "<group>"; };
53A657AE2A8B64B300AE0B4F /* PBMORTBSDKConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PBMORTBSDKConfiguration.h; sourceTree = "<group>"; };
53A657AF2A8B64C200AE0B4F /* PBMORTBSDKConfiguration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PBMORTBSDKConfiguration.m; sourceTree = "<group>"; };
53A657B42A8B8B0500AE0B4F /* PBMORTBBidResponseExtPrebid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PBMORTBBidResponseExtPrebid.h; sourceTree = "<group>"; };
53A657B62A8B8B6400AE0B4F /* PBMORTBBidResponseExtPrebid.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PBMORTBBidResponseExtPrebid.m; sourceTree = "<group>"; };
53B221CE2A0E3D2800C91CCB /* PrebidJSLibrary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidJSLibrary.swift; sourceTree = "<group>"; };
53B221D02A0E3D3D00C91CCB /* PrebidJSLibraryManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidJSLibraryManager.swift; sourceTree = "<group>"; };
53B221D22A0E3DA900C91CCB /* PrebidJSLibraryManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidJSLibraryManagerTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2275,10 +2283,10 @@
isa = PBXGroup;
children = (
5BC37779271F1CFE00444D5E /* PBMAdLoadManagerBase.h */,
5BC3777A271F1CFE00444D5E /* PBMAdLoadManagerVAST.h */,
5BC3777B271F1CFE00444D5E /* PBMAdLoadManagerProtocol.h */,
5BC3777C271F1CFE00444D5E /* PBMAdLoadManagerDelegate.h */,
5BC3777D271F1CFE00444D5E /* PBMAdLoadManagerBase.m */,
5BC3777C271F1CFE00444D5E /* PBMAdLoadManagerDelegate.h */,
5BC3777B271F1CFE00444D5E /* PBMAdLoadManagerProtocol.h */,
5BC3777A271F1CFE00444D5E /* PBMAdLoadManagerVAST.h */,
5BC3777E271F1CFE00444D5E /* PBMAdLoadManagerVAST.m */,
);
path = AdLoadManager;
Expand Down Expand Up @@ -2402,6 +2410,8 @@
5BC37814271F1CFF00444D5E /* Prebid */ = {
isa = PBXGroup;
children = (
924F661927FDB82600C8DAF7 /* PBMORTBAdConfiguration.h */,
924F661B27FDBA5200C8DAF7 /* PBMORTBAdConfiguration.m */,
5BC37820271F1CFF00444D5E /* PBMORTBBidExt.h */,
5BC3781A271F1CFF00444D5E /* PBMORTBBidExt.m */,
5BC37821271F1CFF00444D5E /* PBMORTBBidExtPrebid.h */,
Expand All @@ -2412,17 +2422,19 @@
5BC3781B271F1CFF00444D5E /* PBMORTBBidExtPrebidCacheBids.m */,
5BC3781F271F1CFF00444D5E /* PBMORTBBidExtSkadn.h */,
5BC37818271F1CFF00444D5E /* PBMORTBBidExtSkadn.m */,
92664564272AB5BB0064F7BD /* PBMORTBSkadnFidelity.h */,
92664566272AB5DD0064F7BD /* PBMORTBSkadnFidelity.m */,
5BC3781D271F1CFF00444D5E /* PBMORTBBidResponseExt.h */,
5BC37817271F1CFF00444D5E /* PBMORTBBidResponseExt.m */,
5BC3781C271F1CFF00444D5E /* PBMORTBPrebid.h */,
924F661727FDB79C00C8DAF7 /* PBMORTBExtPrebidPassthrough.h */,
924F661927FDB82600C8DAF7 /* PBMORTBAdConfiguration.h */,
924F661B27FDBA5200C8DAF7 /* PBMORTBAdConfiguration.m */,
924F661D27FDBC3100C8DAF7 /* PBMORTBExtPrebidPassthrough.m */,
53A657B42A8B8B0500AE0B4F /* PBMORTBBidResponseExtPrebid.h */,
53A657B62A8B8B6400AE0B4F /* PBMORTBBidResponseExtPrebid.m */,
539B0D92282A66B800513501 /* PBMORTBExtPrebidEvents.h */,
539B0D94282A675E00513501 /* PBMORTBExtPrebidEvents.m */,
924F661727FDB79C00C8DAF7 /* PBMORTBExtPrebidPassthrough.h */,
924F661D27FDBC3100C8DAF7 /* PBMORTBExtPrebidPassthrough.m */,
5BC3781C271F1CFF00444D5E /* PBMORTBPrebid.h */,
53A657AE2A8B64B300AE0B4F /* PBMORTBSDKConfiguration.h */,
53A657AF2A8B64C200AE0B4F /* PBMORTBSDKConfiguration.m */,
92664564272AB5BB0064F7BD /* PBMORTBSkadnFidelity.h */,
92664566272AB5DD0064F7BD /* PBMORTBSkadnFidelity.m */,
);
path = Prebid;
sourceTree = "<group>";
Expand Down Expand Up @@ -3291,6 +3303,7 @@
5BC378E7271F1CFF00444D5E /* PBMORTBBidRequestExtPrebid.h in Headers */,
5BC37930271F1D0000444D5E /* PBMVideoVerificationParameters.h in Headers */,
5BC37A23271F1D0000444D5E /* PBMSafariVCOpener.h in Headers */,
53A657B52A8B8B0500AE0B4F /* PBMORTBBidResponseExtPrebid.h in Headers */,
5BC378DA271F1CFF00444D5E /* PBMORTBSource.h in Headers */,
5BC37A1A271F1D0000444D5E /* PBMRawBidResponse.h in Headers */,
5BC3796F271F1D0000444D5E /* PBMVastCreativeCompanionAdsCompanion.h in Headers */,
Expand All @@ -3316,6 +3329,7 @@
5BC379CC271F1D0000444D5E /* PBMAdLoadManagerVAST.h in Headers */,
5BC37985271F1D0000444D5E /* PBMMRAIDController.h in Headers */,
5BC3790F271F1CFF00444D5E /* PBMDeviceAccessManager.h in Headers */,
53A657B12A8B650900AE0B4F /* PBMORTBSDKConfiguration.h in Headers */,
5BC379CA271F1D0000444D5E /* PBMTransaction.h in Headers */,
5BC379F5271F1D0000444D5E /* PBMTrackingURLVisitors.h in Headers */,
5BC378E3271F1CFF00444D5E /* PBMORTBImp.h in Headers */,
Expand Down Expand Up @@ -3904,6 +3918,7 @@
5BC379A6271F1D0000444D5E /* PBMModalState.m in Sources */,
5BC37AAD271F1D0000444D5E /* RewardedEventHandlerStandalone.swift in Sources */,
FAEE4D21262DC2B200AD9966 /* VideoBasedAdUnitProtocol.swift in Sources */,
53A657B72A8B8B6400AE0B4F /* PBMORTBBidResponseExtPrebid.m in Sources */,
5BC37910271F1CFF00444D5E /* PBMWindowLocker.m in Sources */,
FAEE4D0D262DC2B200AD9966 /* Log.swift in Sources */,
5BC37A99271F1D0000444D5E /* PBMInterstitialAdLoader.m in Sources */,
Expand Down Expand Up @@ -4039,6 +4054,7 @@
FAEE4D12262DC2B200AD9966 /* RewardedVideoAdUnit.swift in Sources */,
5BC3795B271F1D0000444D5E /* PBMVastCreativeCompanionAdsCompanion.m in Sources */,
5BC37A92271F1D0000444D5E /* RewardedEventLoadingDelegate.swift in Sources */,
53A657B02A8B64C200AE0B4F /* PBMORTBSDKConfiguration.m in Sources */,
92C85D5C27A96C680080BAC5 /* NativeImage.swift in Sources */,
5BC37A86271F1D0000444D5E /* BannerView.swift in Sources */,
5BC3796E271F1D0000444D5E /* PBMVastWrapperAd.m in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions PrebidMobile/BuildFiles/PrebidMobile.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ framework module PrebidMobile {
header "PBMORTBBidExt.h"
header "PBMORTBSeatBid.h"
header "PBMORTBBidExtPrebid.h"
header "PBMORTBBidResponseExtPrebid.h"
header "PBMORTBExtPrebidPassthrough.h"
header "PBMORTBAdConfiguration.h"
header "PBMORTBSDKConfiguration.h"
header "PBMORTBBidExtSkadn.h"
header "PBMORTBSkadnFidelity.h"
header "PBMORTBExtPrebidEvents.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, strong, nullable) PBMORTBBidExtSkadn *skadnInfo;
@property (nonatomic, strong, nullable) NSString *impURL; // bidResponse.ext.prebid.events.imp
@property (nonatomic, strong, nullable) NSString *winURL; // idResponse.ext.prebid.events.win
@property (nonatomic, strong, nullable) NSString *winURL; // bidResponse.ext.prebid.events.win

@property (atomic, weak, nullable) id<PBMTransactionDelegate> delegate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class BidResponse: NSObject {

public private(set) var tmaxrequest: NSNumber?

public private(set) var ext: PBMORTBBidResponseExt?

private(set) var rawResponse: RawBidResponse<PBMORTBBidResponseExt, NSDictionary, PBMORTBBidExt>?

public convenience init(adUnitId: String?, targetingInfo: [String: String]?) {
Expand Down Expand Up @@ -85,6 +87,7 @@ public class BidResponse: NSObject {
self.allBids = allBids
self.targetingInfo = targetingInfo.count > 0 ? targetingInfo : nil
tmaxrequest = rawBidResponse.ext.tmaxrequest
self.ext = rawBidResponse.ext
}

public func setTargetingInfo(with newValue: [String : String]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
 */

#import "PBMORTBAbstract.h"
#import "PBMORTBBidResponseExtPrebid.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -25,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
/// [Integer]
@property (nonatomic, strong, nullable) NSNumber *tmaxrequest;

@property (nonatomic, strong, nullable) PBMORTBBidResponseExtPrebid *extPrebid;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ - (instancetype)initWithJsonDictionary:(PBMJsonDictionary *)jsonDictionary {
}
_responsetimemillis = jsonDictionary[@"responsetimemillis"];
_tmaxrequest = jsonDictionary[@"tmaxrequest"];

PBMJsonDictionary * extPrebid = jsonDictionary[@"prebid"];
if (extPrebid) {
_extPrebid = [[PBMORTBBidResponseExtPrebid alloc] initWithJsonDictionary:extPrebid];
}

return self;
}

Expand All @@ -32,6 +38,7 @@ - (PBMJsonDictionary *)toJsonDictionary {

ret[@"responsetimemillis"] = self.responsetimemillis;
ret[@"tmaxrequest"] = self.tmaxrequest;
ret[@"prebid"] = [self.extPrebid toJsonDictionary];

[ret pbmRemoveEmptyVals];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*   Copyright 2018-2021 Prebid.org, Inc.
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

#import "PBMORTBAbstract.h"
#import "PBMORTBExtPrebidPassthrough.h"

NS_ASSUME_NONNULL_BEGIN

@interface PBMORTBBidResponseExtPrebid : PBMORTBAbstract

@property (nonatomic, copy, nullable) NSArray<PBMORTBExtPrebidPassthrough *> *passthrough;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*   Copyright 2018-2021 Prebid.org, Inc.
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

#import "PBMORTBBidResponseExtPrebid.h"

@implementation PBMORTBBidResponseExtPrebid

- (instancetype)initWithJsonDictionary:(PBMJsonDictionary *)jsonDictionary {
if (!(self = [super init])) {
return nil;
}

NSArray * const passthroughDics = jsonDictionary[@"passthrough"];
_passthrough = nil;
if (passthroughDics) {
NSMutableArray * const newPassthrough = [[NSMutableArray alloc] initWithCapacity:passthroughDics.count];
for(PBMJsonDictionary *nextDic in passthroughDics) {
PBMORTBExtPrebidPassthrough * const nextPassthrough = [[PBMORTBExtPrebidPassthrough alloc] initWithJsonDictionary:nextDic];
if (nextPassthrough) {
[newPassthrough addObject:nextPassthrough];
}
}
if (newPassthrough.count > 0) {
_passthrough = newPassthrough;
}
}

return self;
}

- (PBMJsonDictionary *)toJsonDictionary {
PBMMutableJsonDictionary * const ret = [[PBMMutableJsonDictionary alloc] init];

NSMutableArray * const passthroughDicArr = [[NSMutableArray alloc] initWithCapacity:self.passthrough.count];
for(PBMORTBExtPrebidPassthrough *nextPassthrough in self.passthrough) {
[passthroughDicArr addObject:[nextPassthrough toJsonDictionary]];
}

if (passthroughDicArr.count > 0) {
ret[@"passthrough"] = passthroughDicArr;
}

[ret pbmRemoveEmptyVals];

return ret;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
 */

#import "PBMORTBAbstract.h"
#import "PBMORTBAbstract+Protected.h"

@class PBMORTBAdConfiguration;
@class PBMORTBSDKConfiguration;

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -25,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, strong, nullable) PBMORTBAdConfiguration *adConfiguration;

@property (nonatomic, strong, nullable) PBMORTBSDKConfiguration *sdkConfiguration;

@end

NS_ASSUME_NONNULL_END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
 limitations under the License.
 */

#import "PBMORTBAbstract+Protected.h"
#import "PBMORTBExtPrebidPassthrough.h"
#import "PBMORTBAdConfiguration.h"
#import "PBMORTBSDKConfiguration.h"

@implementation PBMORTBExtPrebidPassthrough

Expand All @@ -32,6 +32,12 @@ - (instancetype)initWithJsonDictionary:(PBMJsonDictionary *)jsonDictionary {
_adConfiguration = [[PBMORTBAdConfiguration alloc] initWithJsonDictionary:adConfigDic];
}

PBMJsonDictionary * const sdkConfigDic = jsonDictionary[@"sdkconfiguration"];

if (sdkConfigDic) {
_sdkConfiguration = [[PBMORTBSDKConfiguration alloc] initWithJsonDictionary:sdkConfigDic];
}

return self;
}

Expand All @@ -42,6 +48,8 @@ - (PBMJsonDictionary *)toJsonDictionary {

ret[@"adconfiguration"] = [self.adConfiguration toJsonDictionary];

ret[@"sdkconfiguration"] = [self.sdkConfiguration toJsonDictionary];

[ret pbmRemoveEmptyVals];

return ret;
Expand Down
Loading

0 comments on commit b377074

Please sign in to comment.