{"action":"created","comment":{"url":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments/64214849","id":64214849,"diff_hunk":"@@ -1,5 +1,48 @@\n module Cartodb\n   class EventTracker\n+\n+    def track_exported_map(user, vis)\n+      if !vis.nil?\n+        custom_properties = { privacy: vis.privacy, type: vis.type, vis_id: vis.id }\n+        send_event(user, 'Exported map', custom_properties)\n+      else\n+        report_error('Exported map', user, type: 'Null visualization')\n+      end\n+    end\n+\n+    def track_import(user, import_id, results, visualization_id, from_common_data)\n+      # Generate an event for every new imported dataset\n+      results.each do |result|\n+        begin\n+          if result.success?\n+            if !result.name.nil?\n+              map = UserTable.where(data_import_id: import_id, name: result.name).first\n+              origin = from_common_data ? 'common-data' : 'import'\n+            else\n+              map = UserTable.where(data_import_id: import_id).first\n+              origin = 'copy'\n+            end\n+            vis = Carto::Visualization.where(map_id: map.map_id).first\n+            custom_properties = { privacy: vis.privacy, type: vis.type, vis_id: vis.id, origin: origin }\n+            send_event(user, 'Created dataset', custom_properties)\n+          end\n+        rescue => e\n+          report_error('Created dataset', user, type: 'Invalid import result', error: e.inspect)","path":"lib/cartodb/event_tracker.rb","position":30,"original_position":30,"commit_id":"1d2c754c6e62e4edf7107d844126edca25af1810","original_commit_id":"1d2c754c6e62e4edf7107d844126edca25af1810","user":{"login":"juanignaciosl","id":932968,"avatar_url":"https://avatars.githubusercontent.com/u/932968?v=3","gravatar_id":"","url":"https://api.github.com/users/juanignaciosl","html_url":"https://github.com/juanignaciosl","followers_url":"https://api.github.com/users/juanignaciosl/followers","following_url":"https://api.github.com/users/juanignaciosl/following{/other_user}","gists_url":"https://api.github.com/users/juanignaciosl/gists{/gist_id}","starred_url":"https://api.github.com/users/juanignaciosl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juanignaciosl/subscriptions","organizations_url":"https://api.github.com/users/juanignaciosl/orgs","repos_url":"https://api.github.com/users/juanignaciosl/repos","events_url":"https://api.github.com/users/juanignaciosl/events{/privacy}","received_events_url":"https://api.github.com/users/juanignaciosl/received_events","type":"User","site_admin":false},"body":"PS: and even something from `result`, since this `rescue` block is inside a loop.","created_at":"2016-05-23T12:39:22Z","updated_at":"2016-05-23T12:39:22Z","html_url":"https://github.com/CartoDB/cartodb/pull/7438#discussion_r64214849","pull_request_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/7438","_links":{"self":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments/64214849"},"html":{"href":"https://github.com/CartoDB/cartodb/pull/7438#discussion_r64214849"},"pull_request":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/7438"}}},"pull_request":{"url":"https://api.github.com/repos/CartoDB/cartodb/pulls/7438","id":70710281,"html_url":"https://github.com/CartoDB/cartodb/pull/7438","diff_url":"https://github.com/CartoDB/cartodb/pull/7438.diff","patch_url":"https://github.com/CartoDB/cartodb/pull/7438.patch","issue_url":"https://api.github.com/repos/CartoDB/cartodb/issues/7438","number":7438,"state":"open","locked":false,"title":"[Metrics] Adds 'Exported map' events","user":{"login":"jmartinter","id":6340904,"avatar_url":"https://avatars.githubusercontent.com/u/6340904?v=3","gravatar_id":"","url":"https://api.github.com/users/jmartinter","html_url":"https://github.com/jmartinter","followers_url":"https://api.github.com/users/jmartinter/followers","following_url":"https://api.github.com/users/jmartinter/following{/other_user}","gists_url":"https://api.github.com/users/jmartinter/gists{/gist_id}","starred_url":"https://api.github.com/users/jmartinter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmartinter/subscriptions","organizations_url":"https://api.github.com/users/jmartinter/orgs","repos_url":"https://api.github.com/users/jmartinter/repos","events_url":"https://api.github.com/users/jmartinter/events{/privacy}","received_events_url":"https://api.github.com/users/jmartinter/received_events","type":"User","site_admin":false},"body":"Closes: #7434 \r\n\r\nAdds:\r\n - launches new 'Exported map' event when map is exported by user (app/controllers/carto/api/visualization_exports_controller.rb)\r\n - launches new  'Created map' event when user imports a file with both datasets and map (app/models/data_import.rb)\r\n\r\nModifies:\r\n- Encapsulates event generation functionality with exception catching (inside specific private function) (in app/models/data_import.rb) So, in case of any event-related error, app execution wouldn't be affected.\r\n\r\nCR @juanignaciosl, @xavijam, please ","created_at":"2016-05-19T15:02:43Z","updated_at":"2016-05-23T12:39:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c112b1aaecd38d410144acd3983479a438e2c055","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/7438/commits","review_comments_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/7438/comments","review_comment_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/issues/7438/comments","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/1d2c754c6e62e4edf7107d844126edca25af1810","head":{"label":"CartoDB:export_map","ref":"export_map","sha":"1d2c754c6e62e4edf7107d844126edca25af1810","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":4909355,"name":"cartodb","full_name":"CartoDB/cartodb","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/cartodb","description":"Location Intelligence & Data Visualization tool","fork":false,"url":"https://api.github.com/repos/CartoDB/cartodb","forks_url":"https://api.github.com/repos/CartoDB/cartodb/forks","keys_url":"https://api.github.com/repos/CartoDB/cartodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/cartodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/cartodb/teams","hooks_url":"https://api.github.com/repos/CartoDB/cartodb/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/cartodb/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/cartodb/events","assignees_url":"https://api.github.com/repos/CartoDB/cartodb/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/cartodb/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/cartodb/tags","blobs_url":"https://api.github.com/repos/CartoDB/cartodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/cartodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/cartodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/cartodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/cartodb/languages","stargazers_url":"https://api.github.com/repos/CartoDB/cartodb/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/cartodb/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/cartodb/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/cartodb/subscription","commits_url":"https://api.github.com/repos/CartoDB/cartodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/cartodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/cartodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/cartodb/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/cartodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/cartodb/merges","archive_url":"https://api.github.com/repos/CartoDB/cartodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/cartodb/downloads","issues_url":"https://api.github.com/repos/CartoDB/cartodb/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/cartodb/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/cartodb/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/cartodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/cartodb/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/cartodb/releases{/id}","deployments_url":"https://api.github.com/repos/CartoDB/cartodb/deployments","created_at":"2012-07-05T15:23:45Z","updated_at":"2016-05-22T21:45:08Z","pushed_at":"2016-05-23T12:24:43Z","git_url":"git://github.com/CartoDB/cartodb.git","ssh_url":"git@github.com:CartoDB/cartodb.git","clone_url":"https://github.com/CartoDB/cartodb.git","svn_url":"https://github.com/CartoDB/cartodb","homepage":"http://cartodb.com","size":386657,"stargazers_count":1139,"watchers_count":1139,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":288,"mirror_url":null,"open_issues_count":914,"forks":288,"open_issues":914,"watchers":1139,"default_branch":"master"}},"base":{"label":"CartoDB:master","ref":"master","sha":"0a09ce6de7cde60eea5a9c995e7a83507199c4ba","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":4909355,"name":"cartodb","full_name":"CartoDB/cartodb","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/cartodb","description":"Location Intelligence & Data Visualization tool","fork":false,"url":"https://api.github.com/repos/CartoDB/cartodb","forks_url":"https://api.github.com/repos/CartoDB/cartodb/forks","keys_url":"https://api.github.com/repos/CartoDB/cartodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/cartodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/cartodb/teams","hooks_url":"https://api.github.com/repos/CartoDB/cartodb/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/cartodb/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/cartodb/events","assignees_url":"https://api.github.com/repos/CartoDB/cartodb/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/cartodb/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/cartodb/tags","blobs_url":"https://api.github.com/repos/CartoDB/cartodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/cartodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/cartodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/cartodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/cartodb/languages","stargazers_url":"https://api.github.com/repos/CartoDB/cartodb/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/cartodb/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/cartodb/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/cartodb/subscription","commits_url":"https://api.github.com/repos/CartoDB/cartodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/cartodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/cartodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/cartodb/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/cartodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/cartodb/merges","archive_url":"https://api.github.com/repos/CartoDB/cartodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/cartodb/downloads","issues_url":"https://api.github.com/repos/CartoDB/cartodb/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/cartodb/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/cartodb/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/cartodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/cartodb/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/cartodb/releases{/id}","deployments_url":"https://api.github.com/repos/CartoDB/cartodb/deployments","created_at":"2012-07-05T15:23:45Z","updated_at":"2016-05-22T21:45:08Z","pushed_at":"2016-05-23T12:24:43Z","git_url":"git://github.com/CartoDB/cartodb.git","ssh_url":"git@github.com:CartoDB/cartodb.git","clone_url":"https://github.com/CartoDB/cartodb.git","svn_url":"https://github.com/CartoDB/cartodb","homepage":"http://cartodb.com","size":386657,"stargazers_count":1139,"watchers_count":1139,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":288,"mirror_url":null,"open_issues_count":914,"forks":288,"open_issues":914,"watchers":1139,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/7438"},"html":{"href":"https://github.com/CartoDB/cartodb/pull/7438"},"issue":{"href":"https://api.github.com/repos/CartoDB/cartodb/issues/7438"},"comments":{"href":"https://api.github.com/repos/CartoDB/cartodb/issues/7438/comments"},"review_comments":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/7438/comments"},"review_comment":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/7438/commits"},"statuses":{"href":"https://api.github.com/repos/CartoDB/cartodb/statuses/1d2c754c6e62e4edf7107d844126edca25af1810"}}}}
{"actor":{"display_login":"juanignaciosl"}}