Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 656d71a

Browse files
fix(bootstrap): config.id not updated when id is a function
1 parent af161dd commit 656d71a

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/bootstrap.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { loadScript, onAnalyticsReady, hasGoogleScript } from './helpers'
2-
import config, { update } from './config'
2+
import config from './config'
33
import createTrackers from './create-trackers'
44
import collectors from './collectors'
55
import untracked from 'lib/untracked'
@@ -38,21 +38,12 @@ export default function bootstrap () {
3838
return onAnalyticsReady()
3939
})
4040
.then(() => {
41-
let newId = id
42-
43-
if (typeof newId === 'function') {
44-
newId = newId()
45-
}
46-
47-
if (typeof newId.then === 'function') {
48-
return newId.then(response => {
49-
config.id = response
50-
})
51-
}
52-
53-
return newId
41+
// see https://github.com/MatteoGabriele/vue-analytics/issues/78
42+
return typeof id === 'function' ? id() : id
5443
})
55-
.then(response => {
44+
.then(id => {
45+
// Update the ID with the new value
46+
config.id = id
5647
// Create analytics trackers first
5748
createTrackers()
5849
// Add all collectors

0 commit comments

Comments
 (0)