Explorar o código

toggling on wf feature sync endpoint since we know the request load now (#30014)

GitOrigin-RevId: d7f9944caffdcb5cf42693cac7d2895026b38775
Jimmy Domagala-Tang hai 10 meses
pai
achega
ea5de4984f
Modificáronse 1 ficheiros con 15 adicións e 17 borrados
  1. 15 17
      services/web/app/src/Features/Subscription/FeaturesUpdater.mjs

+ 15 - 17
services/web/app/src/Features/Subscription/FeaturesUpdater.mjs

@@ -16,8 +16,7 @@ import AnalyticsManager from '../Analytics/AnalyticsManager.mjs'
 import Queues from '../../infrastructure/Queues.mjs'
 import Queues from '../../infrastructure/Queues.mjs'
 import Modules from '../../infrastructure/Modules.mjs'
 import Modules from '../../infrastructure/Modules.mjs'
 import { AI_ADD_ON_CODE } from './AiHelper.mjs'
 import { AI_ADD_ON_CODE } from './AiHelper.mjs'
-// import { fetchNothing } from '@overleaf/fetch-utils'
-import metrics from '@overleaf/metrics'
+import { fetchNothing } from '@overleaf/fetch-utils'
 
 
 /**
 /**
  * Enqueue a job for refreshing features for the given user
  * Enqueue a job for refreshing features for the given user
@@ -78,22 +77,21 @@ async function refreshFeatures(userId, reason) {
   if (featuresChanged && reason !== 'writefullEntitlementSynced') {
   if (featuresChanged && reason !== 'writefullEntitlementSynced') {
     try {
     try {
       // update WF with the current feature set for the user
       // update WF with the current feature set for the user
-      // await fetchNothing(
-      //   `${Settings.writefull.overleafApiUrl}/api/user/status/update-overleaf-status`,
-      //   {
-      //     headers: {
-      //       'x-api-key': Settings.writefull.overleafApiKey,
-      //     },
-      //     json: {
-      //       userOverleafId: userId,
-      //       hasAiAssist: newFeatures.aiErrorAssistant,
-      //     },
-      //     method: 'POST',
-      //   }
-      // )
-      // increment a metric instead of calling WF so we cna give them an idea of the # of requests they will recieve
-      metrics.inc('feature_sync_called_to_wf')
+      await fetchNothing(
+        `${Settings.writefull.overleafApiUrl}/api/user/status/update-overleaf-status`,
+        {
+          headers: {
+            'x-api-key': Settings.writefull.overleafApiKey,
+          },
+          json: {
+            userOverleafId: userId,
+            hasAiAssist: newFeatures.aiErrorAssistant,
+          },
+          method: 'POST',
+        }
+      )
     } catch (err) {
     } catch (err) {
+      // continue with sync even if we cant communicate with wf
       logger.warn(
       logger.warn(
         { userId, reason },
         { userId, reason },
         'failed to sync entitlement to Writefull after a feature refresh'
         'failed to sync entitlement to Writefull after a feature refresh'