Skip to content
Permalink
Browse files

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 db7d00a
  • Loading branch information
davidtaylorhq committed Dec 19, 2019
1 parent fdea0a0 commit 7737ecd0fed808a1c0e429565058c817af99d707
Showing with 6 additions and 2 deletions.
  1. +6 −2 app/assets/javascripts/discourse-common/lib/icon-library.js.es6
@@ -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);
}
}

1 comment on commit 7737ecd

@discoursebot

This comment has been minimized.

Copy link

@discoursebot discoursebot commented on 7737ecd Mar 26, 2020

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/icon-deprecation-warnings-causing-rate-limiting-issues/145586/5

Please sign in to comment.
You can’t perform that action at this time.