Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Collecting Arbitrary ORTB Parameters #941

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5c27578
Makes unregister function public.
jsligh Nov 1, 2023
0897cc5
checking for nil and invalidating timer but may have to dive deeper f…
jsligh Nov 1, 2023
e3b7521
Added in multiple places just need to figure out the merging / what t…
jsligh Dec 6, 2023
dad6d27
Loading and sending arbitrary values done.
jsligh Dec 11, 2023
c85bf65
Finished writing tests.
jsligh Dec 12, 2023
c3c62be
Update GAM version
jsligh Dec 13, 2023
65fa06b
whoops, removing this.
jsligh Dec 15, 2023
8ec26b3
Finished imp and imp.ext levels. Need to do global ext.
jsligh Jan 3, 2024
2f3f6ba
Support all the way through.
jsligh Jan 3, 2024
a642064
I believe this covers the implementation for the global ext object in…
jsligh Jan 4, 2024
86cc5df
Added globally.
jsligh Jan 4, 2024
e52f234
Merge branch 'master' into 877-support-collecting-arbitrary-ortb-para…
jsligh Jan 4, 2024
79fde02
fixes
jsligh Jan 4, 2024
b029432
more syntax
jsligh Jan 4, 2024
d7ab955
Added back imp-level and tests.
jsligh Jan 4, 2024
473684e
Remove from test.
jsligh Jan 4, 2024
5579256
Fixed test
jsligh Jan 4, 2024
452b4e6
Makes unregister function public.
jsligh Nov 1, 2023
8a87df7
checking for nil and invalidating timer but may have to dive deeper f…
jsligh Nov 1, 2023
c44632a
Merge branch '908-stop-viewabilitytimer-when-viewfortracking-has-beco…
jsligh Jan 11, 2024
036bdbb
Makes unregister function public.
jsligh Nov 1, 2023
27747b5
checking for nil and invalidating timer but may have to dive deeper f…
jsligh Nov 1, 2023
491bca5
Merge branch '908-stop-viewabilitytimer-when-viewfortracking-has-beco…
jsligh Jan 11, 2024
0280711
We believe there may be some type casting issues that are causing the…
jsligh Jan 16, 2024
e8c17c0
Needed to change the check bounds to make sure isIABViewable is true …
jsligh Jan 16, 2024
428e9a5
removed previous changes.
jsligh Jan 16, 2024
a9d03e4
Proposed changes.
jsligh Jan 17, 2024
88cf61d
Merge pull request #949 from prebid/908-stop-viewabilitytimer-when-vi…
jsligh Jan 18, 2024
8b7b66e
changes for 2.2.0 release
jsligh Jan 19, 2024
7034d23
Merge pull request #952 from prebid/prerelease-2.2.0
jsligh Jan 19, 2024
be74795
Update README.md
jsligh Jan 19, 2024
46f53b7
Merge pull request #953 from prebid/jsligh-patch-1
jsligh Jan 19, 2024
faacf22
Merge branch '877-support-collecting-arbitrary-ortb-parameters' of ht…
jsligh Feb 8, 2024
843ad3a
Pretty Sure my merging logic is correct.
jsligh Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions EventHandlers/EventHandlers.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -1200,7 +1200,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2.1.6;
CURRENT_PROJECT_VERSION = 2.2.0;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -1214,7 +1214,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.2.0;
MODULEMAP_FILE = "";
PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileGAMEventHandlers;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
Expand All @@ -1235,7 +1235,7 @@
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2.1.6;
CURRENT_PROJECT_VERSION = 2.2.0;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -1249,7 +1249,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.2.0;
MODULEMAP_FILE = "";
PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileGAMEventHandlers;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
Expand All @@ -1269,7 +1269,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.1.6;
CURRENT_PROJECT_VERSION = 2.2.0;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -1284,7 +1284,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileMAXAdapters;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand All @@ -1304,7 +1304,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.1.6;
CURRENT_PROJECT_VERSION = 2.2.0;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -1319,7 +1319,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileMAXAdapters;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -1381,7 +1381,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.1.6;
CURRENT_PROJECT_VERSION = 2.2.0;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -1395,7 +1395,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileAdMobAdapters;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = None;
Expand All @@ -1416,7 +1416,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2.1.6;
CURRENT_PROJECT_VERSION = 2.2.0;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -1430,7 +1430,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.prebid.mobile.PrebidMobileAdMobAdapters;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = None;
Expand Down
2 changes: 1 addition & 1 deletion PrebidMobile.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "PrebidMobile"
s.version = "2.1.6"
s.version = "2.2.0"
s.summary = "PrebidMobile is a lightweight framework that integrates directly with Prebid Server."

