Giter VIP home page Giter VIP logo

Comments (2)

william-will-angi avatar william-will-angi commented on September 18, 2024

We are following step 2a of this doc:
https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2a-add-the-segment-snippet

It says to include an inline script which creates a window.analytics object that has a number of different methods on it, but it doesn't include user,

My understanding is that this is meant as a temporary queue so that you can call analytics methods while the request for the segment script is in flight. If a user has an ad blocker enabled though, the request to segment is blocked, meaning window.analytics is defined from the inline script but it will not have the user method available. Which means when we try to call the method user(), we get a run time error.

Now we first check for the existence of user on the analytics object before calling it, but we have to ignore the typescript definition since the compiler thinks it's always defined.

from analytics-next.

silesky avatar silesky commented on September 18, 2024

@william-will-angi Apologies, I deleted my comment and reopened the issue that you responded immediately after I posted it, when I double checked and realized that user is not one of the buffered methods on the list -- didn't mean for you to see it (but I assume you got notified). You're correct.

On npm (AnalyticsBrowser), user is always defined and returns a promise, but not in the snippet -- a bit confusing. Unifying the api is something I'm noodling on.

from analytics-next.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.