{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/frontend/pulls/comments/116262167","pull_request_review_id":37874971,"id":116262167,"diff_hunk":"@@ -0,0 +1,199 @@\n+// @flow\n+\n+/* eslint no-param-reassign: \"off\" */\n+\n+import raven from 'lib/raven';\n+import config from 'lib/config';\n+import { getCurrentTime } from 'lib/user-timing';\n+import beacon from 'common/modules/analytics/beacon';\n+import ophan from 'ophan/ng';\n+\n+type Module = {\n+    name: string,\n+    start: number,\n+    duration?: number,\n+};\n+\n+type Baseline = {\n+    name: string,\n+    startTime: number,\n+    endTime?: number,\n+};\n+\n+type AdvertMetrics = {\n+    id: string,\n+    isEmpty: boolean,\n+    createTime: number,\n+    startLoading: number,\n+    stopLoading: number,\n+    startRendering: number,\n+    stopRendering: number,\n+    loadingMethod: number,\n+    lazyWaitComplete: number,\n+};\n+\n+const performanceLog = {\n+    viewId: 'unknown',\n+    tags: ([]: Array<string>),\n+    modules: ([]: Array<Module>),\n+    adverts: ([]: Array<AdvertMetrics>),\n+    baselines: ([]: Array<Baseline>),\n+};\n+const primaryBaseline = 'primary';\n+\n+// moduleStart() and moduleEnd() can be used for measuring modules ad-hoc,\n+// when they don't align to a baseline.\n+const moduleStart = (moduleName: string): void => {\n+    const timerStart = getCurrentTime();\n+    performanceLog.modules.push({\n+        name: moduleName,\n+        start: timerStart,\n+    });\n+};\n+\n+const moduleEnd = (moduleName: string): void => {\n+    const timerEnd = getCurrentTime();\n+\n+    const moduleIndex = performanceLog.modules.findIndex(\n+        module => module.name === moduleName\n+    );\n+\n+    if (moduleIndex !== -1) {\n+        const module: Module = performanceLog.modules[moduleIndex];\n+        module.duration = timerEnd - module.start;\n+    }\n+};\n+\n+// updateAdvertMetric() is called whenever the advert timings need to be updated.\n+// It may be called multiple times for the same advert, so that we effectively update\n+// the object with additional timings.\n+const updateAdvertMetric = (\n+    advert: Object,\n+    metricName: string,\n+    metricValue: string | number\n+): void => {\n+    performanceLog.adverts = performanceLog.adverts.filter(\n+        element => advert.id !== element.id\n+    );\n+    advert.timings[metricName] = metricValue;\n+    performanceLog.adverts.push(\n+        Object.freeze(\n+            Object.assign(","path":"static/src/javascripts/projects/commercial/modules/dfp/performance-logging.js","position":81,"original_position":81,"commit_id":"42058b49ad0859cc8f70e53ba9546ec13095c303","original_commit_id":"42058b49ad0859cc8f70e53ba9546ec13095c303","user":{"login":"regiskuckaertz","id":629976,"avatar_url":"https://avatars1.githubusercontent.com/u/629976?v=3","gravatar_id":"","url":"https://api.github.com/users/regiskuckaertz","html_url":"https://github.com/regiskuckaertz","followers_url":"https://api.github.com/users/regiskuckaertz/followers","following_url":"https://api.github.com/users/regiskuckaertz/following{/other_user}","gists_url":"https://api.github.com/users/regiskuckaertz/gists{/gist_id}","starred_url":"https://api.github.com/users/regiskuckaertz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/regiskuckaertz/subscriptions","organizations_url":"https://api.github.com/users/regiskuckaertz/orgs","repos_url":"https://api.github.com/users/regiskuckaertz/repos","events_url":"https://api.github.com/users/regiskuckaertz/events{/privacy}","received_events_url":"https://api.github.com/users/regiskuckaertz/received_events","type":"User","site_admin":false},"body":"`Object.assign` ftw 😎 ","created_at":"2017-05-12T15:45:20Z","updated_at":"2017-05-12T15:45:20Z","html_url":"https://github.com/guardian/frontend/pull/16752#discussion_r116262167","pull_request_url":"https://api.github.com/repos/guardian/frontend/pulls/16752","_links":{"self":{"href":"https://api.github.com/repos/guardian/frontend/pulls/comments/116262167"},"html":{"href":"https://github.com/guardian/frontend/pull/16752#discussion_r116262167"},"pull_request":{"href":"https://api.github.com/repos/guardian/frontend/pulls/16752"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/frontend/pulls/16752","id":120351321,"html_url":"https://github.com/guardian/frontend/pull/16752","diff_url":"https://github.com/guardian/frontend/pull/16752.diff","patch_url":"https://github.com/guardian/frontend/pull/16752.patch","issue_url":"https://api.github.com/repos/guardian/frontend/issues/16752","number":16752,"state":"open","locked":false,"title":":es6: performanceLogging","user":{"login":"regiskuckaertz","id":629976,"avatar_url":"https://avatars1.githubusercontent.com/u/629976?v=3","gravatar_id":"","url":"https://api.github.com/users/regiskuckaertz","html_url":"https://github.com/regiskuckaertz","followers_url":"https://api.github.com/users/regiskuckaertz/followers","following_url":"https://api.github.com/users/regiskuckaertz/following{/other_user}","gists_url":"https://api.github.com/users/regiskuckaertz/gists{/gist_id}","starred_url":"https://api.github.com/users/regiskuckaertz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/regiskuckaertz/subscriptions","organizations_url":"https://api.github.com/users/regiskuckaertz/orgs","repos_url":"https://api.github.com/users/regiskuckaertz/repos","events_url":"https://api.github.com/users/regiskuckaertz/events{/privacy}","received_events_url":"https://api.github.com/users/regiskuckaertz/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-05-12T15:43:22Z","updated_at":"2017-05-12T15:45:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c750ab211ee84b6537ff7f2bad8ad221bcc738d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"janua","id":445472,"avatar_url":"https://avatars1.githubusercontent.com/u/445472?v=3","gravatar_id":"","url":"https://api.github.com/users/janua","html_url":"https://github.com/janua","followers_url":"https://api.github.com/users/janua/followers","following_url":"https://api.github.com/users/janua/following{/other_user}","gists_url":"https://api.github.com/users/janua/gists{/gist_id}","starred_url":"https://api.github.com/users/janua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janua/subscriptions","organizations_url":"https://api.github.com/users/janua/orgs","repos_url":"https://api.github.com/users/janua/repos","events_url":"https://api.github.com/users/janua/events{/privacy}","received_events_url":"https://api.github.com/users/janua/received_events","type":"User","site_admin":false},{"login":"JonNorman","id":1821099,"avatar_url":"https://avatars1.githubusercontent.com/u/1821099?v=3","gravatar_id":"","url":"https://api.github.com/users/JonNorman","html_url":"https://github.com/JonNorman","followers_url":"https://api.github.com/users/JonNorman/followers","following_url":"https://api.github.com/users/JonNorman/following{/other_user}","gists_url":"https://api.github.com/users/JonNorman/gists{/gist_id}","starred_url":"https://api.github.com/users/JonNorman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JonNorman/subscriptions","organizations_url":"https://api.github.com/users/JonNorman/orgs","repos_url":"https://api.github.com/users/JonNorman/repos","events_url":"https://api.github.com/users/JonNorman/events{/privacy}","received_events_url":"https://api.github.com/users/JonNorman/received_events","type":"User","site_admin":false},{"login":"rich-nguyen","id":4549425,"avatar_url":"https://avatars1.githubusercontent.com/u/4549425?v=3","gravatar_id":"","url":"https://api.github.com/users/rich-nguyen","html_url":"https://github.com/rich-nguyen","followers_url":"https://api.github.com/users/rich-nguyen/followers","following_url":"https://api.github.com/users/rich-nguyen/following{/other_user}","gists_url":"https://api.github.com/users/rich-nguyen/gists{/gist_id}","starred_url":"https://api.github.com/users/rich-nguyen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rich-nguyen/subscriptions","organizations_url":"https://api.github.com/users/rich-nguyen/orgs","repos_url":"https://api.github.com/users/rich-nguyen/repos","events_url":"https://api.github.com/users/rich-nguyen/events{/privacy}","received_events_url":"https://api.github.com/users/rich-nguyen/received_events","type":"User","site_admin":false},{"login":"lps88","id":6290008,"avatar_url":"https://avatars0.githubusercontent.com/u/6290008?v=3","gravatar_id":"","url":"https://api.github.com/users/lps88","html_url":"https://github.com/lps88","followers_url":"https://api.github.com/users/lps88/followers","following_url":"https://api.github.com/users/lps88/following{/other_user}","gists_url":"https://api.github.com/users/lps88/gists{/gist_id}","starred_url":"https://api.github.com/users/lps88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lps88/subscriptions","organizations_url":"https://api.github.com/users/lps88/orgs","repos_url":"https://api.github.com/users/lps88/repos","events_url":"https://api.github.com/users/lps88/events{/privacy}","received_events_url":"https://api.github.com/users/lps88/received_events","type":"User","site_admin":false},{"login":"katebee","id":8607683,"avatar_url":"https://avatars0.githubusercontent.com/u/8607683?v=3","gravatar_id":"","url":"https://api.github.com/users/katebee","html_url":"https://github.com/katebee","followers_url":"https://api.github.com/users/katebee/followers","following_url":"https://api.github.com/users/katebee/following{/other_user}","gists_url":"https://api.github.com/users/katebee/gists{/gist_id}","starred_url":"https://api.github.com/users/katebee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katebee/subscriptions","organizations_url":"https://api.github.com/users/katebee/orgs","repos_url":"https://api.github.com/users/katebee/repos","events_url":"https://api.github.com/users/katebee/events{/privacy}","received_events_url":"https://api.github.com/users/katebee/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/guardian/frontend/pulls/16752/commits","review_comments_url":"https://api.github.com/repos/guardian/frontend/pulls/16752/comments","review_comment_url":"https://api.github.com/repos/guardian/frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/frontend/issues/16752/comments","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/42058b49ad0859cc8f70e53ba9546ec13095c303","head":{"label":"guardian:rk-es6-performanceLogging","ref":"rk-es6-performanceLogging","sha":"42058b49ad0859cc8f70e53ba9546ec13095c303","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars3.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":4370755,"name":"frontend","full_name":"guardian/frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars3.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/frontend","description":"Source for theguardian.com","fork":false,"url":"https://api.github.com/repos/guardian/frontend","forks_url":"https://api.github.com/repos/guardian/frontend/forks","keys_url":"https://api.github.com/repos/guardian/frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/frontend/teams","hooks_url":"https://api.github.com/repos/guardian/frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/frontend/events","assignees_url":"https://api.github.com/repos/guardian/frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/frontend/tags","blobs_url":"https://api.github.com/repos/guardian/frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/frontend/subscription","commits_url":"https://api.github.com/repos/guardian/frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/frontend/merges","archive_url":"https://api.github.com/repos/guardian/frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/frontend/downloads","issues_url":"https://api.github.com/repos/guardian/frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/frontend/deployments","created_at":"2012-05-18T15:39:15Z","updated_at":"2017-05-12T15:05:13Z","pushed_at":"2017-05-12T15:43:22Z","git_url":"git://github.com/guardian/frontend.git","ssh_url":"git@github.com:guardian/frontend.git","clone_url":"https://github.com/guardian/frontend.git","svn_url":"https://github.com/guardian/frontend","homepage":"https://www.theguardian.com","size":521884,"stargazers_count":3562,"watchers_count":3562,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":385,"mirror_url":null,"open_issues_count":65,"forks":385,"open_issues":65,"watchers":3562,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"d9d39edc59bfdabb09113070565bc911323edf58","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars3.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":4370755,"name":"frontend","full_name":"guardian/frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars3.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/frontend","description":"Source for theguardian.com","fork":false,"url":"https://api.github.com/repos/guardian/frontend","forks_url":"https://api.github.com/repos/guardian/frontend/forks","keys_url":"https://api.github.com/repos/guardian/frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/frontend/teams","hooks_url":"https://api.github.com/repos/guardian/frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/frontend/events","assignees_url":"https://api.github.com/repos/guardian/frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/frontend/tags","blobs_url":"https://api.github.com/repos/guardian/frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/frontend/subscription","commits_url":"https://api.github.com/repos/guardian/frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/frontend/merges","archive_url":"https://api.github.com/repos/guardian/frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/frontend/downloads","issues_url":"https://api.github.com/repos/guardian/frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/frontend/deployments","created_at":"2012-05-18T15:39:15Z","updated_at":"2017-05-12T15:05:13Z","pushed_at":"2017-05-12T15:43:22Z","git_url":"git://github.com/guardian/frontend.git","ssh_url":"git@github.com:guardian/frontend.git","clone_url":"https://github.com/guardian/frontend.git","svn_url":"https://github.com/guardian/frontend","homepage":"https://www.theguardian.com","size":521884,"stargazers_count":3562,"watchers_count":3562,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":385,"mirror_url":null,"open_issues_count":65,"forks":385,"open_issues":65,"watchers":3562,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/frontend/pulls/16752"},"html":{"href":"https://github.com/guardian/frontend/pull/16752"},"issue":{"href":"https://api.github.com/repos/guardian/frontend/issues/16752"},"comments":{"href":"https://api.github.com/repos/guardian/frontend/issues/16752/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/frontend/pulls/16752/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/frontend/pulls/16752/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/frontend/statuses/42058b49ad0859cc8f70e53ba9546ec13095c303"}}}}
{"actor":{"display_login":"regiskuckaertz"}}