Skip to content

Commit

Permalink
Bug 1496793 - Event telemetry should trim values if length > 80 chars…
Browse files Browse the repository at this point in the history
… r=jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D7989

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Michael Ratcliffe committed Oct 8, 2018
1 parent 5000a5e commit 1341efa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions devtools/client/shared/telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,17 +552,20 @@ class Telemetry {
if (extra) {
for (let [name, val] of Object.entries(extra)) {
val = val + "";
extra[name] = val;

if (val.length > 80) {
const sig = `${method},${object},${value}`;

throw new Error(`The property "${name}" was added to a telemetry ` +
`event with the signature ${sig} but it's value ` +
`"${val}" is longer than the maximum allowed length ` +
`of 80 characters\n` +
`CALLER: ${getCaller()}`);
dump(`Warning: The property "${name}" was added to a telemetry ` +
`event with the signature ${sig} but it's value "${val}" is ` +
`longer than the maximum allowed length of 80 characters.\n` +
`The property value has been trimmed to 80 characters before ` +
`sending.\nCALLER: ${getCaller()}`);

val = val.substring(0, 80);
}

extra[name] = val;
}
}
Services.telemetry.recordEvent(CATEGORY, method, object, value, extra);
Expand Down

0 comments on commit 1341efa

Please sign in to comment.