diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index f407df97e..943618a44 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -128,31 +128,39 @@ public class NativeAd: NSObject, CacheExpiryDelegate { return nil } - let macrosHelper = PBMORTBMacrosHelper(bid: rawBid) - rawBid.adm = macrosHelper.replaceMacros(in: rawBid.adm) - rawBid.nurl = macrosHelper.replaceMacros(in: rawBid.nurl) + let bid = Bid(bid: rawBid) let ad = NativeAd() let internalEventTracker = PrebidServerEventTracker() - if let impURL = rawBid.ext.prebid?.events?.imp { + if let impURL = bid.events?.imp { let impEvent = ServerEvent(url: impURL, expectedEventType: .impression) internalEventTracker.addServerEvents([impEvent]) } - if let winURL = rawBid.ext.prebid?.events?.win { + if let burl = bid.burl { + let billingEvent = ServerEvent(url: burl, expectedEventType: .impression) + internalEventTracker.addServerEvents([billingEvent]) + } + + if let winURL = bid.events?.win { let winEvent = ServerEvent(url: winURL, expectedEventType: .prebidWin) internalEventTracker.addServerEvents([winEvent]) } + if let nurl = bid.nurl { + let noticeEvent = ServerEvent(url: nurl, expectedEventType: .prebidWin) + internalEventTracker.addServerEvents([noticeEvent]) + } + ad.eventManager.registerTracker(internalEventTracker) // Track win event immediately ad.eventManager.trackEvent(.prebidWin) guard let nativeAdMarkup = NativeAdMarkup(jsonString: rawBid.adm) else { - Log.warn("Can't retrieve native ad markup from bid response.") + Log.error("SDK couldn't retrieve native ad markup from bid response.") return nil } diff --git a/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/AdLoadManager/PBMAdLoadManagerBase.m b/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/AdLoadManager/PBMAdLoadManagerBase.m index 4c44a5039..65c673a4f 100644 --- a/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/AdLoadManager/PBMAdLoadManagerBase.m +++ b/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/AdLoadManager/PBMAdLoadManagerBase.m @@ -59,10 +59,8 @@ - (void)makeCreativesWithCreativeModels:(NSArray *)creativeM self.currentTransaction = [[PBMTransaction alloc] initWithServerConnection:self.connection adConfiguration:self.adConfiguration models:creativeModels]; - - self.currentTransaction.skadnInfo = self.bid.skadn; - self.currentTransaction.impURL = self.bid.events.imp; - self.currentTransaction.winURL = self.bid.events.win; + + self.currentTransaction.bid = self.bid; self.currentTransaction.delegate = self; diff --git a/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/PBMAbstractCreative.m b/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/PBMAbstractCreative.m index 4e8082b82..f108f7cd0 100644 --- a/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/PBMAbstractCreative.m +++ b/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/PBMAbstractCreative.m @@ -82,8 +82,8 @@ - (instancetype)initWithCreativeModel:(PBMCreativeModel *)creativeModel } if(@available(iOS 14.5, *)) { - if (self.transaction.skadnInfo) { - SKAdImpression *imp = [PBMSkadnParametersManager getSkadnImpressionFor:self.transaction.skadnInfo]; + if (self.transaction.bid.skadn) { + SKAdImpression *imp = [PBMSkadnParametersManager getSkadnImpressionFor:self.transaction.bid.skadn]; if (imp) { PBMSkadnEventTracker *skadnTracker = [[PBMSkadnEventTracker alloc] initWith:imp]; [self.eventManager registerTracker:(id) skadnTracker]; @@ -93,20 +93,27 @@ - (instancetype)initWithCreativeModel:(PBMCreativeModel *)creativeModel PrebidServerEventTracker *internalEventTracker = [[PrebidServerEventTracker alloc] initWithServerEvents:@[]]; - NSString *impURL = self.transaction.impURL; + NSString *impURL = self.transaction.bid.events.imp; if (impURL) { PBMServerEvent *impEvent = [[PBMServerEvent alloc] initWithUrl:impURL expectedEventType:PBMTrackingEventImpression]; [internalEventTracker addServerEvents:@[impEvent]]; } - NSString *winURL = self.transaction.winURL; + NSString *winURL = self.transaction.bid.events.win; if (winURL) { PBMServerEvent *winEvent = [[PBMServerEvent alloc] initWithUrl:winURL expectedEventType:PBMTrackingEventPrebidWin]; [internalEventTracker addServerEvents:@[winEvent]]; } + NSString * burl = self.transaction.bid.burl; + + if (burl) { + PBMServerEvent *billingEvent = [[PBMServerEvent alloc] initWithUrl:burl expectedEventType:PBMTrackingEventImpression]; + [internalEventTracker addServerEvents:@[billingEvent]]; + } + if (internalEventTracker.serverEvents.count > 0) { [self.eventManager registerTracker:(id) internalEventTracker]; } @@ -227,7 +234,7 @@ - (void)handleClickthrough:(NSURL*)url return; } BOOL clickthroughOpened = NO; - PBMJsonDictionary * skadnetProductParameters = [PBMSkadnParametersManager getSkadnProductParametersFor:self.transaction.skadnInfo]; + PBMJsonDictionary * skadnetProductParameters = [PBMSkadnParametersManager getSkadnProductParametersFor:self.transaction.bid.skadn]; if (skadnetProductParameters) { clickthroughOpened = [self handleProductClickthrough:url diff --git a/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/PBMTransaction.h b/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/PBMTransaction.h index 5418215c6..b3f3715d8 100644 --- a/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/PBMTransaction.h +++ b/PrebidMobile/PrebidMobileRendering/AdTypes/AdView/PBMTransaction.h @@ -18,6 +18,7 @@ @protocol PBMTransactionDelegate; +@class Bid; @class WKWebView; @class UIView; @class PBMModalManager; @@ -41,9 +42,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) PBMOpenMeasurementSession *measurementSession; @property (nonatomic, strong) PBMOpenMeasurementWrapper *measurementWrapper; -@property (nonatomic, strong, nullable) PBMORTBBidExtSkadn *skadnInfo; -@property (nonatomic, strong, nullable) NSString *impURL; // bidResponse.ext.prebid.events.imp -@property (nonatomic, strong, nullable) NSString *winURL; // bidResponse.ext.prebid.events.win +@property (nonatomic, strong, nullable) Bid * bid; @property (atomic, weak, nullable) id delegate; diff --git a/PrebidMobile/PrebidMobileRendering/PBMCreativeViewabilityTracker.m b/PrebidMobile/PrebidMobileRendering/PBMCreativeViewabilityTracker.m index 1fa76f97e..4de14a916 100644 --- a/PrebidMobile/PrebidMobileRendering/PBMCreativeViewabilityTracker.m +++ b/PrebidMobile/PrebidMobileRendering/PBMCreativeViewabilityTracker.m @@ -52,7 +52,9 @@ @interface PBMCreativeViewabilityTracker() @implementation PBMCreativeViewabilityTracker -- (instancetype)initWithView:(UIView *)view pollingTimeInterval:(NSTimeInterval)pollingTimeInterval onExposureChange:(PBMViewExposureChangeHandler)onExposureChange { +- (instancetype)initWithView:(UIView *)view + pollingTimeInterval:(NSTimeInterval)pollingTimeInterval + onExposureChange:(PBMViewExposureChangeHandler)onExposureChange { self = [super init]; if (self) { _checker = [[PBMViewExposureChecker alloc] initWithView:view]; @@ -74,7 +76,6 @@ - (instancetype)initWithCreative:(PBMAbstractCreative *)creative { onExposureChange:^(PBMCreativeViewabilityTracker *tracker, PBMViewExposure *viewExposure) { @strongify(creative); -// BOOL const isVisible = viewExposure.exposureFactor > 0; BOOL isVisible = [tracker isVisibleView:tracker.testedView]; [creative onViewabilityChanged:isVisible viewExposure:viewExposure]; }]) { diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/Bid.swift b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/Bid.swift index 98f75cfe3..07e70cc48 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/Bid.swift +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/Bid.swift @@ -37,6 +37,13 @@ public class Bid: NSObject { /// Substitution macros (Section 4.4) may be included in both the URL and optionally returned markup. @objc public private(set) var nurl: String? + /// Billing notice URL called by the exchange when a winning bid + /// becomes billable based on exchange-specific business policy + /// (e.g., typically delivered, viewed, etc.). + @objc public var burl: String? { + bid.burl + } + /// Optional means of conveying ad markup in case the bid wins; supersedes the win notice /// if markup is included in both. /// Substitution macros (Section 4.4) may be included. diff --git a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/TransactionFactory/PBMDisplayTransactionFactory.m b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/TransactionFactory/PBMDisplayTransactionFactory.m index 9b2da7d53..dbdcd5b58 100644 --- a/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/TransactionFactory/PBMDisplayTransactionFactory.m +++ b/PrebidMobile/PrebidMobileRendering/Prebid/PBMCore/TransactionFactory/PBMDisplayTransactionFactory.m @@ -103,9 +103,7 @@ - (void)loadHTMLTransaction:(NSString *)adMarkup { adConfiguration:self.adConfiguration.adConfiguration models:creativeModels]; - self.transaction.skadnInfo = self.bid.skadn; - self.transaction.impURL = self.bid.events.imp; - self.transaction.winURL = self.bid.events.win; + self.transaction.bid = self.bid; self.transaction.delegate = self; [self.transaction startCreativeFactory];