Bladeren bron

Merge pull request #34318 from overleaf/dp-labs-custom-success-notification

Add customisable success notification for Labs experiment enrollment

GitOrigin-RevId: 7d60ea3bac124909b19f8f537e1ab2b6db8d787e
David 2 maanden geleden
bovenliggende
commit
a16274409e

+ 5 - 0
services/web/app/src/Features/SplitTests/SplitTestHandler.mjs

@@ -836,6 +836,11 @@ async function _loadSplitTestInfoInLocals(locals, splitTestName, session) {
         description: splitTest.labsDescription || '',
         icon: splitTest.labsIcon || '',
         surveyLink: splitTest.badgeInfo?.labs?.url || '',
+        successNotification: {
+          content: splitTest.labsSuccessNotification?.content || '',
+          buttonLabel: splitTest.labsSuccessNotification?.buttonLabel || '',
+          buttonUrl: splitTest.labsSuccessNotification?.buttonUrl || '',
+        },
         isFull: SplitTestUtils.isExperimentFull(variant),
         versionCreatedAt:
           currentVersion.createdAt instanceof Date

+ 2 - 0
services/web/app/src/Features/SplitTests/SplitTestManager.mjs

@@ -131,6 +131,7 @@ async function createSplitTest(
     labsTitle: labsInfo.title,
     labsDescription: labsInfo.description,
     labsIcon: labsInfo.icon,
+    labsSuccessNotification: labsInfo.successNotification,
     versions: [
       {
         versionNumber: 1,
@@ -205,6 +206,7 @@ async function updateSplitTestInfo(name, info, labsInfo) {
     splitTest.labsTitle = labsInfo.title
     splitTest.labsDescription = labsInfo.description
     splitTest.labsIcon = labsInfo.icon
+    splitTest.labsSuccessNotification = labsInfo.successNotification
   }
   return _saveSplitTest(splitTest)
 }

+ 22 - 0
services/web/app/src/models/SplitTest.mjs

@@ -40,6 +40,24 @@ const BadgeInfoSchema = new Schema(
   { _id: false }
 )
 
+const LabsSuccessNotificationSchema = new Schema(
+  {
+    content: {
+      type: String,
+      required: false,
+    },
+    buttonLabel: {
+      type: String,
+      required: false,
+    },
+    buttonUrl: {
+      type: String,
+      required: false,
+    },
+  },
+  { _id: false }
+)
+
 const VariantSchema = new Schema(
   {
     name: {
@@ -187,6 +205,10 @@ export const SplitTestSchema = new Schema(
       type: String,
       required: false,
     },
+    labsSuccessNotification: {
+      type: LabsSuccessNotificationSchema,
+      required: false,
+    },
   },
   { minimize: false }
 )

+ 5 - 0
services/web/types/split-test.ts

@@ -22,4 +22,9 @@ export type LabsDetails = {
   description: string
   icon: string
   surveyLink: string
+  successNotification?: {
+    content?: string
+    buttonLabel?: string
+    buttonUrl?: string
+  }
 }