diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 774ba5c0be..1c8f73d242 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -601,14 +601,16 @@ const _ProjectController = { !Features.hasFeature('saas') || (user.features && user.features.symbolPalette) + const userInNonIndividualSub = + userIsMemberOfGroupSubscription || userHasInstitutionLicence + // Persistent upgrade prompts // in header & in share project modal const showUpgradePrompt = Features.hasFeature('saas') && userId && !subscription && - !userIsMemberOfGroupSubscription && - !userHasInstitutionLicence + !userInNonIndividualSub let aiFeaturesAllowed = false if (userId && Features.hasFeature('saas')) { @@ -639,25 +641,42 @@ const _ProjectController = { } // check if a user has never tried writefull before (writefull.enabled will be null) - // if they previously accepted writefull. user.writefull will be true, + // if they previously accepted writefull, or are have been already assigned to a trial, user.writefull will be true, // if they explicitly disabled it, user.writefull will be false - if (aiFeaturesAllowed && user.writefull?.enabled === null) { - // since we are auto-enrolling users into writefull if they are part of the group, we only want to - // auto enroll (set writefull to true) if its the first time they have entered the test - // this ensures that they can still turn writefull off (otherwise, we would be setting writefull on every time they access their projects) - const { variant, metadata } = - await SplitTestHandler.promises.getAssignment( + if ( + aiFeaturesAllowed && + user.writefull?.enabled === null && + !userInNonIndividualSub + ) { + const { variant } = await SplitTestHandler.promises.getAssignment( + req, + res, + 'writefull-auto-account-creation' + ) + + if (variant === 'enabled') { + await UserUpdater.promises.updateUser(userId, { + $set: { + writefull: { enabled: true, autoCreatedAccount: true }, + }, + }) + user.writefull.enabled = true + user.writefull.autoCreatedAccount = true + } else { + const { variant } = await SplitTestHandler.promises.getAssignment( req, res, 'writefull-auto-load' ) - if (variant === 'enabled' && metadata?.isFirstNonDefaultAssignment) { - await UserUpdater.promises.updateUser(userId, { - $set: { - writefull: { enabled: true }, - }, - }) - user.writefull.enabled = true + if (variant === 'enabled') { + await UserUpdater.promises.updateUser(userId, { + $set: { + writefull: { enabled: true }, + }, + }) + user.writefull.enabled = true + user.writefull.firstAutoLoad = true + } } } @@ -690,6 +709,8 @@ const _ProjectController = { refProviders: _.mapValues(user.refProviders, Boolean), writefull: { enabled: Boolean(user.writefull?.enabled && aiFeaturesAllowed), + autoCreatedAccount: Boolean(user.writefull?.autoCreatedAccount), + firstAutoLoad: Boolean(user.writefull?.firstAutoLoad), }, alphaProgram: user.alphaProgram, betaProgram: user.betaProgram, diff --git a/services/web/app/src/models/User.js b/services/web/app/src/models/User.js index 9f2a147602..13a480a5ee 100644 --- a/services/web/app/src/models/User.js +++ b/services/web/app/src/models/User.js @@ -190,6 +190,7 @@ const UserSchema = new Schema( }, writefull: { enabled: { type: Boolean, default: null }, + autoCreatedAccount: { type: Boolean, default: false }, }, alphaProgram: { type: Boolean, default: false }, // experimental features betaProgram: { type: Boolean, default: false }, diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 71df6cabc9..ba407863b5 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -1637,7 +1637,6 @@ "try_recompile_project_or_troubleshoot": "", "try_relinking_provider": "", "try_to_compile_despite_errors": "", - "try_writefull": "", "turn_off": "", "turn_off_link_sharing": "", "turn_on": "", @@ -1777,15 +1776,9 @@ "work_offline": "", "work_with_non_overleaf_users": "", "writefull": "", - "writefull_alternate_login_prompt": "", - "writefull_disable_prompt_body": "", "writefull_learn_more": "", "writefull_loading_error_body": "", "writefull_loading_error_title": "", - "writefull_prompt_body": "", - "writefull_prompt_terms": "", - "writefull_prompt_terms_title": "", - "writefull_prompt_title": "", "writefull_settings_description": "", "x_changes_in": "", "x_changes_in_plural": "", diff --git a/services/web/frontend/js/shared/context/editor-context.tsx b/services/web/frontend/js/shared/context/editor-context.tsx index 4303bf6853..4b4e701f3e 100644 --- a/services/web/frontend/js/shared/context/editor-context.tsx +++ b/services/web/frontend/js/shared/context/editor-context.tsx @@ -20,8 +20,6 @@ import { saveProjectSettings } from '@/features/editor-left-menu/utils/api' import { PermissionsLevel } from '@/features/ide-react/types/permissions' import { useModalsContext } from '@/features/ide-react/context/modals-context' -type writefullAdButtons = '' | 'try-it' | 'log-in' - export const EditorContext = createContext< | { cobranding?: { @@ -50,8 +48,6 @@ export const EditorContext = createContext< inactiveTutorials: string[] currentPopup: string | null setCurrentPopup: Dispatch> - writefullAdClicked: writefullAdButtons - setWritefullAdClicked: Dispatch> setOutOfSync: (value: boolean) => void } | undefined @@ -94,9 +90,6 @@ export const EditorProvider: FC = ({ children }) => { () => getMeta('ol-inactiveTutorials') || [] ) - const [writefullAdClicked, setWritefullAdClicked] = - useState('') - const [currentPopup, setCurrentPopup] = useState(null) const isPendingEditor = useMemo( @@ -189,8 +182,6 @@ export const EditorProvider: FC = ({ children }) => { deactivateTutorial, currentPopup, setCurrentPopup, - writefullAdClicked, - setWritefullAdClicked, setOutOfSync, }), [ @@ -210,8 +201,6 @@ export const EditorProvider: FC = ({ children }) => { deactivateTutorial, currentPopup, setCurrentPopup, - writefullAdClicked, - setWritefullAdClicked, outOfSync, setOutOfSync, ] diff --git a/services/web/locales/en.json b/services/web/locales/en.json index 9e756f970f..ec6aad20c2 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -2251,7 +2251,6 @@ "try_recompile_project_or_troubleshoot": "Please try recompiling the project from scratch, and if that doesn’t help, follow our <0>troubleshooting guide.", "try_relinking_provider": "It looks like you need to re-link your __provider__ account.", "try_to_compile_despite_errors": "Try to compile despite errors", - "try_writefull": "Try Writefull", "turn_off": "Turn off", "turn_off_link_sharing": "Turn off link sharing", "turn_on": "Turn on", @@ -2425,15 +2424,9 @@ "would_you_like_to_see_a_university_subscription": "Would you like to see a university-wide __appName__ subscription at your university?", "write_and_collaborate_faster_with_features_like": "Write and collaborate faster with features like:", "writefull": "Writefull", - "writefull_alternate_login_prompt": "If you have a Writefull account, <0>log in to get started. If you don’t have a Writefull account, we’ll create one for you. By enabling Writefull, you accept Writefull’s <1>terms of service and <2>privacy policy.", - "writefull_disable_prompt_body": "Writefull is enabled. You can switch it on or off in the account settings anytime.", "writefull_learn_more": "Learn more about Writefull for Overleaf", "writefull_loading_error_body": "Try refreshing the page. If this doesn’t work, try disabling any active browser extensions to check they aren’t blocking Writefull from loading.", "writefull_loading_error_title": "Writefull didn’t load correctly", - "writefull_prompt_body": "Get Writefull’s research-tailored, AI-powered language feedback and LaTeX help directly in Overleaf.", - "writefull_prompt_terms": "When you click <0>Try Writefull, your email address and Overleaf user ID will be shared with Writefull. This will either link your Overleaf and Writefull accounts (if you have both with the same email address) or it’ll create a new Writefull account for you.<1> When enabled, Writefull has access to the content of any project you open, so you can get AI language feedback and suggestions. Read more about <2>Writefull for Overleaf.", - "writefull_prompt_terms_title": "What data is shared with Writefull?", - "writefull_prompt_title": "Accelerate your writing process with AI", "writefull_settings_description": "Get free AI-based language feedback specifically tailored for research writing with Writefull for Overleaf.", "x_changes_in": "__count__ change in", "x_changes_in_plural": "__count__ changes in", diff --git a/services/web/types/user.ts b/services/web/types/user.ts index a940014314..1ecd6cdb2e 100644 --- a/services/web/types/user.ts +++ b/services/web/types/user.ts @@ -41,6 +41,8 @@ export type User = { refProviders?: RefProviders writefull?: { enabled: boolean + autoCreatedAccount: boolean + firstAutoLoad: boolean } }