Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoGabriele committed Aug 18, 2019
2 parents eb4afb3 + b8f215a commit 0ecc4c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default () => {
return
}

const { disableScriptLoader: noScript, ready } = config
const { ready } = config
const filename = config.debug.enabled ? 'analytics_debug' : 'analytics'
const resource = config.customResourceURL || `https://www.google-analytics.com/${filename}.js`

Expand All @@ -26,7 +26,7 @@ export default () => {
promisify(config.disabled)
]

if (shouldGaLoad() && (!window.ga || !noScript)) {
if (shouldGaLoad()) {
queue.push(
loadScript(resource).catch(() => {
throw new Error (
Expand Down
13 changes: 12 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,18 @@ export function hasScript () {
}

export function shouldGaLoad () {
return !(config.checkDuplicatedScript && hasScript())
const {
checkDuplicatedScript,
disableScriptLoader
} = config

const requires = [
Boolean(window && window.ga),
(checkDuplicatedScript && !hasScript()),
!disableScriptLoader
]

return requires.some(Boolean)
}

export function getTracker (tracker) {
Expand Down

0 comments on commit 0ecc4c9

Please sign in to comment.