Skip to content
This repository was archived by the owner on Nov 24, 2020. It is now read-only.

Commit 6dae74e

Browse files
fix(Analytics): Move analytics to be loaded async (#102)
* chore(analytics): Update the Analytics config * fix(Test): Update method order to fix lint (#99) Fix tests * fix(Analytics): move analytics to be loaded async (#101) * fix(Test): Update method order to fix lint * fix(test): force exit for mocha tests * refactor(analytics): Move scripts to be async Fix loading the bluemix analytics * chore(Analytics): Remove script tag from layout
1 parent da9c547 commit 6dae74e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,15 @@ import 'watson-react-components/dist/css/watson-react-components.css';
55
import Layout from './layout';
66
import './style.css';
77

8+
function loadAnalytics() {
9+
const analyticsScript = document.createElement('script');
10+
analyticsScript.src = 'https://cdn.rawgit.com/watson-developer-cloud/watson-developer-cloud.github.io/master/analytics.js';
11+
document.head.appendChild(analyticsScript);
12+
}
13+
14+
if (process.env.REACT_APP_BLUEMIX_ANALYTICS) {
15+
// eslint-disable-next-line no-native-reassign, no-underscore-dangle
16+
window.addEventListener('load', loadAnalytics);
17+
}
18+
819
ReactDOM.render(<Layout />, document.getElementById('root'));

src/layout.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export default function Layout() {
3131
</span>
3232
</section>
3333
<Footer />
34-
<script type="text/javascript" src="https://cdn.rawgit.com/watson-developer-cloud/watson-developer-cloud.github.io/master/analytics.js" />
3534
</div>
3635
</div>
3736
);

0 commit comments

Comments
 (0)