Bug 1448945 - Allow underscore in category, method and extra keys of event. r=chutten

According to the documnetation[1] category and method are identifiers,
thus an underscore is allowed. It's less clear for extra keys, but
underscores are already used there.

The documentation is adjusted accordingly.

[1]: https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/events.html#limits

MozReview-Commit-ID: 9pUsDNXCY8m

--HG--
extra : rebase_source : 5f3a3f1a9d8172cfb9695c17bd04e11836a65c93
This commit is contained in:
Jan-Erik Rediger 2018-04-10 13:05:39 +02:00
Родитель 8aee79fc46
Коммит 632d73d2a9
2 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -981,7 +981,7 @@ TelemetryEvent::RegisterEvents(const nsACString& aCategory,
MOZ_ASSERT(XRE_IsParentProcess(),
"Events can only be registered in the parent process");
if (!IsValidIdentifierString(aCategory, 30, true, false)) {
if (!IsValidIdentifierString(aCategory, 30, true, true)) {
JS_ReportErrorASCII(cx, "Category parameter should match the identifier pattern.");
return NS_ERROR_INVALID_ARG;
}
@ -1065,7 +1065,7 @@ TelemetryEvent::RegisterEvents(const nsACString& aCategory,
// Validate methods.
for (auto& method : methods) {
if (!IsValidIdentifierString(method, kMaxMethodNameByteLength, false, false)) {
if (!IsValidIdentifierString(method, kMaxMethodNameByteLength, false, true)) {
JS_ReportErrorASCII(cx, "Method names should match the identifier pattern.");
return NS_ERROR_INVALID_ARG;
}
@ -1085,7 +1085,7 @@ TelemetryEvent::RegisterEvents(const nsACString& aCategory,
return NS_ERROR_INVALID_ARG;
}
for (auto& key : extra_keys) {
if (!IsValidIdentifierString(key, kMaxExtraKeyNameByteLength, false, false)) {
if (!IsValidIdentifierString(key, kMaxExtraKeyNameByteLength, false, true)) {
JS_ReportErrorASCII(cx, "Extra key names should match the identifier pattern.");
return NS_ERROR_INVALID_ARG;
}

Просмотреть файл

@ -43,7 +43,7 @@ Where the individual fields are:
- ``method``: ``String``, identifier. This describes the type of event that occurred, e.g. ``click``, ``keydown`` or ``focus``.
- ``object``: ``String``, identifier. This is the object the event occurred on, e.g. ``reload_button`` or ``urlbar``.
- ``value``: ``String``, optional, may be ``null``. This is a user defined value, providing context for the event.
- ``extra``: ``Object``, optional, may be ``null``. This is an object of the form ``{"key": "value", ...}``, both keys and values need to be strings. This is used for events where additional richer context is needed.
- ``extra``: ``Object``, optional, may be ``null``. This is an object of the form ``{"key": "value", ...}``, both keys and values need to be strings, keys are identifiers. This is used for events where additional richer context is needed.
.. _eventlimits: