From 1553ac6a1aa8cf9dfe8b588f21ef95bbe0a84a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20W=C3=A9br?= Date: Mon, 2 Sep 2024 11:09:21 +0200 Subject: [PATCH 1/3] Add intercom messenger script and remove smartlook --- .github/workflows/deploy.yaml | 2 +- .github/workflows/docs.yaml | 2 +- .github/workflows/lychee.yml | 2 +- .github/workflows/test.yaml | 2 +- apify-docs-theme/package.json | 1 - apify-docs-theme/src/config.js | 2 -- apify-docs-theme/src/theme.js | 15 +++++++++++++++ package-lock.json | 9 +-------- 8 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 8eb00a47fd..742de4bc49 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -13,4 +13,4 @@ jobs: - run: gh workflow run deploy.yaml --repo apify/apify-docs-private env: GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} - SMARTLOOK_PROJECT_KEY: ${{ secrets.SMARTLOOK_PROJECT_KEY }} + INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }} diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 53a0cd1306..3a1cf97b5c 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -36,7 +36,7 @@ jobs: env: APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - SMARTLOOK_PROJECT_KEY: ${{ secrets.SMARTLOOK_PROJECT_KEY }} + INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }} - name: Set up GitHub Pages uses: actions/configure-pages@v5 diff --git a/.github/workflows/lychee.yml b/.github/workflows/lychee.yml index b8d550c565..15a7510883 100644 --- a/.github/workflows/lychee.yml +++ b/.github/workflows/lychee.yml @@ -29,7 +29,7 @@ jobs: env: APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - SMARTLOOK_PROJECT_KEY: ${{ secrets.SMARTLOOK_PROJECT_KEY }} + INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }} - name: Run Lychee Link Checker id: lychee diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 07dae9ce2c..1641501437 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -30,7 +30,7 @@ jobs: - run: npm run build env: - SMARTLOOK_PROJECT_KEY: ${{ secrets.SMARTLOOK_PROJECT_KEY }} + INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }} lint_content: name: Lint markdown content diff --git a/apify-docs-theme/package.json b/apify-docs-theme/package.json index dd425d5151..53c891e63f 100644 --- a/apify-docs-theme/package.json +++ b/apify-docs-theme/package.json @@ -25,7 +25,6 @@ "axios": "^1.7.4", "babel-loader": "^9.1.3", "docusaurus-gtm-plugin": "^0.0.2", - "docusaurus-plugin-smartlook": "^1.0.2", "postcss-preset-env": "^9.3.0", "prism-react-renderer": "^2.0.6" }, diff --git a/apify-docs-theme/src/config.js b/apify-docs-theme/src/config.js index b1c5ca385e..a170092b6b 100644 --- a/apify-docs-theme/src/config.js +++ b/apify-docs-theme/src/config.js @@ -13,7 +13,6 @@ const themeConfig = ({ hideable: true, }, }, - smartlook: { projectKey: process.env.SMARTLOOK_PROJECT_KEY || '-' }, navbar: { title: 'Apify Docs', logo: { @@ -266,7 +265,6 @@ const themeConfig = ({ }); const plugins = [ - 'docusaurus-plugin-smartlook', [ 'docusaurus-gtm-plugin', { diff --git a/apify-docs-theme/src/theme.js b/apify-docs-theme/src/theme.js index 49e8245e23..50a0bd689f 100644 --- a/apify-docs-theme/src/theme.js +++ b/apify-docs-theme/src/theme.js @@ -132,6 +132,21 @@ This either means that your Docusaurus setup is misconfigured, or that your GitH o.plugins.push(postcssPreset); // allow newest CSS syntax return o; }, + injectHtmlTags() { + return { + headTags: [ + { + tagName: 'script', + innerHTML: `window.intercomSettings={api_base:"https://api-iam.intercom.io",app_id:"${process.env.INTERCOM_APP_ID}"};`, + + }, + { + tagName: 'script', + innerHTML: `(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/${process.env.INTERCOM_APP_ID}';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()`, + }, + ], + }; + }, }; } diff --git a/package-lock.json b/package-lock.json index 75173c4e00..f6a0ff3a08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -65,7 +65,7 @@ }, "apify-docs-theme": { "name": "@apify/docs-theme", - "version": "1.0.128", + "version": "1.0.130", "license": "ISC", "dependencies": { "@apify/docs-search-modal": "^1.0.26", @@ -74,7 +74,6 @@ "axios": "^1.7.4", "babel-loader": "^9.1.3", "docusaurus-gtm-plugin": "^0.0.2", - "docusaurus-plugin-smartlook": "^1.0.2", "postcss-preset-env": "^9.3.0", "prism-react-renderer": "^2.0.6" }, @@ -9377,12 +9376,6 @@ "@docusaurus/utils": "^3.0.0" } }, - "node_modules/docusaurus-plugin-smartlook": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/docusaurus-plugin-smartlook/-/docusaurus-plugin-smartlook-1.0.2.tgz", - "integrity": "sha512-HKOavP16LMWsdZ6xpEqGecIweButfZ3hteCy6FZb1+s8c5b3hFsn9n1ohChAC1B1KETQZG5OhmQ270C0ak06Rg==", - "deprecated": "docusaurus-plugin-smartlook is now available at @stackql/docusaurus-plugin-smartlook" - }, "node_modules/docusaurus-theme-redoc": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/docusaurus-theme-redoc/-/docusaurus-theme-redoc-2.0.2.tgz", From cb6965d44a28e9b78fd765adbbd90563276ef88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20W=C3=A9br?= Date: Mon, 2 Sep 2024 13:38:22 +0200 Subject: [PATCH 2/3] add script only if process.env.INTERCOM_APP_ID is defined --- apify-docs-theme/src/theme.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apify-docs-theme/src/theme.js b/apify-docs-theme/src/theme.js index 50a0bd689f..f22916ad2a 100644 --- a/apify-docs-theme/src/theme.js +++ b/apify-docs-theme/src/theme.js @@ -135,12 +135,12 @@ This either means that your Docusaurus setup is misconfigured, or that your GitH injectHtmlTags() { return { headTags: [ - { + process.env.INTERCOM_APP_ID && { tagName: 'script', innerHTML: `window.intercomSettings={api_base:"https://api-iam.intercom.io",app_id:"${process.env.INTERCOM_APP_ID}"};`, }, - { + process.env.INTERCOM_APP_ID && { tagName: 'script', innerHTML: `(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/${process.env.INTERCOM_APP_ID}';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()`, }, From ab553e66e6f9f615641a1949f9840ac12adf9c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20W=C3=A9br?= Date: Mon, 2 Sep 2024 15:06:14 +0200 Subject: [PATCH 3/3] add scripts in Docusaurus configuration instead of the theme --- apify-docs-theme/src/theme.js | 15 --------------- docusaurus.config.js | 14 +++++++++++++- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/apify-docs-theme/src/theme.js b/apify-docs-theme/src/theme.js index f22916ad2a..49e8245e23 100644 --- a/apify-docs-theme/src/theme.js +++ b/apify-docs-theme/src/theme.js @@ -132,21 +132,6 @@ This either means that your Docusaurus setup is misconfigured, or that your GitH o.plugins.push(postcssPreset); // allow newest CSS syntax return o; }, - injectHtmlTags() { - return { - headTags: [ - process.env.INTERCOM_APP_ID && { - tagName: 'script', - innerHTML: `window.intercomSettings={api_base:"https://api-iam.intercom.io",app_id:"${process.env.INTERCOM_APP_ID}"};`, - - }, - process.env.INTERCOM_APP_ID && { - tagName: 'script', - innerHTML: `(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/${process.env.INTERCOM_APP_ID}';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()`, - }, - ], - }; - }, }; } diff --git a/docusaurus.config.js b/docusaurus.config.js index bf418bb5f4..1e2ba8d731 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -33,7 +33,19 @@ module.exports = { sizes: 'any', }, }, - ], + // Intercom messenger + process.env.INTERCOM_APP_ID && { + tagName: 'script', + innerHTML: `window.intercomSettings={api_base:"https://api-iam.intercom.io",app_id:"${process.env.INTERCOM_APP_ID}"};`, + attributes: {}, + }, + // Intercom messenger + process.env.INTERCOM_APP_ID && { + tagName: 'script', + innerHTML: `(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/${process.env.INTERCOM_APP_ID}';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()`, + attributes: {}, + }, + ].filter(Boolean), onBrokenLinks: /** @type {import('@docusaurus/types').ReportingSeverity} */ ('throw'),