Git Product home page Git Product logo

Comments (11)

ianstormtaylor avatar ianstormtaylor commented on August 27, 2024

realized its not that simple, because you have multiple providers you'd need to wait for. if you didn't wait, there's no point in it being a callback because it would just be synchronous.. if you did, well that get's real complex but is possible for each service that does have callbacks only...

from analytics.js.

jsalonen avatar jsalonen commented on August 27, 2024

Here are my two cents:

  • Check if track function has third callback argument
  • If a service provider supports callbacks, pass that function
  • If a service provider doesn't support callbacks, simply call it right afterwards

Not of course an optimal solution, but IMHO better than nothing.

from analytics.js.

afeld avatar afeld commented on August 27, 2024

It should use a Promise (or the callback counter equivalent) to execute the callback after all have finished. For services that don't support callbacks, I'd say executing the callback immediately is fine, or setting a short timeout since that's what the user will probably be doing anyway. Adding a disclaimer to the README about those services should be sufficient.

from analytics.js.

ianstormtaylor avatar ianstormtaylor commented on August 27, 2024

I was thinking a really basic implementation could not even care about the services themselves and put any callback behind a ~100ms timeout. (The kind of solution that Mixpanel and KISSmetrics use for their link tracking, click tracking and form tracking helpers.)

from analytics.js.

afeld avatar afeld commented on August 27, 2024

Safest would certainly be to use their callbacks, but if that's what they're doing in their libraries anyway, maybe it isn't worth the hassle.

from analytics.js.

ianstormtaylor avatar ianstormtaylor commented on August 27, 2024

I'm not sure it's "safest" to use their callbacks, or at least I don't know what you mean by safest. But you could make a good argument for fastest (depending on their servers). Even with using their callbacks though, I think there should be a maximum timeout to prevent the callback from never firing if the servers are down... (Which I assume these services are implementing internally... but you never know. Seen some crazy stuff :p)

from analytics.js.

afeld avatar afeld commented on August 27, 2024

...or from calling it too soon. I wonder which of the providers execute the callbacks only on success, and which handle response errors, and which set a timeout to ensure the callback is always executed. With only a single callback, I'm not sure which would be preferable? I guess the timeout would be easiest because then it's somewhat normalized across the providers, no matter what they offer.

from analytics.js.

ianstormtaylor avatar ianstormtaylor commented on August 27, 2024

Added these in with a default timeout length.

from analytics.js.

philfreo avatar philfreo commented on August 27, 2024

This feature is great, but you should probably document it on http://segmentio.github.com/analytics.js/

from analytics.js.

ianstormtaylor avatar ianstormtaylor commented on August 27, 2024

New documentation is in the works! Should be released tomorrow, stay tuned

from analytics.js.

jsalonen avatar jsalonen commented on August 27, 2024

Guys: thanks a lot for implementing this!

from analytics.js.

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.