From 6a7cb9e6cade709cb29ca8445c9ff8bca9c2e1e0 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Tue, 23 Apr 2024 19:58:44 +0200 Subject: [PATCH 1/4] changing from gtm to thirdPartyScripts.js --- config/webpack/webpack.common.ts | 2 +- web/gtm.js | 11 ----------- web/index.html | 6 +++--- web/thirdPartyScripts.js | 34 ++++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 15 deletions(-) delete mode 100644 web/gtm.js create mode 100644 web/thirdPartyScripts.js diff --git a/config/webpack/webpack.common.ts b/config/webpack/webpack.common.ts index 7cafafca9973..9d397b9557a3 100644 --- a/config/webpack/webpack.common.ts +++ b/config/webpack/webpack.common.ts @@ -98,7 +98,7 @@ const getCommonConfiguration = ({file = '.env', platform = 'web'}: Environment): {from: 'web/apple-touch-icon.png'}, {from: 'assets/images/expensify-app-icon.svg'}, {from: 'web/manifest.json'}, - {from: 'web/gtm.js'}, + {from: 'web/thirdPartyScripts.js'}, {from: 'assets/css', to: 'css'}, {from: 'assets/fonts/web', to: 'fonts'}, {from: 'assets/sounds', to: 'sounds'}, diff --git a/web/gtm.js b/web/gtm.js deleted file mode 100644 index ee96d01b9a67..000000000000 --- a/web/gtm.js +++ /dev/null @@ -1,11 +0,0 @@ -/* eslint-disable no-param-reassign, prefer-template */ -(function (w, d, s, l, i) { - w[l] = w[l] || []; - w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'}); - const f = d.getElementsByTagName(s)[0]; - const j = d.createElement(s); - const dl = l !== 'dataLayer' ? '&l=' + l : ''; - j.async = true; - j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; - f.parentNode.insertBefore(j, f); -})(window, document, 'script', 'dataLayer', 'GTM-N4M3FLJZ'); diff --git a/web/index.html b/web/index.html index 115803573bbd..be6396190d25 100644 --- a/web/index.html +++ b/web/index.html @@ -122,9 +122,9 @@ <% if (htmlWebpackPlugin.options.isProduction) { %> - - - + + + <% } %> <% } %> diff --git a/web/thirdPartyScripts.js b/web/thirdPartyScripts.js new file mode 100644 index 000000000000..26524cacefcb --- /dev/null +++ b/web/thirdPartyScripts.js @@ -0,0 +1,34 @@ +/* eslint-disable no-param-reassign, prefer-template */ +// Google Tag Manager +(function (w, d, s, l, i) { + w[l] = w[l] || []; + w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'}); + const f = d.getElementsByTagName(s)[0]; + const j = d.createElement(s); + const dl = l !== 'dataLayer' ? '&l=' + l : ''; + j.async = true; + j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; + f.parentNode.insertBefore(j, f); +})(window, document, 'script', 'dataLayer', 'GTM-N4M3FLJZ'); + +// FullStory +window['_fs_host'] = 'fullstory.com'; +window['_fs_script'] = 'edge.fullstory.com/s/fs.js'; +window['_fs_org'] = 'o-1WN56P-na1'; +window['_fs_namespace'] = 'FS'; +!function(m,n,e,t,l,o,g,y){var s,f,a=function(h){ +return!(h in m)||(m.console&&m.console.log&&m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].'),!1)}(e) +;function p(b){var h,d=[];function j(){h&&(d.forEach((function(b){var d;try{d=b[h[0]]&&b[h[0]](h[1])}catch(h){return void(b[3]&&b[3](h))} +d&&d.then?d.then(b[2],b[3]):b[2]&&b[2](d)})),d.length=0)}function r(b){return function(d){h||(h=[b,d],j())}}return b(r(0),r(1)),{ +then:function(b,h){return p((function(r,i){d.push([b,h,r,i]),j()}))}}}a&&(g=m[e]=function(){var b=function(b,d,j,r){function i(i,c){ +h(b,d,j,i,c,r)}r=r||2;var c,u=/Async$/;return u.test(b)?(b=b.replace(u,""),"function"==typeof Promise?new Promise(i):p(i)):h(b,d,j,c,c,r)} +;function h(h,d,j,r,i,c){return b._api?b._api(h,d,j,r,i,c):(b.q&&b.q.push([h,d,j,r,i,c]),null)}return b.q=[],b}(),y=function(b){function h(h){ +"function"==typeof h[4]&&h[4](new Error(b))}var d=g.q;if(d){for(var j=0;j Date: Tue, 23 Apr 2024 20:00:49 +0200 Subject: [PATCH 2/4] prettier --- web/thirdPartyScripts.js | 153 +++++++++++++++++++++++++++++++++++---- 1 file changed, 137 insertions(+), 16 deletions(-) diff --git a/web/thirdPartyScripts.js b/web/thirdPartyScripts.js index 26524cacefcb..0d9aa9226b54 100644 --- a/web/thirdPartyScripts.js +++ b/web/thirdPartyScripts.js @@ -16,19 +16,140 @@ window['_fs_host'] = 'fullstory.com'; window['_fs_script'] = 'edge.fullstory.com/s/fs.js'; window['_fs_org'] = 'o-1WN56P-na1'; window['_fs_namespace'] = 'FS'; -!function(m,n,e,t,l,o,g,y){var s,f,a=function(h){ -return!(h in m)||(m.console&&m.console.log&&m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].'),!1)}(e) -;function p(b){var h,d=[];function j(){h&&(d.forEach((function(b){var d;try{d=b[h[0]]&&b[h[0]](h[1])}catch(h){return void(b[3]&&b[3](h))} -d&&d.then?d.then(b[2],b[3]):b[2]&&b[2](d)})),d.length=0)}function r(b){return function(d){h||(h=[b,d],j())}}return b(r(0),r(1)),{ -then:function(b,h){return p((function(r,i){d.push([b,h,r,i]),j()}))}}}a&&(g=m[e]=function(){var b=function(b,d,j,r){function i(i,c){ -h(b,d,j,i,c,r)}r=r||2;var c,u=/Async$/;return u.test(b)?(b=b.replace(u,""),"function"==typeof Promise?new Promise(i):p(i)):h(b,d,j,c,c,r)} -;function h(h,d,j,r,i,c){return b._api?b._api(h,d,j,r,i,c):(b.q&&b.q.push([h,d,j,r,i,c]),null)}return b.q=[],b}(),y=function(b){function h(h){ -"function"==typeof h[4]&&h[4](new Error(b))}var d=g.q;if(d){for(var j=0;j Date: Tue, 23 Apr 2024 20:10:01 +0200 Subject: [PATCH 3/4] removing lint rules on this file --- web/thirdPartyScripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/thirdPartyScripts.js b/web/thirdPartyScripts.js index 0d9aa9226b54..15e77dbd490e 100644 --- a/web/thirdPartyScripts.js +++ b/web/thirdPartyScripts.js @@ -1,4 +1,4 @@ -/* eslint-disable no-param-reassign, prefer-template */ +/* eslint-disable */ // Google Tag Manager (function (w, d, s, l, i) { w[l] = w[l] || []; From 8cabe5a3de625514a5bab412ef22a915fcfcb0e7 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Tue, 23 Apr 2024 20:17:14 +0200 Subject: [PATCH 4/4] changing typecheck to ignore web folder --- .github/workflows/typecheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index f20939f9df0a..88d4d24a5723 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -30,7 +30,7 @@ jobs: # - git diff is used to see the files that were added on this branch # - gh pr view is used to list files touched by this PR. Git diff may give false positives if the branch isn't up-to-date with main # - wc counts the words in the result of the intersection - count_new_js=$(comm -1 -2 <(git diff --name-only --diff-filter=A origin/main HEAD -- 'src/*.js' '__mocks__/*.js' '.storybook/*.js' 'assets/*.js' 'config/*.js' 'desktop/*.js' 'jest/*.js' 'scripts/*.js' 'tests/*.js' 'web/*.js' 'workflow_tests/*.js' '.github/libs/*.js' '.github/scripts/*.js') <(gh pr view ${{ github.event.pull_request.number }} --json files | jq -r '.files | map(.path) | .[]') | wc -l) + count_new_js=$(comm -1 -2 <(git diff --name-only --diff-filter=A origin/main HEAD -- 'src/*.js' '__mocks__/*.js' '.storybook/*.js' 'assets/*.js' 'config/*.js' 'desktop/*.js' 'jest/*.js' 'scripts/*.js' 'tests/*.js' 'workflow_tests/*.js' '.github/libs/*.js' '.github/scripts/*.js') <(gh pr view ${{ github.event.pull_request.number }} --json files | jq -r '.files | map(.path) | .[]') | wc -l) if [ "$count_new_js" -gt "0" ]; then echo "ERROR: Found new JavaScript files in the project; use TypeScript instead." exit 1