Merge pull request #30001 from overleaf/mj-workbench-consent-screen

[web] Add consent screen to workbench

GitOrigin-RevId: 7640154e9c02d340eb9c782e276a84cd961ad755
This commit is contained in:
Mathias Jakobsen
2025-12-03 12:17:40 +00:00
committed by Copybot
parent c4d02f4571
commit 0c07e5ff40
2 changed files with 24 additions and 8 deletions

View File

@@ -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',

View File

@@ -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<string, any>
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<string, any> = {}
@@ -14,18 +25,22 @@ const useTutorial = (
useEditorContext()
const completeTutorial = useCallback(
async ({
event = 'promo-click',
action = 'complete',
...rest
}: {
event: string
action: 'complete' | 'postpone'
} & Record<string, any>) => {
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)