Skip to content

Commit 076a04d

Browse files
committed
add uid2_operator_raw_email_dot_total and record in all paths with raw emails
1 parent a8f0e75 commit 076a04d

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

src/main/java/com/uid2/operator/vertx/UIDOperatorVerticle.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ private void handleTokenValidateV2(RoutingContext rc) {
910910
recordTokenValidateStats(participantSiteId, "invalid_input");
911911
return;
912912
}
913+
recordRawEmailDotMetric(input, rc.request().path());
913914

914915
final Instant now = Instant.now();
915916
final String token = req.getString("token");
@@ -952,6 +953,7 @@ private void handleTokenGenerateV2(RoutingContext rc) {
952953

953954
final InputUtil.InputVal input = this.getTokenInputV2(req);
954955
if (isTokenInputValid(input, rc)) {
956+
recordRawEmailDotMetric(input, rc.request().path());
955957
final String apiContact = getApiContact(rc);
956958

957959
switch (validateUserConsent(req, apiContact)) {
@@ -1008,6 +1010,7 @@ private Future handleLogoutAsyncV2(RoutingContext rc) {
10081010
final InputUtil.InputVal input = getTokenInputV2(req);
10091011
final String uidTraceId = rc.request().getHeader(Audit.UID_TRACE_ID_HEADER);
10101012
if (input != null && input.isValid()) {
1013+
recordRawEmailDotMetric(input, rc.request().path());
10111014
final Instant now = Instant.now();
10121015

10131016
Promise promise = Promise.promise();
@@ -1232,6 +1235,12 @@ private void handleIdentityMapV2(RoutingContext rc) {
12321235

12331236
if (!validateServiceLink(rc)) { return; }
12341237

1238+
if (v2Input.diiType().equals("email")) {
1239+
for (InputUtil.InputVal input : v2Input.inputList()) {
1240+
recordRawEmailDotMetric(input, rc.request().path());
1241+
}
1242+
}
1243+
12351244
final JsonObject resp = processIdentityMapV2Response(rc, v2Input);
12361245
ResponseUtil.SuccessV2(rc, resp);
12371246
} catch (Exception e) {
@@ -1295,6 +1304,13 @@ private void handleIdentityMapV3(RoutingContext rc) {
12951304

12961305
if (!validateServiceLink(rc)) { return; }
12971306

1307+
InputUtil.InputVal[] emailInputs = normalizedInput.get("email");
1308+
if (emailInputs != null) {
1309+
for (InputUtil.InputVal emailInput : emailInputs) {
1310+
recordRawEmailDotMetric(emailInput, rc.request().path());
1311+
}
1312+
}
1313+
12981314
final JsonObject response = processIdentityMapV3Response(rc, normalizedInput);
12991315
ResponseUtil.SuccessV2(rc, response);
13001316
} catch (ClassCastException | JsonProcessingException processingException) {
@@ -1507,6 +1523,24 @@ public TokenVersion getRefreshTokenVersion(String s) {
15071523
return null;
15081524
}
15091525

1526+
private void recordRawEmailDotMetric(InputUtil.InputVal input, String path) {
1527+
if (!input.isValid() || input.getInputType() != InputUtil.IdentityInputType.Raw
1528+
|| input.getIdentityType() != IdentityType.Email) {
1529+
return;
1530+
}
1531+
String provided = input.getProvided();
1532+
int atIndex = provided.indexOf('@');
1533+
boolean hasDot = atIndex > 0 && provided.lastIndexOf('.', atIndex) >= 0;
1534+
boolean isGmail = input.getNormalized().endsWith("@gmail.com");
1535+
Counter.builder("uid2_operator_raw_email_dot_total")
1536+
.description("Count of valid raw emails processed, by presence of dot before @ and gmail domain")
1537+
.tag("path", path)
1538+
.tag("has_dot", String.valueOf(hasDot))
1539+
.tag("is_gmail", String.valueOf(isGmail))
1540+
.register(Metrics.globalRegistry)
1541+
.increment();
1542+
}
1543+
15101544
private void recordRefreshTokenVersionCount(String siteId, TokenVersion tokenVersion) {
15111545
Counter.builder("uid2_refresh_token_received_count_total")
15121546
.description(String.format("Counter for the amount of refresh token %s received", tokenVersion.toString().toLowerCase()))

0 commit comments

Comments
 (0)