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

Add new request type names and fix NPE for setuid and cookiesync #992

Merged
merged 2 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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