Skip to content

Scheduling infrastructure for absolutely everyone.

feat: Enable new booker globally for 3.0 (#9541)

sean-brydonbf3f8acbc0b6
diff --git a/.env.example b/.env.example
index 4bfb15c3f9a..798c7744141 100644
--- a/.env.example
+++ b/.env.example
@@ -203,3 +203,9 @@ PROJECT_ID_VERCEL=
TEAM_ID_VERCEL=
# Get it from: https://vercel.com/account/tokens
AUTH_BEARER_TOKEN_VERCEL=
+
+#Enables New booker for Embed only
+NEW_BOOKER_ENABLED_FOR_EMBED=0
+
+#Enables New booker for All but Embed requests
+NEW_BOOKER_ENABLED_FOR_NON_EMBED=0
\ No newline at end of file
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts
index 283c15a5315..0570b436435 100644
--- a/apps/web/middleware.ts
+++ b/apps/web/middleware.ts
@@ -12,6 +12,21 @@ const middleware: NextMiddleware = async (req) => {
const url = req.nextUrl;
const requestHeaders = new Headers(req.headers);
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(req.headers.get("host") ?? "");
+ const isEmbedRequest = typeof url.searchParams.get("embed") === "string";
+
+ /**
+ * We are using env variable to toggle new-booker because using flags would be an unnecessary delay for booking pages
+ * Also, we can't easily identify the booker page requests here(to just fetch the flags for those requests)
+ */
+ // Enable New Booker for All but embed Requests
+ if (process.env.NEW_BOOKER_ENABLED_FOR_NON_EMBED === "1" && !isEmbedRequest) {
+ requestHeaders.set("new-booker-enabled", "1");
+ }
+
+ // Enable New Booker for Embed Requests
+ if (process.env.NEW_BOOKER_ENABLED_FOR_EMBED === "1" && isEmbedRequest) {
+ requestHeaders.set("new-booker-enabled", "1");
+ }
// Make sure we are in the presence of an organization
if (isValidOrgDomain && url.pathname === "/") {
diff --git a/apps/web/next.config.js b/apps/web/next.config.js
index ba1d14190f6..3ccc300bf34 100644
--- a/apps/web/next.config.js
+++ b/apps/web/next.config.js
@@ -223,6 +223,38 @@ const nextConfig = {
source: "/embed/embed.js",
destination: process.env.NEXT_PUBLIC_EMBED_LIB_URL?,
}, */
+ /**
+ * Header allows us to enable new-booker using middleware which uses env variables to enable/disable new booker
+ */
+ {
+ source: `/:user((?!${pages.join("|")}).*)/:type`,
+ destination: "/new-booker/:user/:type",
+ has: [{ type: "header", key: "new-booker-enabled" }],
+ },
+ {
+ source: `/:user((?!${pages.join("|")}).*)/:type/embed`,
+ destination: "/new-booker/:user/:type/embed",
+ has: [{ type: "header", key: "new-booker-enabled" }],
+ },
+ {
+ source: "/team/:slug/:type",
+ destination: "/new-booker/team/:slug/:type",
+ has: [{ type: "header", key: "new-booker-enabled" }],
+ },
+ {
+ source: "/team/:slug/:type/embed",
+ destination: "/new-booker/team/:slug/:type/embed",
+ has: [{ type: "header", key: "new-booker-enabled" }],
+ },
+ {
+ source: "/d/:link/:slug",
+ destination: "/new-booker/d/:link/:slug",
+ has: [{ type: "header", key: "new-booker-enabled" }],
+ },
+
+ /**
+ * Enables new booker using cookie. It works even if NEW_BOOKER_ENABLED_FOR_NON_EMBED, NEW_BOOKER_ENABLED_FOR_EMBED are disabled
+ */
{
source: `/:user((?!${pages.join("|")}).*)/:type`,
destination: "/new-booker/:user/:type",
diff --git a/turbo.json b/turbo.json
index 3230ff6534c..e8696b66c29 100644
--- a/turbo.json
+++ b/turbo.json
@@ -210,6 +210,8 @@
"LARK_OPEN_VERIFICATION_TOKEN",
"MS_GRAPH_CLIENT_ID",
"MS_GRAPH_CLIENT_SECRET",
+ "NEW_BOOKER_ENABLED_FOR_EMBED",
+ "NEW_BOOKER_ENABLED_FOR_NON_EMBED",
"NEXT_PUBLIC_API_URL",
"NEXT_PUBLIC_APP_NAME",
"NEXT_PUBLIC_COMPANY_NAME",