Merge pull request #20983 from overleaf/jdt-wf-auto-account-create

Auto create Writefull accounts

GitOrigin-RevId: 2b03cd5bc1392c43d7682833d80f840b4da314f2
This commit is contained in:
Jimmy Domagala-Tang 2024-10-11 11:40:52 -04:00 committed by Copybot
parent 4920af44b0
commit e5ead5b42c
6 changed files with 40 additions and 41 deletions

View file

@ -601,14 +601,16 @@ const _ProjectController = {
!Features.hasFeature('saas') || !Features.hasFeature('saas') ||
(user.features && user.features.symbolPalette) (user.features && user.features.symbolPalette)
const userInNonIndividualSub =
userIsMemberOfGroupSubscription || userHasInstitutionLicence
// Persistent upgrade prompts // Persistent upgrade prompts
// in header & in share project modal // in header & in share project modal
const showUpgradePrompt = const showUpgradePrompt =
Features.hasFeature('saas') && Features.hasFeature('saas') &&
userId && userId &&
!subscription && !subscription &&
!userIsMemberOfGroupSubscription && !userInNonIndividualSub
!userHasInstitutionLicence
let aiFeaturesAllowed = false let aiFeaturesAllowed = false
if (userId && Features.hasFeature('saas')) { 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) // 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 they explicitly disabled it, user.writefull will be false
if (aiFeaturesAllowed && user.writefull?.enabled === null) { if (
// since we are auto-enrolling users into writefull if they are part of the group, we only want to aiFeaturesAllowed &&
// auto enroll (set writefull to true) if its the first time they have entered the test user.writefull?.enabled === null &&
// this ensures that they can still turn writefull off (otherwise, we would be setting writefull on every time they access their projects) !userInNonIndividualSub
const { variant, metadata } = ) {
await SplitTestHandler.promises.getAssignment( 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, req,
res, res,
'writefull-auto-load' 'writefull-auto-load'
) )
if (variant === 'enabled' && metadata?.isFirstNonDefaultAssignment) { if (variant === 'enabled') {
await UserUpdater.promises.updateUser(userId, { await UserUpdater.promises.updateUser(userId, {
$set: { $set: {
writefull: { enabled: true }, writefull: { enabled: true },
}, },
}) })
user.writefull.enabled = true user.writefull.enabled = true
user.writefull.firstAutoLoad = true
}
} }
} }
@ -690,6 +709,8 @@ const _ProjectController = {
refProviders: _.mapValues(user.refProviders, Boolean), refProviders: _.mapValues(user.refProviders, Boolean),
writefull: { writefull: {
enabled: Boolean(user.writefull?.enabled && aiFeaturesAllowed), enabled: Boolean(user.writefull?.enabled && aiFeaturesAllowed),
autoCreatedAccount: Boolean(user.writefull?.autoCreatedAccount),
firstAutoLoad: Boolean(user.writefull?.firstAutoLoad),
}, },
alphaProgram: user.alphaProgram, alphaProgram: user.alphaProgram,
betaProgram: user.betaProgram, betaProgram: user.betaProgram,

View file

@ -190,6 +190,7 @@ const UserSchema = new Schema(
}, },
writefull: { writefull: {
enabled: { type: Boolean, default: null }, enabled: { type: Boolean, default: null },
autoCreatedAccount: { type: Boolean, default: false },
}, },
alphaProgram: { type: Boolean, default: false }, // experimental features alphaProgram: { type: Boolean, default: false }, // experimental features
betaProgram: { type: Boolean, default: false }, betaProgram: { type: Boolean, default: false },

View file

@ -1637,7 +1637,6 @@
"try_recompile_project_or_troubleshoot": "", "try_recompile_project_or_troubleshoot": "",
"try_relinking_provider": "", "try_relinking_provider": "",
"try_to_compile_despite_errors": "", "try_to_compile_despite_errors": "",
"try_writefull": "",
"turn_off": "", "turn_off": "",
"turn_off_link_sharing": "", "turn_off_link_sharing": "",
"turn_on": "", "turn_on": "",
@ -1777,15 +1776,9 @@
"work_offline": "", "work_offline": "",
"work_with_non_overleaf_users": "", "work_with_non_overleaf_users": "",
"writefull": "", "writefull": "",
"writefull_alternate_login_prompt": "",
"writefull_disable_prompt_body": "",
"writefull_learn_more": "", "writefull_learn_more": "",
"writefull_loading_error_body": "", "writefull_loading_error_body": "",
"writefull_loading_error_title": "", "writefull_loading_error_title": "",
"writefull_prompt_body": "",
"writefull_prompt_terms": "",
"writefull_prompt_terms_title": "",
"writefull_prompt_title": "",
"writefull_settings_description": "", "writefull_settings_description": "",
"x_changes_in": "", "x_changes_in": "",
"x_changes_in_plural": "", "x_changes_in_plural": "",

