{"action":"created","comment":{"url":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/comments/186496807","pull_request_review_id":118086224,"id":186496807,"diff_hunk":"@@ -0,0 +1,85 @@\n+import configurable from '../utils/configurable'\n+\n+@configurable\n+export default class GoogleTagManager {\n+\n+  constructor(config) {\n+    this.configure(this.defaults, config)\n+  }\n+\n+  get url() {\n+    const { gtmAuth, gtmPreview, gtmId } = this.config\n+    return `//www.googletagmanager.com/gtm.js?id=${gtmId}&gtm_auth=${gtmAuth}&gtm_preview=${gtmPreview}&gtm_cookies_win=x`\n+  }\n+\n+  get queue() {\n+    const queue = this._queue || (this._queue = [])\n+    return queue\n+  }\n+\n+  reset() {\n+    const { gtmId } = this.config\n+    window.google_tag_manager[gtmId].dataLayer.reset()\n+  }\n+\n+  track(data) {\n+    this.queue.push(data)\n+  }\n+\n+  deliver(data) {\n+    window.dataLayer.push(data)\n+  }\n+\n+  loadWithData(reducerModules) {\n+    const script = this.createScriptDoc(reducerModules)\n+    document.getElementsByTagName('head')[0].appendChild(script)\n+\n+    const noscript = this.createNoScript()\n+    document.getElementsByTagName('body')[0].appendChild(noscript)\n+  }\n+\n+  onLoad(reducerModules) {\n+    const {\n+      queue,\n+      config: {\n+        dataLayer,\n+      },\n+    } = this\n+    const dataLayerData = reducerModules.reduce((obj, reducer) => reducer.reduce(obj),\n+      { 'gtm.start': new Date().getTime(), event: 'gtm.js', ...dataLayer })\n+    window.dataLayer = window.dataLayer || []\n+    window.dataLayer.push(dataLayerData)\n+    this.track = data => this.deliver(data)\n+\n+    while (queue.length) {\n+      this.track(queue.pop())\n+    }\n+  }\n+\n+  createScriptDoc(reducerModules) {\n+    const script = document.createElement('script')\n+    script.addEventListener('load', () => this.onLoad(reducerModules))\n+    return Object.assign(script, {\n+      src: this.url,\n+      type: 'text/javascript',\n+      async: true,\n+    })\n+  }\n+\n+  createNoScript() {\n+    const noscript = document.createElement('noscript')\n+    const { gtmAuth, gtmPreview, gtmId } = this.config\n+    noscript.innerHTML = `<iframe src=\"//www.googletagmanager.com/ns.html?id=${gtmId}${gtmAuth}${gtmPreview}&gtm_cookies_win=x\"\n+        height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\" id=\"tag-manager\"></iframe>`\n+    return noscript\n+  }\n+\n+  get defaults() {\n+    return {\n+      gtmId: undefined,\n+      dataLayer: {},\n+      auth: '',\n+      preview: '',","path":"src/providers/GoogleTagManager.js","position":82,"original_position":82,"commit_id":"2c1968a61c006526cf7556d92dd1af904f5ed4c5","original_commit_id":"2c1968a61c006526cf7556d92dd1af904f5ed4c5","user":{"login":"barelyfitz","id":185461,"avatar_url":"https://avatars3.githubusercontent.com/u/185461?v=4","gravatar_id":"","url":"https://api.github.com/users/barelyfitz","html_url":"https://github.com/barelyfitz","followers_url":"https://api.github.com/users/barelyfitz/followers","following_url":"https://api.github.com/users/barelyfitz/following{/other_user}","gists_url":"https://api.github.com/users/barelyfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/barelyfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barelyfitz/subscriptions","organizations_url":"https://api.github.com/users/barelyfitz/orgs","repos_url":"https://api.github.com/users/barelyfitz/repos","events_url":"https://api.github.com/users/barelyfitz/events{/privacy}","received_events_url":"https://api.github.com/users/barelyfitz/received_events","type":"User","site_admin":false},"body":"If gtmId, auth, and preview are not provided will the script or noscript elements work at all? Should we just try to load some nonsense, or maybe thrown an error instead?","created_at":"2018-05-07T17:50:07Z","updated_at":"2018-05-07T17:50:08Z","html_url":"https://github.com/rentpath/event-tracker.js/pull/12#discussion_r186496807","pull_request_url":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/12","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/comments/186496807"},"html":{"href":"https://github.com/rentpath/event-tracker.js/pull/12#discussion_r186496807"},"pull_request":{"href":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/12","id":185792956,"html_url":"https://github.com/rentpath/event-tracker.js/pull/12","diff_url":"https://github.com/rentpath/event-tracker.js/pull/12.diff","patch_url":"https://github.com/rentpath/event-tracker.js/pull/12.patch","issue_url":"https://api.github.com/repos/rentpath/event-tracker.js/issues/12","number":12,"state":"open","locked":false,"title":"EventTracker Provider for Google Tag Manager","user":{"login":"pmyneni-rp","id":35237452,"avatar_url":"https://avatars3.githubusercontent.com/u/35237452?v=4","gravatar_id":"","url":"https://api.github.com/users/pmyneni-rp","html_url":"https://github.com/pmyneni-rp","followers_url":"https://api.github.com/users/pmyneni-rp/followers","following_url":"https://api.github.com/users/pmyneni-rp/following{/other_user}","gists_url":"https://api.github.com/users/pmyneni-rp/gists{/gist_id}","starred_url":"https://api.github.com/users/pmyneni-rp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmyneni-rp/subscriptions","organizations_url":"https://api.github.com/users/pmyneni-rp/orgs","repos_url":"https://api.github.com/users/pmyneni-rp/repos","events_url":"https://api.github.com/users/pmyneni-rp/events{/privacy}","received_events_url":"https://api.github.com/users/pmyneni-rp/received_events","type":"User","site_admin":false},"body":"Needed for rentals.com launch - [Rentals PR](https://github.com/rentpath/rentals-js/pull/170)","created_at":"2018-05-03T17:58:23Z","updated_at":"2018-05-07T17:50:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b397c9907f864e1204786c79a40894386961729d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":322213020,"url":"https://api.github.com/repos/rentpath/event-tracker.js/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/12/commits","review_comments_url":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/12/comments","review_comment_url":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rentpath/event-tracker.js/issues/12/comments","statuses_url":"https://api.github.com/repos/rentpath/event-tracker.js/statuses/2c1968a61c006526cf7556d92dd1af904f5ed4c5","head":{"label":"rentpath:provider_gtm","ref":"provider_gtm","sha":"2c1968a61c006526cf7556d92dd1af904f5ed4c5","user":{"login":"rentpath","id":37622,"avatar_url":"https://avatars3.githubusercontent.com/u/37622?v=4","gravatar_id":"","url":"https://api.github.com/users/rentpath","html_url":"https://github.com/rentpath","followers_url":"https://api.github.com/users/rentpath/followers","following_url":"https://api.github.com/users/rentpath/following{/other_user}","gists_url":"https://api.github.com/users/rentpath/gists{/gist_id}","starred_url":"https://api.github.com/users/rentpath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rentpath/subscriptions","organizations_url":"https://api.github.com/users/rentpath/orgs","repos_url":"https://api.github.com/users/rentpath/repos","events_url":"https://api.github.com/users/rentpath/events{/privacy}","received_events_url":"https://api.github.com/users/rentpath/received_events","type":"Organization","site_admin":false},"repo":{"id":51174439,"name":"event-tracker.js","full_name":"rentpath/event-tracker.js","owner":{"login":"rentpath","id":37622,"avatar_url":"https://avatars3.githubusercontent.com/u/37622?v=4","gravatar_id":"","url":"https://api.github.com/users/rentpath","html_url":"https://github.com/rentpath","followers_url":"https://api.github.com/users/rentpath/followers","following_url":"https://api.github.com/users/rentpath/following{/other_user}","gists_url":"https://api.github.com/users/rentpath/gists{/gist_id}","starred_url":"https://api.github.com/users/rentpath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rentpath/subscriptions","organizations_url":"https://api.github.com/users/rentpath/orgs","repos_url":"https://api.github.com/users/rentpath/repos","events_url":"https://api.github.com/users/rentpath/events{/privacy}","received_events_url":"https://api.github.com/users/rentpath/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rentpath/event-tracker.js","description":"Capture and distribute events.","fork":false,"url":"https://api.github.com/repos/rentpath/event-tracker.js","forks_url":"https://api.github.com/repos/rentpath/event-tracker.js/forks","keys_url":"https://api.github.com/repos/rentpath/event-tracker.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rentpath/event-tracker.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rentpath/event-tracker.js/teams","hooks_url":"https://api.github.com/repos/rentpath/event-tracker.js/hooks","issue_events_url":"https://api.github.com/repos/rentpath/event-tracker.js/issues/events{/number}","events_url":"https://api.github.com/repos/rentpath/event-tracker.js/events","assignees_url":"https://api.github.com/repos/rentpath/event-tracker.js/assignees{/user}","branches_url":"https://api.github.com/repos/rentpath/event-tracker.js/branches{/branch}","tags_url":"https://api.github.com/repos/rentpath/event-tracker.js/tags","blobs_url":"https://api.github.com/repos/rentpath/event-tracker.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rentpath/event-tracker.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rentpath/event-tracker.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/rentpath/event-tracker.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rentpath/event-tracker.js/statuses/{sha}","languages_url":"https://api.github.com/repos/rentpath/event-tracker.js/languages","stargazers_url":"https://api.github.com/repos/rentpath/event-tracker.js/stargazers","contributors_url":"https://api.github.com/repos/rentpath/event-tracker.js/contributors","subscribers_url":"https://api.github.com/repos/rentpath/event-tracker.js/subscribers","subscription_url":"https://api.github.com/repos/rentpath/event-tracker.js/subscription","commits_url":"https://api.github.com/repos/rentpath/event-tracker.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/rentpath/event-tracker.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/rentpath/event-tracker.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/rentpath/event-tracker.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/rentpath/event-tracker.js/contents/{+path}","compare_url":"https://api.github.com/repos/rentpath/event-tracker.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rentpath/event-tracker.js/merges","archive_url":"https://api.github.com/repos/rentpath/event-tracker.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rentpath/event-tracker.js/downloads","issues_url":"https://api.github.com/repos/rentpath/event-tracker.js/issues{/number}","pulls_url":"https://api.github.com/repos/rentpath/event-tracker.js/pulls{/number}","milestones_url":"https://api.github.com/repos/rentpath/event-tracker.js/milestones{/number}","notifications_url":"https://api.github.com/repos/rentpath/event-tracker.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rentpath/event-tracker.js/labels{/name}","releases_url":"https://api.github.com/repos/rentpath/event-tracker.js/releases{/id}","deployments_url":"https://api.github.com/repos/rentpath/event-tracker.js/deployments","created_at":"2016-02-05T21:15:39Z","updated_at":"2017-12-03T06:47:49Z","pushed_at":"2018-05-07T17:13:31Z","git_url":"git://github.com/rentpath/event-tracker.js.git","ssh_url":"git@github.com:rentpath/event-tracker.js.git","clone_url":"https://github.com/rentpath/event-tracker.js.git","svn_url":"https://github.com/rentpath/event-tracker.js","homepage":null,"size":222,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"rentpath:master","ref":"master","sha":"954bb8fa284231fb7864a29a1b01906658739fdf","user":{"login":"rentpath","id":37622,"avatar_url":"https://avatars3.githubusercontent.com/u/37622?v=4","gravatar_id":"","url":"https://api.github.com/users/rentpath","html_url":"https://github.com/rentpath","followers_url":"https://api.github.com/users/rentpath/followers","following_url":"https://api.github.com/users/rentpath/following{/other_user}","gists_url":"https://api.github.com/users/rentpath/gists{/gist_id}","starred_url":"https://api.github.com/users/rentpath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rentpath/subscriptions","organizations_url":"https://api.github.com/users/rentpath/orgs","repos_url":"https://api.github.com/users/rentpath/repos","events_url":"https://api.github.com/users/rentpath/events{/privacy}","received_events_url":"https://api.github.com/users/rentpath/received_events","type":"Organization","site_admin":false},"repo":{"id":51174439,"name":"event-tracker.js","full_name":"rentpath/event-tracker.js","owner":{"login":"rentpath","id":37622,"avatar_url":"https://avatars3.githubusercontent.com/u/37622?v=4","gravatar_id":"","url":"https://api.github.com/users/rentpath","html_url":"https://github.com/rentpath","followers_url":"https://api.github.com/users/rentpath/followers","following_url":"https://api.github.com/users/rentpath/following{/other_user}","gists_url":"https://api.github.com/users/rentpath/gists{/gist_id}","starred_url":"https://api.github.com/users/rentpath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rentpath/subscriptions","organizations_url":"https://api.github.com/users/rentpath/orgs","repos_url":"https://api.github.com/users/rentpath/repos","events_url":"https://api.github.com/users/rentpath/events{/privacy}","received_events_url":"https://api.github.com/users/rentpath/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rentpath/event-tracker.js","description":"Capture and distribute events.","fork":false,"url":"https://api.github.com/repos/rentpath/event-tracker.js","forks_url":"https://api.github.com/repos/rentpath/event-tracker.js/forks","keys_url":"https://api.github.com/repos/rentpath/event-tracker.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rentpath/event-tracker.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rentpath/event-tracker.js/teams","hooks_url":"https://api.github.com/repos/rentpath/event-tracker.js/hooks","issue_events_url":"https://api.github.com/repos/rentpath/event-tracker.js/issues/events{/number}","events_url":"https://api.github.com/repos/rentpath/event-tracker.js/events","assignees_url":"https://api.github.com/repos/rentpath/event-tracker.js/assignees{/user}","branches_url":"https://api.github.com/repos/rentpath/event-tracker.js/branches{/branch}","tags_url":"https://api.github.com/repos/rentpath/event-tracker.js/tags","blobs_url":"https://api.github.com/repos/rentpath/event-tracker.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rentpath/event-tracker.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rentpath/event-tracker.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/rentpath/event-tracker.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rentpath/event-tracker.js/statuses/{sha}","languages_url":"https://api.github.com/repos/rentpath/event-tracker.js/languages","stargazers_url":"https://api.github.com/repos/rentpath/event-tracker.js/stargazers","contributors_url":"https://api.github.com/repos/rentpath/event-tracker.js/contributors","subscribers_url":"https://api.github.com/repos/rentpath/event-tracker.js/subscribers","subscription_url":"https://api.github.com/repos/rentpath/event-tracker.js/subscription","commits_url":"https://api.github.com/repos/rentpath/event-tracker.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/rentpath/event-tracker.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/rentpath/event-tracker.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/rentpath/event-tracker.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/rentpath/event-tracker.js/contents/{+path}","compare_url":"https://api.github.com/repos/rentpath/event-tracker.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rentpath/event-tracker.js/merges","archive_url":"https://api.github.com/repos/rentpath/event-tracker.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rentpath/event-tracker.js/downloads","issues_url":"https://api.github.com/repos/rentpath/event-tracker.js/issues{/number}","pulls_url":"https://api.github.com/repos/rentpath/event-tracker.js/pulls{/number}","milestones_url":"https://api.github.com/repos/rentpath/event-tracker.js/milestones{/number}","notifications_url":"https://api.github.com/repos/rentpath/event-tracker.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rentpath/event-tracker.js/labels{/name}","releases_url":"https://api.github.com/repos/rentpath/event-tracker.js/releases{/id}","deployments_url":"https://api.github.com/repos/rentpath/event-tracker.js/deployments","created_at":"2016-02-05T21:15:39Z","updated_at":"2017-12-03T06:47:49Z","pushed_at":"2018-05-07T17:13:31Z","git_url":"git://github.com/rentpath/event-tracker.js.git","ssh_url":"git@github.com:rentpath/event-tracker.js.git","clone_url":"https://github.com/rentpath/event-tracker.js.git","svn_url":"https://github.com/rentpath/event-tracker.js","homepage":null,"size":222,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/12"},"html":{"href":"https://github.com/rentpath/event-tracker.js/pull/12"},"issue":{"href":"https://api.github.com/repos/rentpath/event-tracker.js/issues/12"},"comments":{"href":"https://api.github.com/repos/rentpath/event-tracker.js/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rentpath/event-tracker.js/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/rentpath/event-tracker.js/statuses/2c1968a61c006526cf7556d92dd1af904f5ed4c5"}},"author_association":"NONE"}}
{"actor":{"display_login":"barelyfitz"}}