FIX: Limit requests and include data when reporting deprecated icons

FIX: Limit requests and include data when reporting deprecated icons

diff --git a/app/assets/javascripts/discourse-common/lib/icon-library.js.es6 b/app/assets/javascripts/discourse-common/lib/icon-library.js.es6
index a4ebfd938f..46c3e72a6a 100644
--- a/app/assets/javascripts/discourse-common/lib/icon-library.js.es6
+++ b/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);
   }
 }

GitHub sha: 7737ecd0

2 Likes

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