Skip to content

Commit

Permalink
Merge pull request #40817 from Expensify/dsilva_changingGTMToThirdPar…
Browse files Browse the repository at this point in the history
…tyScripts

[NO QA] Changing from gtm to thirdPartyScripts.js and including Fullstory
  • Loading branch information
luacmartins authored Apr 23, 2024
2 parents 0358841 + 8cabe5a commit 7ea2b6c
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/webpack/webpack.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand Down
11 changes: 0 additions & 11 deletions web/gtm.js

This file was deleted.

6 changes: 3 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@
<!-- polyfill.io is only needed on Web to support older browsers. It should not be loaded for desktop -->
<script src="https://polyfill.io/v3/polyfill.min.js?features=default%2CResizeObserver&flags=gated"></script>
<% if (htmlWebpackPlugin.options.isProduction) { %>
<!-- Google Tag Manager -->
<script async="" src="gtm.js"></script>
<!-- End Google Tag Manager -->
<!-- Third party scripts -->
<script async="" src="thirdPartyScripts.js"></script>
<!-- End Third party scripts -->
<% } %>
<% } %>
<link rel="manifest" href="/manifest.json" />
Expand Down
155 changes: 155 additions & 0 deletions web/thirdPartyScripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/* eslint-disable */
// 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 < d.length; j++) h(d[j]);
(d.length = 0), (d.push = h);
}
}),
(function () {
((o = n.createElement(t)).async = !0),
(o.crossOrigin = 'anonymous'),
(o.src = 'https://' + l),
(o.onerror = function () {
y('Error loading ' + l);
});
var b = n.getElementsByTagName(t)[0];
b && b.parentNode ? b.parentNode.insertBefore(o, b) : n.head.appendChild(o);
})(),
(function () {
function b() {}
function h(b, h, d) {
g(b, h, d, 1);
}
function d(b, d, j) {
h('setProperties', {type: b, properties: d}, j);
}
function j(b, h) {
d('user', b, h);
}
function r(b, h, d) {
j(
{
uid: b,
},
d,
),
h && j(h, d);
}
(g.identify = r),
(g.setUserVars = j),
(g.identifyAccount = b),
(g.clearUserCookie = b),
(g.setVars = d),
(g.event = function (b, d, j) {
h(
'trackEvent',
{
name: b,
properties: d,
},
j,
);
}),
(g.anonymize = function () {
r(!1);
}),
(g.shutdown = function () {
h('shutdown');
}),
(g.restart = function () {
h('restart');
}),
(g.log = function (b, d) {
h('log', {level: b, msg: d});
}),
(g.consent = function (b) {
h('setIdentity', {consent: !arguments.length || b});
});
})(),
(s = 'fetch'),
(f = 'XMLHttpRequest'),
(g._w = {}),
(g._w[f] = m[f]),
(g._w[s] = m[s]),
m[s] &&
(m[s] = function () {
return g._w[s].apply(this, arguments);
}),
(g._v = '2.0.0'));
})(window, document, window._fs_namespace, 'script', window._fs_script);

0 comments on commit 7ea2b6c

Please sign in to comment.