Skip to content

Commit

Permalink
[DENG-7762] Drop user-characteristics ping from Firefox Android (#2727)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWu authored Jan 30, 2025
1 parent 9c415ed commit 26d6282
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ public static void scrub(Map<String, String> attributes, ObjectNode json)
}
}

if (deng7762Affected(namespace, docType)) {
throw new MessageShouldBeDroppedException("deng7762");
}

// Check for unwanted data; these messages aren't thrown out, but this class of errors will be
// ignored for most pipeline monitoring.
if (IGNORED_NAMESPACES.containsKey(namespace)) {
Expand Down Expand Up @@ -504,6 +508,14 @@ private static void processForBug1751753(ObjectNode json) {
});
}

// See https://mozilla-hub.atlassian.net/browse/DENG-7762
private static boolean deng7762Affected(String namespace, String docType) {
return ("org-mozilla-fenix".equals(namespace) //
|| "org-mozilla-firefox-beta".equals(namespace) //
|| "org-mozilla-firefox".equals(namespace)) //
&& "user-characteristics".equals(docType);
}

private static void sanitizeDesktopSearchKeys(ObjectNode searchNode, Pattern pattern) {
Lists.newArrayList(searchNode.fieldNames()).forEach(name -> {
Matcher match = pattern.matcher(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,4 +773,31 @@ public void testScrubValidDocument() {
.build();
MessageScrubber.scrub(attributes, Json.createObjectNode());
}

@Test
public void testDropDeng7762() {
final ImmutableMap.Builder<String, String> attributeBuilder = ImmutableMap
.<String, String>builder().put(Attribute.DOCUMENT_TYPE, "user-characteristics")
.put(Attribute.X_TELEMETRY_AGENT, "Glean");

assertThrows(MessageShouldBeDroppedException.class,
() -> MessageScrubber.scrub(
attributeBuilder.put(Attribute.DOCUMENT_NAMESPACE, "org-mozilla-fenix").build(),
Json.createObjectNode()));
assertThrows(MessageShouldBeDroppedException.class,
() -> MessageScrubber.scrub(attributeBuilder
.put(Attribute.DOCUMENT_NAMESPACE, "org-mozilla-firefox").buildKeepingLast(),
Json.createObjectNode()));
assertThrows(MessageShouldBeDroppedException.class,
() -> MessageScrubber.scrub(attributeBuilder
.put(Attribute.DOCUMENT_NAMESPACE, "org-mozilla-firefox-beta").buildKeepingLast(),
Json.createObjectNode()));

// valid documents
MessageScrubber.scrub(
attributeBuilder.put(Attribute.DOCUMENT_NAMESPACE, "firefox-desktop").buildKeepingLast(),
Json.createObjectNode());
MessageScrubber.scrub(ImmutableMap.of(Attribute.DOCUMENT_NAMESPACE, "org-mozilla-firefox",
Attribute.DOCUMENT_TYPE, "metrics"), Json.createObjectNode());
}
}

0 comments on commit 26d6282

Please sign in to comment.