Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
f40ec3c
WURFL-devicedetection module implementation (compatible with PBS Java…
andreacastello Jan 17, 2025
eef4efc
updated README.md
andreacastello Jan 17, 2025
12eb97c
updated README.md title
andreacastello Jan 17, 2025
da8fd51
some README.md wording improvements
andreacastello Jan 17, 2025
c0dd077
used markdown table for config params.
andreacastello Jan 17, 2025
39bf6d7
added maintainer email address
andreacastello Jan 17, 2025
3aff037
modified sample request data
andreacastello Jan 17, 2025
eedc3e0
fixed typos
andreacastello Jan 17, 2025
cac7b71
Merge pull request #1 from WURFL/module-wurfl-devicedetection
andreacastello Jan 17, 2025
0e93e64
improved wording
andreacastello Jan 17, 2025
89cb0dd
improved published specific enrichment paragraph
andreacastello Jan 17, 2025
7a55ba2
better doc formatting
andreacastello Jan 17, 2025
9d95efd
Merged upstream master branch to local master
andreacastello Feb 21, 2025
93f3182
Updated WURFL API version, uncommented module add into modules pom. M…
andreacastello Feb 24, 2025
96d91e4
Added WURFL API mock classes
andreacastello Feb 25, 2025
9b8b10e
checkstyle compliance
andreacastello Feb 25, 2025
1bd2865
Updated README. More checkstyle compliance
andreacastello Feb 25, 2025
cee250a
Removed commented dependency
andreacastello Feb 27, 2025
59fe1a6
Improved WURFL module README.md
andreacastello Mar 3, 2025
c0fe0db
Merge pull request #2 from WURFL/module-wurfl-devicedetection
andreacastello Mar 3, 2025
a4fcd1f
potential mock issue fix
andreacastello Mar 3, 2025
958f7c1
Merge pull request #3 from WURFL/module-wurfl-devicedetection
andreacastello Mar 4, 2025
f5bf2e3
WURFL module: improved README
andreacastello Mar 6, 2025
57d2378
WURFL module README: better wording
andreacastello Mar 6, 2025
93cbf8c
WURFL module README: more doc improvement
andreacastello Mar 6, 2025
ffe67fa
PREB-39: simplified call to virtual capabilities API
andreacastello Mar 6, 2025
6af13df
Merge pull request #4 from WURFL/PREB-39
andreacastello Mar 6, 2025
7cf5ccd
Merge branch 'prebid:master' into master
andreacastello Mar 10, 2025
1cbb9b6
Updated WURFL module version to 3.23.0-SNAPSHOT
andreacastello Mar 10, 2025
b846032
Added a WURFL API mock dependency from a public repo. Updated README …
andreacastello Mar 12, 2025
bc21beb
More README update
andreacastello Mar 12, 2025
1215903
Merge pull request #6 from WURFL/wurfl-module-with-mock-from-repo
andreacastello Mar 12, 2025
0850daa
Used WURFL lowecase in module names
andreacastello Mar 12, 2025
e559a6f
removed unused log
andreacastello Mar 12, 2025
8d712ef
handled exception in virtual capability retrieval
andreacastello Mar 12, 2025
4155848
removed print stacktrace used for debug
andreacastello Mar 13, 2025
b596b5f
Merge pull request #7 from WURFL/wurfl-module-with-mock-from-repo
andreacastello Mar 13, 2025
2034a74
Merge branch 'prebid:master' into master
andreacastello Apr 7, 2025
b5466cb
PREB-41: used FileSyncer and FileProcessor to update WURFL file and e…
andreacastello Apr 7, 2025
2c12d92
PREB-41: removed logs
andreacastello Apr 7, 2025
de636c5
PREB-41: added comment
andreacastello Apr 7, 2025
b4b9c88
Merge pull request #9 from WURFL/PREB-41-new
andreacastello Apr 7, 2025
467216f
Item 3, 4, 6, 7, 8 or review: code formatting and move, removal of un…
andreacastello Apr 11, 2025
79fffc7
Items 12, 13 of PR review: remove final modifier in method parameters…
andreacastello Apr 11, 2025
c95afa9
Item 1,2 of Pr review: moved module configuration, removed internal y…
andreacastello Apr 11, 2025
e3f4fa0
Merge pull request #10 from WURFL/PR-3685-review-pass-01-config-move
andreacastello Apr 11, 2025
1320e19
Item 5 of Pr review: removed wurfl prefix from config properties vari…
andreacastello Apr 11, 2025
00c7f20
checkstyle fixes
andreacastello Apr 11, 2025
90af0a7
Item 10 of Pr review: used internal filesyncer backup to rollback WUR…
andreacastello Apr 15, 2025
3c7e544
Item 11 of PR review: removed hardcoded file names in filesyncer
andreacastello Apr 15, 2025
ca17447
Item 10, 11 of PR review: made update process configurable, fixed iss…
andreacastello Apr 17, 2025
a2395b0
Improved check on updater frequency setting
andreacastello Apr 18, 2025
c5c27f7
Updated documentation
andreacastello Apr 18, 2025
67320fb
Merge pull request #11 from WURFL/PR-3685-review-pass-01
andreacastello Apr 18, 2025
d24eaa5
Merge branch 'prebid:master' into master
andreacastello Apr 29, 2025
66435b7
Aligned version after latest PBS release. Some checkstyle fixes on ne…
andreacastello Apr 29, 2025
ac8ae16
Merge branch 'prebid:master' into master
andreacastello May 22, 2025
9d91879
Merge branch 'prebid:master' into master
andreacastello Jun 5, 2025
81895d6
Merge branch 'prebid:master' into master
andreacastello Jun 11, 2025
dae9659
Updated version number in WURFL module
andreacastello Jun 11, 2025
3109b57
Item 1 of review pass 2
andreacastello Jun 11, 2025
b0c9c0d
Item 2 of review pass 2
andreacastello Jun 11, 2025
b4087d3
Used @Value lombok annotation in place of @Getter in AuctionRequestHe…
andreacastello Jun 12, 2025
8760b20
Refactored static and virtual capability retrieval in ExtWURFLMapper …
andreacastello Jun 12, 2025
e8661d5
Removed constant that's not used anymore
andreacastello Jun 12, 2025
9cd9fc3
Simplified ext device mapping: Replaced Map with Set in OrtbDeviceUpd…
andreacastello Jun 12, 2025
422bea9
Removed PlatformNameVersion class (just a wrapper on BrandVersion class)
andreacastello Jun 12, 2025
f027eeb
Removed AccountValidator class, moved its single method to hook class…
andreacastello Jun 13, 2025
90fb9b8
Merge branch 'prebid:master' into PR-3685-pass-2
andreacastello Jun 13, 2025
75b4b3f
Bumped version to 3.28
andreacastello Jun 13, 2025
fb8fc7b
made a method protected
andreacastello Jun 13, 2025
f2e15f3
Merge branch 'prebid:master' into master
andreacastello Jun 13, 2025
bfdd5df
made a createFileSyncer private
andreacastello Jun 13, 2025
f8131d8
made a createFileSyncer private
andreacastello Jun 13, 2025
b22b93c
made a createFileSyncer private
andreacastello Jun 13, 2025
7bdbbfc
Merge branch 'master' into PR-3685-pass-2
andreacastello Jun 13, 2025
1b43e5b
Merge pull request #13 from WURFL/PR-3685-pass-2
andreacastello Jun 13, 2025
01c2ea9
Removed usage of the annotation @Slf4j
andreacastello Jun 24, 2025
9f28869
Removed usage of annotation @Slf4j in favor of classic log instantiat…
andreacastello Jun 25, 2025
81cc02c
Moved Sec-CH-* header names to HttpUtil class. Removed empty lines af…
andreacastello Jun 25, 2025
083d2d4
Renamed WURFLModuleConfigurationException to WURFLDeviceDetectionExce…
andreacastello Jun 25, 2025
4152085
Used objectMapperProvider to create mapper. Used HttpUtil in HeadersR…
andreacastello Jun 25, 2025
2e5de58
Refactored resolve method to avoid "escape" usage
andreacastello Jun 25, 2025
389db27
removed residual empty lines under method declarations
andreacastello Jun 25, 2025
8b287b5
Merge pull request #14 from WURFL/PR-3685-pass-2
andreacastello Jun 25, 2025
367f136
Merge branch 'prebid:master' into master
andreacastello Jul 17, 2025
1fe287c
Updated version number in WURFL module
andreacastello Jul 17, 2025
3638545
made HeadersResolver a static utility class. Code formatting. Items 1…
andreacastello Jul 17, 2025
93dceeb
Used Set for allowedPublisherIDs. Item 17 of PR 3685 review pass 3
andreacastello Jul 17, 2025
30016f2
Refactoring of device update process and auction request hook
andreacastello Jul 17, 2025
36372d6
Merge pull request #15 from WURFL/PR-3685-pass-3
andreacastello Jul 18, 2025
9a1f2aa
More refactoring of device update process for exception handling
andreacastello Jul 21, 2025
abb8c92
Merge pull request #16 from WURFL/PR-3685-pass-4
andreacastello Jul 21, 2025
96b22ee
Made all test classes and methods public
andreacastello Jul 21, 2025
2cf4486
Unit tests revision
andreacastello Jul 22, 2025
f75eb8a
Merge pull request #17 from WURFL/PR-3685-pass-4
andreacastello Jul 22, 2025
7297dcd
Unit tests revision - part 2
andreacastello Jul 23, 2025
66f1f86
Code cleanup
andreacastello Jul 24, 2025
60c0ad8
OOH device type handling
andreacastello Jul 24, 2025
de5027a
reverted return in getWurflDeviceType
andreacastello Jul 24, 2025
ab13bd9
Merge pull request #18 from WURFL/deviceType-dooh-handling
andreacastello Jul 24, 2025
c181745
Merge branch 'prebid:master' into master
andreacastello Jul 24, 2025
213b823
Minor doc update
andreacastello Jul 24, 2025
0d284cb
Minor doc update - 2
andreacastello Jul 24, 2025
a6c70cf
Merge branch 'master' into wurfl-device-detection-conflicts-merge
andreacastello Aug 1, 2025
42eae26
Updated WURFL module version to 3.30.0-snapshot
andreacastello Aug 1, 2025
e3015a9
Fixed merge issue
andreacastello Aug 1, 2025
0224d8e
Merge branch 'prebid:master' into wurfl-device-detection-conflicts-merge
andreacastello Aug 1, 2025
1429026
Merge branch 'prebid:master' into master
andreacastello Aug 6, 2025
2c6d8fc
Merge branch 'prebid:master' into PREB-48
andreacastello Aug 6, 2025
d087e17
PREB-48: initial implementation of check for already enriched Device.…
andreacastello Aug 6, 2025
569e01e
PREB-48: added unit tests
andreacastello Aug 6, 2025
114c43b
PREB-48: removed unused code
andreacastello Aug 6, 2025
05ae935
Merge branch 'prebid:master' into master
andreacastello Sep 2, 2025
5f0849c
Merge branch 'master' into PREB-48
andreacastello Sep 2, 2025
a14c580
PREB-50: initial fix for getDeviceType issue
andreacastello Sep 3, 2025
3f917b4
PREB-50: implementation of form-factor based getDeviceType alg
andreacastello Sep 4, 2025
b41d20b
PREB-50: removed mock expectation in tests for capabilities that are …
andreacastello Sep 4, 2025
7a9a169
PREB-50: added hwm value to Device object
andreacastello Sep 4, 2025
2a78230
Merge pull request #20 from WURFL/PREB-50
andreacastello Sep 5, 2025
4c151a6
Merge branch 'prebid:master' into master
andreacastello Sep 5, 2025
e42e23a
Merge branch 'master' into PREB-48
andreacastello Sep 5, 2025
b295ac3
Added sample config for prefiles-dir
andreacastello Sep 5, 2025
6dae3c1
modified some warn.log messages to avoid dumping too many sstacktraces
andreacastello Sep 5, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public AuctionRequestPayload apply(AuctionRequestPayload auctionRequestPayload)
private Device update(Device ortbDevice) {
final String make = tryUpdateField(ortbDevice.getMake(), this::getWurflMake);
final String model = tryUpdateField(ortbDevice.getModel(), this::getWurflModel);
final String hwv = tryUpdateField(ortbDevice.getHwv(), this::getWurflModel);
final Integer deviceType = tryUpdateField(
Optional.ofNullable(ortbDevice.getDevicetype())
.filter(it -> it > 0)
Expand All @@ -72,6 +73,7 @@ private Device update(Device ortbDevice) {
.make(make)
.model(model)
.devicetype(deviceType)
.hwv(hwv)
.os(os)
.osv(osv)
.h(h)
Expand Down Expand Up @@ -103,49 +105,73 @@ private String getWurflModel() {
}

private Integer getWurflDeviceType() {
try {
if (wurflDevice.getVirtualCapabilityAsBool("is_mobile")) {
// if at least one of these capabilities is not defined, the mobile device type is undefined
final boolean isPhone = wurflDevice.getVirtualCapabilityAsBool("is_phone");
final boolean isTablet = wurflDevice.getCapabilityAsBool("is_tablet");
return isPhone || isTablet ? 1 : 6;
}

if (wurflDevice.getVirtualCapabilityAsBool("is_full_desktop")) {
return 2;
}
if (getWurflIsOtt()) {
return 7;
}

if (wurflDevice.getCapabilityAsBool("is_connected_tv")) {
return 3;
}
final Boolean isConsole = getWurflIsConsole();
if (isConsole) {
return 6;
}

if (wurflDevice.getCapabilityAsBool("is_phone")) {
return 4;
}
if ("out_of_home_device".equals(getWurflPhysicalFormFactor())) {
return 8;
}

if (wurflDevice.getCapabilityAsBool("is_tablet")) {
return 5;
}
final String formFactor = getWurflFormFactor();
return switch (formFactor) {
case "Desktop" -> 2;
case "Smartphone", "Feature Phone" -> 4;
case "Tablet" -> 5;
case "Smart-TV" -> 3;
case "Other Non-Mobile" -> 6;
case "Other Mobile" -> 1;
default -> null;
};
}

if (wurflDevice.getCapabilityAsBool("is_ott")) {
return 7;
}
private Boolean getWurflIsOtt() {
try {
return wurflDevice.getCapabilityAsBool("is_ott");
} catch (CapabilityNotDefinedException e) {
logger.warn("Failed to get is_ott from WURFL device capabilities");
return Boolean.FALSE;
}
}

final String physicalFormFactor = wurflDevice.getCapability("physical_form_factor");
if (physicalFormFactor != null && physicalFormFactor.equals("out_of_home_device")) {
return 8;
}
} catch (CapabilityNotDefinedException | VirtualCapabilityNotDefinedException | NumberFormatException e) {
logger.warn("Failed to determine device type from WURFL device capabilities", e);
private String getWurflFormFactor() {
try {
return wurflDevice.getVirtualCapability("form_factor");
} catch (VirtualCapabilityNotDefinedException e) {
logger.warn("Failed to get form_factor from WURFL device capabilities");
return "";
}
}

private String getWurflPhysicalFormFactor() {
try {
return wurflDevice.getCapability("physical_form_factor");
} catch (CapabilityNotDefinedException e) {
logger.warn("Failed to get physical_form_factor from WURFL device capabilities");
return "";
}
}

private Boolean getWurflIsConsole() {
try {
return wurflDevice.getCapabilityAsBool("is_console");
} catch (CapabilityNotDefinedException e) {
logger.warn("Failed to get is_console from WURFL device capabilities");
return Boolean.FALSE;
}
return null;
}

private String getWurflOs() {
try {
return wurflDevice.getVirtualCapability("advertised_device_os");
} catch (VirtualCapabilityNotDefinedException e) {
logger.warn("Failed to evaluate advertised device OS", e);
logger.warn("Failed to evaluate advertised device OS");
return null;
}
}
Expand All @@ -154,7 +180,7 @@ private String getWurflOsv() {
try {
return wurflDevice.getVirtualCapability("advertised_device_os_version");
} catch (VirtualCapabilityNotDefinedException e) {
logger.warn("Failed to evaluate advertised device OS version", e);
logger.warn("Failed to evaluate advertised device OS version");
}
return null;
}
Expand All @@ -163,7 +189,7 @@ private Integer getWurflH() {
try {
return wurflDevice.getCapabilityAsInt("resolution_height");
} catch (NumberFormatException e) {
logger.warn("Failed to get resolution height from WURFL device capabilities", e);
logger.warn("Failed to get resolution height from WURFL device capabilities");
return null;
}
}
Expand All @@ -172,7 +198,7 @@ private Integer getWurflW() {
try {
return wurflDevice.getCapabilityAsInt("resolution_width");
} catch (NumberFormatException e) {
logger.warn("Failed to get resolution width from WURFL device capabilities", e);
logger.warn("Failed to get resolution width from WURFL device capabilities");
return null;
}
}
Expand All @@ -181,7 +207,7 @@ private Integer getWurflPpi() {
try {
return wurflDevice.getVirtualCapabilityAsInt("pixel_density");
} catch (VirtualCapabilityNotDefinedException e) {
logger.warn("Failed to get pixel density from WURFL device capabilities", e);
logger.warn("Failed to get pixel density from WURFL device capabilities");
return null;
}
}
Expand All @@ -193,7 +219,7 @@ private BigDecimal getWurflPxRatio() {
? new BigDecimal(densityAsString)
: null;
} catch (CapabilityNotDefinedException | NumberFormatException e) {
logger.warn("Failed to get pixel ratio from WURFL device capabilities", e);
logger.warn("Failed to get pixel ratio from WURFL device capabilities");
return null;
}
}
Expand All @@ -202,7 +228,7 @@ private Integer getWurflJs() {
try {
return wurflDevice.getCapabilityAsBool("ajax_support_javascript") ? 1 : 0;
} catch (CapabilityNotDefinedException | NumberFormatException e) {
logger.warn("Failed to get JS support from WURFL device capabilities", e);
logger.warn("Failed to get JS support from WURFL device capabilities");
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.prebid.server.hooks.modules.com.scientiamobile.wurfl.devicedetection.v1;

import com.iab.openrtb.request.Device;
import org.prebid.server.proto.openrtb.ext.request.ExtDevice;
import com.iab.openrtb.request.BidRequest;
import org.prebid.server.log.Logger;
import org.prebid.server.log.LoggerFactory;
Expand Down Expand Up @@ -31,6 +32,7 @@ public class WURFLDeviceDetectionRawAuctionRequestHook implements RawAuctionRequ
private static final Logger logger = LoggerFactory.getLogger(WURFLDeviceDetectionRawAuctionRequestHook.class);

public static final String CODE = "wurfl-devicedetection-raw-auction-request";
private static final String WURFL_PROPERTY = "wurfl";

private final WURFLService wurflService;
private final Set<String> allowedPublisherIDs;
Expand Down Expand Up @@ -62,6 +64,11 @@ public Future<InvocationResult<AuctionRequestPayload>> call(AuctionRequestPayloa
return noActionResult();
}

if (isDeviceAlreadyEnriched(device)) {
logger.info("Device is already enriched, returning original bid request");
return noActionResult();
}

final Map<String, String> requestHeaders =
invocationContext.moduleContext() instanceof AuctionRequestHeadersContext moduleContext
? moduleContext.getHeaders()
Expand All @@ -87,6 +94,18 @@ public Future<InvocationResult<AuctionRequestPayload>> call(AuctionRequestPayloa
.build());
}

private boolean isDeviceAlreadyEnriched(Device device) {
final ExtDevice extDevice = device.getExt();
if (extDevice != null && extDevice.containsProperty(WURFL_PROPERTY)) {
return true;
}

// Check if other some of the other Device data are already set
final Integer deviceType = device.getDevicetype();
final String hwv = device.getHwv();
return deviceType != null && deviceType > 0 && StringUtils.isNotEmpty(hwv);
}

private boolean shouldEnrichDevice(AuctionInvocationContext invocationContext) {
return CollectionUtils.isEmpty(allowedPublisherIDs) || isAccountValid(invocationContext.auctionContext());
}
Expand Down
Loading
Loading