* Compares list of experiments, fires error if an experiment is registered without telemetry entry.
(mainImplList, userMetricsList)
| 206 | * Compares list of experiments, fires error if an experiment is registered without telemetry entry. |
| 207 | */ |
| 208 | function compareExperimentLists(mainImplList, userMetricsList) { |
| 209 | // Ensure both lists are valid |
| 210 | let errorFound = false; |
| 211 | if (!mainImplList) { |
| 212 | console.log( |
| 213 | 'Changes to Devtools Experiment registration have prevented this check from finding registered experiments.', |
| 214 | ); |
| 215 | console.log( |
| 216 | 'Please update scripts/check_experiments.js to account for the new experiment registration.', |
| 217 | ); |
| 218 | errorFound = true; |
| 219 | } |
| 220 | if (!userMetricsList) { |
| 221 | console.log( |
| 222 | 'Changes to Devtools Experiment UserMetrics enum have prevented this check from finding experiments registered for telemetry.', |
| 223 | ); |
| 224 | console.log( |
| 225 | 'Please update scripts/check_experiments.js to account for the new experiment telemetry format.', |
| 226 | ); |
| 227 | errorFound = true; |
| 228 | } |
| 229 | if (errorFound) { |
| 230 | process.exit(1); |
| 231 | } |
| 232 | |
| 233 | // Ensure both lists match |
| 234 | const missingTelemetry = mainImplList.filter( |
| 235 | experiment => !userMetricsList.includes(experiment), |
| 236 | ); |
| 237 | const staleTelemetry = userMetricsList.filter( |
| 238 | experiment => !mainImplList.includes(experiment), |
| 239 | ); |
| 240 | if (missingTelemetry.length) { |
| 241 | console.log( |
| 242 | 'Devtools Experiments have been added without corresponding histogram update!', |
| 243 | ); |
| 244 | console.log(missingTelemetry.join('\n')); |
| 245 | console.log( |
| 246 | 'Please ensure that the DevtoolsExperiments enum in UserMetrics.ts is updated with the new experiment.', |
| 247 | ); |
| 248 | console.log( |
| 249 | 'Please ensure that a corresponding CL is opened against chromium.src/tools/metrics/histograms/metadata/dev/enums.xml to update the DevtoolsExperiments enum', |
| 250 | ); |
| 251 | errorFound = true; |
| 252 | } |
| 253 | if (staleTelemetry.length) { |
| 254 | console.log( |
| 255 | 'Devtools Experiments that are no longer registered are still listed in the telemetry enum!', |
| 256 | ); |
| 257 | console.log(staleTelemetry.join('\n')); |
| 258 | console.log( |
| 259 | 'Please ensure that the DevtoolsExperiments enum in UserMetrics.ts is updated to remove these stale experiments.', |
| 260 | ); |
| 261 | errorFound = true; |
| 262 | } |
| 263 | if (errorFound) { |
| 264 | process.exit(1); |
| 265 | } |