mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #30001 from overleaf/mj-workbench-consent-screen
[web] Add consent screen to workbench GitOrigin-RevId: 7640154e9c02d340eb9c782e276a84cd961ad755
This commit is contained in:
committed by
Copybot
parent
c4d02f4571
commit
0c07e5ff40
@@ -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',
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user