{"action":"created","comment":{"url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/comments/124708764","pull_request_review_id":47019475,"id":124708764,"diff_hunk":"@@ -444,3 +532,121 @@ extension RouteController: CLLocationManagerDelegate {\n         incrementRouteProgress(alertLevel, location: location, updateStepIndex: updateStepIndex)\n     }\n }\n+\n+struct SessionState {\n+    let identifier = UUID()\n+    var departureTimestamp: Date?\n+    var arrivalTimestamp: Date?\n+    \n+    var totalDistanceCompleted: CLLocationDistance = 0\n+    \n+    var numberOfReroutes = 0\n+    var lastReroute: Date?\n+    \n+    var currentRoute: Route!\n+    var currentRequestIdentifier: String?\n+    \n+    var originalRoute: Route!\n+    var originalRequestIdentifier: String?\n+    \n+    var pastLocations = FixedLengthBuffer<CLLocation>(length: 40)\n+}\n+\n+// MARK: - Telemetry\n+extension RouteController {\n+    \n+    func sendDepartEvent() {\n+        let eventName = \"navigation.depart\"\n+        \n+        NSLog(\"Sending \\(eventName)\")\n+        \n+        var eventDictionary = MGLMapboxEvents.addDefaultEvents(routeController: self)\n+        eventDictionary[\"event\"] = eventName\n+\n+        MGLMapboxEvents.pushEvent(eventName, withAttributes: eventDictionary)\n+        MGLMapboxEvents.flush()\n+    }\n+    \n+    func sendFeedbackEvent(event: CoreFeedbackEvent) {\n+        // remove from outstanding event queue\n+        if let index = outstandingFeedbackEvents.index(of: event) {\n+            outstandingFeedbackEvents.remove(at: index)\n+        }\n+        \n+        let eventName = event.eventDictionary[\"event\"] as! String\n+        \n+        NSLog(\"Sending \\(eventName)\")\n+\n+        event.eventDictionary[\"locationsBefore\"] = sessionState.pastLocations.allObjects.filter({$0.timestamp <= event.timestamp }).map({$0.dictionary})\n+        event.eventDictionary[\"locationsAfter\"] = sessionState.pastLocations.allObjects.filter({$0.timestamp > event.timestamp }).map({$0.dictionary})","path":"MapboxCoreNavigation/RouteController.swift","position":219,"original_position":219,"commit_id":"e9ab2d30c70b640c715159d945efdd29aa561a8e","original_commit_id":"e9ab2d30c70b640c715159d945efdd29aa561a8e","user":{"login":"1ec5","id":1231218,"avatar_url":"https://avatars3.githubusercontent.com/u/1231218?v=3","gravatar_id":"","url":"https://api.github.com/users/1ec5","html_url":"https://github.com/1ec5","followers_url":"https://api.github.com/users/1ec5/followers","following_url":"https://api.github.com/users/1ec5/following{/other_user}","gists_url":"https://api.github.com/users/1ec5/gists{/gist_id}","starred_url":"https://api.github.com/users/1ec5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1ec5/subscriptions","organizations_url":"https://api.github.com/users/1ec5/orgs","repos_url":"https://api.github.com/users/1ec5/repos","events_url":"https://api.github.com/users/1ec5/events{/privacy}","received_events_url":"https://api.github.com/users/1ec5/received_events","type":"User","site_admin":false},"body":"Nit: Use trailing closure syntax.","created_at":"2017-06-29T04:15:31Z","updated_at":"2017-06-29T04:35:07Z","html_url":"https://github.com/mapbox/mapbox-navigation-ios/pull/304#discussion_r124708764","pull_request_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/304","_links":{"self":{"href":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/comments/124708764"},"html":{"href":"https://github.com/mapbox/mapbox-navigation-ios/pull/304#discussion_r124708764"},"pull_request":{"href":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/304"}}},"pull_request":{"url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/304","id":126984576,"html_url":"https://github.com/mapbox/mapbox-navigation-ios/pull/304","diff_url":"https://github.com/mapbox/mapbox-navigation-ios/pull/304.diff","patch_url":"https://github.com/mapbox/mapbox-navigation-ios/pull/304.patch","issue_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/issues/304","number":304,"state":"open","locked":false,"title":"Add telemetry events","user":{"login":"bsudekum","id":1058624,"avatar_url":"https://avatars3.githubusercontent.com/u/1058624?v=3","gravatar_id":"","url":"https://api.github.com/users/bsudekum","html_url":"https://github.com/bsudekum","followers_url":"https://api.github.com/users/bsudekum/followers","following_url":"https://api.github.com/users/bsudekum/following{/other_user}","gists_url":"https://api.github.com/users/bsudekum/gists{/gist_id}","starred_url":"https://api.github.com/users/bsudekum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsudekum/subscriptions","organizations_url":"https://api.github.com/users/bsudekum/orgs","repos_url":"https://api.github.com/users/bsudekum/repos","events_url":"https://api.github.com/users/bsudekum/events{/privacy}","received_events_url":"https://api.github.com/users/bsudekum/received_events","type":"User","site_admin":false},"body":"_Telem events manager needs to be made public first: https://github.com/mapbox/mapbox-gl-native/tree/bs-telem-api_\r\n\r\nThis PR adds the ground work for telemetry events and also adds the first event, rerouting. On every reroute, an event will be pushed to the event manager containing the last 20 locations prior to the reroute and up to 20 locations after the reroute. The event manager in the iOS SDK will then push all events in a single network request to the server.\r\n\r\nThe goal here is help improve all aspects of the navigation SKD and also the directions API which this SDK relies on. \r\n\r\n/cc @1ec5 @ericrwolfe @frederoni \r\n\r\n","created_at":"2017-06-22T12:51:59Z","updated_at":"2017-06-29T04:35:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38bedaaee211b41d213e8f67e51c98f87a7539d8","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/304/commits","review_comments_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/304/comments","review_comment_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/issues/304/comments","statuses_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/statuses/e9ab2d30c70b640c715159d945efdd29aa561a8e","head":{"label":"mapbox:telem","ref":"telem","sha":"e9ab2d30c70b640c715159d945efdd29aa561a8e","user":{"login":"mapbox","id":600935,"avatar_url":"https://avatars2.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"repo":{"id":73870932,"name":"mapbox-navigation-ios","full_name":"mapbox/mapbox-navigation-ios","owner":{"login":"mapbox","id":600935,"avatar_url":"https://avatars2.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapbox/mapbox-navigation-ios","description":"Turn-by-turn navigation logic and UI in Swift or Objective-C on iOS","fork":false,"url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios","forks_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/forks","keys_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/teams","hooks_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/hooks","issue_events_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/issues/events{/number}","events_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/events","assignees_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/assignees{/user}","branches_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/branches{/branch}","tags_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/tags","blobs_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/languages","stargazers_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/stargazers","contributors_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/contributors","subscribers_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/subscribers","subscription_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/subscription","commits_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/contents/{+path}","compare_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/merges","archive_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/downloads","issues_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/issues{/number}","pulls_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/labels{/name}","releases_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/releases{/id}","deployments_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/deployments","created_at":"2016-11-16T01:23:44Z","updated_at":"2017-06-28T16:43:49Z","pushed_at":"2017-06-29T00:20:18Z","git_url":"git://github.com/mapbox/mapbox-navigation-ios.git","ssh_url":"git@github.com:mapbox/mapbox-navigation-ios.git","clone_url":"https://github.com/mapbox/mapbox-navigation-ios.git","svn_url":"https://github.com/mapbox/mapbox-navigation-ios","homepage":"https://www.mapbox.com/navigation-sdk/","size":5520,"stargazers_count":87,"watchers_count":87,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":35,"mirror_url":null,"open_issues_count":51,"forks":35,"open_issues":51,"watchers":87,"default_branch":"master"}},"base":{"label":"mapbox:master","ref":"master","sha":"2e2779d4056e1319e9901476b88319774833220f","user":{"login":"mapbox","id":600935,"avatar_url":"https://avatars2.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"repo":{"id":73870932,"name":"mapbox-navigation-ios","full_name":"mapbox/mapbox-navigation-ios","owner":{"login":"mapbox","id":600935,"avatar_url":"https://avatars2.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapbox/mapbox-navigation-ios","description":"Turn-by-turn navigation logic and UI in Swift or Objective-C on iOS","fork":false,"url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios","forks_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/forks","keys_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/teams","hooks_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/hooks","issue_events_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/issues/events{/number}","events_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/events","assignees_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/assignees{/user}","branches_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/branches{/branch}","tags_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/tags","blobs_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/languages","stargazers_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/stargazers","contributors_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/contributors","subscribers_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/subscribers","subscription_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/subscription","commits_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/contents/{+path}","compare_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/merges","archive_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/downloads","issues_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/issues{/number}","pulls_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/labels{/name}","releases_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/releases{/id}","deployments_url":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/deployments","created_at":"2016-11-16T01:23:44Z","updated_at":"2017-06-28T16:43:49Z","pushed_at":"2017-06-29T00:20:18Z","git_url":"git://github.com/mapbox/mapbox-navigation-ios.git","ssh_url":"git@github.com:mapbox/mapbox-navigation-ios.git","clone_url":"https://github.com/mapbox/mapbox-navigation-ios.git","svn_url":"https://github.com/mapbox/mapbox-navigation-ios","homepage":"https://www.mapbox.com/navigation-sdk/","size":5520,"stargazers_count":87,"watchers_count":87,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":35,"mirror_url":null,"open_issues_count":51,"forks":35,"open_issues":51,"watchers":87,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/304"},"html":{"href":"https://github.com/mapbox/mapbox-navigation-ios/pull/304"},"issue":{"href":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/issues/304"},"comments":{"href":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/issues/304/comments"},"review_comments":{"href":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/304/comments"},"review_comment":{"href":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/pulls/304/commits"},"statuses":{"href":"https://api.github.com/repos/mapbox/mapbox-navigation-ios/statuses/e9ab2d30c70b640c715159d945efdd29aa561a8e"}}}}
{"actor":{"display_login":"1ec5"}}