diff --git a/storybook/.storybook/main.ts b/storybook/.storybook/main.ts
index 906acfa442..d4f050483b 100644
--- a/storybook/.storybook/main.ts
+++ b/storybook/.storybook/main.ts
@@ -3,6 +3,14 @@ import react from '@vitejs/plugin-react-swc';
import ViteYaml from '@modyfi/vite-plugin-yaml';
import remarkGfm from 'remark-gfm';
import { join, dirname, resolve } from 'path';
+import { readFileSync } from 'fs';
+import { prepareManagerHeadFile } from './../scripts/prepare-manager-head-file';
+
+const isProduction = process.env.NODE_ENV === 'production';
+const prodHead = readFileSync(
+ join(__dirname, './manager-head.prod.html'),
+ 'utf8'
+);
/**
* This function is used to resolve the absolute path of a package.
@@ -18,6 +26,11 @@ const config: StorybookConfig = {
'../../packages/components/**/*.stories.@(js|jsx|mjs|ts|tsx)',
'../../packages/components/**/*.mdx',
],
+ // head = the manager-header.html file contents
+ managerHead: (head) => `
+ ${head}
+ ${isProduction ? prepareManagerHeadFile(prodHead) : ''}
+ `,
addons: [
//getAbsolutePath('@storybook/addon-webpack5-compiler-swc'),
getAbsolutePath('@storybook/addon-links'),
diff --git a/storybook/.storybook/manager-head.prod.html b/storybook/.storybook/manager-head.prod.html
new file mode 100644
index 0000000000..5d6d9569e9
--- /dev/null
+++ b/storybook/.storybook/manager-head.prod.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
diff --git a/storybook/scripts/prepare-manager-head-file.ts b/storybook/scripts/prepare-manager-head-file.ts
new file mode 100644
index 0000000000..1ed1f57231
--- /dev/null
+++ b/storybook/scripts/prepare-manager-head-file.ts
@@ -0,0 +1,20 @@
+const envVars: Record = {
+ /** ENV's needed for CookieConsent script integration */
+ COOKIELAW_ORG: process.env.COOKIELAW_ORG,
+ /** ENV's needed for FullStory integration */
+ FS_HOST: process.env.FS_HOST,
+ FS_SCRIPT: process.env.FS_SCRIPT,
+ FS_ORG: process.env.FS_ORG,
+ /** ENV's needed for UserGuiding integration */
+ USERGUIDING_ORG: process.env.USERGUIDING_ORG,
+};
+
+// this function replaces {{VARIABLE_NAME}} variables in the given string
+export const prepareManagerHeadFile = (html: string) => {
+ return html.replace(/{{(.*?)}}/g, (_, varName): string => {
+ // Trim any extra spaces in the variable name
+ varName = varName.trim();
+ // If the variable exists in the object, replace it. Otherwise, return an empty string
+ return envVars[varName] || '';
+ });
+};