{"action":"created","comment":{"url":"https://api.github.com/repos/segmentio/analytics.js/pulls/comments/24925631","id":24925631,"diff_hunk":"@@ -0,0 +1,90 @@\n+\n+/**\n+ * Module Dependencies.\n+ */\n+\n+var indexof = require('component/indexof');\n+var defaults = require('defaults');\n+var map = require('component/map');\n+var each = require('each');\n+var is = require('is');\n+\n+/**\n+ * Expose `normalize`\n+ */\n+\n+module.exports = normalize;\n+\n+/**\n+ * Toplevel properties.\n+ */\n+\n+var toplevel = [\n+  'integrations',\n+  'anonymousId',\n+  'properties',\n+  'previousId',\n+  'timestamp',\n+  'category',\n+  'context',\n+  'groupId',\n+  'userId',\n+  'traits',\n+  'event',\n+  'name'\n+];\n+\n+/**\n+ * Normalize `msg` based on integrations `list`.\n+ *\n+ * @param {Object} msg\n+ * @param {Array} list\n+ * @return {Function}\n+ */\n+\n+function normalize(msg, list){\n+  var lower = map(list, function(s){ return s.toLowerCase(); });\n+  var opts = msg.options || {};\n+  var integrations = opts.integrations || {};\n+  var providers = opts.providers || {};\n+  var context = opts.context || {};\n+  var ret = {};\n+\n+  // integrations.\n+  each(opts, function(key, value){\n+    if (!integration(key)) return;\n+    integrations[key] = value;\n+    delete opts[key];\n+  });\n+\n+  // providers.\n+  delete opts.providers;\n+  each(providers, function(key, value){\n+    if (!integration(key)) return;\n+    if (is.object(integrations[key])) return;","path":"lib/normalize.js","position":64,"original_position":64,"commit_id":"d12e423d1fad563b9cd007f6f4247dc78189fd38","original_commit_id":"47736e5dbb5071a9558a3cfc5e8c913979d9b5e4","user":{"login":"ianstormtaylor","id":311752,"avatar_url":"https://avatars.githubusercontent.com/u/311752?v=3","gravatar_id":"","url":"https://api.github.com/users/ianstormtaylor","html_url":"https://github.com/ianstormtaylor","followers_url":"https://api.github.com/users/ianstormtaylor/followers","following_url":"https://api.github.com/users/ianstormtaylor/following{/other_user}","gists_url":"https://api.github.com/users/ianstormtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/ianstormtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianstormtaylor/subscriptions","organizations_url":"https://api.github.com/users/ianstormtaylor/orgs","repos_url":"https://api.github.com/users/ianstormtaylor/repos","events_url":"https://api.github.com/users/ianstormtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/ianstormtaylor/received_events","type":"User","site_admin":false},"body":"Ah I guess I was thinking the logic we want is:\r\n\r\n- if there's something top-level that's an integration, move it to `integrations`, but don't clobber.\r\n- if there's something in `providers`, move it to `integrations`, but don't clobber.\r\n\r\nBut then it seems like this case clobbers if `integrations.integration = true` and `providers.integrations = {}`? Which might get more confusing in odd cases, whereas we could go with the simpler \"move but don't clobber\" logic everywhere instead?\r\n\r\nI also might be missing something haha\r\n\r\n","created_at":"2015-02-18T18:21:33Z","updated_at":"2015-02-18T18:21:33Z","html_url":"https://github.com/segmentio/analytics.js/pull/432#discussion_r24925631","pull_request_url":"https://api.github.com/repos/segmentio/analytics.js/pulls/432","_links":{"self":{"href":"https://api.github.com/repos/segmentio/analytics.js/pulls/comments/24925631"},"html":{"href":"https://github.com/segmentio/analytics.js/pull/432#discussion_r24925631"},"pull_request":{"href":"https://api.github.com/repos/segmentio/analytics.js/pulls/432"}}},"pull_request":{"url":"https://api.github.com/repos/segmentio/analytics.js/pulls/432","id":29429476,"html_url":"https://github.com/segmentio/analytics.js/pull/432","diff_url":"https://github.com/segmentio/analytics.js/pull/432.diff","patch_url":"https://github.com/segmentio/analytics.js/pull/432.patch","issue_url":"https://api.github.com/repos/segmentio/analytics.js/issues/432","number":432,"state":"open","locked":false,"title":"Normalize","user":{"login":"yields","id":1661587,"avatar_url":"https://avatars.githubusercontent.com/u/1661587?v=3","gravatar_id":"","url":"https://api.github.com/users/yields","html_url":"https://github.com/yields","followers_url":"https://api.github.com/users/yields/followers","following_url":"https://api.github.com/users/yields/following{/other_user}","gists_url":"https://api.github.com/users/yields/gists{/gist_id}","starred_url":"https://api.github.com/users/yields/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yields/subscriptions","organizations_url":"https://api.github.com/users/yields/orgs","repos_url":"https://api.github.com/users/yields/repos","events_url":"https://api.github.com/users/yields/events{/privacy}","received_events_url":"https://api.github.com/users/yields/received_events","type":"User","site_admin":false},"body":"cc @ianstormtaylor @calvinfo ","created_at":"2015-02-17T09:57:43Z","updated_at":"2015-02-18T18:21:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5c3f983cc1155766fe8198274f61ef057c066914","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/segmentio/analytics.js/pulls/432/commits","review_comments_url":"https://api.github.com/repos/segmentio/analytics.js/pulls/432/comments","review_comment_url":"https://api.github.com/repos/segmentio/analytics.js/pulls/comments/{number}","comments_url":"https://api.github.com/repos/segmentio/analytics.js/issues/432/comments","statuses_url":"https://api.github.com/repos/segmentio/analytics.js/statuses/d12e423d1fad563b9cd007f6f4247dc78189fd38","head":{"label":"segmentio:normalize","ref":"normalize","sha":"d12e423d1fad563b9cd007f6f4247dc78189fd38","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","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":4697589,"name":"analytics.js","full_name":"segmentio/analytics.js","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","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","description":"The hassle-free way to integrate analytics into any web application.","fork":false,"url":"https://api.github.com/repos/segmentio/analytics.js","forks_url":"https://api.github.com/repos/segmentio/analytics.js/forks","keys_url":"https://api.github.com/repos/segmentio/analytics.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/analytics.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/analytics.js/teams","hooks_url":"https://api.github.com/repos/segmentio/analytics.js/hooks","issue_events_url":"https://api.github.com/repos/segmentio/analytics.js/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/analytics.js/events","assignees_url":"https://api.github.com/repos/segmentio/analytics.js/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/analytics.js/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/analytics.js/tags","blobs_url":"https://api.github.com/repos/segmentio/analytics.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/analytics.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/analytics.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/analytics.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/analytics.js/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/analytics.js/languages","stargazers_url":"https://api.github.com/repos/segmentio/analytics.js/stargazers","contributors_url":"https://api.github.com/repos/segmentio/analytics.js/contributors","subscribers_url":"https://api.github.com/repos/segmentio/analytics.js/subscribers","subscription_url":"https://api.github.com/repos/segmentio/analytics.js/subscription","commits_url":"https://api.github.com/repos/segmentio/analytics.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/analytics.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/analytics.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/analytics.js/issues/comments/{number}","contents_url":"https://api.github.com/repos/segmentio/analytics.js/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/analytics.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/analytics.js/merges","archive_url":"https://api.github.com/repos/segmentio/analytics.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/analytics.js/downloads","issues_url":"https://api.github.com/repos/segmentio/analytics.js/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/analytics.js/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/analytics.js/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/analytics.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/analytics.js/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/analytics.js/releases{/id}","created_at":"2012-06-18T05:38:24Z","updated_at":"2015-02-18T13:22:19Z","pushed_at":"2015-02-18T06:17:43Z","git_url":"git://github.com/segmentio/analytics.js.git","ssh_url":"git@github.com:segmentio/analytics.js.git","clone_url":"https://github.com/segmentio/analytics.js.git","svn_url":"https://github.com/segmentio/analytics.js","homepage":"https://segment.io/libraries/analytics.js","size":15069,"stargazers_count":2866,"watchers_count":2866,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":314,"mirror_url":null,"open_issues_count":52,"forks":314,"open_issues":52,"watchers":2866,"default_branch":"master"}},"base":{"label":"segmentio:master","ref":"master","sha":"02d00b352747c4ca1eef2121c7dadf0be96ae329","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","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":4697589,"name":"analytics.js","full_name":"segmentio/analytics.js","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars.githubusercontent.com/u/819518?v=3","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","description":"The hassle-free way to integrate analytics into any web application.","fork":false,"url":"https://api.github.com/repos/segmentio/analytics.js","forks_url":"https://api.github.com/repos/segmentio/analytics.js/forks","keys_url":"https://api.github.com/repos/segmentio/analytics.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/analytics.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/analytics.js/teams","hooks_url":"https://api.github.com/repos/segmentio/analytics.js/hooks","issue_events_url":"https://api.github.com/repos/segmentio/analytics.js/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/analytics.js/events","assignees_url":"https://api.github.com/repos/segmentio/analytics.js/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/analytics.js/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/analytics.js/tags","blobs_url":"https://api.github.com/repos/segmentio/analytics.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/analytics.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/analytics.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/analytics.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/analytics.js/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/analytics.js/languages","stargazers_url":"https://api.github.com/repos/segmentio/analytics.js/stargazers","contributors_url":"https://api.github.com/repos/segmentio/analytics.js/contributors","subscribers_url":"https://api.github.com/repos/segmentio/analytics.js/subscribers","subscription_url":"https://api.github.com/repos/segmentio/analytics.js/subscription","commits_url":"https://api.github.com/repos/segmentio/analytics.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/analytics.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/analytics.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/analytics.js/issues/comments/{number}","contents_url":"https://api.github.com/repos/segmentio/analytics.js/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/analytics.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/analytics.js/merges","archive_url":"https://api.github.com/repos/segmentio/analytics.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/analytics.js/downloads","issues_url":"https://api.github.com/repos/segmentio/analytics.js/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/analytics.js/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/analytics.js/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/analytics.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/analytics.js/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/analytics.js/releases{/id}","created_at":"2012-06-18T05:38:24Z","updated_at":"2015-02-18T13:22:19Z","pushed_at":"2015-02-18T06:17:43Z","git_url":"git://github.com/segmentio/analytics.js.git","ssh_url":"git@github.com:segmentio/analytics.js.git","clone_url":"https://github.com/segmentio/analytics.js.git","svn_url":"https://github.com/segmentio/analytics.js","homepage":"https://segment.io/libraries/analytics.js","size":15069,"stargazers_count":2866,"watchers_count":2866,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":314,"mirror_url":null,"open_issues_count":52,"forks":314,"open_issues":52,"watchers":2866,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/segmentio/analytics.js/pulls/432"},"html":{"href":"https://github.com/segmentio/analytics.js/pull/432"},"issue":{"href":"https://api.github.com/repos/segmentio/analytics.js/issues/432"},"comments":{"href":"https://api.github.com/repos/segmentio/analytics.js/issues/432/comments"},"review_comments":{"href":"https://api.github.com/repos/segmentio/analytics.js/pulls/432/comments"},"review_comment":{"href":"https://api.github.com/repos/segmentio/analytics.js/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/segmentio/analytics.js/pulls/432/commits"},"statuses":{"href":"https://api.github.com/repos/segmentio/analytics.js/statuses/d12e423d1fad563b9cd007f6f4247dc78189fd38"}}}}