Allow removal of entries from UMA enums

`recordEnumeratedHistogram()` needs both the actual bucket and the total
number of buckets. The total number of buckets was previously determined
by `Object.keys(someMap).length`. This prevented us from ever removing
keys from `someMap` since its length would change.
By explicitly adding a `LastValidEnumPosition` we can now safely remove
keys.

Bug: 1278403
Change-Id: Ib256fc2cf54123f596aa9c5525cce2aabe28bec0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3329541
Reviewed-by: Simon Zünd <szuend@chromium.org>
Commit-Queue: Wolfgang Beyer <wolfi@chromium.org>
diff --git a/scripts/check_experiments.js b/scripts/check_experiments.js
index 28c82ea..7ae635b 100644
--- a/scripts/check_experiments.js
+++ b/scripts/check_experiments.js
@@ -15,7 +15,7 @@
   range: true,
 };
 
-const USER_METRICS_ENUM_ENDPOINT = '__lastValidEnumPosition';
+const USER_METRICS_ENUM_ENDPOINT = 'MaxValue';
 
 /**
  * Determines if a node is a class declaration.
@@ -162,8 +162,7 @@
  * Determines if AST Node is the DevtoolsExperiments Enum declaration
  */
 function isExperimentEnumDeclaration(node) {
-  return node.type === 'ExportNamedDeclaration' && node.declaration.declarations &&
-      node.declaration.declarations[0].id.name === 'DevtoolsExperiments';
+  return node.type === 'ExportNamedDeclaration' && node?.declaration?.id?.name === 'DevtoolsExperiments';
 }
 
 /**
@@ -173,9 +172,7 @@
   const userMetricsAST = espree.parse(userMetricsFile, {ecmaVersion: 11, sourceType: 'module', range: true});
   for (const node of userMetricsAST.body) {
     if (isExperimentEnumDeclaration(node)) {
-      return node.declaration.declarations[0].init.properties.map(property => {
-        return property.key.value;
-      });
+      return node.declaration.members.map(member => member.id.value);
     }
   }
   return null;