Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Add analytics.ready(name, fn) function #33

Closed
wants to merge 1 commit into from
Closed

Conversation

f2prateek
Copy link
Contributor

@f2prateek f2prateek commented Feb 22, 2017

See segmentio/analytics.js#409

This adds the ability to set a ready callback per integration.

todo:

[ ] document the function behaviour (need help here on what syntax to use)
[ ] test for already readied integration

@f2prateek f2prateek force-pushed the ready-integration branch 2 times, most recently from 2ff25cb to fd360ba Compare February 22, 2017 01:26
*/

Analytics.prototype.ready = function(a, b) {
if (is.fn(a)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @segmentio/gateway what's the javascript convention here as to how to document this?

@tsholmes I think i've seen some code/PR by you that had this overloaded function behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this would be right:

@param {(Function|String)} a
@param {Function} [b]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rowno any suggestions for naming the parameters? I used a/b coz I couldn't think of anything better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯_(ツ)_/¯ At least add description to the parameters though. e.g:

@param {(Function|String)} a Callback function or integration name.
@param {Function} [b] Callback function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rowno updated

@f2prateek
Copy link
Contributor Author

I think tests are failing with saucelabs (unsure if it's a test error or saucelabs error)? https://circleci.com/api/v1.1/project/github/segmentio/analytics.js-core/156/output/13/0?file=true

22 02 2017 01:30:50.095:WARN [launcher]: internet explorer 7 on SauceLabs have not captured in 60000 ms, killing.
22 02 2017 01:30:50.111:WARN [launcher]: internet explorer 8 on SauceLabs have not captured in 60000 ms, killing.
22 02 2017 01:30:50.271:ERROR [launcher]: internet explorer 7 on SauceLabs failed 2 times (timeout). Giving up.
22 02 2017 01:30:50.290:ERROR [launcher]: internet explorer 8 on SauceLabs failed 2 times (timeout). Giving up.
22 02 2017 01:30:50.293:INFO [launcher.sauce]: Shutting down Sauce Connect
make: *** [test-browser] Error 1

make test returned exit code 2

@tsholmes
Copy link

@f2prateek set the karma deps to (pinned exactly):
"karma": "1.3.0"
"karma-mocha": "1.0.1"

@f2prateek
Copy link
Contributor Author

@tsholmes same issue I think

@f2prateek
Copy link
Contributor Author

@tsholmes reverted the package.json changes, will tackle in a different PR

@f2prateek f2prateek force-pushed the ready-integration branch 3 times, most recently from e4e97c6 to c4cb3df Compare February 24, 2017 18:58
@elgreg
Copy link

elgreg commented Nov 15, 2017

Hi! Would love to have this as I'm experiencing the exact problem outlined in segmentio/analytics.js#488 (comment)

Is this project still active?

@f2prateek
Copy link
Contributor Author

@elgreg yes, analytics.js is used by thousands of companies :)

This particular issue has been on the back burner though. We'll try to pick it back up.

@f2prateek
Copy link
Contributor Author

Added to our internal tracker as well https://segment.atlassian.net/browse/LIB-103.

@elgreg
Copy link

elgreg commented Nov 23, 2017

@f2prateek Ha! Sorry - I was just referring to this particular PR when I asked if the project was still active. I should have been more clear. That's great news about this potentially becoming a feature! We just released our first pass at a conversion to analytics.js and are experiencing the issue referred to by some others where adBlock blocking one integration ends up blocking ready(). I'll follow this issue closely for updates!

See segmentio/analytics.js#409

This adds the ability to set a ready callback per integration.

todo:

* document the function behaviour (need help here on what syntax to use)
* test for already readied integration
@dozoisch
Copy link

dozoisch commented Aug 1, 2019

@f2prateek sorry for resurrecting this. Ran into this today where adblocker blocked 1 integration which prevents from knowing when other integrations had loaded and are ready to use.

@danieljackins
Copy link
Contributor

Closing this PR. If this is still a problem, please reopen so that we can get it properly reprioritized.

@danieljackins danieljackins deleted the ready-integration branch March 5, 2020 23:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants