{"action":"created","comment":{"url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/comments/104451080","pull_request_review_id":25289414,"id":104451080,"diff_hunk":"@@ -0,0 +1,145 @@\n+/*\n+ * SonarLint for IntelliJ IDEA\n+ * Copyright (C) 2015 SonarSource\n+ * sonarlint@sonarsource.com\n+ *\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU Lesser General Public\n+ * License as published by the Free Software Foundation; either\n+ * version 3 of the License, or (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+ * Lesser General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Lesser General Public\n+ * License along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02\n+ */\n+package org.sonarlint.intellij.telemetry;\n+\n+import com.intellij.concurrency.JobScheduler;\n+import com.intellij.openapi.application.PathManager;\n+import com.intellij.openapi.components.ApplicationComponent;\n+import com.intellij.openapi.project.ProjectManager;\n+import java.io.IOException;\n+import java.nio.file.Files;\n+import java.nio.file.Path;\n+import java.nio.file.Paths;\n+import java.time.LocalDate;\n+import java.time.LocalDateTime;\n+import java.time.temporal.ChronoUnit;\n+import java.util.concurrent.ScheduledFuture;\n+import java.util.concurrent.TimeUnit;\n+import org.jetbrains.annotations.NotNull;\n+import org.sonarlint.intellij.SonarApplication;\n+import org.sonarsource.sonarlint.core.WsHelperImpl;\n+\n+public class SonarLintTelemetry implements ApplicationComponent {\n+  private static final String STORAGE_FILENAME = \"sonarlint_usage.json\";\n+  private final TelemetryClient worker;\n+  private TelemetryStorage storage;\n+  private ScheduledFuture<?> scheduledFuture;\n+\n+  public SonarLintTelemetry(SonarApplication application, ProjectManager projectManager) {\n+    this.worker = new TelemetryClient(new WsHelperImpl(), application, projectManager);\n+  }\n+\n+  private boolean loadStorage() {\n+    Path filePath = getStorageFilePath();\n+\n+    if (Files.exists(filePath)) {\n+      try {\n+        storage = TelemetryStorage.load(filePath);\n+      } catch (IOException e) {\n+        // ignore, we will recreate\n+      }\n+    }\n+\n+    if (storage == null) {\n+      storage = new TelemetryStorage();\n+      try {\n+        storage.save(filePath);\n+      } catch (IOException e) {\n+        // no data should be sent\n+        return false;\n+      }\n+    }\n+    return true;\n+  }\n+\n+  public boolean enabled() {\n+    return storage.enabled();\n+  }\n+\n+  public void setEnabled(boolean enabled) {\n+    storage.setEnabled(enabled);\n+    saveData();\n+  }\n+\n+  @Override public void initComponent() {\n+    try {\n+      if (loadStorage()) {\n+        scheduleUpload();\n+      }\n+    } catch (Exception e) {","path":"src/main/java/org/sonarlint/intellij/telemetry/SonarLintTelemetry.java","position":86,"original_position":86,"commit_id":"92b5fef6ab69d5a87b31dcaf105fef58cdc27104","original_commit_id":"92b5fef6ab69d5a87b31dcaf105fef58cdc27104","user":{"login":"SonarTech","id":1842438,"avatar_url":"https://avatars1.githubusercontent.com/u/1842438?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarTech","html_url":"https://github.com/SonarTech","followers_url":"https://api.github.com/users/SonarTech/followers","following_url":"https://api.github.com/users/SonarTech/following{/other_user}","gists_url":"https://api.github.com/users/SonarTech/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarTech/subscriptions","organizations_url":"https://api.github.com/users/SonarTech/orgs","repos_url":"https://api.github.com/users/SonarTech/repos","events_url":"https://api.github.com/users/SonarTech/events{/privacy}","received_events_url":"https://api.github.com/users/SonarTech/received_events","type":"User","site_admin":false},"body":"![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png 'Severity: MAJOR') Either log or rethrow this exception. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](https://next.sonarqube.com/sonarqube/coding_rules#rule_key=squid%3AS1166)\n","created_at":"2017-03-06T16:08:41Z","updated_at":"2017-03-06T16:08:41Z","html_url":"https://github.com/SonarSource/sonarlint-intellij/pull/100#discussion_r104451080","pull_request_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/100","_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/comments/104451080"},"html":{"href":"https://github.com/SonarSource/sonarlint-intellij/pull/100#discussion_r104451080"},"pull_request":{"href":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/100"}}},"pull_request":{"url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/100","id":109260263,"html_url":"https://github.com/SonarSource/sonarlint-intellij/pull/100","diff_url":"https://github.com/SonarSource/sonarlint-intellij/pull/100.diff","patch_url":"https://github.com/SonarSource/sonarlint-intellij/pull/100.patch","issue_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/issues/100","number":100,"state":"open","locked":false,"title":"SLI-187 Collect anonymous statistics","user":{"login":"dbmeneses","id":12492673,"avatar_url":"https://avatars3.githubusercontent.com/u/12492673?v=3","gravatar_id":"","url":"https://api.github.com/users/dbmeneses","html_url":"https://github.com/dbmeneses","followers_url":"https://api.github.com/users/dbmeneses/followers","following_url":"https://api.github.com/users/dbmeneses/following{/other_user}","gists_url":"https://api.github.com/users/dbmeneses/gists{/gist_id}","starred_url":"https://api.github.com/users/dbmeneses/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbmeneses/subscriptions","organizations_url":"https://api.github.com/users/dbmeneses/orgs","repos_url":"https://api.github.com/users/dbmeneses/repos","events_url":"https://api.github.com/users/dbmeneses/events{/privacy}","received_events_url":"https://api.github.com/users/dbmeneses/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-06T13:41:10Z","updated_at":"2017-03-06T16:08:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78b9506abbb136a0eb5a8c673de536ae03030fc3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/100/commits","review_comments_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/100/comments","review_comment_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/issues/100/comments","statuses_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/statuses/92b5fef6ab69d5a87b31dcaf105fef58cdc27104","head":{"label":"SonarSource:telemetry","ref":"telemetry","sha":"92b5fef6ab69d5a87b31dcaf105fef58cdc27104","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars3.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":13929787,"name":"sonarlint-intellij","full_name":"SonarSource/sonarlint-intellij","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars3.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonarlint-intellij","description":"IntelliJ IDEA Plugin","fork":false,"url":"https://api.github.com/repos/SonarSource/sonarlint-intellij","forks_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/forks","keys_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/events","assignees_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/merges","archive_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/releases{/id}","deployments_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/deployments","created_at":"2013-10-28T15:27:56Z","updated_at":"2017-03-02T10:28:19Z","pushed_at":"2017-03-06T16:04:42Z","git_url":"git://github.com/SonarSource/sonarlint-intellij.git","ssh_url":"git@github.com:SonarSource/sonarlint-intellij.git","clone_url":"https://github.com/SonarSource/sonarlint-intellij.git","svn_url":"https://github.com/SonarSource/sonarlint-intellij","homepage":"https://plugins.jetbrains.com/plugin/4971","size":19596,"stargazers_count":133,"watchers_count":133,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":1,"forks":30,"open_issues":1,"watchers":133,"default_branch":"master"}},"base":{"label":"SonarSource:master","ref":"master","sha":"9c26df2efc4ef34959d96c92ef5a0f2fb9223c72","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars3.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":13929787,"name":"sonarlint-intellij","full_name":"SonarSource/sonarlint-intellij","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars3.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonarlint-intellij","description":"IntelliJ IDEA Plugin","fork":false,"url":"https://api.github.com/repos/SonarSource/sonarlint-intellij","forks_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/forks","keys_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/events","assignees_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/merges","archive_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/releases{/id}","deployments_url":"https://api.github.com/repos/SonarSource/sonarlint-intellij/deployments","created_at":"2013-10-28T15:27:56Z","updated_at":"2017-03-02T10:28:19Z","pushed_at":"2017-03-06T16:04:42Z","git_url":"git://github.com/SonarSource/sonarlint-intellij.git","ssh_url":"git@github.com:SonarSource/sonarlint-intellij.git","clone_url":"https://github.com/SonarSource/sonarlint-intellij.git","svn_url":"https://github.com/SonarSource/sonarlint-intellij","homepage":"https://plugins.jetbrains.com/plugin/4971","size":19596,"stargazers_count":133,"watchers_count":133,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":1,"forks":30,"open_issues":1,"watchers":133,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/100"},"html":{"href":"https://github.com/SonarSource/sonarlint-intellij/pull/100"},"issue":{"href":"https://api.github.com/repos/SonarSource/sonarlint-intellij/issues/100"},"comments":{"href":"https://api.github.com/repos/SonarSource/sonarlint-intellij/issues/100/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/100/comments"},"review_comment":{"href":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SonarSource/sonarlint-intellij/pulls/100/commits"},"statuses":{"href":"https://api.github.com/repos/SonarSource/sonarlint-intellij/statuses/92b5fef6ab69d5a87b31dcaf105fef58cdc27104"}}}}
{"actor":{"display_login":"SonarTech"}}