{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/comments/64916012","id":64916012,"diff_hunk":"@@ -0,0 +1,119 @@\n+/*\n+ * Copyright (C) 2016 The Android Open Source Project\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package com.google.cloud.tools.intellij.analytics;\n+\n+import com.google.cloud.metrics.Event;\n+import com.google.cloud.metrics.MetricsException;\n+import com.google.cloud.metrics.MetricsSender;\n+import com.google.common.annotations.VisibleForTesting;\n+import com.google.common.base.Preconditions;\n+import com.google.common.base.Predicate;\n+import com.google.common.collect.ImmutableMap;\n+\n+import com.intellij.ide.util.PropertiesComponent;\n+import com.intellij.openapi.diagnostic.Logger;\n+import com.intellij.openapi.updateSettings.impl.UpdateChecker;\n+\n+import org.jetbrains.annotations.NotNull;\n+import org.jetbrains.annotations.Nullable;\n+\n+import java.util.Map;\n+\n+/**\n+ * Utility class to send client-side, opt-in usage events to Google Analytics (GA).\n+ * <p/>\n+ * Actual Tracking ID of a target GA Property (ANALYTICS_TRACKING_ID) will be read from a config\n+ * property \"usage.analytics.tracking.id\". (Note that we don't hardcode the Tracking ID in our\n+ * codebase. See \"google-account-plugin/build.gradle\" for how we set the property when we release\n+ * our plugin.)\n+ */\n+public class IdeaUsageTracker {\n+\n+  private static final Logger logger = Logger.getInstance(IdeaUsageTracker.class);\n+\n+  // UUID for this IntelliJ installation. Will be used to uniquely identify a user.\n+  private static final String clientUuid =\n+      UpdateChecker.getInstallationUID(PropertiesComponent.getInstance());\n+\n+  private String ideaType;\n+  private String analyticsTrackingId;\n+  private Predicate<Object> optedIn;\n+\n+  /**\n+   * Initialize the tracker.\n+   *\n+   * @param ideaTypePostfix String indicating IntelliJ IDEA type (e.g., Community Edition or\n+   *      Ultimate Edition) appended to the event type string reported to GA.\n+   * @param analyticsTrackingId In our IntelliJ codebase, the Tracking ID is supposed to come from\n+   *     \"google-account-plugin/resources/config.properties\". The property name is\n+   *     \"usage.analytics.tracking.id\".\n+   * @param optedIn A predicate (effectively an 0-argument lambda function) returning if a user has\n+   *     opted in for client-side usage reporting.\n+   */\n+  public void init(@Nullable String ideaTypePostfix,\n+      @Nullable String analyticsTrackingId, @Nullable Predicate<Object> optedIn) {\n+    // Do the basic checking to see if \"google-account-plugin/build.gradle\" has expanded the\n+    // Tracking ID property. Analytics Tracking ID has the form of \"UA-xxxxxxxx-y\"\n+    // (https://support.google.com/analytics/answer/1032385?hl=en).\n+    if (analyticsTrackingId != null && analyticsTrackingId.startsWith(\"UA-\")) {\n+      Preconditions.checkNotNull(optedIn);","path":"common-lib/src/main/java/com/google/cloud/tools/intellij/analytics/IdeaUsageTracker.java","position":73,"original_position":73,"commit_id":"a4fee269b785a5955bf629fba74b73e010147013","original_commit_id":"a4fee269b785a5955bf629fba74b73e010147013","user":{"login":"etanshaul","id":1735744,"avatar_url":"https://avatars.githubusercontent.com/u/1735744?v=3","gravatar_id":"","url":"https://api.github.com/users/etanshaul","html_url":"https://github.com/etanshaul","followers_url":"https://api.github.com/users/etanshaul/followers","following_url":"https://api.github.com/users/etanshaul/following{/other_user}","gists_url":"https://api.github.com/users/etanshaul/gists{/gist_id}","starred_url":"https://api.github.com/users/etanshaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etanshaul/subscriptions","organizations_url":"https://api.github.com/users/etanshaul/orgs","repos_url":"https://api.github.com/users/etanshaul/repos","events_url":"https://api.github.com/users/etanshaul/events{/privacy}","received_events_url":"https://api.github.com/users/etanshaul/received_events","type":"User","site_admin":false},"body":"or just make the paramater `@NotNull` ","created_at":"2016-05-27T14:48:01Z","updated_at":"2016-05-27T14:48:01Z","html_url":"https://github.com/GoogleCloudPlatform/gcloud-intellij/pull/699#discussion_r64916012","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/699","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/comments/64916012"},"html":{"href":"https://github.com/GoogleCloudPlatform/gcloud-intellij/pull/699#discussion_r64916012"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/699"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/699","id":71306821,"html_url":"https://github.com/GoogleCloudPlatform/gcloud-intellij/pull/699","diff_url":"https://github.com/GoogleCloudPlatform/gcloud-intellij/pull/699.diff","patch_url":"https://github.com/GoogleCloudPlatform/gcloud-intellij/pull/699.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/issues/699","number":699,"state":"open","locked":false,"title":"Set up new usage tracking facilities","user":{"login":"chanseokoh","id":10523105,"avatar_url":"https://avatars.githubusercontent.com/u/10523105?v=3","gravatar_id":"","url":"https://api.github.com/users/chanseokoh","html_url":"https://github.com/chanseokoh","followers_url":"https://api.github.com/users/chanseokoh/followers","following_url":"https://api.github.com/users/chanseokoh/following{/other_user}","gists_url":"https://api.github.com/users/chanseokoh/gists{/gist_id}","starred_url":"https://api.github.com/users/chanseokoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chanseokoh/subscriptions","organizations_url":"https://api.github.com/users/chanseokoh/orgs","repos_url":"https://api.github.com/users/chanseokoh/repos","events_url":"https://api.github.com/users/chanseokoh/events{/privacy}","received_events_url":"https://api.github.com/users/chanseokoh/received_events","type":"User","site_admin":false},"body":"Adds one new class for new opt-in usage reporting. The new class utilizes [the cloud-reporting library](https://github.com/google/cloud-reporting).\r\n\r\nI put the class under `common-lib` because it didn't feel right to place it under `google-account-plugin`.\r\n\r\nI suspect that there is an issue regarding class loading and class version mismatch. The above library uses many other libraries internally, and those libraries probably overlap with what we currently have. I observed ClassCastExceptions in other places (e.g., while casting `org.apache.http.message.BasicNameValuePair` to `org.apache.http.NameValuePair`). This must to be resolved. Not sure what's really happening.","created_at":"2016-05-24T23:00:32Z","updated_at":"2016-05-27T14:48:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9e649b67669f420d92ddc6e0f21aa5882f93eb59","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/699/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/699/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/issues/699/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/statuses/a4fee269b785a5955bf629fba74b73e010147013","head":{"label":"GoogleCloudPlatform:new-usage-tracking","ref":"new-usage-tracking","sha":"a4fee269b785a5955bf629fba74b73e010147013","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":38834157,"name":"gcloud-intellij","full_name":"GoogleCloudPlatform/gcloud-intellij","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/gcloud-intellij","description":"Plugin to support the Google Cloud Platform in IntelliJ IDEA.","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/deployments","created_at":"2015-07-09T17:08:59Z","updated_at":"2016-05-26T04:20:11Z","pushed_at":"2016-05-26T21:44:16Z","git_url":"git://github.com/GoogleCloudPlatform/gcloud-intellij.git","ssh_url":"git@github.com:GoogleCloudPlatform/gcloud-intellij.git","clone_url":"https://github.com/GoogleCloudPlatform/gcloud-intellij.git","svn_url":"https://github.com/GoogleCloudPlatform/gcloud-intellij","homepage":"","size":19625,"stargazers_count":27,"watchers_count":27,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":61,"forks":7,"open_issues":61,"watchers":27,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"305ecd76d1ca103910d35773b7283cbe8fcc7bc1","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":38834157,"name":"gcloud-intellij","full_name":"GoogleCloudPlatform/gcloud-intellij","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/gcloud-intellij","description":"Plugin to support the Google Cloud Platform in IntelliJ IDEA.","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/deployments","created_at":"2015-07-09T17:08:59Z","updated_at":"2016-05-26T04:20:11Z","pushed_at":"2016-05-26T21:44:16Z","git_url":"git://github.com/GoogleCloudPlatform/gcloud-intellij.git","ssh_url":"git@github.com:GoogleCloudPlatform/gcloud-intellij.git","clone_url":"https://github.com/GoogleCloudPlatform/gcloud-intellij.git","svn_url":"https://github.com/GoogleCloudPlatform/gcloud-intellij","homepage":"","size":19625,"stargazers_count":27,"watchers_count":27,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":61,"forks":7,"open_issues":61,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/699"},"html":{"href":"https://github.com/GoogleCloudPlatform/gcloud-intellij/pull/699"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/issues/699"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/issues/699/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/699/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/pulls/699/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-intellij/statuses/a4fee269b785a5955bf629fba74b73e010147013"}}}}
{"actor":{"display_login":"etanshaul"}}