Skip to content

Commit

Permalink
Add new request type names and fix NPE for setuid and cookiesync (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
DGarbar committed Nov 3, 2020
1 parent 03bd910 commit f5fce4c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public Future<PrivacyContext> contextFromSetuidRequest(
final String ipAddress = HttpUtil.ipFrom(httpRequest);
final AccountGdprConfig accountGdpr = account.getGdpr();
final String accountId = account.getId();
final RequestLogInfo requestLogInfo = requestLogInfo(null, null, accountId);
final RequestLogInfo requestLogInfo = requestLogInfo(MetricName.setuid, null, accountId);

return tcfDefinerService.resolveTcfContext(privacy, ipAddress, accountGdpr, requestLogInfo, timeout)
.map(tcfContext -> PrivacyContext.of(privacy, tcfContext));
Expand All @@ -144,7 +144,7 @@ public Future<PrivacyContext> contextFromCookieSyncRequest(
final String ipAddress = HttpUtil.ipFrom(httpRequest);
final AccountGdprConfig accountGdpr = account.getGdpr();
final String accountId = account.getId();
final RequestLogInfo requestLogInfo = requestLogInfo(null, null, accountId);
final RequestLogInfo requestLogInfo = requestLogInfo(MetricName.cookiesync, null, accountId);

return tcfDefinerService.resolveTcfContext(privacy, ipAddress, accountGdpr, requestLogInfo, timeout)
.map(tcfContext -> PrivacyContext.of(privacy, tcfContext));
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/prebid/server/metric/MetricName.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public enum MetricName {
amp,
video,
legacy,
cookiesync,
setuid,


// request and adapter statuses
ok,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ private TCString decodeTcString(String consentString, RequestLogInfo requestLogI
}

private static void logWarn(String consent, String message, RequestLogInfo requestLogInfo) {
if (requestLogInfo == null) {
if (requestLogInfo == null || requestLogInfo.getRequestType() == null) {
final String exceptionMessage = String.format("Parsing consent string:\"%s\" failed for undefined type "
+ "with exception %s", consent, message);
UNDEFINED_CORRUPT_CONSENT_LOGGER.info(exceptionMessage, 100);
Expand All @@ -436,6 +436,8 @@ private static void logWarn(String consent, String message, RequestLogInfo reque
logMessage(consent, MetricName.legacy.toString(), requestLogInfo, message), 100);
break;
case video:
case cookiesync:
case setuid:
default:
UNDEFINED_CORRUPT_CONSENT_LOGGER.info(
logMessage(consent, "video or sync or setuid", requestLogInfo, message), 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void contextFromSetuidRequestShouldReturnContext() {
final Privacy privacy = Privacy.of("1", "consent", Ccpa.EMPTY, 0);
FutureAssertion.assertThat(privacyContext).succeededWith(PrivacyContext.of(privacy, tcfContext));

final RequestLogInfo expectedRequestLogInfo = RequestLogInfo.of(null, null, accountId);
final RequestLogInfo expectedRequestLogInfo = RequestLogInfo.of(MetricName.setuid, null, accountId);
verify(tcfDefinerService)
.resolveTcfContext(eq(privacy), eq("ip"), isNull(), eq(expectedRequestLogInfo), isNull());
}
Expand Down Expand Up @@ -317,7 +317,7 @@ public void contextFromCookieSyncRequestShouldReturnContext() {
final Privacy privacy = Privacy.of("1", "consent", Ccpa.of("1YYY"), 0);
FutureAssertion.assertThat(privacyContext).succeededWith(PrivacyContext.of(privacy, tcfContext));

final RequestLogInfo expectedRequestLogInfo = RequestLogInfo.of(null, null, accountId);
final RequestLogInfo expectedRequestLogInfo = RequestLogInfo.of(MetricName.cookiesync, null, accountId);
verify(tcfDefinerService)
.resolveTcfContext(eq(privacy), eq("ip"), isNull(), eq(expectedRequestLogInfo), isNull());
}
Expand Down

0 comments on commit f5fce4c

Please sign in to comment.