Skip to content

Commit f9d6dc8

Browse files
author
softcoder594
committed
New module: optable-targeting
1 parent 8dbce72 commit f9d6dc8

73 files changed

Lines changed: 4777 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

extra/bundle/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
<artifactId>pb-request-correction</artifactId>
5656
<version>${project.version}</version>
5757
</dependency>
58+
<dependency>
59+
<groupId>org.prebid.server.hooks.modules</groupId>
60+
<artifactId>optable-targeting</artifactId>
61+
<version>${project.version}</version>
62+
</dependency>
5863
</dependencies>
5964

6065
<build>

extra/modules/optable-targeting/README.md

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lombok.anyConstructor.addConstructorProperties = true
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.prebid.server.hooks.modules</groupId>
7+
<artifactId>all-modules</artifactId>
8+
<version>3.22.0-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>optable-targeting</artifactId>
12+
13+
<name>optable-targeting</name>
14+
<description>Optable targeting module</description>
15+
16+
<properties>
17+
18+
<!-- plugin versions -->
19+
<checkstyle-plugin.version>3.4.0</checkstyle-plugin.version>
20+
<checkstyle.version>10.17.0</checkstyle.version>
21+
</properties>
22+
23+
<build>
24+
<pluginManagement>
25+
<plugins>
26+
<plugin>
27+
<groupId>org.apache.maven.plugins</groupId>
28+
<artifactId>maven-checkstyle-plugin</artifactId>
29+
<version>${checkstyle-plugin.version}</version>
30+
<configuration>
31+
<!-- Project rooted path to CheckStyle configuration file. -->
32+
<configLocation>../checkstyle.xml</configLocation>
33+
<encoding>UTF-8</encoding>
34+
<consoleOutput>true</consoleOutput>
35+
<!-- true if project build should fails on any style violation. -->
36+
<failsOnError>true</failsOnError>
37+
<linkXRef>false</linkXRef>
38+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
39+
</configuration>
40+
<dependencies>
41+
<dependency>
42+
<groupId>com.puppycrawl.tools</groupId>
43+
<artifactId>checkstyle</artifactId>
44+
<version>${checkstyle.version}</version>
45+
</dependency>
46+
</dependencies>
47+
</plugin>
48+
</plugins>
49+
</pluginManagement>
50+
<plugins>
51+
<plugin>
52+
<groupId>org.apache.maven.plugins</groupId>
53+
<artifactId>maven-checkstyle-plugin</artifactId>
54+
<executions>
55+
<execution>
56+
<phase>validate</phase>
57+
<goals>
58+
<goal>checkstyle</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
</plugin>
63+
</plugins>
64+
</build>
65+
66+
<dependencies>
67+
<dependency>
68+
<groupId>com.fasterxml.jackson.dataformat</groupId>
69+
<artifactId>jackson-dataformat-xml</artifactId>
70+
</dependency>
71+
<dependency>
72+
<groupId>com.puppycrawl.tools</groupId>
73+
<artifactId>checkstyle</artifactId>
74+
<version>${checkstyle.version}</version>
75+
</dependency>
76+
</dependencies>
77+
</project>
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
{
2+
"test": 1,
3+
"id": "1",
4+
"imp":
5+
[
6+
{
7+
"id": "1",
8+
"banner":
9+
{
10+
"w": 300,
11+
"h": 250
12+
},
13+
"ext":
14+
{
15+
"prebid":
16+
{
17+
"storedauctionresponse": { "id": "optable-stored-response" },
18+
"bidder":
19+
{
20+
"appnexus":
21+
{
22+
"placementId": 0
23+
}
24+
}
25+
}
26+
}
27+
}
28+
],
29+
"site":
30+
{
31+
"domain": "test.com",
32+
"publisher":
33+
{
34+
"domain": "test.com",
35+
"id": "1"
36+
},
37+
"page": "https://www.test.com/"
38+
},
39+
"device":
40+
{
41+
"ip": "8.8.8.8"
42+
},
43+
"user":
44+
{
45+
"ext":
46+
{
47+
"optable":
48+
{
49+
"email": "fd911bd8cac2e603a80efafca2210b7a917c97410f0c29d9f2bfb99867e5a589"
50+
},
51+
"eids":
52+
[
53+
{
54+
"source": "growthcode.io",
55+
"uids":
56+
[
57+
{
58+
"id": "fb58593e-7ac6-48bd-b2de-89a758726362",
59+
"atype": 1
60+
}
61+
]
62+
},
63+
{
64+
"source": "pubcid.org",
65+
"uids": [
66+
{
67+
"id": "f9528392fd38786082c7fd01cd2aa5a60d2c3a2788789b1f9de4574a7c9dabae",
68+
"atype": 1
69+
}
70+
]
71+
},
72+
{
73+
"source": "crwdcntrl.net",
74+
"uids":
75+
[
76+
{
77+
"id": "dd1b31e65f5e45548c11a0275ba3a8072c00e3a2a0493e8f5a8f54f8067e8b00",
78+
"atype": 1
79+
}
80+
]
81+
},
82+
{
83+
"source": "id5-sync.com",
84+
"uids":
85+
[
86+
{
87+
"id": "ID5*dd1b31e65f5e45548c11a0275ba3a8072c00e3a2a0493e8f5a8f54f8067e8b00",
88+
"atype": 1
89+
}
90+
]
91+
},
92+
{
93+
"source": "amxdt.net",
94+
"uids":
95+
[
96+
{
97+
"id": "amx*3*a583802a-e6fe-48d7-87c6-7db1b6a4a73a*70f06cdcf8ab0b4ac07a56860ed0e0b6ef0388dc0b0ab5a1dd725999d3b339cf",
98+
"atype": 1
99+
}
100+
]
101+
},
102+
{
103+
"source": "audigent.com",
104+
"uids":
105+
[
106+
{
107+
"id": "f84456cd3c72296d7898f62e1c46dd964206ff4d47e64b690c3c5a1d6b1bd286",
108+
"atype": 1
109+
}
110+
]
111+
},
112+
{
113+
"source": "adnxs.com",
114+
"uids":
115+
[
116+
{
117+
"id": "d4fd63f0f4f7ce0d128348cb145c7e0f"
118+
}
119+
]
120+
}
121+
]
122+
}
123+
},
124+
"ext": {
125+
"prebid": {
126+
"targeting": {
127+
"includebidderkeys": true
128+
},
129+
"analytics":
130+
{
131+
"options": {
132+
"enableclientdetails": true
133+
}
134+
}
135+
}
136+
}
137+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
package org.prebid.server.hooks.modules.optable.targeting.config;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import io.vertx.core.Vertx;
5+
import org.prebid.server.hooks.modules.optable.targeting.model.config.OptableTargetingProperties;
6+
import org.prebid.server.hooks.modules.optable.targeting.v1.core.AuctionResponseValidator;
7+
import org.prebid.server.hooks.modules.optable.targeting.v1.net.OptableHttpClientWrapper;
8+
import org.prebid.server.hooks.modules.optable.targeting.v1.OptableTargetingAuctionResponseHook;
9+
import org.prebid.server.hooks.modules.optable.targeting.v1.OptableTargetingModule;
10+
import org.prebid.server.hooks.modules.optable.targeting.v1.OptableTargetingProcessedAuctionRequestHook;
11+
import org.prebid.server.hooks.modules.optable.targeting.v1.analytics.AnalyticTagsResolver;
12+
import org.prebid.server.hooks.modules.optable.targeting.v1.core.IdsMapper;
13+
import org.prebid.server.hooks.modules.optable.targeting.v1.core.IpResolver;
14+
import org.prebid.server.hooks.modules.optable.targeting.v1.core.OptableTargeting;
15+
import org.prebid.server.hooks.modules.optable.targeting.v1.core.PayloadResolver;
16+
import org.prebid.server.hooks.modules.optable.targeting.v1.core.OptableAttributesResolver;
17+
import org.prebid.server.hooks.modules.optable.targeting.v1.core.QueryBuilder;
18+
import org.prebid.server.hooks.modules.optable.targeting.v1.net.APIClient;
19+
import org.prebid.server.hooks.modules.optable.targeting.v1.net.OptableResponseParser;
20+
import org.prebid.server.json.JacksonMapper;
21+
import org.prebid.server.spring.config.VertxContextScope;
22+
import org.prebid.server.spring.config.model.HttpClientProperties;
23+
import org.prebid.server.util.HttpUtil;
24+
import org.springframework.beans.factory.annotation.Value;
25+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
26+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
27+
import org.springframework.context.annotation.Bean;
28+
import org.springframework.context.annotation.Configuration;
29+
import org.springframework.context.annotation.Scope;
30+
import org.springframework.context.annotation.ScopedProxyMode;
31+
32+
import java.util.List;
33+
import java.util.Objects;
34+
35+
@ConditionalOnProperty(prefix = "hooks." + OptableTargetingModule.CODE, name = "enabled", havingValue = "true")
36+
@Configuration
37+
@EnableConfigurationProperties(OptableTargetingProperties.class)
38+
public class OptableTargetingConfig {
39+
40+
@Bean
41+
ObjectMapper objectMapper() {
42+
return new ObjectMapper();
43+
}
44+
45+
@Bean
46+
AnalyticTagsResolver analyticTagsResolver(ObjectMapper objectMapper) {
47+
return new AnalyticTagsResolver(objectMapper);
48+
}
49+
50+
@Bean
51+
IdsMapper queryParametersExtractor(OptableTargetingProperties properties, ObjectMapper objectMapper) {
52+
return new IdsMapper(objectMapper, properties.getPpidMapping());
53+
}
54+
55+
@Bean
56+
PayloadResolver payloadResolver(ObjectMapper mapper) {
57+
return new PayloadResolver(mapper);
58+
}
59+
60+
@Bean
61+
QueryBuilder queryBuilder(OptableTargetingProperties properties) {
62+
return new QueryBuilder(properties.getIdPrefixOrder());
63+
}
64+
65+
@Bean
66+
OptableResponseParser optableResponseParser(JacksonMapper mapper) {
67+
return new OptableResponseParser(mapper);
68+
}
69+
70+
@Bean
71+
@Scope(scopeName = VertxContextScope.NAME, proxyMode = ScopedProxyMode.TARGET_CLASS)
72+
@ConditionalOnProperty(prefix = "http-client.circuit-breaker", name = "enabled", havingValue = "false",
73+
matchIfMissing = true)
74+
OptableHttpClientWrapper optableHttpClient(Vertx vertx, HttpClientProperties httpClientProperties) {
75+
return new OptableHttpClientWrapper(vertx, httpClientProperties);
76+
}
77+
78+
@Bean
79+
APIClient apiClient(OptableHttpClientWrapper httpClientWrapper,
80+
@Value("${logging.sampling-rate:0.01}")
81+
double logSamplingRate,
82+
OptableTargetingProperties properties,
83+
OptableResponseParser responseParser) {
84+
85+
final String endpoint = HttpUtil.validateUrl(Objects.requireNonNull(properties.getApiEndpoint()));
86+
87+
return new APIClient(endpoint, httpClientWrapper.getHttpClient(), logSamplingRate, responseParser,
88+
properties.getApiKey());
89+
}
90+
91+
@Bean
92+
OptableAttributesResolver optableAttributesResolver(IpResolver ipResolver) {
93+
return new OptableAttributesResolver(ipResolver);
94+
}
95+
96+
@Bean()
97+
OptableTargeting optableTargeting(IdsMapper parametersExtractor,
98+
QueryBuilder queryBuilder, APIClient apiClient) {
99+
100+
return new OptableTargeting(parametersExtractor, queryBuilder, apiClient);
101+
}
102+
103+
@Bean
104+
IpResolver ipResolver() {
105+
return new IpResolver();
106+
}
107+
108+
@Bean
109+
AuctionResponseValidator auctionResponseValidator() {
110+
return new AuctionResponseValidator();
111+
}
112+
113+
@Bean
114+
OptableTargetingModule optableTargetingModule(OptableTargetingProperties properties,
115+
AnalyticTagsResolver analyticTagsResolver,
116+
OptableTargeting optableTargeting,
117+
PayloadResolver payloadResolver,
118+
OptableAttributesResolver optableAttributesResolver,
119+
AuctionResponseValidator auctionResponseValidator) {
120+
121+
return new OptableTargetingModule(List.of(
122+
new OptableTargetingProcessedAuctionRequestHook(properties, optableTargeting, payloadResolver,
123+
optableAttributesResolver),
124+
new OptableTargetingAuctionResponseHook(analyticTagsResolver, payloadResolver,
125+
properties.getAdserverTargeting(), auctionResponseValidator)));
126+
}
127+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.prebid.server.hooks.modules.optable.targeting.model;
2+
3+
import lombok.Builder;
4+
5+
@Builder(toBuilder = true)
6+
public record EnrichmentStatus(Status status, Reason reason) {
7+
8+
public static EnrichmentStatus fail() {
9+
return EnrichmentStatus.builder().status(Status.FAIL).build();
10+
}
11+
12+
public static EnrichmentStatus success() {
13+
return EnrichmentStatus.builder().status(Status.SUCCESS).build();
14+
}
15+
}

0 commit comments

Comments
 (0)