{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments/41415005","id":41415005,"diff_hunk":"@@ -0,0 +1,82 @@\n+/*global snowplow_name_here, guardian */\n+define(['lodash/object'], function (_) {\n+    'use strict';\n+\n+    var snowplow;\n+\n+    var schema = {\n+        '$schema': 'http://json-schema.org/schema#',\n+        'self': {\n+            'vendor': 'com.gu',\n+            'name': 'page_load',\n+            'format': 'jsonschema',\n+            'version': '1-0-0'\n+        },\n+        'type': 'object',\n+        'properties': {\n+            'eventSource': {\n+                'type': 'string'\n+            },\n+            'pageName': {\n+                'type': 'string'\n+            },\n+            'channel': {\n+                'type': 'string'\n+            },\n+            'productBillingFrequency': {\n+                'type': 'string'\n+            },\n+            'productBillingAmount': {\n+                'type': 'string'\n+            },\n+            'productType': {\n+                'type': 'string'\n+            }\n+        },\n+        'required': ['eventSource', 'pageName', 'channel', 'productBillingFrequency', 'productBillingAmount', 'productType'],\n+        'additionalProperties': false\n+    };\n+\n+\n+    function trackActivity(source, data) {\n+        var eventData = _.merge({\n+            eventSource: source\n+        }, (data || {}));\n+\n+        snowplow('trackUnstructEvent', {schema: schema, data: eventData})\n+    }\n+\n+    function trackPageLoad() {\n+        var pageInfo = guardian.pageInfo,\n+            productData = guardian.productData;\n+\n+        var data = {\n+            pageName: pageInfo.name,\n+            channel: pageInfo.channel,\n+            productBillingFrequency: '', //NOTE Seems that snowplow doesnt work without these default values and requiring in schema\n+            productBillingAmount: '',\n+            productType: ''\n+        };\n+\n+        if (productData) {\n+            data.productBillingFrequency = productData.frequency.toString();\n+            data.productBillingAmount = productData.amount;\n+            data.productType = productData.type;\n+        }\n+\n+        trackActivity('pageLoaded', data);\n+    }\n+\n+    function init() {","path":"assets/javascripts/modules/analytics/snowplow.js","position":70,"original_position":70,"commit_id":"d8db6c2105da78ad3eac4e9ac5355aab63722db2","original_commit_id":"d8db6c2105da78ad3eac4e9ac5355aab63722db2","user":{"login":"davidrapson","id":123386,"avatar_url":"https://avatars.githubusercontent.com/u/123386?v=3","gravatar_id":"","url":"https://api.github.com/users/davidrapson","html_url":"https://github.com/davidrapson","followers_url":"https://api.github.com/users/davidrapson/followers","following_url":"https://api.github.com/users/davidrapson/following{/other_user}","gists_url":"https://api.github.com/users/davidrapson/gists{/gist_id}","starred_url":"https://api.github.com/users/davidrapson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidrapson/subscriptions","organizations_url":"https://api.github.com/users/davidrapson/orgs","repos_url":"https://api.github.com/users/davidrapson/repos","events_url":"https://api.github.com/users/davidrapson/events{/privacy}","received_events_url":"https://api.github.com/users/davidrapson/received_events","type":"User","site_admin":false},"body":"Mentioned above, but could we handle the actual loading of the snowplow js and setup in here too, rather than as inline script blocks?","created_at":"2015-10-07T16:49:04Z","updated_at":"2015-10-07T16:49:04Z","html_url":"https://github.com/guardian/subscriptions-frontend/pull/246#discussion_r41415005","pull_request_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/246","_links":{"self":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments/41415005"},"html":{"href":"https://github.com/guardian/subscriptions-frontend/pull/246#discussion_r41415005"},"pull_request":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/246"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/246","id":47051443,"html_url":"https://github.com/guardian/subscriptions-frontend/pull/246","diff_url":"https://github.com/guardian/subscriptions-frontend/pull/246.diff","patch_url":"https://github.com/guardian/subscriptions-frontend/pull/246.patch","issue_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/246","number":246,"state":"open","locked":false,"title":"Event tracking","user":{"login":"chrisjowen","id":80583,"avatar_url":"https://avatars.githubusercontent.com/u/80583?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisjowen","html_url":"https://github.com/chrisjowen","followers_url":"https://api.github.com/users/chrisjowen/followers","following_url":"https://api.github.com/users/chrisjowen/following{/other_user}","gists_url":"https://api.github.com/users/chrisjowen/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisjowen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisjowen/subscriptions","organizations_url":"https://api.github.com/users/chrisjowen/orgs","repos_url":"https://api.github.com/users/chrisjowen/repos","events_url":"https://api.github.com/users/chrisjowen/events{/privacy}","received_events_url":"https://api.github.com/users/chrisjowen/received_events","type":"User","site_admin":false},"body":"Snowplow tracking added for all page loads and checkout start and registration events. ","created_at":"2015-10-07T16:40:17Z","updated_at":"2015-10-07T16:49:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e0f323a71d2c5cea03407377a722b74f2b4fa15","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/246/commits","review_comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/246/comments","review_comment_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/246/comments","statuses_url":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/d8db6c2105da78ad3eac4e9ac5355aab63722db2","head":{"label":"guardian:event-tracking","ref":"event-tracking","sha":"d8db6c2105da78ad3eac4e9ac5355aab63722db2","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.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":34392023,"name":"subscriptions-frontend","full_name":"guardian/subscriptions-frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.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/subscriptions-frontend","description":"","fork":false,"url":"https://api.github.com/repos/guardian/subscriptions-frontend","forks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/forks","keys_url":"https://api.github.com/repos/guardian/subscriptions-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/subscriptions-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/subscriptions-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/events","assignees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/subscriptions-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/subscriptions-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/subscriptions-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/subscriptions-frontend/merges","archive_url":"https://api.github.com/repos/guardian/subscriptions-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/subscriptions-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/subscriptions-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/subscriptions-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/subscriptions-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/subscriptions-frontend/releases{/id}","created_at":"2015-04-22T13:30:13Z","updated_at":"2015-08-22T03:37:45Z","pushed_at":"2015-10-07T16:40:17Z","git_url":"git://github.com/guardian/subscriptions-frontend.git","ssh_url":"git@github.com:guardian/subscriptions-frontend.git","clone_url":"https://github.com/guardian/subscriptions-frontend.git","svn_url":"https://github.com/guardian/subscriptions-frontend","homepage":"https://sites.google.com/a/guardian.co.uk/guardian-subscriptions/","size":6756,"stargazers_count":4,"watchers_count":4,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":4,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"a6f630aba5a29335ad5563ced7e4edb53940b5fd","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.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":34392023,"name":"subscriptions-frontend","full_name":"guardian/subscriptions-frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.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/subscriptions-frontend","description":"","fork":false,"url":"https://api.github.com/repos/guardian/subscriptions-frontend","forks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/forks","keys_url":"https://api.github.com/repos/guardian/subscriptions-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/subscriptions-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/subscriptions-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/subscriptions-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/subscriptions-frontend/events","assignees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/subscriptions-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/subscriptions-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/subscriptions-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/subscriptions-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/subscriptions-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/subscriptions-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/subscriptions-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/subscriptions-frontend/merges","archive_url":"https://api.github.com/repos/guardian/subscriptions-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/subscriptions-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/subscriptions-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/subscriptions-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/subscriptions-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/subscriptions-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/subscriptions-frontend/releases{/id}","created_at":"2015-04-22T13:30:13Z","updated_at":"2015-08-22T03:37:45Z","pushed_at":"2015-10-07T16:40:17Z","git_url":"git://github.com/guardian/subscriptions-frontend.git","ssh_url":"git@github.com:guardian/subscriptions-frontend.git","clone_url":"https://github.com/guardian/subscriptions-frontend.git","svn_url":"https://github.com/guardian/subscriptions-frontend","homepage":"https://sites.google.com/a/guardian.co.uk/guardian-subscriptions/","size":6756,"stargazers_count":4,"watchers_count":4,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/246"},"html":{"href":"https://github.com/guardian/subscriptions-frontend/pull/246"},"issue":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/246"},"comments":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/issues/246/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/246/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/pulls/246/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/subscriptions-frontend/statuses/d8db6c2105da78ad3eac4e9ac5355aab63722db2"}}}}