{"action":"created","comment":{"url":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/comments/35447542","id":35447542,"diff_hunk":"@@ -112,14 +113,30 @@ function common(facade){\n   if (facade.city()) ret.city = facade.city();\n   if (facade.region()) ret.region = facade.region();\n \n-  if (os && os.toLowerCase() == 'ios') {\n+  function mobileDeviceType(){\n+    if (!library && !os) return 'unknown';\n+    if (contains('ios')) return 'ios';\n+    if (contains('android')) return 'android';\n+    return 'unknown';\n+\n+    function contains(str) {\n+      return getField(library).toLowerCase().indexOf(str) !== -1\n+          || getField(os).toLowerCase().indexOf(str) !== -1;\n+    }\n+\n+    function getField(field) {\n+      return typeof field === 'string' ? field : field.name;\n+    }","path":"lib/mapper.js","position":26,"original_position":26,"commit_id":"b77b0e20038b67e36b06a7cc01d64ce760eb93be","original_commit_id":"b77b0e20038b67e36b06a7cc01d64ce760eb93be","user":{"login":"ndhoule","id":1863990,"avatar_url":"https://avatars.githubusercontent.com/u/1863990?v=3","gravatar_id":"","url":"https://api.github.com/users/ndhoule","html_url":"https://github.com/ndhoule","followers_url":"https://api.github.com/users/ndhoule/followers","following_url":"https://api.github.com/users/ndhoule/following{/other_user}","gists_url":"https://api.github.com/users/ndhoule/gists{/gist_id}","starred_url":"https://api.github.com/users/ndhoule/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndhoule/subscriptions","organizations_url":"https://api.github.com/users/ndhoule/orgs","repos_url":"https://api.github.com/users/ndhoule/repos","events_url":"https://api.github.com/users/ndhoule/events{/privacy}","received_events_url":"https://api.github.com/users/ndhoule/received_events","type":"User","site_admin":false},"body":"Same with both of these, except they're being reconstructed twice per invocation of `mobileDeviceType`","created_at":"2015-07-24T17:50:44Z","updated_at":"2015-07-24T17:50:44Z","html_url":"https://github.com/segmentio/integration-amplitude/pull/6#discussion_r35447542","pull_request_url":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/comments/35447542"},"html":{"href":"https://github.com/segmentio/integration-amplitude/pull/6#discussion_r35447542"},"pull_request":{"href":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/6","id":40732881,"html_url":"https://github.com/segmentio/integration-amplitude/pull/6","diff_url":"https://github.com/segmentio/integration-amplitude/pull/6.diff","patch_url":"https://github.com/segmentio/integration-amplitude/pull/6.patch","issue_url":"https://api.github.com/repos/segmentio/integration-amplitude/issues/6","number":6,"state":"open","locked":false,"title":"Fix/adid","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":"The key here is that we're now also checking `context.library`, not just `context.os`, to discern device type. not sure why `os.name` would ever be missing, but have seen it in certain cases. Also, we generally use library over OS in other integrations / at the API level for this.\r\n\r\n![](https://cloudup.com/chROxGUukja+)\r\n\r\nthis exercise also uncovered an issue in a test! (hence second commit, separate for clarity)\r\n\r\n@f2prateek @ndhoule ","created_at":"2015-07-24T00:32:46Z","updated_at":"2015-07-24T17:50:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fa2bbde92e16116e89d970ce2c86a2174f32cb47","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/6/commits","review_comments_url":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/6/comments","review_comment_url":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/comments{/number}","comments_url":"https://api.github.com/repos/segmentio/integration-amplitude/issues/6/comments","statuses_url":"https://api.github.com/repos/segmentio/integration-amplitude/statuses/b77b0e20038b67e36b06a7cc01d64ce760eb93be","head":{"label":"segmentio:fix/adid","ref":"fix/adid","sha":"b77b0e20038b67e36b06a7cc01d64ce760eb93be","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":26639832,"name":"integration-amplitude","full_name":"segmentio/integration-amplitude","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/integration-amplitude","description":"Amplitude server-side integration","fork":false,"url":"https://api.github.com/repos/segmentio/integration-amplitude","forks_url":"https://api.github.com/repos/segmentio/integration-amplitude/forks","keys_url":"https://api.github.com/repos/segmentio/integration-amplitude/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/integration-amplitude/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/integration-amplitude/teams","hooks_url":"https://api.github.com/repos/segmentio/integration-amplitude/hooks","issue_events_url":"https://api.github.com/repos/segmentio/integration-amplitude/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/integration-amplitude/events","assignees_url":"https://api.github.com/repos/segmentio/integration-amplitude/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/integration-amplitude/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/integration-amplitude/tags","blobs_url":"https://api.github.com/repos/segmentio/integration-amplitude/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/integration-amplitude/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/integration-amplitude/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/integration-amplitude/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/integration-amplitude/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/integration-amplitude/languages","stargazers_url":"https://api.github.com/repos/segmentio/integration-amplitude/stargazers","contributors_url":"https://api.github.com/repos/segmentio/integration-amplitude/contributors","subscribers_url":"https://api.github.com/repos/segmentio/integration-amplitude/subscribers","subscription_url":"https://api.github.com/repos/segmentio/integration-amplitude/subscription","commits_url":"https://api.github.com/repos/segmentio/integration-amplitude/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/integration-amplitude/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/integration-amplitude/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/integration-amplitude/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/integration-amplitude/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/integration-amplitude/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/integration-amplitude/merges","archive_url":"https://api.github.com/repos/segmentio/integration-amplitude/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/integration-amplitude/downloads","issues_url":"https://api.github.com/repos/segmentio/integration-amplitude/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/integration-amplitude/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/integration-amplitude/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/integration-amplitude/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/integration-amplitude/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/integration-amplitude/releases{/id}","created_at":"2014-11-14T13:31:36Z","updated_at":"2015-06-30T22:43:36Z","pushed_at":"2015-07-24T00:32:46Z","git_url":"git://github.com/segmentio/integration-amplitude.git","ssh_url":"git@github.com:segmentio/integration-amplitude.git","clone_url":"https://github.com/segmentio/integration-amplitude.git","svn_url":"https://github.com/segmentio/integration-amplitude","homepage":"segment.com","size":319,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"segmentio:master","ref":"master","sha":"21b8d2062bcc614dd5d377a736e62a6f6cbfbc2f","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":26639832,"name":"integration-amplitude","full_name":"segmentio/integration-amplitude","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/integration-amplitude","description":"Amplitude server-side integration","fork":false,"url":"https://api.github.com/repos/segmentio/integration-amplitude","forks_url":"https://api.github.com/repos/segmentio/integration-amplitude/forks","keys_url":"https://api.github.com/repos/segmentio/integration-amplitude/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/integration-amplitude/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/integration-amplitude/teams","hooks_url":"https://api.github.com/repos/segmentio/integration-amplitude/hooks","issue_events_url":"https://api.github.com/repos/segmentio/integration-amplitude/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/integration-amplitude/events","assignees_url":"https://api.github.com/repos/segmentio/integration-amplitude/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/integration-amplitude/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/integration-amplitude/tags","blobs_url":"https://api.github.com/repos/segmentio/integration-amplitude/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/integration-amplitude/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/integration-amplitude/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/integration-amplitude/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/integration-amplitude/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/integration-amplitude/languages","stargazers_url":"https://api.github.com/repos/segmentio/integration-amplitude/stargazers","contributors_url":"https://api.github.com/repos/segmentio/integration-amplitude/contributors","subscribers_url":"https://api.github.com/repos/segmentio/integration-amplitude/subscribers","subscription_url":"https://api.github.com/repos/segmentio/integration-amplitude/subscription","commits_url":"https://api.github.com/repos/segmentio/integration-amplitude/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/integration-amplitude/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/integration-amplitude/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/integration-amplitude/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/integration-amplitude/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/integration-amplitude/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/integration-amplitude/merges","archive_url":"https://api.github.com/repos/segmentio/integration-amplitude/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/integration-amplitude/downloads","issues_url":"https://api.github.com/repos/segmentio/integration-amplitude/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/integration-amplitude/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/integration-amplitude/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/integration-amplitude/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/integration-amplitude/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/integration-amplitude/releases{/id}","created_at":"2014-11-14T13:31:36Z","updated_at":"2015-06-30T22:43:36Z","pushed_at":"2015-07-24T00:32:46Z","git_url":"git://github.com/segmentio/integration-amplitude.git","ssh_url":"git@github.com:segmentio/integration-amplitude.git","clone_url":"https://github.com/segmentio/integration-amplitude.git","svn_url":"https://github.com/segmentio/integration-amplitude","homepage":"segment.com","size":319,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/6"},"html":{"href":"https://github.com/segmentio/integration-amplitude/pull/6"},"issue":{"href":"https://api.github.com/repos/segmentio/integration-amplitude/issues/6"},"comments":{"href":"https://api.github.com/repos/segmentio/integration-amplitude/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/segmentio/integration-amplitude/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/segmentio/integration-amplitude/statuses/b77b0e20038b67e36b06a7cc01d64ce760eb93be"}}}}