diff --git a/services/web/app/src/Features/Tutorial/TutorialController.mjs b/services/web/app/src/Features/Tutorial/TutorialController.mjs index 41c1cbb983..d7c1f49f9f 100644 --- a/services/web/app/src/Features/Tutorial/TutorialController.mjs +++ b/services/web/app/src/Features/Tutorial/TutorialController.mjs @@ -8,6 +8,7 @@ const VALID_KEYS = [ 'writefull-oauth-promotion', 'bib-file-tpr-prompt', 'ai-error-assistant-consent', + 'workbench-consent', 'history-restore-promo', 'us-gov-banner', 'us-gov-banner-fedramp', diff --git a/services/web/frontend/js/shared/hooks/promotions/use-tutorial.tsx b/services/web/frontend/js/shared/hooks/promotions/use-tutorial.tsx index b74a3ca736..7974584c5b 100644 --- a/services/web/frontend/js/shared/hooks/promotions/use-tutorial.tsx +++ b/services/web/frontend/js/shared/hooks/promotions/use-tutorial.tsx @@ -4,6 +4,17 @@ import { postJSON } from '@/infrastructure/fetch-json' import { debugConsole } from '@/utils/debugging' import { useEditorContext } from '@/shared/context/editor-context' +type CompleteTutorialParams = { + event: string + action: 'complete' | 'postpone' +} & Record + +type CompleteTutorialOptions = { + // Whether to ignore errors if the request fails. Defaults to true. If + // successfull completion is required, set this to false. + failSilently?: boolean +} + const useTutorial = ( tutorialKey: string, eventData: Record = {} @@ -14,18 +25,22 @@ const useTutorial = ( useEditorContext() const completeTutorial = useCallback( - async ({ - event = 'promo-click', - action = 'complete', - ...rest - }: { - event: string - action: 'complete' | 'postpone' - } & Record) => { + async ( + { + event = 'promo-click', + action = 'complete', + ...rest + }: CompleteTutorialParams, + options: CompleteTutorialOptions = {} + ) => { eventTracking.sendMB(event, { ...eventData, ...rest }) try { await postJSON(`/tutorial/${tutorialKey}/${action}`) } catch (err) { + const failSilently = options.failSilently ?? true + if (!failSilently) { + throw err + } debugConsole.error(err) } setShowPopup(false)