View file

@ -20,8 +20,6 @@ import { saveProjectSettings } from '@/features/editor-left-menu/utils/api'
import { PermissionsLevel } from '@/features/ide-react/types/permissions' import { PermissionsLevel } from '@/features/ide-react/types/permissions'
import { useModalsContext } from '@/features/ide-react/context/modals-context' import { useModalsContext } from '@/features/ide-react/context/modals-context'
type writefullAdButtons = '' | 'try-it' | 'log-in'
export const EditorContext = createContext< export const EditorContext = createContext<
| { | {
cobranding?: { cobranding?: {
@ -50,8 +48,6 @@ export const EditorContext = createContext<
inactiveTutorials: string[] inactiveTutorials: string[]
currentPopup: string | null currentPopup: string | null
setCurrentPopup: Dispatch<SetStateAction<string | null>> setCurrentPopup: Dispatch<SetStateAction<string | null>>
writefullAdClicked: writefullAdButtons
setWritefullAdClicked: Dispatch<SetStateAction<writefullAdButtons>>
setOutOfSync: (value: boolean) => void setOutOfSync: (value: boolean) => void
} }
| undefined | undefined
@ -94,9 +90,6 @@ export const EditorProvider: FC = ({ children }) => {
() => getMeta('ol-inactiveTutorials') || [] () => getMeta('ol-inactiveTutorials') || []
) )
const [writefullAdClicked, setWritefullAdClicked] =
useState<writefullAdButtons>('')
const [currentPopup, setCurrentPopup] = useState<string | null>(null) const [currentPopup, setCurrentPopup] = useState<string | null>(null)
const isPendingEditor = useMemo( const isPendingEditor = useMemo(
@ -189,8 +182,6 @@ export const EditorProvider: FC = ({ children }) => {
deactivateTutorial, deactivateTutorial,
currentPopup, currentPopup,
setCurrentPopup, setCurrentPopup,
writefullAdClicked,
setWritefullAdClicked,
setOutOfSync, setOutOfSync,
}), }),
[ [
@ -210,8 +201,6 @@ export const EditorProvider: FC = ({ children }) => {
deactivateTutorial, deactivateTutorial,
currentPopup, currentPopup,
setCurrentPopup, setCurrentPopup,
writefullAdClicked,
setWritefullAdClicked,
outOfSync, outOfSync,
setOutOfSync, setOutOfSync,
] ]

View file

@ -2251,7 +2251,6 @@
"try_recompile_project_or_troubleshoot": "Please try recompiling the project from scratch, and if that doesnt help, follow our <0>troubleshooting guide</0>.", "try_recompile_project_or_troubleshoot": "Please try recompiling the project from scratch, and if that doesnt help, follow our <0>troubleshooting guide</0>.",
"try_relinking_provider": "It looks like you need to re-link your __provider__ account.", "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_to_compile_despite_errors": "Try to compile despite errors",
"try_writefull": "Try Writefull",
"turn_off": "Turn off", "turn_off": "Turn off",
"turn_off_link_sharing": "Turn off link sharing", "turn_off_link_sharing": "Turn off link sharing",
"turn_on": "Turn on", "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?", "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:", "write_and_collaborate_faster_with_features_like": "Write and collaborate faster with features like:",
"writefull": "Writefull", "writefull": "Writefull",
"writefull_alternate_login_prompt": "If you have a Writefull account, <0>log in</0> to get started. If you dont have a Writefull account, well create one for you. By enabling Writefull, you accept Writefulls <1>terms of service</1> and <2>privacy policy.</2>",
"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_learn_more": "Learn more about Writefull for Overleaf",
"writefull_loading_error_body": "Try refreshing the page. If this doesnt work, try disabling any active browser extensions to check they arent blocking Writefull from loading.", "writefull_loading_error_body": "Try refreshing the page. If this doesnt work, try disabling any active browser extensions to check they arent blocking Writefull from loading.",
"writefull_loading_error_title": "Writefull didnt load correctly", "writefull_loading_error_title": "Writefull didnt load correctly",
"writefull_prompt_body": "Get Writefulls research-tailored, AI-powered language feedback and LaTeX help directly in Overleaf.",
"writefull_prompt_terms": "When you click <0>Try Writefull</0>, 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 itll create a new Writefull account for you.<1></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.</2>",
"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.", "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": "__count__ change in",
"x_changes_in_plural": "__count__ changes in", "x_changes_in_plural": "__count__ changes in",

View file

@ -41,6 +41,8 @@ export type User = {
refProviders?: RefProviders refProviders?: RefProviders
writefull?: { writefull?: {
enabled: boolean enabled: boolean
autoCreatedAccount: boolean
firstAutoLoad: boolean
} }
} }