diff --git a/docusaurus/docusaurus.config.js b/docusaurus/docusaurus.config.js
index ea53178634..51cb1f3447 100644
--- a/docusaurus/docusaurus.config.js
+++ b/docusaurus/docusaurus.config.js
@@ -1,7 +1,7 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
-const {themes} = require('prism-react-renderer');
+const { themes } = require('prism-react-renderer');
// const lightCodeTheme = themes.github;
const darkCodeTheme = themes.dracula;
@@ -25,7 +25,8 @@ const config = {
},
headTags: [
- { // Useful for SEO even if we don't have multiple languages
+ {
+ // Useful for SEO even if we don't have multiple languages
tagName: 'link',
attributes: {
rel: 'alternate',
@@ -91,17 +92,22 @@ const config = {
'data-project-name': 'Strapi',
'data-project-logo': 'https://strapi.io/assets/favicon-32x32.png',
'data-button-hide': 'true',
- 'data-modal-disclaimer': 'Disclaimer: Answers are AI-generated and might be inaccurate. Please ensure you double-check the information provided by visiting source pages.',
+ 'data-modal-disclaimer':
+ 'Disclaimer: Answers are AI-generated and might be inaccurate. Please ensure you double-check the information provided by visiting source pages.',
'data-project-color': '#4945FF',
'data-button-bg-color': '#32324D',
// 'data-modal-open-on-command-k': 'true',
- 'data-modal-override-open-class': "kapa-widget-button",
+ 'data-modal-override-open-class': 'kapa-widget-button',
'data-modal-title-ask-ai': 'Ask your question',
'data-modal-border-radius': '4px',
'data-submit-query-button-bg-color': '#4945FF',
'data-modal-body-padding-top': '20px',
async: true,
},
+ {
+ src: `https://cdn.amplitude.com/script/181a95e5a6b8053f7ffb7da9f0ef7ef4.experiment.js`,
+ async: true,
+ },
],
stylesheets: [
{
@@ -118,7 +124,8 @@ const config = {
docs: {
routeBasePath: '/',
sidebarPath: require.resolve('./sidebars.js'),
- editUrl: 'https://github.com/strapi/documentation/edit/main/docusaurus',
+ editUrl:
+ 'https://github.com/strapi/documentation/edit/main/docusaurus',
admonitions: {
keywords: [
// Admonitions defaults
@@ -178,7 +185,7 @@ const config = {
appId: '392RJ63O14',
apiKey: 'ed62374a794e8da5accb298e13618614',
indexName: 'strapiDocsNextstrapiDocsNext',
- },
+ },
navbar: {
hideOnScroll: false,
logo: {
@@ -192,14 +199,14 @@ const config = {
docId: 'user-docs/intro',
position: 'left',
// label: 'CMS',
- html: ' User Guide'
+ html: ' User Guide',
},
{
type: 'doc',
docId: 'dev-docs/intro',
position: 'left',
// label: 'CMS',
- html: ' Dev Docs'
+ html: ' Dev Docs',
},
{
type: 'doc',
@@ -222,44 +229,44 @@ const config = {
items: [
{
label: "What's new?",
- href: '/dev-docs/whats-new'
+ href: '/dev-docs/whats-new',
},
{
- label: "Release notes",
- href: '/release-notes'
+ label: 'Release notes',
+ href: '/release-notes',
},
{
- label: "FAQ",
- href: '/dev-docs/faq'
+ label: 'FAQ',
+ href: '/dev-docs/faq',
},
{
- label: "Community & Support",
- href: '/dev-docs/community'
+ label: 'Community & Support',
+ href: '/dev-docs/community',
},
{
- label: "Usage information",
- href: '/dev-docs/usage-information'
+ label: 'Usage information',
+ href: '/dev-docs/usage-information',
},
- ]
+ ],
},
{
title: 'Additional resources',
items: [
{
label: 'v4 Docs',
- href: 'https://docs-v4.strapi.io'
+ href: 'https://docs-v4.strapi.io',
},
{
label: 'Contributor Docs',
- href: 'https://contributor.strapi.io'
+ href: 'https://contributor.strapi.io',
},
{
label: 'Strapi Design System',
- href: 'https://design-system.strapi.io/'
+ href: 'https://design-system.strapi.io/',
},
{
label: 'v3 Docs (unsupported)',
- href: 'https://docs-v3.strapi.io'
+ href: 'https://docs-v3.strapi.io',
},
],
},
@@ -326,6 +333,7 @@ const config = {
* related to the Docusaurus canary build or not.
*/
],
+ clientModules: [require.resolve('./src/analytics/amplitude.js')],
};
module.exports = config;
diff --git a/docusaurus/package.json b/docusaurus/package.json
index bdc625cf0d..a3149ac01c 100644
--- a/docusaurus/package.json
+++ b/docusaurus/package.json
@@ -14,6 +14,7 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
+ "@amplitude/analytics-browser": "^2.11.11",
"@docusaurus/core": "3.5.2",
"@docusaurus/plugin-client-redirects": "3.5.2",
"@docusaurus/plugin-google-tag-manager": "3.5.2",
@@ -26,6 +27,7 @@
"docusaurus-plugin-hubspot": "^1.0.1",
"docusaurus-plugin-image-zoom": "^0.1.1",
"docusaurus-plugin-sass": "^0.2.3",
+ "docusaurus2-dotenv": "^1.4.0",
"embla-carousel-autoplay": "^7.1.0",
"embla-carousel-react": "^7.1.0",
"embla-carousel-wheel-gestures": "^3.0.0",
diff --git a/docusaurus/src/analytics/amplitude.js b/docusaurus/src/analytics/amplitude.js
new file mode 100644
index 0000000000..1c29f5c7a0
--- /dev/null
+++ b/docusaurus/src/analytics/amplitude.js
@@ -0,0 +1,66 @@
+import * as amplitude from '@amplitude/analytics-browser';
+
+let amplitudeInstance = null;
+
+// Utility to get cookie by name
+const getCookie = (name) => {
+ if (typeof window !== 'undefined') {
+ const value = `; ${document.cookie}`;
+ const parts = value.split(`; ${name}=`);
+ if (parts.length === 2) return parts.pop().split(';').shift();
+ return null;
+ }
+ return null;
+};
+
+// Extract the Google Analytics Client ID from the _ga cookie
+const getGoogleAnalyticsClientId = () => {
+ const gaCookie = getCookie('_ga');
+ if (gaCookie) {
+ const parts = gaCookie.split('.');
+ return parts.length === 4 ? `${parts[2]}.${parts[3]}` : null;
+ }
+ return null;
+};
+
+export const initializeAmplitude = () => {
+ // Check if we're already initialized
+ if (!amplitudeInstance && process.env.NODE_ENV === 'production') {
+ // Extract the Google Analytics Client ID
+ const googleAnalyticsClientId = getGoogleAnalyticsClientId();
+ if (!googleAnalyticsClientId) {
+ console.warn('Google Analytics Client ID not found in cookies.');
+ }
+
+ // Initialize Amplitude with the client ID as the deviceId
+ amplitudeInstance = amplitude.init(
+ '181a95e5a6b8053f7ffb7da9f0ef7ef4', // This key is Public
+ googleAnalyticsClientId,
+ {
+ ...(googleAnalyticsClientId && { deviceId: googleAnalyticsClientId }),
+ autocapture: true,
+ }
+ );
+ }
+};
+
+export const amplitudeTrack = (eventName, eventProperties) => {
+ if (amplitudeInstance) {
+ try {
+ const googleAnalyticsClientId = getGoogleAnalyticsClientId();
+ amplitude.track({
+ event_type: eventName,
+ deviceId: googleAnalyticsClientId,
+ event_properties: eventProperties,
+ });
+ } catch (error) {
+ console.error('Error tracking Amplitude event:', error);
+ }
+ } else {
+ console.error('Amplitude is not initialized.');
+ }
+};
+
+if (typeof document !== 'undefined') {
+ initializeAmplitude();
+}
diff --git a/docusaurus/yarn.lock b/docusaurus/yarn.lock
index a91ffe2f27..06d9719c68 100644
--- a/docusaurus/yarn.lock
+++ b/docusaurus/yarn.lock
@@ -271,6 +271,85 @@
"@algolia/logger-common" "4.24.0"
"@algolia/requester-common" "4.24.0"
+"@amplitude/analytics-browser@^2.11.11":
+ version "2.11.11"
+ resolved "https://registry.yarnpkg.com/@amplitude/analytics-browser/-/analytics-browser-2.11.11.tgz#b41dea21ca97b8688b3e3acf392cc1481d5f9485"
+ integrity sha512-AdpNNPwoNPezojeeU2ITcyqKcrrW8edVBHlCEvDNIXYkf5Y0i5Blbes3x6rgONsOeV2hx85trTXhhVkilWgHcg==
+ dependencies:
+ "@amplitude/analytics-client-common" "^2.3.7"
+ "@amplitude/analytics-core" "^2.5.5"
+ "@amplitude/analytics-remote-config" "^0.4.0"
+ "@amplitude/analytics-types" "^2.8.4"
+ "@amplitude/plugin-autocapture-browser" "^1.0.2"
+ "@amplitude/plugin-page-view-tracking-browser" "^2.3.7"
+ tslib "^2.4.1"
+
+"@amplitude/analytics-client-common@>=1 <3", "@amplitude/analytics-client-common@^2.3.7":
+ version "2.3.7"
+ resolved "https://registry.yarnpkg.com/@amplitude/analytics-client-common/-/analytics-client-common-2.3.7.tgz#f943325ea317eb89c2eb92291fff19e4b4a3e3ea"
+ integrity sha512-HuwP2MFoeCTZWFIxkeYZOy5GP9ydjRO+n2KUMhHXTXGUx1M9vxIx1BUHsHKOZ4BZ5qEUTacgmznyc6uJJUiCWg==
+ dependencies:
+ "@amplitude/analytics-connector" "^1.4.8"
+ "@amplitude/analytics-core" "^2.5.5"
+ "@amplitude/analytics-types" "^2.8.4"
+ tslib "^2.4.1"
+
+"@amplitude/analytics-connector@^1.4.8":
+ version "1.6.2"
+ resolved "https://registry.yarnpkg.com/@amplitude/analytics-connector/-/analytics-connector-1.6.2.tgz#0c0da82fe4722061591c1c5b75d7f585b95cb292"
+ integrity sha512-9bk2IjyV3VgUdbI3ounKUuP+4u4ABftDWGdOKxshEQrHg6WhgC8V4hdhSHv9wOHebGTvZntRKM5LlSXUyDYBpw==
+ dependencies:
+ "@amplitude/experiment-core" "^0.10.1"
+
+"@amplitude/analytics-core@>=1 <3", "@amplitude/analytics-core@^2.5.5":
+ version "2.5.5"
+ resolved "https://registry.yarnpkg.com/@amplitude/analytics-core/-/analytics-core-2.5.5.tgz#2df29bc1607bfbf23b531413c0dc8d0c4ac9bc59"
+ integrity sha512-OSB1WSD6qYoHyHliZaSujyatik2SP+vtoy8Y0vgRdYIpbE24F2q+SwBF3X5A1IeUqZ5fdpz+BNMwwUVl0Z4Ykg==
+ dependencies:
+ "@amplitude/analytics-types" "^2.8.4"
+ tslib "^2.4.1"
+
+"@amplitude/analytics-remote-config@^0.4.0":
+ version "0.4.1"
+ resolved "https://registry.yarnpkg.com/@amplitude/analytics-remote-config/-/analytics-remote-config-0.4.1.tgz#b62cf8aa82290f68b314197e20351b10ea44ae3e"
+ integrity sha512-BYl6kQ9qjztrCACsugpxO+foLaQIC0aSEzoXEAb/gwOzInmqkyyI+Ub+aWTBih4xgB/lhWlOcidWHAmNiTJTNw==
+ dependencies:
+ "@amplitude/analytics-client-common" ">=1 <3"
+ "@amplitude/analytics-core" ">=1 <3"
+ "@amplitude/analytics-types" ">=1 <3"
+ tslib "^2.4.1"
+
+"@amplitude/analytics-types@>=1 <3", "@amplitude/analytics-types@^2.8.2", "@amplitude/analytics-types@^2.8.4":
+ version "2.8.4"
+ resolved "https://registry.yarnpkg.com/@amplitude/analytics-types/-/analytics-types-2.8.4.tgz#0d9ec0d3a0d00b729b5520b38ef8a158e691ffd2"
+ integrity sha512-jQ8WY1aPbpBshl0L/0YEeQn/wZlBr8Jlqc20qf8nbuDuimFy8RqAkE+BVaMI86FCkr3AJ7PjMXkGwCSbUx88CA==
+
+"@amplitude/experiment-core@^0.10.1":
+ version "0.10.1"
+ resolved "https://registry.yarnpkg.com/@amplitude/experiment-core/-/experiment-core-0.10.1.tgz#85bb0bf55b419fe1b7bcee428182ed1eda010ff3"
+ integrity sha512-2h0vqOaHoACmNiliGT78hnu9K/tmb7pWU1xw1KitlTtxK6wQqsY/IZPLMwBMG5MLp/AOzNEA/uelODfhBC5+SQ==
+ dependencies:
+ js-base64 "^3.7.5"
+
+"@amplitude/plugin-autocapture-browser@^1.0.2":
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/@amplitude/plugin-autocapture-browser/-/plugin-autocapture-browser-1.0.4.tgz#ac1ed156c565bf6767ee7474110aa00f9ebca56c"
+ integrity sha512-+aUSsH4hRX4bWtSL90S3Irb3JctvIM+6aQ/wRSo1bYtnpXp7JQjWKzTYVxKx41b92Cb5DCBvmYgcWyg75BKi9Q==
+ dependencies:
+ "@amplitude/analytics-client-common" ">=1 <3"
+ "@amplitude/analytics-types" "^2.8.2"
+ rxjs "^7.8.1"
+ tslib "^2.4.1"
+
+"@amplitude/plugin-page-view-tracking-browser@^2.3.7":
+ version "2.3.7"
+ resolved "https://registry.yarnpkg.com/@amplitude/plugin-page-view-tracking-browser/-/plugin-page-view-tracking-browser-2.3.7.tgz#a19e295e5a83c7f29ea02b987ceae2d17453c860"
+ integrity sha512-9LEzU33vpQ1OdPwVn0nwcCqPLkfK3P19hLmFTflx+aBM70TH9xCwvJL6nJ5eyc4kkmE9x7r0mRVnQIxaHfTxGg==
+ dependencies:
+ "@amplitude/analytics-client-common" "^2.3.7"
+ "@amplitude/analytics-types" "^2.8.4"
+ tslib "^2.4.1"
+
"@ampproject/remapping@^2.2.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.3.0.tgz#ed441b6fa600072520ce18b43d2c8cc8caecc7f4"
@@ -4140,6 +4219,13 @@ docusaurus-plugin-sass@^0.2.3:
dependencies:
sass-loader "^16.0.2"
+docusaurus2-dotenv@^1.4.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/docusaurus2-dotenv/-/docusaurus2-dotenv-1.4.0.tgz#9ab900e29de9081f9f1f28f7224ff63760385641"
+ integrity sha512-iWqem5fnBAyeBBtX75Fxp71uUAnwFaXzOmade8zAhN4vL3RG9m27sLSRwjJGVVgIkEo3esjGyCcTGTiCjfi+sg==
+ dependencies:
+ dotenv-webpack "1.7.0"
+
dom-converter@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/dom-converter/-/dom-converter-0.2.0.tgz#6721a9daee2e293682955b6afe416771627bb768"
@@ -4222,6 +4308,25 @@ dot-prop@^6.0.1:
dependencies:
is-obj "^2.0.0"
+dotenv-defaults@^1.0.2:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/dotenv-defaults/-/dotenv-defaults-1.1.1.tgz#032c024f4b5906d9990eb06d722dc74cc60ec1bd"
+ integrity sha512-6fPRo9o/3MxKvmRZBD3oNFdxODdhJtIy1zcJeUSCs6HCy4tarUpd+G67UTU9tF6OWXeSPqsm4fPAB+2eY9Rt9Q==
+ dependencies:
+ dotenv "^6.2.0"
+
+dotenv-webpack@1.7.0:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/dotenv-webpack/-/dotenv-webpack-1.7.0.tgz#4384d8c57ee6f405c296278c14a9f9167856d3a1"
+ integrity sha512-wwNtOBW/6gLQSkb8p43y0Wts970A3xtNiG/mpwj9MLUhtPCQG6i+/DSXXoNN7fbPCU/vQ7JjwGmgOeGZSSZnsw==
+ dependencies:
+ dotenv-defaults "^1.0.2"
+
+dotenv@^6.2.0:
+ version "6.2.0"
+ resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064"
+ integrity sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w==
+
dunder-proto@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.1.tgz#d7ae667e1dc83482f8b70fd0f6eefc50da30f58a"
@@ -5709,6 +5814,11 @@ joi@^17.9.2:
"@sideway/formula" "^3.0.1"
"@sideway/pinpoint" "^2.0.0"
+js-base64@^3.7.5:
+ version "3.7.7"
+ resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.7.7.tgz#e51b84bf78fbf5702b9541e2cb7bfcb893b43e79"
+ integrity sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==
+
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@@ -8399,6 +8509,13 @@ rw@1:
resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4"
integrity sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==
+rxjs@^7.8.1:
+ version "7.8.1"
+ resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543"
+ integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==
+ dependencies:
+ tslib "^2.1.0"
+
sade@^1.7.3:
version "1.8.1"
resolved "https://registry.yarnpkg.com/sade/-/sade-1.8.1.tgz#0a78e81d658d394887be57d2a409bf703a3b2701"
@@ -8833,7 +8950,16 @@ std-env@^3.0.1:
resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.8.0.tgz#b56ffc1baf1a29dcc80a3bdf11d7fca7c315e7d5"
integrity sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==
-"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0:
+"string-width-cjs@npm:string-width@^4.2.0":
+ version "4.2.3"
+ resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
+ integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
+ dependencies:
+ emoji-regex "^8.0.0"
+ is-fullwidth-code-point "^3.0.0"
+ strip-ansi "^6.0.1"
+
+string-width@^4.1.0, string-width@^4.2.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -8882,7 +9008,14 @@ stringify-object@^3.3.0:
is-obj "^1.0.1"
is-regexp "^1.0.0"
-"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
+"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
+ version "6.0.1"
+ resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
+ integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
+ dependencies:
+ ansi-regex "^5.0.1"
+
+strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -9102,7 +9235,7 @@ ts-interface-checker@^0.1.9:
resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699"
integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==
-tslib@^2.0.3, tslib@^2.6.0:
+tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.1, tslib@^2.6.0:
version "2.8.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==