{"action":"created","comment":{"url":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/comments/62407416","id":62407416,"diff_hunk":"@@ -247,6 +255,110 @@ fn test_max_body_size() {\n     delete_file(\"cid.dat\");\n }\n \n+\n+// This test is being ignored as it requires you to setup an environment variable\n+// called GOOGLE_ACCESS_TOKEN.  The token can be obtained from the Metrics Explorer.\n+#[ignore]\n+#[cfg(feature = \"integration\")]\n+#[test]\n+fn test_google_analytics_received() {\n+    let event_category     = \"test\";\n+    let event_action       = \"integration\";\n+    let event_label        = &Uuid::new_v4().to_simple_string().to_string();\n+    let event_value        = 999999;\n+    let ei = get_event_info();\n+\n+    let mut metrics_controller = MetricsController::new(\n+        ei.app_name.to_string(), ei.app_version.to_string(), ei.app_update_channel.to_string(),\n+        ei.app_build_id.to_string(), ei.app_platform.to_string(), ei.locale.to_string(),\n+        ei.device.to_string(), ei.arch.to_string(), ei.os.to_string(), ei.os_version.to_string());\n+\n+    metrics_controller.record_event(event_category, event_action, event_label, event_value);\n+\n+    // This sleep is necessary so the main thread does not exit.\n+    thread::sleep(std::time::Duration::from_secs(30));\n+\n+    // Read the environment variable for the Google Access Token... Obtain\n+    // this from Query Explorer. It is good for an hour.\n+    let access_token:String;\n+    let key = \"GOOGLE_ACCESS_TOKEN\";\n+    match env::var_os(key) {\n+        Some(val) => {\n+            access_token = val.to_str().unwrap().to_string();\n+            println!(\"{}\", access_token);\n+        },\n+        None => panic!(\"GOOGLE_ACCESS_TOKEN is not defined in the environment. \\\n+                        Retrieve this value from the query explorer\")\n+    }\n+\n+    // Get the time so we can filter by it.\n+    let ts = time::now();\n+    let filter_time = format!(\"{0:4}-{1:02}-{2:02}\", ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday);\n+\n+    let report_url = format!(\"https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A121095747&\\\n+                             start-date={0}&end-date={1}&metrics=ga%3AeventValue&\\\n+                             dimensions=ga%3AeventCategory%2Cga%3AeventAction%2Cga%3AeventLabel&\\\n+                             filters=ga%3AeventLabel%3D%3D{2}&access_token={3}\",\n+                             filter_time, filter_time, event_label, access_token);\n+\n+    println!(\"REPORT URL: {}\", report_url);\n+\n+    // This is set to success only when the eventValue matches what we sent above.\n+    let mut success: bool = false;\n+\n+    // Loop 10 times to give the data time to be queryable by the reporting API.\n+    // As an observation it seems to take about 2.5 minutes for the data to arrive.\n+    for _ in 0 .. 10 {\n+        thread::sleep(std::time::Duration::from_secs(30));\n+\n+        let client = Client::new();\n+        let mut res = client.get(&report_url.to_string()).send().unwrap();\n+\n+        if hyper::status::StatusCode::Unauthorized == res.status {\n+            println!(\"Access Token missing or expired.  Set environment /\n+                      variable GOOGLE_ACCESS_TOKEN to access token\");\n+        }\n+\n+        // Read the Response Code.\n+        assert_eq!(res.status, hyper::Ok);\n+\n+        let mut s = String::new();\n+        res.read_to_string(&mut s).unwrap();\n+\n+        let data: Value = serde_json::from_str(&s).unwrap();\n+        let obj = data.as_object().unwrap();\n+\n+        let val: Option<Value> = Some(obj.get(&\"totalsForAllResults\".to_string()).unwrap().clone());","path":"tests/lib.rs","position":123,"original_position":123,"commit_id":"79ad951083c08d585716b10c5e9ceeb88ec7223a","original_commit_id":"79ad951083c08d585716b10c5e9ceeb88ec7223a","user":{"login":"russnicoletti","id":5983096,"avatar_url":"https://avatars.githubusercontent.com/u/5983096?v=3","gravatar_id":"","url":"https://api.github.com/users/russnicoletti","html_url":"https://github.com/russnicoletti","followers_url":"https://api.github.com/users/russnicoletti/followers","following_url":"https://api.github.com/users/russnicoletti/following{/other_user}","gists_url":"https://api.github.com/users/russnicoletti/gists{/gist_id}","starred_url":"https://api.github.com/users/russnicoletti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/russnicoletti/subscriptions","organizations_url":"https://api.github.com/users/russnicoletti/orgs","repos_url":"https://api.github.com/users/russnicoletti/repos","events_url":"https://api.github.com/users/russnicoletti/events{/privacy}","received_events_url":"https://api.github.com/users/russnicoletti/received_events","type":"User","site_admin":false},"body":"Is it necessary to use an Option here? It's always being set to 'Some(...)' so it seems it will never be 'None'. Shouldn't we set 'val' to 'obj.get(&\"totalsForAllResults\".to_string())' because '.get' itself returns an Option that will be either Some if the key was found and None if it wasn't found.","created_at":"2016-05-07T00:35:33Z","updated_at":"2016-05-07T00:35:33Z","html_url":"https://github.com/tamarahills/metrics_controller/pull/65#discussion_r62407416","pull_request_url":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/65","_links":{"self":{"href":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/comments/62407416"},"html":{"href":"https://github.com/tamarahills/metrics_controller/pull/65#discussion_r62407416"},"pull_request":{"href":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/65"}}},"pull_request":{"url":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/65","id":69221851,"html_url":"https://github.com/tamarahills/metrics_controller/pull/65","diff_url":"https://github.com/tamarahills/metrics_controller/pull/65.diff","patch_url":"https://github.com/tamarahills/metrics_controller/pull/65.patch","issue_url":"https://api.github.com/repos/tamarahills/metrics_controller/issues/65","number":65,"state":"open","locked":false,"title":"Issue #64 - Create an end to end Integration test with sending data t…","user":{"login":"tamarahills","id":7558944,"avatar_url":"https://avatars.githubusercontent.com/u/7558944?v=3","gravatar_id":"","url":"https://api.github.com/users/tamarahills","html_url":"https://github.com/tamarahills","followers_url":"https://api.github.com/users/tamarahills/followers","following_url":"https://api.github.com/users/tamarahills/following{/other_user}","gists_url":"https://api.github.com/users/tamarahills/gists{/gist_id}","starred_url":"https://api.github.com/users/tamarahills/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamarahills/subscriptions","organizations_url":"https://api.github.com/users/tamarahills/orgs","repos_url":"https://api.github.com/users/tamarahills/repos","events_url":"https://api.github.com/users/tamarahills/events{/privacy}","received_events_url":"https://api.github.com/users/tamarahills/received_events","type":"User","site_admin":false},"body":"…o GA and using reporting API to validate.","created_at":"2016-05-06T23:02:11Z","updated_at":"2016-05-07T00:35:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e1b9dc1fe88275dd77eb7955712a6f010f907de8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/65/commits","review_comments_url":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/65/comments","review_comment_url":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tamarahills/metrics_controller/issues/65/comments","statuses_url":"https://api.github.com/repos/tamarahills/metrics_controller/statuses/79ad951083c08d585716b10c5e9ceeb88ec7223a","head":{"label":"tamarahills:issue/64-end-to-end-integration-test-with-google","ref":"issue/64-end-to-end-integration-test-with-google","sha":"79ad951083c08d585716b10c5e9ceeb88ec7223a","user":{"login":"tamarahills","id":7558944,"avatar_url":"https://avatars.githubusercontent.com/u/7558944?v=3","gravatar_id":"","url":"https://api.github.com/users/tamarahills","html_url":"https://github.com/tamarahills","followers_url":"https://api.github.com/users/tamarahills/followers","following_url":"https://api.github.com/users/tamarahills/following{/other_user}","gists_url":"https://api.github.com/users/tamarahills/gists{/gist_id}","starred_url":"https://api.github.com/users/tamarahills/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamarahills/subscriptions","organizations_url":"https://api.github.com/users/tamarahills/orgs","repos_url":"https://api.github.com/users/tamarahills/repos","events_url":"https://api.github.com/users/tamarahills/events{/privacy}","received_events_url":"https://api.github.com/users/tamarahills/received_events","type":"User","site_admin":false},"repo":{"id":53618407,"name":"metrics_controller","full_name":"tamarahills/metrics_controller","owner":{"login":"tamarahills","id":7558944,"avatar_url":"https://avatars.githubusercontent.com/u/7558944?v=3","gravatar_id":"","url":"https://api.github.com/users/tamarahills","html_url":"https://github.com/tamarahills","followers_url":"https://api.github.com/users/tamarahills/followers","following_url":"https://api.github.com/users/tamarahills/following{/other_user}","gists_url":"https://api.github.com/users/tamarahills/gists{/gist_id}","starred_url":"https://api.github.com/users/tamarahills/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamarahills/subscriptions","organizations_url":"https://api.github.com/users/tamarahills/orgs","repos_url":"https://api.github.com/users/tamarahills/repos","events_url":"https://api.github.com/users/tamarahills/events{/privacy}","received_events_url":"https://api.github.com/users/tamarahills/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tamarahills/metrics_controller","description":"Metrics for Mozilla Connected Devices Projects","fork":false,"url":"https://api.github.com/repos/tamarahills/metrics_controller","forks_url":"https://api.github.com/repos/tamarahills/metrics_controller/forks","keys_url":"https://api.github.com/repos/tamarahills/metrics_controller/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tamarahills/metrics_controller/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tamarahills/metrics_controller/teams","hooks_url":"https://api.github.com/repos/tamarahills/metrics_controller/hooks","issue_events_url":"https://api.github.com/repos/tamarahills/metrics_controller/issues/events{/number}","events_url":"https://api.github.com/repos/tamarahills/metrics_controller/events","assignees_url":"https://api.github.com/repos/tamarahills/metrics_controller/assignees{/user}","branches_url":"https://api.github.com/repos/tamarahills/metrics_controller/branches{/branch}","tags_url":"https://api.github.com/repos/tamarahills/metrics_controller/tags","blobs_url":"https://api.github.com/repos/tamarahills/metrics_controller/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tamarahills/metrics_controller/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tamarahills/metrics_controller/git/refs{/sha}","trees_url":"https://api.github.com/repos/tamarahills/metrics_controller/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tamarahills/metrics_controller/statuses/{sha}","languages_url":"https://api.github.com/repos/tamarahills/metrics_controller/languages","stargazers_url":"https://api.github.com/repos/tamarahills/metrics_controller/stargazers","contributors_url":"https://api.github.com/repos/tamarahills/metrics_controller/contributors","subscribers_url":"https://api.github.com/repos/tamarahills/metrics_controller/subscribers","subscription_url":"https://api.github.com/repos/tamarahills/metrics_controller/subscription","commits_url":"https://api.github.com/repos/tamarahills/metrics_controller/commits{/sha}","git_commits_url":"https://api.github.com/repos/tamarahills/metrics_controller/git/commits{/sha}","comments_url":"https://api.github.com/repos/tamarahills/metrics_controller/comments{/number}","issue_comment_url":"https://api.github.com/repos/tamarahills/metrics_controller/issues/comments{/number}","contents_url":"https://api.github.com/repos/tamarahills/metrics_controller/contents/{+path}","compare_url":"https://api.github.com/repos/tamarahills/metrics_controller/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tamarahills/metrics_controller/merges","archive_url":"https://api.github.com/repos/tamarahills/metrics_controller/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tamarahills/metrics_controller/downloads","issues_url":"https://api.github.com/repos/tamarahills/metrics_controller/issues{/number}","pulls_url":"https://api.github.com/repos/tamarahills/metrics_controller/pulls{/number}","milestones_url":"https://api.github.com/repos/tamarahills/metrics_controller/milestones{/number}","notifications_url":"https://api.github.com/repos/tamarahills/metrics_controller/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tamarahills/metrics_controller/labels{/name}","releases_url":"https://api.github.com/repos/tamarahills/metrics_controller/releases{/id}","deployments_url":"https://api.github.com/repos/tamarahills/metrics_controller/deployments","created_at":"2016-03-10T21:29:21Z","updated_at":"2016-03-28T22:43:15Z","pushed_at":"2016-05-06T23:25:48Z","git_url":"git://github.com/tamarahills/metrics_controller.git","ssh_url":"git@github.com:tamarahills/metrics_controller.git","clone_url":"https://github.com/tamarahills/metrics_controller.git","svn_url":"https://github.com/tamarahills/metrics_controller","homepage":"","size":89,"stargazers_count":3,"watchers_count":3,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":3,"default_branch":"master"}},"base":{"label":"tamarahills:master","ref":"master","sha":"75c335318bae84205ecc3fed17aef139fe028abd","user":{"login":"tamarahills","id":7558944,"avatar_url":"https://avatars.githubusercontent.com/u/7558944?v=3","gravatar_id":"","url":"https://api.github.com/users/tamarahills","html_url":"https://github.com/tamarahills","followers_url":"https://api.github.com/users/tamarahills/followers","following_url":"https://api.github.com/users/tamarahills/following{/other_user}","gists_url":"https://api.github.com/users/tamarahills/gists{/gist_id}","starred_url":"https://api.github.com/users/tamarahills/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamarahills/subscriptions","organizations_url":"https://api.github.com/users/tamarahills/orgs","repos_url":"https://api.github.com/users/tamarahills/repos","events_url":"https://api.github.com/users/tamarahills/events{/privacy}","received_events_url":"https://api.github.com/users/tamarahills/received_events","type":"User","site_admin":false},"repo":{"id":53618407,"name":"metrics_controller","full_name":"tamarahills/metrics_controller","owner":{"login":"tamarahills","id":7558944,"avatar_url":"https://avatars.githubusercontent.com/u/7558944?v=3","gravatar_id":"","url":"https://api.github.com/users/tamarahills","html_url":"https://github.com/tamarahills","followers_url":"https://api.github.com/users/tamarahills/followers","following_url":"https://api.github.com/users/tamarahills/following{/other_user}","gists_url":"https://api.github.com/users/tamarahills/gists{/gist_id}","starred_url":"https://api.github.com/users/tamarahills/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamarahills/subscriptions","organizations_url":"https://api.github.com/users/tamarahills/orgs","repos_url":"https://api.github.com/users/tamarahills/repos","events_url":"https://api.github.com/users/tamarahills/events{/privacy}","received_events_url":"https://api.github.com/users/tamarahills/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tamarahills/metrics_controller","description":"Metrics for Mozilla Connected Devices Projects","fork":false,"url":"https://api.github.com/repos/tamarahills/metrics_controller","forks_url":"https://api.github.com/repos/tamarahills/metrics_controller/forks","keys_url":"https://api.github.com/repos/tamarahills/metrics_controller/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tamarahills/metrics_controller/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tamarahills/metrics_controller/teams","hooks_url":"https://api.github.com/repos/tamarahills/metrics_controller/hooks","issue_events_url":"https://api.github.com/repos/tamarahills/metrics_controller/issues/events{/number}","events_url":"https://api.github.com/repos/tamarahills/metrics_controller/events","assignees_url":"https://api.github.com/repos/tamarahills/metrics_controller/assignees{/user}","branches_url":"https://api.github.com/repos/tamarahills/metrics_controller/branches{/branch}","tags_url":"https://api.github.com/repos/tamarahills/metrics_controller/tags","blobs_url":"https://api.github.com/repos/tamarahills/metrics_controller/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tamarahills/metrics_controller/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tamarahills/metrics_controller/git/refs{/sha}","trees_url":"https://api.github.com/repos/tamarahills/metrics_controller/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tamarahills/metrics_controller/statuses/{sha}","languages_url":"https://api.github.com/repos/tamarahills/metrics_controller/languages","stargazers_url":"https://api.github.com/repos/tamarahills/metrics_controller/stargazers","contributors_url":"https://api.github.com/repos/tamarahills/metrics_controller/contributors","subscribers_url":"https://api.github.com/repos/tamarahills/metrics_controller/subscribers","subscription_url":"https://api.github.com/repos/tamarahills/metrics_controller/subscription","commits_url":"https://api.github.com/repos/tamarahills/metrics_controller/commits{/sha}","git_commits_url":"https://api.github.com/repos/tamarahills/metrics_controller/git/commits{/sha}","comments_url":"https://api.github.com/repos/tamarahills/metrics_controller/comments{/number}","issue_comment_url":"https://api.github.com/repos/tamarahills/metrics_controller/issues/comments{/number}","contents_url":"https://api.github.com/repos/tamarahills/metrics_controller/contents/{+path}","compare_url":"https://api.github.com/repos/tamarahills/metrics_controller/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tamarahills/metrics_controller/merges","archive_url":"https://api.github.com/repos/tamarahills/metrics_controller/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tamarahills/metrics_controller/downloads","issues_url":"https://api.github.com/repos/tamarahills/metrics_controller/issues{/number}","pulls_url":"https://api.github.com/repos/tamarahills/metrics_controller/pulls{/number}","milestones_url":"https://api.github.com/repos/tamarahills/metrics_controller/milestones{/number}","notifications_url":"https://api.github.com/repos/tamarahills/metrics_controller/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tamarahills/metrics_controller/labels{/name}","releases_url":"https://api.github.com/repos/tamarahills/metrics_controller/releases{/id}","deployments_url":"https://api.github.com/repos/tamarahills/metrics_controller/deployments","created_at":"2016-03-10T21:29:21Z","updated_at":"2016-03-28T22:43:15Z","pushed_at":"2016-05-06T23:25:48Z","git_url":"git://github.com/tamarahills/metrics_controller.git","ssh_url":"git@github.com:tamarahills/metrics_controller.git","clone_url":"https://github.com/tamarahills/metrics_controller.git","svn_url":"https://github.com/tamarahills/metrics_controller","homepage":"","size":89,"stargazers_count":3,"watchers_count":3,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/65"},"html":{"href":"https://github.com/tamarahills/metrics_controller/pull/65"},"issue":{"href":"https://api.github.com/repos/tamarahills/metrics_controller/issues/65"},"comments":{"href":"https://api.github.com/repos/tamarahills/metrics_controller/issues/65/comments"},"review_comments":{"href":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/65/comments"},"review_comment":{"href":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tamarahills/metrics_controller/pulls/65/commits"},"statuses":{"href":"https://api.github.com/repos/tamarahills/metrics_controller/statuses/79ad951083c08d585716b10c5e9ceeb88ec7223a"}}}}