GitHub PullRequestReviewCommentEvent at 2014-12-19 04:06:17
Repository: bugsnag-android
Actor: snmaynard
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/comments/22089054","id":22089054,"diff_hunk":"@@ -0,0 +1,125 @@\n+package com.bugsnag.android;\n+\n+import android.content.Context;\n+import android.content.pm.ApplicationInfo;;\n+import android.content.pm.PackageManager;\n+\n+/**\n+ * Information about the running Android app which doesn't change over time,\n+ * including app name, version and release stage.\n+ *\n+ * App information in this class is cached during construction for faster\n+ * subsequent lookups and to reduce GC overhead.\n+ */\n+class AppData implements JsonStream.Streamable {\n+    private Configuration config;\n+    private Context appContext;\n+\n+    private String packageName;\n+    private String appName;\n+    private Integer versionCode;\n+    private String versionName;\n+    private String releaseStage;\n+\n+    AppData(Context appContext, Configuration config) {\n+        this.config = config;\n+        this.appContext = appContext;\n+\n+        packageName = getPackageName();\n+        appName = getAppName();\n+        versionCode = getVersionCode();\n+        versionName = getVersionName();\n+        releaseStage = getReleaseStage();\n+    }\n+\n+    public void toStream(JsonStream writer) {\n+        writer.beginObject();\n+            writer.name(\"id\").value(packageName);\n+            writer.name(\"name\").value(appName);\n+            writer.name(\"packageName\").value(packageName);\n+            writer.name(\"versionName\").value(versionName);\n+            writer.name(\"versionCode\").value(versionCode);\n+\n+            // Prefer user-configured appVersion\n+            if(config.appVersion != null) {\n+                writer.name(\"version\").value(config.appVersion);\n+            } else {\n+                writer.name(\"version\").value(versionName);\n+            }\n+\n+            // Prefer user-configured releaseStage\n+            if(config.releaseStage != null) {\n+                writer.name(\"releaseStage\").value(config.releaseStage);\n+            } else {\n+                writer.name(\"releaseStage\").value(releaseStage);\n+            }\n+\n+        writer.endObject();\n+    }\n+\n+    /**\n+     * The package name of the running Android app, eg: com.example.myapp\n+     */\n+    public String getPackageName() {\n+        return appContext.getPackageName();\n+    }\n+\n+    /**\n+     * The name of the running Android app, from android:label in\n+     * AndroidManifest.xml\n+     */\n+    public String getAppName() {\n+        try {\n+            PackageManager packageManager = appContext.getPackageManager();\n+            ApplicationInfo appInfo = packageManager.getApplicationInfo(packageName, 0);\n+\n+            return (String)packageManager.getApplicationLabel(appInfo);\n+        } catch (PackageManager.NameNotFoundException e) {\n+            Logger.warn(\"Could not get app name\");\n+        }\n+\n+        return null;\n+    }\n+\n+    /**\n+     * The version code of the running Android app, from android:versionCode\n+     * in AndroidManifest.xml\n+     */\n+    public Integer getVersionCode() {\n+        try {\n+            return appContext.getPackageManager().getPackageInfo(packageName, 0).versionCode;\n+        } catch (PackageManager.NameNotFoundException e) {\n+            Logger.warn(\"Could not get versionCode\");\n+        }\n+        return null;\n+    }\n+\n+    /**\n+     * The version code of the running Android app, from android:versionName\n+     * in AndroidManifest.xml\n+     */\n+    public String getVersionName() {\n+        try {\n+            return appContext.getPackageManager().getPackageInfo(packageName, 0).versionName;\n+        } catch (PackageManager.NameNotFoundException e) {\n+            Logger.warn(\"Could not get versionName\");\n+        }\n+        return null;\n+    }\n+\n+    /**\n+     * Guess the release stage of the running Android app by checking the\n+     * android:debuggable flag from AndroidManifest.xml\n+     */\n+    public String getReleaseStage() {","path":"src/main/java/com/bugsnag/android/AppData.java","position":114,"original_position":114,"commit_id":"87842caf91e78f32cabf7236cfd83fb6652113a5","original_commit_id":"87842caf91e78f32cabf7236cfd83fb6652113a5","user":{"login":"snmaynard","id":829837,"avatar_url":"https://avatars.githubusercontent.com/u/829837?v=3","gravatar_id":"","url":"https://api.github.com/users/snmaynard","html_url":"https://github.com/snmaynard","followers_url":"https://api.github.com/users/snmaynard/followers","following_url":"https://api.github.com/users/snmaynard/following{/other_user}","gists_url":"https://api.github.com/users/snmaynard/gists{/gist_id}","starred_url":"https://api.github.com/users/snmaynard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snmaynard/subscriptions","organizations_url":"https://api.github.com/users/snmaynard/orgs","repos_url":"https://api.github.com/users/snmaynard/repos","events_url":"https://api.github.com/users/snmaynard/events{/privacy}","received_events_url":"https://api.github.com/users/snmaynard/received_events","type":"User","site_admin":false},"body":"Could this not return config.releaseStage if it isnt null? It just feels weird for that code to be in here and also Diagnostics","created_at":"2014-12-19T04:06:17Z","updated_at":"2014-12-19T04:06:17Z","html_url":"https://github.com/bugsnag/bugsnag-android/pull/35#discussion_r22089054","pull_request_url":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/comments/22089054"},"html":{"href":"https://github.com/bugsnag/bugsnag-android/pull/35#discussion_r22089054"},"pull_request":{"href":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/35","id":25251975,"html_url":"https://github.com/bugsnag/bugsnag-android/pull/35","diff_url":"https://github.com/bugsnag/bugsnag-android/pull/35.diff","patch_url":"https://github.com/bugsnag/bugsnag-android/pull/35.patch","issue_url":"https://api.github.com/repos/bugsnag/bugsnag-android/issues/35","number":35,"state":"open","locked":false,"title":"V3","user":{"login":"loopj","id":104009,"avatar_url":"https://avatars.githubusercontent.com/u/104009?v=3","gravatar_id":"","url":"https://api.github.com/users/loopj","html_url":"https://github.com/loopj","followers_url":"https://api.github.com/users/loopj/followers","following_url":"https://api.github.com/users/loopj/following{/other_user}","gists_url":"https://api.github.com/users/loopj/gists{/gist_id}","starred_url":"https://api.github.com/users/loopj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loopj/subscriptions","organizations_url":"https://api.github.com/users/loopj/orgs","repos_url":"https://api.github.com/users/loopj/repos","events_url":"https://api.github.com/users/loopj/events{/privacy}","received_events_url":"https://api.github.com/users/loopj/received_events","type":"User","site_admin":false},"body":"# Bugsnag Android v3\r\n\r\n## What's New\r\n-   Thread-state collection (technically this was in the last v2 release but never announced)\r\n-   Fixed app name detection (was broken in v2)\r\n-   Easier \"top activity\" tracking\r\n-   Device brand information is now collected (eg. \"Samsung\")\r\n-   SSL is now enabled by default\r\n-   `MetaData` is now easier to use\r\n-   Reduced memory usage, using lazy-loading and streaming\r\n-   Removed dependency on `bugsnag-java`\r\n-   Uses Android's [new build system](http://tools.android.com/tech-docs/new-build-system) (gradle based)\r\n-   Added tests (a lot of them)\r\n-   Tests automatically run on Travis on multiple Android versions\r\n\r\n## Notes\r\n-   Some methods have changed or been removed\r\n-   ActivityStack/BugsnagActivity no longer exist\r\n-   Top activity/context tracking now requires `GET_TASKS` (or android 5+)\r\n-   We no longer generate a UUID for the default user id (to avoid a\r\n    strictmode violation), instead we use `Settings.Secure.ANDROID_ID` which\r\n    is now considered stable enough to use\r\n\r\n## TODO\r\n-   Check if having both .jar and .aar on maven central is ok\r\n-   Check installation in a normal app via maven\r\n-   Check installation in a nromal app via gradle\r\n-   Check installation in a normal app via jar","created_at":"2014-12-01T07:46:37Z","updated_at":"2014-12-19T04:06:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eead11d03d5a3eb9fd997f9f9e459dfc13e8dd0a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/35/commits","review_comments_url":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/35/comments","review_comment_url":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/comments/{number}","comments_url":"https://api.github.com/repos/bugsnag/bugsnag-android/issues/35/comments","statuses_url":"https://api.github.com/repos/bugsnag/bugsnag-android/statuses/87842caf91e78f32cabf7236cfd83fb6652113a5","head":{"label":"bugsnag:v3","ref":"v3","sha":"87842caf91e78f32cabf7236cfd83fb6652113a5","user":{"login":"bugsnag","id":1058895,"avatar_url":"https://avatars.githubusercontent.com/u/1058895?v=3","gravatar_id":"","url":"https://api.github.com/users/bugsnag","html_url":"https://github.com/bugsnag","followers_url":"https://api.github.com/users/bugsnag/followers","following_url":"https://api.github.com/users/bugsnag/following{/other_user}","gists_url":"https://api.github.com/users/bugsnag/gists{/gist_id}","starred_url":"https://api.github.com/users/bugsnag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bugsnag/subscriptions","organizations_url":"https://api.github.com/users/bugsnag/orgs","repos_url":"https://api.github.com/users/bugsnag/repos","events_url":"https://api.github.com/users/bugsnag/events{/privacy}","received_events_url":"https://api.github.com/users/bugsnag/received_events","type":"Organization","site_admin":false},"repo":{"id":2406783,"name":"bugsnag-android","full_name":"bugsnag/bugsnag-android","owner":{"login":"bugsnag","id":1058895,"avatar_url":"https://avatars.githubusercontent.com/u/1058895?v=3","gravatar_id":"","url":"https://api.github.com/users/bugsnag","html_url":"https://github.com/bugsnag","followers_url":"https://api.github.com/users/bugsnag/followers","following_url":"https://api.github.com/users/bugsnag/following{/other_user}","gists_url":"https://api.github.com/users/bugsnag/gists{/gist_id}","starred_url":"https://api.github.com/users/bugsnag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bugsnag/subscriptions","organizations_url":"https://api.github.com/users/bugsnag/orgs","repos_url":"https://api.github.com/users/bugsnag/repos","events_url":"https://api.github.com/users/bugsnag/events{/privacy}","received_events_url":"https://api.github.com/users/bugsnag/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bugsnag/bugsnag-android","description":"The bugsnag notifier for android clients.","fork":false,"url":"https://api.github.com/repos/bugsnag/bugsnag-android","forks_url":"https://api.github.com/repos/bugsnag/bugsnag-android/forks","keys_url":"https://api.github.com/repos/bugsnag/bugsnag-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bugsnag/bugsnag-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bugsnag/bugsnag-android/teams","hooks_url":"https://api.github.com/repos/bugsnag/bugsnag-android/hooks","issue_events_url":"https://api.github.com/repos/bugsnag/bugsnag-android/issues/events{/number}","events_url":"https://api.github.com/repos/bugsnag/bugsnag-android/events","assignees_url":"https://api.github.com/repos/bugsnag/bugsnag-android/assignees{/user}","branches_url":"https://api.github.com/repos/bugsnag/bugsnag-android/branches{/branch}","tags_url":"https://api.github.com/repos/bugsnag/bugsnag-android/tags","blobs_url":"https://api.github.com/repos/bugsnag/bugsnag-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bugsnag/bugsnag-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bugsnag/bugsnag-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/bugsnag/bugsnag-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bugsnag/bugsnag-android/statuses/{sha}","languages_url":"https://api.github.com/repos/bugsnag/bugsnag-android/languages","stargazers_url":"https://api.github.com/repos/bugsnag/bugsnag-android/stargazers","contributors_url":"https://api.github.com/repos/bugsnag/bugsnag-android/contributors","subscribers_url":"https://api.github.com/repos/bugsnag/bugsnag-android/subscribers","subscription_url":"https://api.github.com/repos/bugsnag/bugsnag-android/subscription","commits_url":"https://api.github.com/repos/bugsnag/bugsnag-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/bugsnag/bugsnag-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/bugsnag/bugsnag-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/bugsnag/bugsnag-android/issues/comments/{number}","contents_url":"https://api.github.com/repos/bugsnag/bugsnag-android/contents/{+path}","compare_url":"https://api.github.com/repos/bugsnag/bugsnag-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bugsnag/bugsnag-android/merges","archive_url":"https://api.github.com/repos/bugsnag/bugsnag-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bugsnag/bugsnag-android/downloads","issues_url":"https://api.github.com/repos/bugsnag/bugsnag-android/issues{/number}","pulls_url":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls{/number}","milestones_url":"https://api.github.com/repos/bugsnag/bugsnag-android/milestones{/number}","notifications_url":"https://api.github.com/repos/bugsnag/bugsnag-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bugsnag/bugsnag-android/labels{/name}","releases_url":"https://api.github.com/repos/bugsnag/bugsnag-android/releases{/id}","created_at":"2011-09-17T21:18:06Z","updated_at":"2014-12-12T02:04:31Z","pushed_at":"2014-12-19T03:28:11Z","git_url":"git://github.com/bugsnag/bugsnag-android.git","ssh_url":"git@github.com:bugsnag/bugsnag-android.git","clone_url":"https://github.com/bugsnag/bugsnag-android.git","svn_url":"https://github.com/bugsnag/bugsnag-android","homepage":"https://bugsnag.com","size":1262,"stargazers_count":125,"watchers_count":125,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":9,"forks":23,"open_issues":9,"watchers":125,"default_branch":"master"}},"base":{"label":"bugsnag:master","ref":"master","sha":"f0fb442dac4823cc63aec0f6e4282e976138cede","user":{"login":"bugsnag","id":1058895,"avatar_url":"https://avatars.githubusercontent.com/u/1058895?v=3","gravatar_id":"","url":"https://api.github.com/users/bugsnag","html_url":"https://github.com/bugsnag","followers_url":"https://api.github.com/users/bugsnag/followers","following_url":"https://api.github.com/users/bugsnag/following{/other_user}","gists_url":"https://api.github.com/users/bugsnag/gists{/gist_id}","starred_url":"https://api.github.com/users/bugsnag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bugsnag/subscriptions","organizations_url":"https://api.github.com/users/bugsnag/orgs","repos_url":"https://api.github.com/users/bugsnag/repos","events_url":"https://api.github.com/users/bugsnag/events{/privacy}","received_events_url":"https://api.github.com/users/bugsnag/received_events","type":"Organization","site_admin":false},"repo":{"id":2406783,"name":"bugsnag-android","full_name":"bugsnag/bugsnag-android","owner":{"login":"bugsnag","id":1058895,"avatar_url":"https://avatars.githubusercontent.com/u/1058895?v=3","gravatar_id":"","url":"https://api.github.com/users/bugsnag","html_url":"https://github.com/bugsnag","followers_url":"https://api.github.com/users/bugsnag/followers","following_url":"https://api.github.com/users/bugsnag/following{/other_user}","gists_url":"https://api.github.com/users/bugsnag/gists{/gist_id}","starred_url":"https://api.github.com/users/bugsnag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bugsnag/subscriptions","organizations_url":"https://api.github.com/users/bugsnag/orgs","repos_url":"https://api.github.com/users/bugsnag/repos","events_url":"https://api.github.com/users/bugsnag/events{/privacy}","received_events_url":"https://api.github.com/users/bugsnag/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bugsnag/bugsnag-android","description":"The bugsnag notifier for android clients.","fork":false,"url":"https://api.github.com/repos/bugsnag/bugsnag-android","forks_url":"https://api.github.com/repos/bugsnag/bugsnag-android/forks","keys_url":"https://api.github.com/repos/bugsnag/bugsnag-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bugsnag/bugsnag-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bugsnag/bugsnag-android/teams","hooks_url":"https://api.github.com/repos/bugsnag/bugsnag-android/hooks","issue_events_url":"https://api.github.com/repos/bugsnag/bugsnag-android/issues/events{/number}","events_url":"https://api.github.com/repos/bugsnag/bugsnag-android/events","assignees_url":"https://api.github.com/repos/bugsnag/bugsnag-android/assignees{/user}","branches_url":"https://api.github.com/repos/bugsnag/bugsnag-android/branches{/branch}","tags_url":"https://api.github.com/repos/bugsnag/bugsnag-android/tags","blobs_url":"https://api.github.com/repos/bugsnag/bugsnag-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bugsnag/bugsnag-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bugsnag/bugsnag-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/bugsnag/bugsnag-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bugsnag/bugsnag-android/statuses/{sha}","languages_url":"https://api.github.com/repos/bugsnag/bugsnag-android/languages","stargazers_url":"https://api.github.com/repos/bugsnag/bugsnag-android/stargazers","contributors_url":"https://api.github.com/repos/bugsnag/bugsnag-android/contributors","subscribers_url":"https://api.github.com/repos/bugsnag/bugsnag-android/subscribers","subscription_url":"https://api.github.com/repos/bugsnag/bugsnag-android/subscription","commits_url":"https://api.github.com/repos/bugsnag/bugsnag-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/bugsnag/bugsnag-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/bugsnag/bugsnag-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/bugsnag/bugsnag-android/issues/comments/{number}","contents_url":"https://api.github.com/repos/bugsnag/bugsnag-android/contents/{+path}","compare_url":"https://api.github.com/repos/bugsnag/bugsnag-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bugsnag/bugsnag-android/merges","archive_url":"https://api.github.com/repos/bugsnag/bugsnag-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bugsnag/bugsnag-android/downloads","issues_url":"https://api.github.com/repos/bugsnag/bugsnag-android/issues{/number}","pulls_url":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls{/number}","milestones_url":"https://api.github.com/repos/bugsnag/bugsnag-android/milestones{/number}","notifications_url":"https://api.github.com/repos/bugsnag/bugsnag-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bugsnag/bugsnag-android/labels{/name}","releases_url":"https://api.github.com/repos/bugsnag/bugsnag-android/releases{/id}","created_at":"2011-09-17T21:18:06Z","updated_at":"2014-12-12T02:04:31Z","pushed_at":"2014-12-19T03:28:11Z","git_url":"git://github.com/bugsnag/bugsnag-android.git","ssh_url":"git@github.com:bugsnag/bugsnag-android.git","clone_url":"https://github.com/bugsnag/bugsnag-android.git","svn_url":"https://github.com/bugsnag/bugsnag-android","homepage":"https://bugsnag.com","size":1262,"stargazers_count":125,"watchers_count":125,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":9,"forks":23,"open_issues":9,"watchers":125,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/35"},"html":{"href":"https://github.com/bugsnag/bugsnag-android/pull/35"},"issue":{"href":"https://api.github.com/repos/bugsnag/bugsnag-android/issues/35"},"comments":{"href":"https://api.github.com/repos/bugsnag/bugsnag-android/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/bugsnag/bugsnag-android/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/bugsnag/bugsnag-android/statuses/87842caf91e78f32cabf7236cfd83fb6652113a5"}}}}