{"action":"created","comment":{"url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/comments/33014251","id":33014251,"diff_hunk":"@@ -109,30 +125,60 @@ exports.track = function(track){};\n  * // => []\n  */\n \n-exports.map = function(events, event){\n-  var normalizedEvent = normalize(event);\n-\n-  return foldl(function(matchingEvents, val, key, events) {\n-    // If true, this is a `mixed` value, which is structured like so:\n-    //     { key: 'testEvent', value: { event: 'testEvent', someValue: 'xyz' } }\n-    // We need to extract the key, which we use to match against\n-    // `normalizedEvent`, and return `value` as part of `matchingEvents` if that\n-    // match succeds.\n-    if (type(events) === 'array') {\n-      // If there's no key attached to this event mapping (unusual), skip this\n-      // item.\n-      if (!val.key) return matchingEvents;\n-      // Extract the key and value from the `mixed` object.\n-      key = val.key;\n-      val = val.value;\n+exports.map = function(mapping, key){\n+  var normalizedComparator = normalize(key);\n+  var mappingType = getMappingType(mapping);\n+\n+  function getMappingType(mapping) {\n+    if (type(mapping) === 'object' && every(isString, mapping)) return 'map';\n+    if (type(mapping) === 'array' && every(isString, mapping)) return 'array';\n+    if (type(mapping) === 'array' && every(isMixed, mapping)) return 'mixed';\n+    return 'unknown';\n+  }\n+\n+  function isString(item) {\n+    return type(item) === 'string';\n+  }\n+\n+  /* eslint-disable no-extra-parens */\n+  function isMixed(item) {\n+    return (\n+      type(item) === 'object'\n+      && has.call(item, 'key')\n+      && has.call(item, 'value')","path":"lib/protos.js","position":null,"original_position":87,"commit_id":"838b9c4108355d60c316d8d99cb24b240c4c52ed","original_commit_id":"1f781c164aa9d5c7166edbdfa2d5227a91e3bf74","user":{"login":"sperand-io","id":3130232,"avatar_url":"https://avatars.githubusercontent.com/u/3130232?v=3","gravatar_id":"","url":"https://api.github.com/users/sperand-io","html_url":"https://github.com/sperand-io","followers_url":"https://api.github.com/users/sperand-io/followers","following_url":"https://api.github.com/users/sperand-io/following{/other_user}","gists_url":"https://api.github.com/users/sperand-io/gists{/gist_id}","starred_url":"https://api.github.com/users/sperand-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sperand-io/subscriptions","organizations_url":"https://api.github.com/users/sperand-io/orgs","repos_url":"https://api.github.com/users/sperand-io/repos","events_url":"https://api.github.com/users/sperand-io/events{/privacy}","received_events_url":"https://api.github.com/users/sperand-io/received_events","type":"User","site_admin":false},"body":"check and check ","created_at":"2015-06-23T06:57:44Z","updated_at":"2015-06-23T06:57:44Z","html_url":"https://github.com/segmentio/analytics.js-integration/pull/45#discussion_r33014251","pull_request_url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/45","_links":{"self":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/comments/33014251"},"html":{"href":"https://github.com/segmentio/analytics.js-integration/pull/45#discussion_r33014251"},"pull_request":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/45"}}},"pull_request":{"url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/45","id":37317103,"html_url":"https://github.com/segmentio/analytics.js-integration/pull/45","diff_url":"https://github.com/segmentio/analytics.js-integration/pull/45.diff","patch_url":"https://github.com/segmentio/analytics.js-integration/pull/45.patch","issue_url":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/45","number":45,"state":"open","locked":false,"title":"Integration.prototype.map — add support for array type","user":{"login":"sperand-io","id":3130232,"avatar_url":"https://avatars.githubusercontent.com/u/3130232?v=3","gravatar_id":"","url":"https://api.github.com/users/sperand-io","html_url":"https://github.com/sperand-io","followers_url":"https://api.github.com/users/sperand-io/followers","following_url":"https://api.github.com/users/sperand-io/following{/other_user}","gists_url":"https://api.github.com/users/sperand-io/gists{/gist_id}","starred_url":"https://api.github.com/users/sperand-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sperand-io/subscriptions","organizations_url":"https://api.github.com/users/sperand-io/orgs","repos_url":"https://api.github.com/users/sperand-io/repos","events_url":"https://api.github.com/users/sperand-io/events{/privacy}","received_events_url":"https://api.github.com/users/sperand-io/received_events","type":"User","site_admin":false},"body":"More craziness around the `.map` prototype method — it was not well documented or thoroughly tested at the outset; couple that with the multitude of \"mappable\" data types and we hit a few snags when refactoring in 4fd8c4170bfd74e497cdfa3bd2dbfb038ac3fede\r\n\r\nThis PR adds back support for mapping basic **arrays of strings**, a structure used in metadata to store conversion events for such integrations as Steelhouse:\r\n\r\n![](https://cloudup.com/cLVpr5rvF0F+)\r\n\r\n@ndhoule \r\n\r\n","created_at":"2015-06-10T01:33:26Z","updated_at":"2015-06-23T06:57:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8d14185d702c66fd0b300a57a976a7ed37da641e","assignee":{"login":"sperand-io","id":3130232,"avatar_url":"https://avatars.githubusercontent.com/u/3130232?v=3","gravatar_id":"","url":"https://api.github.com/users/sperand-io","html_url":"https://github.com/sperand-io","followers_url":"https://api.github.com/users/sperand-io/followers","following_url":"https://api.github.com/users/sperand-io/following{/other_user}","gists_url":"https://api.github.com/users/sperand-io/gists{/gist_id}","starred_url":"https://api.github.com/users/sperand-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sperand-io/subscriptions","organizations_url":"https://api.github.com/users/sperand-io/orgs","repos_url":"https://api.github.com/users/sperand-io/repos","events_url":"https://api.github.com/users/sperand-io/events{/privacy}","received_events_url":"https://api.github.com/users/sperand-io/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/45/commits","review_comments_url":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/45/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/45/comments","statuses_url":"https://api.github.com/repos/segmentio/analytics.js-integration/statuses/838b9c4108355d60c316d8d99cb24b240c4c52ed","head":{"label":"segmentio:map/array","ref":"map/array","sha":"838b9c4108355d60c316d8d99cb24b240c4c52ed","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":13977006,"name":"analytics.js-integration","full_name":"segmentio/analytics.js-integration","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-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}","created_at":"2013-10-30T04:11:49Z","updated_at":"2015-02-13T00:45:28Z","pushed_at":"2015-06-23T06:56:01Z","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":954,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":7,"forks":6,"open_issues":7,"watchers":5,"default_branch":"master"}},"base":{"label":"segmentio:master","ref":"master","sha":"2b6154fa0612861dc5b7c416141db059a91368ec","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":13977006,"name":"analytics.js-integration","full_name":"segmentio/analytics.js-integration","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-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}","created_at":"2013-10-30T04:11:49Z","updated_at":"2015-02-13T00:45:28Z","pushed_at":"2015-06-23T06:56:01Z","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":954,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":7,"forks":6,"open_issues":7,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/45"},"html":{"href":"https://github.com/segmentio/analytics.js-integration/pull/45"},"issue":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/45"},"comments":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/pulls/45/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/45/commits"},"statuses":{"href":"https://api.github.com/repos/segmentio/analytics.js-integration/statuses/838b9c4108355d60c316d8d99cb24b240c4c52ed"}}}}