{"action":"created","comment":{"url":"https://api.github.com/repos/2gis/mapsapi/pulls/comments/50945979","id":50945979,"diff_hunk":"@@ -22,23 +22,33 @@ window.__dgApi__ = window.__dgApi__ || {};\n DG.version = window.__dgApi__.version;\n DG.Icon.Default.imagePath  = '../img/vendors/leaflet';\n \n-DG.Map.addInitHook(function () {\n-    /*eslint-disable */\n-    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n-    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n-    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n-    })(window,document,'script',DG.config.protocol+DG.config.googleAnalytics,'ga');\n+DG.Map.addInitHook((function () {\n+    var inited = false;\n \n-    ga('create', DG.config.gaCode, 'none', {name: 'mapsapi2gis'});\n-    ga('mapsapi2gis.send', 'pageview');\n-    /*eslint-enable */\n+    // Analytics inited once\n+    return function () {\n+        if (inited) {\n+            return;\n+        }\n \n-    var newImg = new Image();\n-    newImg.src = DG.config.protocol + DG.config.analytics + '?' +\n-        'sr=' + window.screen.width + 'x' + window.screen.height + '&' +\n-        'v=' + DG.version;\n+        /*eslint-disable */\n+        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n+        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n+        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n+        })(window,document,'script',DG.config.protocol+DG.config.googleAnalytics,'ga');\n \n-});\n+        ga('create', DG.config.gaCode, 'none', {name: 'mapsapi2gis'});\n+        ga('mapsapi2gis.send', 'pageview');","path":"src/DGCore/src/DGCore.js","position":34,"original_position":34,"commit_id":"9f0172427c65e493d1b81d91814f55b439b22a61","original_commit_id":"9f0172427c65e493d1b81d91814f55b439b22a61","user":{"login":"RLRR","id":4540062,"avatar_url":"https://avatars.githubusercontent.com/u/4540062?v=3","gravatar_id":"","url":"https://api.github.com/users/RLRR","html_url":"https://github.com/RLRR","followers_url":"https://api.github.com/users/RLRR/followers","following_url":"https://api.github.com/users/RLRR/following{/other_user}","gists_url":"https://api.github.com/users/RLRR/gists{/gist_id}","starred_url":"https://api.github.com/users/RLRR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RLRR/subscriptions","organizations_url":"https://api.github.com/users/RLRR/orgs","repos_url":"https://api.github.com/users/RLRR/repos","events_url":"https://api.github.com/users/RLRR/events{/privacy}","received_events_url":"https://api.github.com/users/RLRR/received_events","type":"User","site_admin":false},"body":"Думается мне, весь код, начиная с этой строчки, нужно-таки выполнять при каждом ините карты.\r\n@ilfa глянь, пожалуйста","created_at":"2016-01-27T06:30:31Z","updated_at":"2016-01-27T06:30:31Z","html_url":"https://github.com/2gis/mapsapi/pull/316#discussion_r50945979","pull_request_url":"https://api.github.com/repos/2gis/mapsapi/pulls/316","_links":{"self":{"href":"https://api.github.com/repos/2gis/mapsapi/pulls/comments/50945979"},"html":{"href":"https://github.com/2gis/mapsapi/pull/316#discussion_r50945979"},"pull_request":{"href":"https://api.github.com/repos/2gis/mapsapi/pulls/316"}}},"pull_request":{"url":"https://api.github.com/repos/2gis/mapsapi/pulls/316","id":57317547,"html_url":"https://github.com/2gis/mapsapi/pull/316","diff_url":"https://github.com/2gis/mapsapi/pull/316.diff","patch_url":"https://github.com/2gis/mapsapi/pull/316.patch","issue_url":"https://api.github.com/repos/2gis/mapsapi/issues/316","number":316,"state":"open","locked":false,"title":"Wrapper for analytics oncetime initialization","user":{"login":"eugeny-dementev","id":9016345,"avatar_url":"https://avatars.githubusercontent.com/u/9016345?v=3","gravatar_id":"","url":"https://api.github.com/users/eugeny-dementev","html_url":"https://github.com/eugeny-dementev","followers_url":"https://api.github.com/users/eugeny-dementev/followers","following_url":"https://api.github.com/users/eugeny-dementev/following{/other_user}","gists_url":"https://api.github.com/users/eugeny-dementev/gists{/gist_id}","starred_url":"https://api.github.com/users/eugeny-dementev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eugeny-dementev/subscriptions","organizations_url":"https://api.github.com/users/eugeny-dementev/orgs","repos_url":"https://api.github.com/users/eugeny-dementev/repos","events_url":"https://api.github.com/users/eugeny-dementev/events{/privacy}","received_events_url":"https://api.github.com/users/eugeny-dementev/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-27T06:04:18Z","updated_at":"2016-01-27T06:30:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef4ed56ee48685b4daeca95717768c96e022797e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/2gis/mapsapi/pulls/316/commits","review_comments_url":"https://api.github.com/repos/2gis/mapsapi/pulls/316/comments","review_comment_url":"https://api.github.com/repos/2gis/mapsapi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/2gis/mapsapi/issues/316/comments","statuses_url":"https://api.github.com/repos/2gis/mapsapi/statuses/9f0172427c65e493d1b81d91814f55b439b22a61","head":{"label":"2gis:analytics-init-once","ref":"analytics-init-once","sha":"9f0172427c65e493d1b81d91814f55b439b22a61","user":{"login":"2gis","id":1481435,"avatar_url":"https://avatars.githubusercontent.com/u/1481435?v=3","gravatar_id":"","url":"https://api.github.com/users/2gis","html_url":"https://github.com/2gis","followers_url":"https://api.github.com/users/2gis/followers","following_url":"https://api.github.com/users/2gis/following{/other_user}","gists_url":"https://api.github.com/users/2gis/gists{/gist_id}","starred_url":"https://api.github.com/users/2gis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2gis/subscriptions","organizations_url":"https://api.github.com/users/2gis/orgs","repos_url":"https://api.github.com/users/2gis/repos","events_url":"https://api.github.com/users/2gis/events{/privacy}","received_events_url":"https://api.github.com/users/2gis/received_events","type":"Organization","site_admin":false},"repo":{"id":8050444,"name":"mapsapi","full_name":"2gis/mapsapi","owner":{"login":"2gis","id":1481435,"avatar_url":"https://avatars.githubusercontent.com/u/1481435?v=3","gravatar_id":"","url":"https://api.github.com/users/2gis","html_url":"https://github.com/2gis","followers_url":"https://api.github.com/users/2gis/followers","following_url":"https://api.github.com/users/2gis/following{/other_user}","gists_url":"https://api.github.com/users/2gis/gists{/gist_id}","starred_url":"https://api.github.com/users/2gis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2gis/subscriptions","organizations_url":"https://api.github.com/users/2gis/orgs","repos_url":"https://api.github.com/users/2gis/repos","events_url":"https://api.github.com/users/2gis/events{/privacy}","received_events_url":"https://api.github.com/users/2gis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/2gis/mapsapi","description":"Карты 2ГИС — это точные данные обо всех объектах города, включая новостройки, с детализацией до заборов и внутриквартальных проездов.","fork":false,"url":"https://api.github.com/repos/2gis/mapsapi","forks_url":"https://api.github.com/repos/2gis/mapsapi/forks","keys_url":"https://api.github.com/repos/2gis/mapsapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/2gis/mapsapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/2gis/mapsapi/teams","hooks_url":"https://api.github.com/repos/2gis/mapsapi/hooks","issue_events_url":"https://api.github.com/repos/2gis/mapsapi/issues/events{/number}","events_url":"https://api.github.com/repos/2gis/mapsapi/events","assignees_url":"https://api.github.com/repos/2gis/mapsapi/assignees{/user}","branches_url":"https://api.github.com/repos/2gis/mapsapi/branches{/branch}","tags_url":"https://api.github.com/repos/2gis/mapsapi/tags","blobs_url":"https://api.github.com/repos/2gis/mapsapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/2gis/mapsapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/2gis/mapsapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/2gis/mapsapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/2gis/mapsapi/statuses/{sha}","languages_url":"https://api.github.com/repos/2gis/mapsapi/languages","stargazers_url":"https://api.github.com/repos/2gis/mapsapi/stargazers","contributors_url":"https://api.github.com/repos/2gis/mapsapi/contributors","subscribers_url":"https://api.github.com/repos/2gis/mapsapi/subscribers","subscription_url":"https://api.github.com/repos/2gis/mapsapi/subscription","commits_url":"https://api.github.com/repos/2gis/mapsapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/2gis/mapsapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/2gis/mapsapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/2gis/mapsapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/2gis/mapsapi/contents/{+path}","compare_url":"https://api.github.com/repos/2gis/mapsapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/2gis/mapsapi/merges","archive_url":"https://api.github.com/repos/2gis/mapsapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/2gis/mapsapi/downloads","issues_url":"https://api.github.com/repos/2gis/mapsapi/issues{/number}","pulls_url":"https://api.github.com/repos/2gis/mapsapi/pulls{/number}","milestones_url":"https://api.github.com/repos/2gis/mapsapi/milestones{/number}","notifications_url":"https://api.github.com/repos/2gis/mapsapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/2gis/mapsapi/labels{/name}","releases_url":"https://api.github.com/repos/2gis/mapsapi/releases{/id}","deployments_url":"https://api.github.com/repos/2gis/mapsapi/deployments","created_at":"2013-02-06T11:59:11Z","updated_at":"2016-01-11T04:50:08Z","pushed_at":"2016-01-27T06:04:18Z","git_url":"git://github.com/2gis/mapsapi.git","ssh_url":"git@github.com:2gis/mapsapi.git","clone_url":"https://github.com/2gis/mapsapi.git","svn_url":"https://github.com/2gis/mapsapi","homepage":"","size":16459,"stargazers_count":71,"watchers_count":71,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":20,"forks":1,"open_issues":20,"watchers":71,"default_branch":"master"}},"base":{"label":"2gis:master","ref":"master","sha":"fd07e54bd395161dad83a8c7a19b42c80dc45237","user":{"login":"2gis","id":1481435,"avatar_url":"https://avatars.githubusercontent.com/u/1481435?v=3","gravatar_id":"","url":"https://api.github.com/users/2gis","html_url":"https://github.com/2gis","followers_url":"https://api.github.com/users/2gis/followers","following_url":"https://api.github.com/users/2gis/following{/other_user}","gists_url":"https://api.github.com/users/2gis/gists{/gist_id}","starred_url":"https://api.github.com/users/2gis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2gis/subscriptions","organizations_url":"https://api.github.com/users/2gis/orgs","repos_url":"https://api.github.com/users/2gis/repos","events_url":"https://api.github.com/users/2gis/events{/privacy}","received_events_url":"https://api.github.com/users/2gis/received_events","type":"Organization","site_admin":false},"repo":{"id":8050444,"name":"mapsapi","full_name":"2gis/mapsapi","owner":{"login":"2gis","id":1481435,"avatar_url":"https://avatars.githubusercontent.com/u/1481435?v=3","gravatar_id":"","url":"https://api.github.com/users/2gis","html_url":"https://github.com/2gis","followers_url":"https://api.github.com/users/2gis/followers","following_url":"https://api.github.com/users/2gis/following{/other_user}","gists_url":"https://api.github.com/users/2gis/gists{/gist_id}","starred_url":"https://api.github.com/users/2gis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2gis/subscriptions","organizations_url":"https://api.github.com/users/2gis/orgs","repos_url":"https://api.github.com/users/2gis/repos","events_url":"https://api.github.com/users/2gis/events{/privacy}","received_events_url":"https://api.github.com/users/2gis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/2gis/mapsapi","description":"Карты 2ГИС — это точные данные обо всех объектах города, включая новостройки, с детализацией до заборов и внутриквартальных проездов.","fork":false,"url":"https://api.github.com/repos/2gis/mapsapi","forks_url":"https://api.github.com/repos/2gis/mapsapi/forks","keys_url":"https://api.github.com/repos/2gis/mapsapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/2gis/mapsapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/2gis/mapsapi/teams","hooks_url":"https://api.github.com/repos/2gis/mapsapi/hooks","issue_events_url":"https://api.github.com/repos/2gis/mapsapi/issues/events{/number}","events_url":"https://api.github.com/repos/2gis/mapsapi/events","assignees_url":"https://api.github.com/repos/2gis/mapsapi/assignees{/user}","branches_url":"https://api.github.com/repos/2gis/mapsapi/branches{/branch}","tags_url":"https://api.github.com/repos/2gis/mapsapi/tags","blobs_url":"https://api.github.com/repos/2gis/mapsapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/2gis/mapsapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/2gis/mapsapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/2gis/mapsapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/2gis/mapsapi/statuses/{sha}","languages_url":"https://api.github.com/repos/2gis/mapsapi/languages","stargazers_url":"https://api.github.com/repos/2gis/mapsapi/stargazers","contributors_url":"https://api.github.com/repos/2gis/mapsapi/contributors","subscribers_url":"https://api.github.com/repos/2gis/mapsapi/subscribers","subscription_url":"https://api.github.com/repos/2gis/mapsapi/subscription","commits_url":"https://api.github.com/repos/2gis/mapsapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/2gis/mapsapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/2gis/mapsapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/2gis/mapsapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/2gis/mapsapi/contents/{+path}","compare_url":"https://api.github.com/repos/2gis/mapsapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/2gis/mapsapi/merges","archive_url":"https://api.github.com/repos/2gis/mapsapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/2gis/mapsapi/downloads","issues_url":"https://api.github.com/repos/2gis/mapsapi/issues{/number}","pulls_url":"https://api.github.com/repos/2gis/mapsapi/pulls{/number}","milestones_url":"https://api.github.com/repos/2gis/mapsapi/milestones{/number}","notifications_url":"https://api.github.com/repos/2gis/mapsapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/2gis/mapsapi/labels{/name}","releases_url":"https://api.github.com/repos/2gis/mapsapi/releases{/id}","deployments_url":"https://api.github.com/repos/2gis/mapsapi/deployments","created_at":"2013-02-06T11:59:11Z","updated_at":"2016-01-11T04:50:08Z","pushed_at":"2016-01-27T06:04:18Z","git_url":"git://github.com/2gis/mapsapi.git","ssh_url":"git@github.com:2gis/mapsapi.git","clone_url":"https://github.com/2gis/mapsapi.git","svn_url":"https://github.com/2gis/mapsapi","homepage":"","size":16459,"stargazers_count":71,"watchers_count":71,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":20,"forks":1,"open_issues":20,"watchers":71,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/2gis/mapsapi/pulls/316"},"html":{"href":"https://github.com/2gis/mapsapi/pull/316"},"issue":{"href":"https://api.github.com/repos/2gis/mapsapi/issues/316"},"comments":{"href":"https://api.github.com/repos/2gis/mapsapi/issues/316/comments"},"review_comments":{"href":"https://api.github.com/repos/2gis/mapsapi/pulls/316/comments"},"review_comment":{"href":"https://api.github.com/repos/2gis/mapsapi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/2gis/mapsapi/pulls/316/commits"},"statuses":{"href":"https://api.github.com/repos/2gis/mapsapi/statuses/9f0172427c65e493d1b81d91814f55b439b22a61"}}}}