FIX: Limit requests and include data when reporting deprecated icons

- Only report each icon to the server once, to avoid hitting rate limits
- Correct typo in ajax `data` parameter

Follow-up to db7d00a8dc
This commit is contained in:
David Taylor 2019-12-19 22:11:45 +00:00
parent fdea0a0838
commit 7737ecd0fe

View File

@ -580,21 +580,25 @@ function warnIfMissing(id) {
}
}
const reportedIcons = [];
function warnIfDeprecated(oldId, newId) {
deprecated(
`Please replace all occurrences of "${oldId}"" with "${newId}". FontAwesome 4.7 icon names are now deprecated and will be removed in the next release.`
);
if (!Discourse.testing) {
if (!Discourse.testing && !reportedIcons.includes(oldId)) {
const errorData = {
message: `FA icon deprecation: replace "${oldId}"" with "${newId}".`,
stacktrace: Error().stack
};
Ember.$.ajax(`${Discourse.BaseUri}/logs/report_js_error`, {
errorData,
data: errorData,
type: "POST",
cache: false
});
reportedIcons.push(oldId);
}
}