s.description = <<-DESC
Expand Down
10 changes: 5 additions & 5 deletions PrebidMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -4455,7 +4455,7 @@
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
CURRENT_PROJECT_VERSION = 2.1.6;
CURRENT_PROJECT_VERSION = 2.2.0;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -4474,7 +4474,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.2.0;
MODULEMAP_FILE = PrebidMobile/BuildFiles/PrebidMobile.modulemap;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -4491,7 +4491,7 @@
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
CURRENT_PROJECT_VERSION = 2.1.6;
CURRENT_PROJECT_VERSION = 2.2.0;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -4510,7 +4510,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.6;
MARKETING_VERSION = 2.2.0;
MODULEMAP_FILE = PrebidMobile/BuildFiles/PrebidMobile.modulemap;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
Expand Down
12 changes: 11 additions & 1 deletion PrebidMobile/AdUnits/AdUnit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AdUnit: NSObject, DispatcherDelegate {
var adSizes: [CGSize] {
get { [adUnitConfig.adSize] + (adUnitConfig.additionalSizes ?? []) }
}

private static let PB_MIN_RefreshTime = 30000.0

private(set) var dispatcher: Dispatcher?
Expand Down Expand Up @@ -387,6 +387,16 @@ public class AdUnit: NSObject, DispatcherDelegate {
return adUnitConfig.gpid
}

// MARK: Global ORTBObject

public func setOrtbConfig(_ ortbObject: [String: Any]?) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The custom request should be set as a String.

Publishers should just put the JSON string as a configuration option and not a dictionary.

adUnitConfig.ortbConfig = ortbObject
}

public func getOrtbConfig() -> [String: Any]? {
return adUnitConfig.ortbConfig
}

// MARK: - others

