{"action":"created","comment":{"url":"https://api.github.com/repos/segmentio/analytics-php/pulls/comments/168359435","pull_request_review_id":96713124,"id":168359435,"diff_hunk":"@@ -0,0 +1,136 @@\n+<?php\n+\n+phpinfo();\n+\n+require_once(dirname(__FILE__) . \"/../lib/Segment.php\");\n+\n+class AxiosClient\n+{\n+  private $BaseAddress = null;\n+  private $Timeout = 3000;\n+  private $Authorization = \"\";\n+  private $RetryCount = 1;\n+\n+  public function __construct($baseAddress, $timeout, $authorization) {\n+    $this->BaseAddress = $baseAddress ? $baseAddress : \"https://api.runscope.com\";\n+    if ($timeout)\n+      $this->Timeout = $timeout;\n+    if ($authorization)\n+      $this->Authorization = $authorization;\n+  }\n+\n+  public function setRetryCount($count) {\n+    $this->RetryCount = $count > 0 ? $count : 1;\n+  }\n+\n+  public function get($url) {\n+    for ($i = 0; $i < $this->RetryCount; $i++) {\n+      // open connection\n+      $ch = curl_init();\n+\n+      // Set timeout\n+      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->Timeout);\n+      curl_setopt($ch, CURLOPT_TIMEOUT, $this->Timeout);\n+\n+      // Set authorization\n+      if ($this->Authorization) {\n+        $header = array();\n+        $header[] = 'Authorization: Bearer ' . $this->Authorization;\n+\n+        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);\n+      }\n+\n+      // Set url\n+      curl_setopt($ch, CURLOPT_URL, $this->BaseAddress . \"/\" . $url);\n+      curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);\n+\n+      $output = curl_exec($ch);\n+      $response = curl_getinfo($ch, CURLINFO_HTTP_CODE);\n+      curl_close($ch);\n+\n+      if ((int)$response == 200)\n+        return $output;\n+\n+      usleep(3);\n+    }\n+\n+    return NULL;\n+  }\n+}\n+\n+class AnalyticsE2ETest extends PHPUnit_Framework_TestCase {\n+\n+  private static $WRITE_KEY = \"Cum1GHo14CegfLd83gVxsbc5Sb6jK8SN\";\n+  private static $RUNSCOPE_BUCKET = \"pwb8mcmfks0f\";\n+  private $id = \"\";\n+\n+  private static function messageId(){\n+    return sprintf(\"%04x%04x%04x%04x%04x%04x%04x%04x\"\n+      , mt_rand(0, 0xffff)\n+      , mt_rand(0, 0xffff)\n+      , mt_rand(0, 0xffff)\n+      , mt_rand(0, 0x0fff) | 0x4000\n+      , mt_rand(0, 0x3fff) | 0x8000\n+      , mt_rand(0, 0xffff)\n+      , mt_rand(0, 0xffff)\n+      , mt_rand(0, 0xffff));\n+  }\n+\n+  function setUp() {\n+    date_default_timezone_set(\"UTC\");\n+\n+    $this->id = self::messageId();\n+\n+    // Segment Write Key for https://segment.com/segment-libraries/sources/analytics_node_e2e_test/overview.\n+    // This source is configured to send events to a Runscope bucket used by this test.\n+    Segment::init(self::$WRITE_KEY, array(\"debug\" => true));\n+    Segment::track(array(\n+      \"userId\" => \"prateek\",\n+      \"event\" => \"Item Purchased\",\n+      \"anonymousId\" => $this->id,\n+    ));\n+    Segment::flush();\n+\n+    // Give some time for events to be delivered from the API to destinations.\n+    sleep(5);     // 5 seconds.\n+  }\n+\n+  function testE2E() {\n+    // Verify RUNSCOPE_TOKEN is defined as system variable\n+    $this->assertTrue(isset($_SERVER[\"RUNSCOPE_TOKEN\"]));\n+    $token = $_SERVER[\"RUNSCOPE_TOKEN\"];\n+\n+    $client = new AxiosClient(\"https://api.runscope.com\", 10 * 1000, $token);\n+    $client->setRetryCount(3);\n+\n+    for ($i = 0; $i < 5; $i++)\n+    {\n+      // Runscope Bucket for https://www.runscope.com/stream/pwb8mcmfks0f.","path":"test/AnalyticsE2ETest.php","position":108,"original_position":108,"commit_id":"17897c115455848c8045699b249d1c3700e8c530","original_commit_id":"17897c115455848c8045699b249d1c3700e8c530","user":{"login":"f2prateek","id":843979,"avatar_url":"https://avatars2.githubusercontent.com/u/843979?v=4","gravatar_id":"","url":"https://api.github.com/users/f2prateek","html_url":"https://github.com/f2prateek","followers_url":"https://api.github.com/users/f2prateek/followers","following_url":"https://api.github.com/users/f2prateek/following{/other_user}","gists_url":"https://api.github.com/users/f2prateek/gists{/gist_id}","starred_url":"https://api.github.com/users/f2prateek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f2prateek/subscriptions","organizations_url":"https://api.github.com/users/f2prateek/orgs","repos_url":"https://api.github.com/users/f2prateek/repos","events_url":"https://api.github.com/users/f2prateek/events{/privacy}","received_events_url":"https://api.github.com/users/f2prateek/received_events","type":"User","site_admin":false},"body":"Let's change URL to https://www.runscope.com/stream/bmbbsjxdttr7","created_at":"2018-02-15T01:06:33Z","updated_at":"2018-02-15T01:06:33Z","html_url":"https://github.com/segmentio/analytics-php/pull/102#discussion_r168359435","pull_request_url":"https://api.github.com/repos/segmentio/analytics-php/pulls/102","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/segmentio/analytics-php/pulls/comments/168359435"},"html":{"href":"https://github.com/segmentio/analytics-php/pull/102#discussion_r168359435"},"pull_request":{"href":"https://api.github.com/repos/segmentio/analytics-php/pulls/102"}}},"pull_request":{"url":"https://api.github.com/repos/segmentio/analytics-php/pulls/102","id":168415740,"html_url":"https://github.com/segmentio/analytics-php/pull/102","diff_url":"https://github.com/segmentio/analytics-php/pull/102.diff","patch_url":"https://github.com/segmentio/analytics-php/pull/102.patch","issue_url":"https://api.github.com/repos/segmentio/analytics-php/issues/102","number":102,"state":"open","locked":false,"title":"Add E2E test","user":{"login":"kevingilliard","id":13878119,"avatar_url":"https://avatars2.githubusercontent.com/u/13878119?v=4","gravatar_id":"","url":"https://api.github.com/users/kevingilliard","html_url":"https://github.com/kevingilliard","followers_url":"https://api.github.com/users/kevingilliard/followers","following_url":"https://api.github.com/users/kevingilliard/following{/other_user}","gists_url":"https://api.github.com/users/kevingilliard/gists{/gist_id}","starred_url":"https://api.github.com/users/kevingilliard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevingilliard/subscriptions","organizations_url":"https://api.github.com/users/kevingilliard/orgs","repos_url":"https://api.github.com/users/kevingilliard/repos","events_url":"https://api.github.com/users/kevingilliard/events{/privacy}","received_events_url":"https://api.github.com/users/kevingilliard/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-10T19:04:35Z","updated_at":"2018-02-15T01:06:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"099b0ddb584dcb415c4809ffa314a883dd8e6973","assignee":{"login":"f2prateek","id":843979,"avatar_url":"https://avatars2.githubusercontent.com/u/843979?v=4","gravatar_id":"","url":"https://api.github.com/users/f2prateek","html_url":"https://github.com/f2prateek","followers_url":"https://api.github.com/users/f2prateek/followers","following_url":"https://api.github.com/users/f2prateek/following{/other_user}","gists_url":"https://api.github.com/users/f2prateek/gists{/gist_id}","starred_url":"https://api.github.com/users/f2prateek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f2prateek/subscriptions","organizations_url":"https://api.github.com/users/f2prateek/orgs","repos_url":"https://api.github.com/users/f2prateek/repos","events_url":"https://api.github.com/users/f2prateek/events{/privacy}","received_events_url":"https://api.github.com/users/f2prateek/received_events","type":"User","site_admin":false},"assignees":[{"login":"f2prateek","id":843979,"avatar_url":"https://avatars2.githubusercontent.com/u/843979?v=4","gravatar_id":"","url":"https://api.github.com/users/f2prateek","html_url":"https://github.com/f2prateek","followers_url":"https://api.github.com/users/f2prateek/followers","following_url":"https://api.github.com/users/f2prateek/following{/other_user}","gists_url":"https://api.github.com/users/f2prateek/gists{/gist_id}","starred_url":"https://api.github.com/users/f2prateek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f2prateek/subscriptions","organizations_url":"https://api.github.com/users/f2prateek/orgs","repos_url":"https://api.github.com/users/f2prateek/repos","events_url":"https://api.github.com/users/f2prateek/events{/privacy}","received_events_url":"https://api.github.com/users/f2prateek/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/segmentio/analytics-php/pulls/102/commits","review_comments_url":"https://api.github.com/repos/segmentio/analytics-php/pulls/102/comments","review_comment_url":"https://api.github.com/repos/segmentio/analytics-php/pulls/comments{/number}","comments_url":"https://api.github.com/repos/segmentio/analytics-php/issues/102/comments","statuses_url":"https://api.github.com/repos/segmentio/analytics-php/statuses/17897c115455848c8045699b249d1c3700e8c530","head":{"label":"segmentio:e2e_test","ref":"e2e_test","sha":"17897c115455848c8045699b249d1c3700e8c530","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"repo":{"id":7763939,"name":"analytics-php","full_name":"segmentio/analytics-php","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/segmentio/analytics-php","description":"The hassle-free way to integrate analytics into any php application.","fork":false,"url":"https://api.github.com/repos/segmentio/analytics-php","forks_url":"https://api.github.com/repos/segmentio/analytics-php/forks","keys_url":"https://api.github.com/repos/segmentio/analytics-php/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/analytics-php/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/analytics-php/teams","hooks_url":"https://api.github.com/repos/segmentio/analytics-php/hooks","issue_events_url":"https://api.github.com/repos/segmentio/analytics-php/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/analytics-php/events","assignees_url":"https://api.github.com/repos/segmentio/analytics-php/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/analytics-php/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/analytics-php/tags","blobs_url":"https://api.github.com/repos/segmentio/analytics-php/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/analytics-php/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/analytics-php/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/analytics-php/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/analytics-php/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/analytics-php/languages","stargazers_url":"https://api.github.com/repos/segmentio/analytics-php/stargazers","contributors_url":"https://api.github.com/repos/segmentio/analytics-php/contributors","subscribers_url":"https://api.github.com/repos/segmentio/analytics-php/subscribers","subscription_url":"https://api.github.com/repos/segmentio/analytics-php/subscription","commits_url":"https://api.github.com/repos/segmentio/analytics-php/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/analytics-php/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/analytics-php/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/analytics-php/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/analytics-php/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/analytics-php/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/analytics-php/merges","archive_url":"https://api.github.com/repos/segmentio/analytics-php/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/analytics-php/downloads","issues_url":"https://api.github.com/repos/segmentio/analytics-php/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/analytics-php/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/analytics-php/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/analytics-php/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/analytics-php/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/analytics-php/releases{/id}","deployments_url":"https://api.github.com/repos/segmentio/analytics-php/deployments","created_at":"2013-01-22T23:41:14Z","updated_at":"2018-01-31T22:18:43Z","pushed_at":"2018-02-12T22:18:15Z","git_url":"git://github.com/segmentio/analytics-php.git","ssh_url":"git@github.com:segmentio/analytics-php.git","clone_url":"https://github.com/segmentio/analytics-php.git","svn_url":"https://github.com/segmentio/analytics-php","homepage":"https://segment.com/libraries/php","size":204,"stargazers_count":164,"watchers_count":164,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":94,"mirror_url":null,"archived":false,"open_issues_count":7,"license":null,"forks":94,"open_issues":7,"watchers":164,"default_branch":"master"}},"base":{"label":"segmentio:master","ref":"master","sha":"5d1c3d0a9017eb675f9b5777eed748026e68bf77","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"repo":{"id":7763939,"name":"analytics-php","full_name":"segmentio/analytics-php","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/segmentio/analytics-php","description":"The hassle-free way to integrate analytics into any php application.","fork":false,"url":"https://api.github.com/repos/segmentio/analytics-php","forks_url":"https://api.github.com/repos/segmentio/analytics-php/forks","keys_url":"https://api.github.com/repos/segmentio/analytics-php/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/analytics-php/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/analytics-php/teams","hooks_url":"https://api.github.com/repos/segmentio/analytics-php/hooks","issue_events_url":"https://api.github.com/repos/segmentio/analytics-php/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/analytics-php/events","assignees_url":"https://api.github.com/repos/segmentio/analytics-php/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/analytics-php/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/analytics-php/tags","blobs_url":"https://api.github.com/repos/segmentio/analytics-php/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/analytics-php/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/analytics-php/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/analytics-php/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/analytics-php/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/analytics-php/languages","stargazers_url":"https://api.github.com/repos/segmentio/analytics-php/stargazers","contributors_url":"https://api.github.com/repos/segmentio/analytics-php/contributors","subscribers_url":"https://api.github.com/repos/segmentio/analytics-php/subscribers","subscription_url":"https://api.github.com/repos/segmentio/analytics-php/subscription","commits_url":"https://api.github.com/repos/segmentio/analytics-php/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/analytics-php/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/analytics-php/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/analytics-php/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/analytics-php/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/analytics-php/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/analytics-php/merges","archive_url":"https://api.github.com/repos/segmentio/analytics-php/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/analytics-php/downloads","issues_url":"https://api.github.com/repos/segmentio/analytics-php/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/analytics-php/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/analytics-php/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/analytics-php/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/analytics-php/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/analytics-php/releases{/id}","deployments_url":"https://api.github.com/repos/segmentio/analytics-php/deployments","created_at":"2013-01-22T23:41:14Z","updated_at":"2018-01-31T22:18:43Z","pushed_at":"2018-02-12T22:18:15Z","git_url":"git://github.com/segmentio/analytics-php.git","ssh_url":"git@github.com:segmentio/analytics-php.git","clone_url":"https://github.com/segmentio/analytics-php.git","svn_url":"https://github.com/segmentio/analytics-php","homepage":"https://segment.com/libraries/php","size":204,"stargazers_count":164,"watchers_count":164,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":94,"mirror_url":null,"archived":false,"open_issues_count":7,"license":null,"forks":94,"open_issues":7,"watchers":164,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/segmentio/analytics-php/pulls/102"},"html":{"href":"https://github.com/segmentio/analytics-php/pull/102"},"issue":{"href":"https://api.github.com/repos/segmentio/analytics-php/issues/102"},"comments":{"href":"https://api.github.com/repos/segmentio/analytics-php/issues/102/comments"},"review_comments":{"href":"https://api.github.com/repos/segmentio/analytics-php/pulls/102/comments"},"review_comment":{"href":"https://api.github.com/repos/segmentio/analytics-php/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/segmentio/analytics-php/pulls/102/commits"},"statuses":{"href":"https://api.github.com/repos/segmentio/analytics-php/statuses/17897c115455848c8045699b249d1c3700e8c530"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"f2prateek"}}