diff --git a/apps/builder/components/settings/GeneralSettingsForm.tsx b/apps/builder/components/settings/GeneralSettingsForm.tsx
index 46db50d3aa0..918041423d0 100644
--- a/apps/builder/components/settings/GeneralSettingsForm.tsx
+++ b/apps/builder/components/settings/GeneralSettingsForm.tsx
@@ -47,6 +47,12 @@ export const GeneralSettingsForm = ({
isInputPrefillEnabled,
})
+ const handleHideQueryParamsChange = (isHideQueryParamsEnabled: boolean) =>
+ onGeneralSettingsChange({
+ ...generalSettings,
+ isHideQueryParamsEnabled,
+ })
+
return (
@@ -78,6 +84,13 @@ export const GeneralSettingsForm = ({
initialValue={generalSettings.isNewResultOnRefreshEnabled ?? false}
onCheckChange={handleNewResultOnRefreshChange}
/>
+
)
}
diff --git a/apps/viewer/layouts/TypebotPage.tsx b/apps/viewer/layouts/TypebotPage.tsx
index 123a39472e3..e496693c7a6 100644
--- a/apps/viewer/layouts/TypebotPage.tsx
+++ b/apps/viewer/layouts/TypebotPage.tsx
@@ -53,7 +53,11 @@ export const TypebotPage = ({
const clearQueryParams = () => {
const hasQueryParams = asPath.includes('?')
- if (hasQueryParams) push(asPath.split('?')[0], undefined, { shallow: true })
+ if (
+ hasQueryParams &&
+ typebot.settings.general.isHideQueryParamsEnabled !== false
+ )
+ push(asPath.split('?')[0], undefined, { shallow: true })
}
const initializeResult = async () => {
diff --git a/apps/viewer/playwright/services/database.ts b/apps/viewer/playwright/services/database.ts
index f0c4b61db09..14f088d3d6f 100644
--- a/apps/viewer/playwright/services/database.ts
+++ b/apps/viewer/playwright/services/database.ts
@@ -74,6 +74,19 @@ export const createTypebots = async (partialTypebots: Partial[]) => {
})
}
+export const updateTypebot = async (
+ partialTypebot: Partial & { id: string }
+) => {
+ await prisma.typebot.updateMany({
+ where: { id: partialTypebot.id },
+ data: partialTypebot,
+ })
+ return prisma.publicTypebot.updateMany({
+ where: { typebotId: partialTypebot.id },
+ data: partialTypebot,
+ })
+}
+
const parseTypebotToPublicTypebot = (
id: string,
typebot: Typebot
diff --git a/apps/viewer/playwright/tests/settings.spec.ts b/apps/viewer/playwright/tests/settings.spec.ts
index c9dce76f7d7..62e884b55a7 100644
--- a/apps/viewer/playwright/tests/settings.spec.ts
+++ b/apps/viewer/playwright/tests/settings.spec.ts
@@ -1,5 +1,9 @@
import test, { expect } from '@playwright/test'
-import { createTypebots, parseDefaultBlockWithStep } from '../services/database'
+import {
+ createTypebots,
+ parseDefaultBlockWithStep,
+ updateTypebot,
+} from '../services/database'
import cuid from 'cuid'
import { defaultSettings, defaultTextInputOptions, InputStepType } from 'models'
@@ -71,3 +75,31 @@ test.describe('Create result on page refresh enabled', () => {
expect(resultId).toBe(null)
})
})
+
+test('Hide query params', async ({ page }) => {
+ const typebotId = cuid()
+ await createTypebots([
+ {
+ id: typebotId,
+ ...parseDefaultBlockWithStep({
+ type: InputStepType.TEXT,
+ options: defaultTextInputOptions,
+ }),
+ },
+ ])
+ await page.goto(`/${typebotId}-public?Name=John`)
+ await page.waitForTimeout(1000)
+ expect(page.url()).toEqual(`http://localhost:3001/${typebotId}-public`)
+ await updateTypebot({
+ id: typebotId,
+ settings: {
+ ...defaultSettings,
+ general: { ...defaultSettings.general, isHideQueryParamsEnabled: false },
+ },
+ })
+ await page.goto(`/${typebotId}-public?Name=John`)
+ await page.waitForTimeout(1000)
+ expect(page.url()).toEqual(
+ `http://localhost:3001/${typebotId}-public?Name=John`
+ )
+})
diff --git a/packages/models/src/typebot/settings.ts b/packages/models/src/typebot/settings.ts
index cedf33946a6..ebb3ec8e860 100644
--- a/packages/models/src/typebot/settings.ts
+++ b/packages/models/src/typebot/settings.ts
@@ -8,6 +8,7 @@ export type GeneralSettings = {
isBrandingEnabled: boolean
isNewResultOnRefreshEnabled?: boolean
isInputPrefillEnabled?: boolean
+ isHideQueryParamsEnabled?: boolean
}
export type TypingEmulation = {
@@ -29,6 +30,7 @@ export const defaultSettings: Settings = {
isBrandingEnabled: true,
isNewResultOnRefreshEnabled: false,
isInputPrefillEnabled: true,
+ isHideQueryParamsEnabled: true,
},
typingEmulation: { enabled: true, speed: 300, maxDelay: 1.5 },
metadata: {