/**
Expand Down
2 changes: 2 additions & 0 deletions PrebidMobile/AdUnits/MultiformatAdUnit/PrebidRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class PrebidRequest: NSObject {

private(set) var gpid: String?

private(set) var ortbConfig: [String: Any]?

// MARK: - Private properties

private var extData = [String: Set<String>]()
Expand Down
15 changes: 11 additions & 4 deletions PrebidMobile/AdUnits/Native/NativeAd.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,14 @@ public class NativeAd: NSObject, CacheExpiryDelegate {
Log.error("The native Ad is expired, cannot use it for tracking")
return false
}
viewForTracking = view
setupViewabilityTracker()
attachGestureRecognizersToNativeView(nativeView: view, withClickableViews: clickableViews)
return true
if (viewForTracking != nil || impressionHasBeenTracked) {
return false
} else {
viewForTracking = view
setupViewabilityTracker()
attachGestureRecognizersToNativeView(nativeView: view, withClickableViews: clickableViews)
return true
}
}

private func unregisterViewFromTracking() {
Expand Down Expand Up @@ -219,6 +223,9 @@ public class NativeAd: NSObject, CacheExpiryDelegate {
return
}
strongSelf.checkViewability()
if (strongSelf.viewForTracking == nil) {
timer.invalidate()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion PrebidMobile/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import UIKit
public let PrebidLocalCacheIdKey = "hb_cache_id_local"

@objc public class Constants: NSObject {
@objc public static let PREBID_VERSION = "2.1.6"
@objc public static let PREBID_VERSION = "2.2.0"
}

extension String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ public class AdConfiguration: AutoRefreshCountConfig {

public var clickHandlerOverride: ((PBMVoidBlock) -> Void)?

public var ortbConfig: [String: Any]?

// MARK: Private properties

private var _autoRefreshDelay: TimeInterval? = PBMAutoRefresh.AUTO_REFRESH_DELAY_DEFAULT

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ @implementation PBMParameterBuilderService
}

+ (nonnull NSDictionary<NSString* , NSString *> *)buildParamsDictWithAdConfiguration:(nonnull PBMAdConfiguration *)adConfiguration extraParameterBuilders:(nullable NSArray<id<PBMParameterBuilder> > *)extraParameterBuilders {
//build
return [self buildParamsDictWithAdConfiguration:adConfiguration
bundle:NSBundle.mainBundle
pbmLocationManager:PBMLocationManager.shared
Expand All @@ -71,6 +72,7 @@ @implementation PBMParameterBuilderService
extraParameterBuilders:(nullable NSArray<id<PBMParameterBuilder> > *)extraParameterBuilders{

PBMORTBBidRequest *bidRequest = [PBMParameterBuilderService createORTBBidRequestWithTargeting:targeting];
bidRequest.ortbObject = adConfiguration.ortbConfig;
NSMutableArray<id<PBMParameterBuilder> > * const parameterBuilders = [[NSMutableArray alloc] init];
[parameterBuilders addObjectsFromArray:@[
[[PBMBasicParameterBuilder alloc] initWithAdConfiguration:adConfiguration
Expand Down Expand Up @@ -109,7 +111,7 @@ + (nonnull PBMORTBBidRequest *)createORTBBidRequestWithTargeting:(nonnull Target
bidRequest.user.buyeruid = targeting.buyerUID;
bidRequest.user.customdata = targeting.userCustomData;
bidRequest.user.userid = targeting.userID;

if (targeting.userExt) {
bidRequest.user.ext = [targeting.userExt mutableCopy];
}
Expand Down
4 changes: 4 additions & 0 deletions PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, strong) PBMORTBBidRequestExtPrebid *extPrebid;

@property (nonatomic, strong, nullable) NSDictionary<NSString *, id> *arbitraryJsonConfig;

@property (nonatomic, strong, nullable) NSDictionary<NSString *, id> *ortbObject;

- (instancetype)init;

@end
Expand Down
54 changes: 54 additions & 0 deletions PrebidMobile/PrebidMobileRendering/ORTB/PBMORTBBidRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,58 @@ - (nonnull PBMJsonDictionary *)toJsonDictionary {
ext[@"prebid"] = [[self.extPrebid toJsonDictionary] nullIfEmpty];
ret[@"ext"] = [[ext pbmCopyWithoutEmptyVals] nullIfEmpty];

//remove "protected" fields from ortbObject then do a merge but merge ret into the ortbObject (addEntriesFromDictionary)
NSMutableDictionary *o = [self.arbitraryJsonConfig mutableCopy];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid such names for variables.

if (o[@"regs"]) {
o[@"regs"] = nil;
}
if (o[@"device"]) {
o[@"device"] = nil;
}
if (o[@"geo"]) {
o[@"geo"] = nil;
}
//merge with config from API/JSON
ret = [self mergeDictionaries: ret joiningArgument2: o joiningArgument3: false];

NSMutableDictionary *o2 = [self.ortbObject mutableCopy];

if (o2[@"regs"]) {
o2[@"regs"] = nil;
}
if (o2[@"device"]) {
o2[@"device"] = nil;
}
if (o2[@"geo"]) {
o[@"geo"] = nil;
}
//merge with ortbConfig from SDK
ret = [self mergeDictionaries: ret joiningArgument2: o2 joiningArgument3: true];

ret = [ret pbmCopyWithoutEmptyVals];

return ret;
}

- (nonnull PBMMutableJsonDictionary *)mergeDictionaries:(NSMutableDictionary*)dictionary1 joiningArgument2:(NSMutableDictionary*)dictionary2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, we can merge dictionaries. This path is faster to implement. However, it makes the solution restricted to such things as

  • RTB protocol validation (proper structure, objects, and types)
  • Warnings for objects prohibited from merging.
  • Upgrading protocol version. See the item 1 - the validation issue.

It is not critical, but I would still merge serialized objects. It is a more reliable approach from the support perspective.

joiningArgument3:(Boolean)firstHasPriority{
PBMMutableJsonDictionary *ret = dictionary1;

for (id key in dictionary2)
if ([ret objectForKey: key]){
if ([[ret objectForKey: key] isKindOfClass: [NSDictionary class]]) {
//if is dictionary, need to call this method recursively for ret object for key and dictionary2 for key
[ret setObject:[self mergeDictionaries:[ret objectForKey: key] joiningArgument2: [dictionary2 objectForKey: key] joiningArgument3:firstHasPriority] forKey: key];
} else {
if (!firstHasPriority) {
[ret setObject:[dictionary2 objectForKey: key] forKey:key];
}
}
//not sure what to do if array of objects
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this comment. Does it mean that the algorithm doesn't merge part of the data?

} else {
[ret setObject:[dictionary2 objectForKey:key] forKey: key];
}

ret = [ret pbmCopyWithoutEmptyVals];

return ret;
Expand Down Expand Up @@ -98,6 +150,8 @@ - (instancetype)initWithJsonDictionary:(nonnull PBMJsonDictionary *)jsonDictiona

_extPrebid = [[PBMORTBBidRequestExtPrebid alloc] initWithJsonDictionary:jsonDictionary[@"ext"][@"prebid"] ?: @{}];

_arbitraryJsonConfig = jsonDictionary;

return self;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public class BannerView: UIView,
set { adUnitConfig.adPosition = newValue }
}

@objc public var ortbConfig: [String: Any]? {
get { adUnitConfig.ortbConfig }
set { adUnitConfig.ortbConfig = newValue }
}

@objc public weak var delegate: BannerViewDelegate?

// MARK: Readonly storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public class BaseInterstitialAdUnit :
get { adUnitConfig.adFormats }
set { adUnitConfig.adFormats = newValue }
}

@objc public var ortbConfig: [String: Any]? {
get { adUnitConfig.ortbConfig }
set { adUnitConfig.ortbConfig = newValue }
}

@objc public var isReady: Bool {
objc_sync_enter(blocksLockToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public class MediationBannerAdUnit : NSObject {
set { adUnitConfig.additionalSizes = newValue }
}

public var ortbConfig: [String: Any]? {
get { adUnitConfig.ortbConfig }
set { adUnitConfig.ortbConfig = newValue }
}

// MARK: - Ext Data (imp[].ext.data)

@available(*, deprecated, message: "This method is deprecated. Please, use addExtData method instead.")
Expand Down
Loading