{"action":"created","comment":{"url":"https://api.github.com/repos/status-im/status-react/pulls/comments/183636373","pull_request_review_id":114669200,"id":183636373,"diff_hunk":"@@ -75,20 +76,28 @@\n     (when-not offline?\n       (async/go (async/<! (drain-events-queue!))))))\n \n+(def event-tag \"events\")\n+\n ;; Mixpanel events definition\n-(def events (reader/read-string (slurp/slurp \"./src/status_im/utils/mixpanel_events.edn\")))\n-(def event-by-trigger (reduce-kv #(assoc %1 (:trigger %3) %3) {} events))\n+(defn event->triggers [events]\n+  (reduce (fn [m {:keys [trigger] :as event}]\n+            (update-in m (conj trigger event-tag) conj event))\n+          {}\n+          events))\n+\n+(def event-by-trigger\n+  (event->triggers mixpanel-events/events))\n \n-(defn matches? [event trigger]\n-  (cond (= 1 (count trigger))\n-        (= (first event) (first trigger))\n-        (= 2 (count trigger))\n-        (and\n-          (= (first event) (first trigger))\n-          (= (second event) (second trigger)))\n-        :else\n-        (= event trigger)))\n+(defn matching-events [[event-name first-arg :as event] triggers]\n+  (let [cnt      (count event)\n+        triggers (cond->\n+                  (get-in triggers [event-name event-tag])\n \n-(defn matching-events [event definitions]\n-  (reduce-kv #(if (matches? event %2) (conj %1 %3) %1) [] definitions))\n+                  (>= 2 cnt)\n+                  (concat (get-in triggers [event-name first-arg event-tag]))\n \n+                  (> 2 cnt)\n+                  (concat (get-in triggers (conj [event] event-tag))))]","path":"src/status_im/utils/mixpanel.cljs","position":59,"original_position":59,"commit_id":"6e19f819a206e0f6f971a1e34e00d81d232226d9","original_commit_id":"6e19f819a206e0f6f971a1e34e00d81d232226d9","user":{"login":"rasom","id":2364994,"avatar_url":"https://avatars2.githubusercontent.com/u/2364994?v=4","gravatar_id":"","url":"https://api.github.com/users/rasom","html_url":"https://github.com/rasom","followers_url":"https://api.github.com/users/rasom/followers","following_url":"https://api.github.com/users/rasom/following{/other_user}","gists_url":"https://api.github.com/users/rasom/gists{/gist_id}","starred_url":"https://api.github.com/users/rasom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rasom/subscriptions","organizations_url":"https://api.github.com/users/rasom/orgs","repos_url":"https://api.github.com/users/rasom/repos","events_url":"https://api.github.com/users/rasom/events{/privacy}","received_events_url":"https://api.github.com/users/rasom/received_events","type":"User","site_admin":false},"body":"wait it should be `(conj event event-tag)`. I will add a test case ","created_at":"2018-04-24T07:57:33Z","updated_at":"2018-04-24T07:57:33Z","html_url":"https://github.com/status-im/status-react/pull/3974#discussion_r183636373","pull_request_url":"https://api.github.com/repos/status-im/status-react/pulls/3974","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/status-im/status-react/pulls/comments/183636373"},"html":{"href":"https://github.com/status-im/status-react/pull/3974#discussion_r183636373"},"pull_request":{"href":"https://api.github.com/repos/status-im/status-react/pulls/3974"}},"in_reply_to_id":183627852},"pull_request":{"url":"https://api.github.com/repos/status-im/status-react/pulls/3974","id":183635450,"html_url":"https://github.com/status-im/status-react/pull/3974","diff_url":"https://github.com/status-im/status-react/pull/3974.diff","patch_url":"https://github.com/status-im/status-react/pull/3974.patch","issue_url":"https://api.github.com/repos/status-im/status-react/issues/3974","number":3974,"state":"open","locked":false,"title":"Extend mixpanel's definitions","user":{"login":"rasom","id":2364994,"avatar_url":"https://avatars2.githubusercontent.com/u/2364994?v=4","gravatar_id":"","url":"https://api.github.com/users/rasom","html_url":"https://github.com/rasom","followers_url":"https://api.github.com/users/rasom/followers","following_url":"https://api.github.com/users/rasom/following{/other_user}","gists_url":"https://api.github.com/users/rasom/gists{/gist_id}","starred_url":"https://api.github.com/users/rasom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rasom/subscriptions","organizations_url":"https://api.github.com/users/rasom/orgs","repos_url":"https://api.github.com/users/rasom/repos","events_url":"https://api.github.com/users/rasom/events{/privacy}","received_events_url":"https://api.github.com/users/rasom/received_events","type":"User","site_admin":false},"body":"is necessary for https://github.com/status-im/status-react/issues/3792\r\n\r\n`mixpanel_events.edn` is now cljs file, so that we can define functions there if necessary. Each event may contain `:filter-fn` and `:data-fn` options. The former one allows to filter event using its parameters, the latter can return map which will be merged with `:properties` before sending.\r\n\r\nAlso `matching-events` function was rewritten so that it doesn't iterate over all possible events on each re-frame's events. It tooks >2ms for each re-frame event on slow devices, 10-12 times faster now. \r\n\r\n \r\nstatus: ready\r\n","created_at":"2018-04-24T06:46:31Z","updated_at":"2018-04-24T07:57:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddd7aec5ee97ebcf0bd5bced9bb554f1082cab0e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/status-im/status-react/pulls/3974/commits","review_comments_url":"https://api.github.com/repos/status-im/status-react/pulls/3974/comments","review_comment_url":"https://api.github.com/repos/status-im/status-react/pulls/comments{/number}","comments_url":"https://api.github.com/repos/status-im/status-react/issues/3974/comments","statuses_url":"https://api.github.com/repos/status-im/status-react/statuses/6e19f819a206e0f6f971a1e34e00d81d232226d9","head":{"label":"status-im:feature/filters-and-events-data-mixpanel","ref":"feature/filters-and-events-data-mixpanel","sha":"6e19f819a206e0f6f971a1e34e00d81d232226d9","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":52308441,"name":"status-react","full_name":"status-im/status-react","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/status-react","description":"a free (libre) open source, mobile OS for Ethereum","fork":false,"url":"https://api.github.com/repos/status-im/status-react","forks_url":"https://api.github.com/repos/status-im/status-react/forks","keys_url":"https://api.github.com/repos/status-im/status-react/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/status-react/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/status-react/teams","hooks_url":"https://api.github.com/repos/status-im/status-react/hooks","issue_events_url":"https://api.github.com/repos/status-im/status-react/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/status-react/events","assignees_url":"https://api.github.com/repos/status-im/status-react/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/status-react/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/status-react/tags","blobs_url":"https://api.github.com/repos/status-im/status-react/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/status-react/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/status-react/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/status-react/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/status-react/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/status-react/languages","stargazers_url":"https://api.github.com/repos/status-im/status-react/stargazers","contributors_url":"https://api.github.com/repos/status-im/status-react/contributors","subscribers_url":"https://api.github.com/repos/status-im/status-react/subscribers","subscription_url":"https://api.github.com/repos/status-im/status-react/subscription","commits_url":"https://api.github.com/repos/status-im/status-react/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/status-react/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/status-react/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/status-react/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/status-react/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/status-react/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/status-react/merges","archive_url":"https://api.github.com/repos/status-im/status-react/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/status-react/downloads","issues_url":"https://api.github.com/repos/status-im/status-react/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/status-react/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/status-react/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/status-react/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/status-react/labels{/name}","releases_url":"https://api.github.com/repos/status-im/status-react/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/status-react/deployments","created_at":"2016-02-22T21:48:48Z","updated_at":"2018-04-24T03:25:45Z","pushed_at":"2018-04-24T07:23:32Z","git_url":"git://github.com/status-im/status-react.git","ssh_url":"git@github.com:status-im/status-react.git","clone_url":"https://github.com/status-im/status-react.git","svn_url":"https://github.com/status-im/status-react","homepage":"https://status.im","size":53520,"stargazers_count":2150,"watchers_count":2150,"language":"Clojure","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":523,"mirror_url":null,"archived":false,"open_issues_count":567,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":523,"open_issues":567,"watchers":2150,"default_branch":"develop"}},"base":{"label":"status-im:develop","ref":"develop","sha":"a7bd6b6e5c3d646120e8e9304d54627370aa8e88","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":52308441,"name":"status-react","full_name":"status-im/status-react","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/status-react","description":"a free (libre) open source, mobile OS for Ethereum","fork":false,"url":"https://api.github.com/repos/status-im/status-react","forks_url":"https://api.github.com/repos/status-im/status-react/forks","keys_url":"https://api.github.com/repos/status-im/status-react/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/status-react/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/status-react/teams","hooks_url":"https://api.github.com/repos/status-im/status-react/hooks","issue_events_url":"https://api.github.com/repos/status-im/status-react/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/status-react/events","assignees_url":"https://api.github.com/repos/status-im/status-react/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/status-react/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/status-react/tags","blobs_url":"https://api.github.com/repos/status-im/status-react/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/status-react/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/status-react/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/status-react/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/status-react/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/status-react/languages","stargazers_url":"https://api.github.com/repos/status-im/status-react/stargazers","contributors_url":"https://api.github.com/repos/status-im/status-react/contributors","subscribers_url":"https://api.github.com/repos/status-im/status-react/subscribers","subscription_url":"https://api.github.com/repos/status-im/status-react/subscription","commits_url":"https://api.github.com/repos/status-im/status-react/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/status-react/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/status-react/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/status-react/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/status-react/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/status-react/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/status-react/merges","archive_url":"https://api.github.com/repos/status-im/status-react/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/status-react/downloads","issues_url":"https://api.github.com/repos/status-im/status-react/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/status-react/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/status-react/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/status-react/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/status-react/labels{/name}","releases_url":"https://api.github.com/repos/status-im/status-react/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/status-react/deployments","created_at":"2016-02-22T21:48:48Z","updated_at":"2018-04-24T03:25:45Z","pushed_at":"2018-04-24T07:23:32Z","git_url":"git://github.com/status-im/status-react.git","ssh_url":"git@github.com:status-im/status-react.git","clone_url":"https://github.com/status-im/status-react.git","svn_url":"https://github.com/status-im/status-react","homepage":"https://status.im","size":53520,"stargazers_count":2150,"watchers_count":2150,"language":"Clojure","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":523,"mirror_url":null,"archived":false,"open_issues_count":567,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":523,"open_issues":567,"watchers":2150,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/status-im/status-react/pulls/3974"},"html":{"href":"https://github.com/status-im/status-react/pull/3974"},"issue":{"href":"https://api.github.com/repos/status-im/status-react/issues/3974"},"comments":{"href":"https://api.github.com/repos/status-im/status-react/issues/3974/comments"},"review_comments":{"href":"https://api.github.com/repos/status-im/status-react/pulls/3974/comments"},"review_comment":{"href":"https://api.github.com/repos/status-im/status-react/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/status-im/status-react/pulls/3974/commits"},"statuses":{"href":"https://api.github.com/repos/status-im/status-react/statuses/6e19f819a206e0f6f971a1e34e00d81d232226d9"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"rasom"}}