{"action":"opened","number":63,"pull_request":{"url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/63","id":189162381,"html_url":"https://github.com/segmentio/analytics.js-integration/pull/63","diff_url":"https://github.com/segmentio/analytics.js-integration/pull/63.diff","patch_url":"https://github.com/segmentio/analytics.js-integration/pull/63.patch","issue_url":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/63","number":63,"state":"open","locked":false,"title":".ready: fix behavior when packages fail to load","user":{"login":"calvinfo","id":487539,"avatar_url":"https://avatars0.githubusercontent.com/u/487539?v=4","gravatar_id":"","url":"https://api.github.com/users/calvinfo","html_url":"https://github.com/calvinfo","followers_url":"https://api.github.com/users/calvinfo/followers","following_url":"https://api.github.com/users/calvinfo/following{/other_user}","gists_url":"https://api.github.com/users/calvinfo/gists{/gist_id}","starred_url":"https://api.github.com/users/calvinfo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calvinfo/subscriptions","organizations_url":"https://api.github.com/users/calvinfo/orgs","repos_url":"https://api.github.com/users/calvinfo/repos","events_url":"https://api.github.com/users/calvinfo/events{/privacy}","received_events_url":"https://api.github.com/users/calvinfo/received_events","type":"User","site_admin":false},"body":"Netto brought an error with the Appcues integration up to my\r\nattention. Apparently when the script fails to load, it causes\r\nan exception which bubbles up to the top.\r\n\r\nI looked through the code and was pretty surprised by this, since\r\nthe Appcues integration itself is very few lines of code, and\r\nnothing out of the ordinary.\r\n\r\nWhen I dug in, I realized that this comes from an error where the\r\nAppcues javascript fails to load for some reason.\r\n\r\nWhen that happens here's the sequence of events:\r\n\r\n- segmentio/load-script gets called, and then calls a callback\r\n  with the error\r\n- this in turn calls .ready (in Appcues, but I think also many\r\n  other integrations)\r\n- this emits a ready handler, which then immediately starts\r\n  flushing the message queue, causing an uncaught exception\r\n\r\nThis fix instead causes .ready when called with an error to\r\n_not_ mark the integration as ready. Avoiding further errors.\r\n\r\nThe one thing I'm unsure of here is whether we ever end up calling\r\n.ready() with an argument–my hunch is 'no' given that it wouldn't\r\ndo anything, but it might be worth adding an instanceof Error check.\r\n\r\nThoughts?\r\n\r\nRelevant Appcues code: https://github.com/segment-integrations/analytics.js-integration-appcues/blob/master/lib/index.js#L27-L29","created_at":"2018-05-19T00:52:11Z","updated_at":"2018-05-19T00:52:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/63/commits","review_comments_url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/63/comments","review_comment_url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/comments{/number}","comments_url":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/63/comments","statuses_url":"https://api.github.com/repos/segmentio/analytics.js-integration/statuses/4b02c83ff11f211a7cd97104e1d00e0537b78f64","head":{"label":"segmentio:fix-ajs-ready","ref":"fix-ajs-ready","sha":"4b02c83ff11f211a7cd97104e1d00e0537b78f64","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"repo":{"id":13977006,"name":"analytics.js-integration","full_name":"segmentio/analytics.js-integration","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/segmentio/analytics.js-integration","description":"The base integration factory used to create custom analytics integrations for analytics.js.","fork":false,"url":"https://api.github.com/repos/segmentio/analytics.js-integration","forks_url":"https://api.github.com/repos/segmentio/analytics.js-integration/forks","keys_url":"https://api.github.com/repos/segmentio/analytics.js-integration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/analytics.js-integration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/analytics.js-integration/teams","hooks_url":"https://api.github.com/repos/segmentio/analytics.js-integration/hooks","issue_events_url":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/analytics.js-integration/events","assignees_url":"https://api.github.com/repos/segmentio/analytics.js-integration/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/analytics.js-integration/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/analytics.js-integration/tags","blobs_url":"https://api.github.com/repos/segmentio/analytics.js-integration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/analytics.js-integration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/analytics.js-integration/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/analytics.js-integration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/analytics.js-integration/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/analytics.js-integration/languages","stargazers_url":"https://api.github.com/repos/segmentio/analytics.js-integration/stargazers","contributors_url":"https://api.github.com/repos/segmentio/analytics.js-integration/contributors","subscribers_url":"https://api.github.com/repos/segmentio/analytics.js-integration/subscribers","subscription_url":"https://api.github.com/repos/segmentio/analytics.js-integration/subscription","commits_url":"https://api.github.com/repos/segmentio/analytics.js-integration/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/analytics.js-integration/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/analytics.js-integration/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/analytics.js-integration/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/analytics.js-integration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/analytics.js-integration/merges","archive_url":"https://api.github.com/repos/segmentio/analytics.js-integration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/analytics.js-integration/downloads","issues_url":"https://api.github.com/repos/segmentio/analytics.js-integration/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/analytics.js-integration/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/analytics.js-integration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/analytics.js-integration/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/analytics.js-integration/releases{/id}","deployments_url":"https://api.github.com/repos/segmentio/analytics.js-integration/deployments","created_at":"2013-10-30T04:11:49Z","updated_at":"2018-04-23T22:50:53Z","pushed_at":"2018-05-19T00:51:15Z","git_url":"git://github.com/segmentio/analytics.js-integration.git","ssh_url":"git@github.com:segmentio/analytics.js-integration.git","clone_url":"https://github.com/segmentio/analytics.js-integration.git","svn_url":"https://github.com/segmentio/analytics.js-integration","homepage":null,"size":265,"stargazers_count":26,"watchers_count":26,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":27,"open_issues":3,"watchers":26,"default_branch":"master"}},"base":{"label":"segmentio:master","ref":"master","sha":"9392b72c34ee2446e97e37b737966fde3fee58cb","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"repo":{"id":13977006,"name":"analytics.js-integration","full_name":"segmentio/analytics.js-integration","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/segmentio/analytics.js-integration","description":"The base integration factory used to create custom analytics integrations for analytics.js.","fork":false,"url":"https://api.github.com/repos/segmentio/analytics.js-integration","forks_url":"https://api.github.com/repos/segmentio/analytics.js-integration/forks","keys_url":"https://api.github.com/repos/segmentio/analytics.js-integration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/analytics.js-integration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/analytics.js-integration/teams","hooks_url":"https://api.github.com/repos/segmentio/analytics.js-integration/hooks","issue_events_url":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/analytics.js-integration/events","assignees_url":"https://api.github.com/repos/segmentio/analytics.js-integration/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/analytics.js-integration/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/analytics.js-integration/tags","blobs_url":"https://api.github.com/repos/segmentio/analytics.js-integration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/analytics.js-integration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/analytics.js-integration/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/analytics.js-integration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/analytics.js-integration/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/analytics.js-integration/languages","stargazers_url":"https://api.github.com/repos/segmentio/analytics.js-integration/stargazers","contributors_url":"https://api.github.com/repos/segmentio/analytics.js-integration/contributors","subscribers_url":"https://api.github.com/repos/segmentio/analytics.js-integration/subscribers","subscription_url":"https://api.github.com/repos/segmentio/analytics.js-integration/subscription","commits_url":"https://api.github.com/repos/segmentio/analytics.js-integration/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/analytics.js-integration/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/analytics.js-integration/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/analytics.js-integration/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/analytics.js-integration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/analytics.js-integration/merges","archive_url":"https://api.github.com/repos/segmentio/analytics.js-integration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/analytics.js-integration/downloads","issues_url":"https://api.github.com/repos/segmentio/analytics.js-integration/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/analytics.js-integration/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/analytics.js-integration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/analytics.js-integration/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/analytics.js-integration/releases{/id}","deployments_url":"https://api.github.com/repos/segmentio/analytics.js-integration/deployments","created_at":"2013-10-30T04:11:49Z","updated_at":"2018-04-23T22:50:53Z","pushed_at":"2018-05-19T00:51:15Z","git_url":"git://github.com/segmentio/analytics.js-integration.git","ssh_url":"git@github.com:segmentio/analytics.js-integration.git","clone_url":"https://github.com/segmentio/analytics.js-integration.git","svn_url":"https://github.com/segmentio/analytics.js-integration","homepage":null,"size":265,"stargazers_count":26,"watchers_count":26,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":27,"open_issues":3,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/63"},"html":{"href":"https://github.com/segmentio/analytics.js-integration/pull/63"},"issue":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/63"},"comments":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/statuses/4b02c83ff11f211a7cd97104e1d00e0537b78f64"}},"author_association":"MEMBER","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":26,"deletions":1,"changed_files":2}}
{"actor":{"display_login":"calvinfo"}}