Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue.$segment.user().anonymousId() does not work. #15

Open
slavestys opened this issue Feb 10, 2021 · 2 comments
Open

Vue.$segment.user().anonymousId() does not work. #15

slavestys opened this issue Feb 10, 2021 · 2 comments

Comments

@slavestys
Copy link

Hello! Vue.$segment.user is undefined. Maybe I'm doing something wrong?

@slavestys
Copy link
Author

This is because the method call occurs before initialization analytics.js

@slavestys
Copy link
Author

slavestys commented Feb 10, 2021

This is my solution:

async anonymousUserId() {
    if (Vue.$segment.user) {
      return Vue.$segment.user().anonymousId()
    }

    return new Promise((resolve) => {
      let timerId = setInterval(() => {
        if (Vue.$segment.user) {
          clearInterval(timerId)
          resolve(Vue.$segment.user().anonymousId())
        }
      }, 50)
    })
  }

Maybe there is a better solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant