{"action":"created","comment":{"url":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/comments/213174149","pull_request_review_id":149953845,"id":213174149,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMzE3NDE0OQ==","diff_hunk":"@@ -0,0 +1,232 @@\n+/**\n+ * @file mip-analytics 统计框架\n+ * @author {306880673@qq.com, tfciw}\n+ * @transfer-date 2018/08\n+ */\n+const { CustomElement, util, performance } = MIP\n+\n+export default class MipAnalytics extends CustomElement {\n+  constructor (...args) {\n+    super(...args)\n+    this.mipSpeedInfo = {}\n+    this.timer = []\n+    this.eventPoint = [\n+      'MIPStart',\n+      'MIPPageShow',\n+      'MIPDomContentLoaded',\n+      'MIPFirstScreen'\n+    ]\n+    this.defaultDispKey = 'domready'\n+    this.isSendDisp = {}\n+    this.isSendDisp[this.defaultDispKey] = 0\n+    this.triggers = {\n+\n+      /**\n+       * 点击\n+       *\n+       * @param {Object} triggers\n+       */\n+      click (triggers) {\n+        this.clickHandle(triggers, 'click')\n+      },\n+\n+      /**\n+       * 触摸结束\n+       *\n+       * @param {Object} triggers\n+       */\n+      touchend (triggers) {\n+        this.clickHandle(triggers, 'touchend')\n+      },\n+\n+      disp (triggers) {\n+        performance.on('update', data => {\n+          if (!this.isSendDisp[this.defaultDispKey] && this.isDomReady(data)) {\n+            this.mipSpeedInfo = data\n+            triggers.forEach(el => {\n+              this.send(el)\n+            })\n+          }\n+        })\n+      },\n+\n+      scroll () {\n+\n+      },\n+\n+      timer (triggers) {\n+        triggers.forEach(el => {\n+          this.timer.push(setInterval(() => {\n+            this.send(el)\n+          }, el.option.interval || 4000))\n+        })\n+      }\n+\n+    }\n+  }\n+\n+  build () {\n+    // 获取config\n+    let cfg = {}\n+    try {\n+      let script = this.element.querySelector('script[type=\"application/json\"]')\n+      cfg = JSON.parse(script.textContent.toString())\n+    } catch (e) {\n+      console.warn('json is illegal'); // eslint-disable-line\n+      console.warn(e); // eslint-disable-line\n+      return\n+    }\n+    if (!cfg.setting || !cfg.hosts) {\n+      return\n+    }\n+\n+    // 全局代理事件\n+    for (let prop in cfg.setting) {\n+      if (cfg.setting.hasOwnProperty(prop)) {\n+        // 替换host变量\n+        let events = cfg.setting[prop]\n+        events.forEach(el => {\n+          el.host = cfg.hosts[el.host]\n+        })\n+        this.triggers[prop] && this.triggers[prop].call(this, events)\n+      }\n+    }\n+  }\n+\n+  /**\n+   * 点击事件handle\n+   *\n+   * @param {Object} triggers\n+   * @param {string} 事件名\n+   */\n+  clickHandle (triggers, eventName) {\n+    triggers.forEach(el => {\n+      let ancestors = el.tag ? document.querySelectorAll(el.selector) : [document]\n+      let eventTag = el.tag || el.selector\n+\n+      ancestors.forEach(dom => {\n+        util.event.delegate(dom, eventTag, eventName, () => {\n+          let params = this.element.getAttribute('data-click') || ''\n+          let paramsObj = (function () {\n+            return params\n+          }())\n+          this.send(el, paramsObj)\n+        }, false)\n+      })\n+    })\n+  }\n+\n+  /**\n+   * 判断dom是否处于ready\n+   *\n+   * @param {Object}} performance 触发update事件的返回对象\n+   * @return {String || Boolean} data返回的对象含有定义的eventPoint，data不存在即返回false\n+   */\n+  isDomReady (data) {\n+    return data ? this.eventPoint.every(el => {\n+      return data[el]\n+    })\n+      : false\n+  }\n+\n+  /**\n+   * 判断是否为对象\n+   *\n+   * @param {Object}\n+   * @return {boolean}\n+   */\n+  isObject (obj) {\n+    return typeof obj === 'object'\n+  }\n+\n+  /**\n+   * 使用img的方式发送日志\n+   *\n+   * @param {string} url src链接\n+   */\n+  imgSendLog (url) {\n+    let key = 'IMAGE' + (new Date()).getTime()\n+    let img = window[key] = new Image()\n+    img.addEventListener('load', () => {\n+      // 防止多次触发onload;\n+      img.onload = img.onerror = img.onabort = null\n+      // 清空引用,避免内存泄漏\n+      window[key] = null\n+      img = null\n+    })\n+    img.src = url\n+  }\n+\n+  /**\n+   * 替换插值 ${var}\n+   *\n+   * @param {string}  str 被替换的字符串\n+   * @param {string}  vars 替换变量\n+   * @return {string}\n+   */\n+  valReplace (str, vars) {\n+    vars = vars || {}\n+    util.fn.extend(vars, this.mipSpeedInfo)","path":"components/mip-analytics/mip-analytics.js","position":169,"original_position":169,"commit_id":"190c1a89f6f3527bba9030ad4a5a88a5dc2a2dad","original_commit_id":"190c1a89f6f3527bba9030ad4a5a88a5dc2a2dad","user":{"login":"Espoir-L","id":25815613,"node_id":"MDQ6VXNlcjI1ODE1NjEz","avatar_url":"https://avatars1.githubusercontent.com/u/25815613?v=4","gravatar_id":"","url":"https://api.github.com/users/Espoir-L","html_url":"https://github.com/Espoir-L","followers_url":"https://api.github.com/users/Espoir-L/followers","following_url":"https://api.github.com/users/Espoir-L/following{/other_user}","gists_url":"https://api.github.com/users/Espoir-L/gists{/gist_id}","starred_url":"https://api.github.com/users/Espoir-L/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Espoir-L/subscriptions","organizations_url":"https://api.github.com/users/Espoir-L/orgs","repos_url":"https://api.github.com/users/Espoir-L/repos","events_url":"https://api.github.com/users/Espoir-L/events{/privacy}","received_events_url":"https://api.github.com/users/Espoir-L/received_events","type":"User","site_admin":false},"body":"MIP2中不推荐使用extend，推荐使用Object.assign","created_at":"2018-08-28T03:18:33Z","updated_at":"2018-08-28T03:18:33Z","html_url":"https://github.com/mipengine/mip2-extensions/pull/239#discussion_r213174149","pull_request_url":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/239","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/comments/213174149"},"html":{"href":"https://github.com/mipengine/mip2-extensions/pull/239#discussion_r213174149"},"pull_request":{"href":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/239"}}},"pull_request":{"url":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/239","id":211028828,"node_id":"MDExOlB1bGxSZXF1ZXN0MjExMDI4ODI4","html_url":"https://github.com/mipengine/mip2-extensions/pull/239","diff_url":"https://github.com/mipengine/mip2-extensions/pull/239.diff","patch_url":"https://github.com/mipengine/mip2-extensions/pull/239.patch","issue_url":"https://api.github.com/repos/mipengine/mip2-extensions/issues/239","number":239,"state":"open","locked":false,"title":"feat:迁移组件analytics","user":{"login":"tfciw","id":18052602,"node_id":"MDQ6VXNlcjE4MDUyNjAy","avatar_url":"https://avatars2.githubusercontent.com/u/18052602?v=4","gravatar_id":"","url":"https://api.github.com/users/tfciw","html_url":"https://github.com/tfciw","followers_url":"https://api.github.com/users/tfciw/followers","following_url":"https://api.github.com/users/tfciw/following{/other_user}","gists_url":"https://api.github.com/users/tfciw/gists{/gist_id}","starred_url":"https://api.github.com/users/tfciw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfciw/subscriptions","organizations_url":"https://api.github.com/users/tfciw/orgs","repos_url":"https://api.github.com/users/tfciw/repos","events_url":"https://api.github.com/users/tfciw/events{/privacy}","received_events_url":"https://api.github.com/users/tfciw/received_events","type":"User","site_admin":false},"body":"**提交pr时需要关联issue，请大家遵守**\r\n#11  迁移mip-analytics 免测\r\n**1、升级点** （清晰准确的描述升级的功能点）\r\n无\r\n**2、影响范围** （描述该需求上线会影响什么功能）\r\n\r\n**3、自测 checklist**\r\n\r\n**4、需要覆盖的场景和case**\r\n- [ ] 是否覆盖了sf打开mip页\r\n- [ ] 是否验证了极速服务mip页面效果\r\n**5、自测机型和浏览器** \r\n- [ ] 是否覆盖了ios系统手机\r\n- [ ] 是否覆盖了安卓系统手机\r\n- [ ] 是否覆盖了iphone版式浏览器（比如qq、uc、chrome、safari、安卓自带浏览器）\r\n- [ ] 是否覆盖了手百\r\n\r\n\r\n\r\n","created_at":"2018-08-27T07:34:04Z","updated_at":"2018-08-28T03:18:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"95c674303b96963b650cd81a94f89edabe905eba","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/239/commits","review_comments_url":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/239/comments","review_comment_url":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mipengine/mip2-extensions/issues/239/comments","statuses_url":"https://api.github.com/repos/mipengine/mip2-extensions/statuses/190c1a89f6f3527bba9030ad4a5a88a5dc2a2dad","head":{"label":"mipengine:fix/analytics","ref":"fix/analytics","sha":"190c1a89f6f3527bba9030ad4a5a88a5dc2a2dad","user":{"login":"mipengine","id":19966931,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTY2OTMx","avatar_url":"https://avatars0.githubusercontent.com/u/19966931?v=4","gravatar_id":"","url":"https://api.github.com/users/mipengine","html_url":"https://github.com/mipengine","followers_url":"https://api.github.com/users/mipengine/followers","following_url":"https://api.github.com/users/mipengine/following{/other_user}","gists_url":"https://api.github.com/users/mipengine/gists{/gist_id}","starred_url":"https://api.github.com/users/mipengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mipengine/subscriptions","organizations_url":"https://api.github.com/users/mipengine/orgs","repos_url":"https://api.github.com/users/mipengine/repos","events_url":"https://api.github.com/users/mipengine/events{/privacy}","received_events_url":"https://api.github.com/users/mipengine/received_events","type":"Organization","site_admin":false},"repo":{"id":135115912,"node_id":"MDEwOlJlcG9zaXRvcnkxMzUxMTU5MTI=","name":"mip2-extensions","full_name":"mipengine/mip2-extensions","owner":{"login":"mipengine","id":19966931,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTY2OTMx","avatar_url":"https://avatars0.githubusercontent.com/u/19966931?v=4","gravatar_id":"","url":"https://api.github.com/users/mipengine","html_url":"https://github.com/mipengine","followers_url":"https://api.github.com/users/mipengine/followers","following_url":"https://api.github.com/users/mipengine/following{/other_user}","gists_url":"https://api.github.com/users/mipengine/gists{/gist_id}","starred_url":"https://api.github.com/users/mipengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mipengine/subscriptions","organizations_url":"https://api.github.com/users/mipengine/orgs","repos_url":"https://api.github.com/users/mipengine/repos","events_url":"https://api.github.com/users/mipengine/events{/privacy}","received_events_url":"https://api.github.com/users/mipengine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mipengine/mip2-extensions","description":"MIP2.0 官方组件库","fork":false,"url":"https://api.github.com/repos/mipengine/mip2-extensions","forks_url":"https://api.github.com/repos/mipengine/mip2-extensions/forks","keys_url":"https://api.github.com/repos/mipengine/mip2-extensions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mipengine/mip2-extensions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mipengine/mip2-extensions/teams","hooks_url":"https://api.github.com/repos/mipengine/mip2-extensions/hooks","issue_events_url":"https://api.github.com/repos/mipengine/mip2-extensions/issues/events{/number}","events_url":"https://api.github.com/repos/mipengine/mip2-extensions/events","assignees_url":"https://api.github.com/repos/mipengine/mip2-extensions/assignees{/user}","branches_url":"https://api.github.com/repos/mipengine/mip2-extensions/branches{/branch}","tags_url":"https://api.github.com/repos/mipengine/mip2-extensions/tags","blobs_url":"https://api.github.com/repos/mipengine/mip2-extensions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mipengine/mip2-extensions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mipengine/mip2-extensions/git/refs{/sha}","trees_url":"https://api.github.com/repos/mipengine/mip2-extensions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mipengine/mip2-extensions/statuses/{sha}","languages_url":"https://api.github.com/repos/mipengine/mip2-extensions/languages","stargazers_url":"https://api.github.com/repos/mipengine/mip2-extensions/stargazers","contributors_url":"https://api.github.com/repos/mipengine/mip2-extensions/contributors","subscribers_url":"https://api.github.com/repos/mipengine/mip2-extensions/subscribers","subscription_url":"https://api.github.com/repos/mipengine/mip2-extensions/subscription","commits_url":"https://api.github.com/repos/mipengine/mip2-extensions/commits{/sha}","git_commits_url":"https://api.github.com/repos/mipengine/mip2-extensions/git/commits{/sha}","comments_url":"https://api.github.com/repos/mipengine/mip2-extensions/comments{/number}","issue_comment_url":"https://api.github.com/repos/mipengine/mip2-extensions/issues/comments{/number}","contents_url":"https://api.github.com/repos/mipengine/mip2-extensions/contents/{+path}","compare_url":"https://api.github.com/repos/mipengine/mip2-extensions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mipengine/mip2-extensions/merges","archive_url":"https://api.github.com/repos/mipengine/mip2-extensions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mipengine/mip2-extensions/downloads","issues_url":"https://api.github.com/repos/mipengine/mip2-extensions/issues{/number}","pulls_url":"https://api.github.com/repos/mipengine/mip2-extensions/pulls{/number}","milestones_url":"https://api.github.com/repos/mipengine/mip2-extensions/milestones{/number}","notifications_url":"https://api.github.com/repos/mipengine/mip2-extensions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mipengine/mip2-extensions/labels{/name}","releases_url":"https://api.github.com/repos/mipengine/mip2-extensions/releases{/id}","deployments_url":"https://api.github.com/repos/mipengine/mip2-extensions/deployments","created_at":"2018-05-28T06:00:58Z","updated_at":"2018-08-24T07:56:42Z","pushed_at":"2018-08-28T03:01:09Z","git_url":"git://github.com/mipengine/mip2-extensions.git","ssh_url":"git@github.com:mipengine/mip2-extensions.git","clone_url":"https://github.com/mipengine/mip2-extensions.git","svn_url":"https://github.com/mipengine/mip2-extensions","homepage":null,"size":737,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"archived":false,"open_issues_count":49,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":24,"open_issues":49,"watchers":8,"default_branch":"master"}},"base":{"label":"mipengine:master","ref":"master","sha":"7968439d103cd862ae0e6df23afb89cf84119233","user":{"login":"mipengine","id":19966931,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTY2OTMx","avatar_url":"https://avatars0.githubusercontent.com/u/19966931?v=4","gravatar_id":"","url":"https://api.github.com/users/mipengine","html_url":"https://github.com/mipengine","followers_url":"https://api.github.com/users/mipengine/followers","following_url":"https://api.github.com/users/mipengine/following{/other_user}","gists_url":"https://api.github.com/users/mipengine/gists{/gist_id}","starred_url":"https://api.github.com/users/mipengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mipengine/subscriptions","organizations_url":"https://api.github.com/users/mipengine/orgs","repos_url":"https://api.github.com/users/mipengine/repos","events_url":"https://api.github.com/users/mipengine/events{/privacy}","received_events_url":"https://api.github.com/users/mipengine/received_events","type":"Organization","site_admin":false},"repo":{"id":135115912,"node_id":"MDEwOlJlcG9zaXRvcnkxMzUxMTU5MTI=","name":"mip2-extensions","full_name":"mipengine/mip2-extensions","owner":{"login":"mipengine","id":19966931,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTY2OTMx","avatar_url":"https://avatars0.githubusercontent.com/u/19966931?v=4","gravatar_id":"","url":"https://api.github.com/users/mipengine","html_url":"https://github.com/mipengine","followers_url":"https://api.github.com/users/mipengine/followers","following_url":"https://api.github.com/users/mipengine/following{/other_user}","gists_url":"https://api.github.com/users/mipengine/gists{/gist_id}","starred_url":"https://api.github.com/users/mipengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mipengine/subscriptions","organizations_url":"https://api.github.com/users/mipengine/orgs","repos_url":"https://api.github.com/users/mipengine/repos","events_url":"https://api.github.com/users/mipengine/events{/privacy}","received_events_url":"https://api.github.com/users/mipengine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mipengine/mip2-extensions","description":"MIP2.0 官方组件库","fork":false,"url":"https://api.github.com/repos/mipengine/mip2-extensions","forks_url":"https://api.github.com/repos/mipengine/mip2-extensions/forks","keys_url":"https://api.github.com/repos/mipengine/mip2-extensions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mipengine/mip2-extensions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mipengine/mip2-extensions/teams","hooks_url":"https://api.github.com/repos/mipengine/mip2-extensions/hooks","issue_events_url":"https://api.github.com/repos/mipengine/mip2-extensions/issues/events{/number}","events_url":"https://api.github.com/repos/mipengine/mip2-extensions/events","assignees_url":"https://api.github.com/repos/mipengine/mip2-extensions/assignees{/user}","branches_url":"https://api.github.com/repos/mipengine/mip2-extensions/branches{/branch}","tags_url":"https://api.github.com/repos/mipengine/mip2-extensions/tags","blobs_url":"https://api.github.com/repos/mipengine/mip2-extensions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mipengine/mip2-extensions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mipengine/mip2-extensions/git/refs{/sha}","trees_url":"https://api.github.com/repos/mipengine/mip2-extensions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mipengine/mip2-extensions/statuses/{sha}","languages_url":"https://api.github.com/repos/mipengine/mip2-extensions/languages","stargazers_url":"https://api.github.com/repos/mipengine/mip2-extensions/stargazers","contributors_url":"https://api.github.com/repos/mipengine/mip2-extensions/contributors","subscribers_url":"https://api.github.com/repos/mipengine/mip2-extensions/subscribers","subscription_url":"https://api.github.com/repos/mipengine/mip2-extensions/subscription","commits_url":"https://api.github.com/repos/mipengine/mip2-extensions/commits{/sha}","git_commits_url":"https://api.github.com/repos/mipengine/mip2-extensions/git/commits{/sha}","comments_url":"https://api.github.com/repos/mipengine/mip2-extensions/comments{/number}","issue_comment_url":"https://api.github.com/repos/mipengine/mip2-extensions/issues/comments{/number}","contents_url":"https://api.github.com/repos/mipengine/mip2-extensions/contents/{+path}","compare_url":"https://api.github.com/repos/mipengine/mip2-extensions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mipengine/mip2-extensions/merges","archive_url":"https://api.github.com/repos/mipengine/mip2-extensions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mipengine/mip2-extensions/downloads","issues_url":"https://api.github.com/repos/mipengine/mip2-extensions/issues{/number}","pulls_url":"https://api.github.com/repos/mipengine/mip2-extensions/pulls{/number}","milestones_url":"https://api.github.com/repos/mipengine/mip2-extensions/milestones{/number}","notifications_url":"https://api.github.com/repos/mipengine/mip2-extensions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mipengine/mip2-extensions/labels{/name}","releases_url":"https://api.github.com/repos/mipengine/mip2-extensions/releases{/id}","deployments_url":"https://api.github.com/repos/mipengine/mip2-extensions/deployments","created_at":"2018-05-28T06:00:58Z","updated_at":"2018-08-24T07:56:42Z","pushed_at":"2018-08-28T03:01:09Z","git_url":"git://github.com/mipengine/mip2-extensions.git","ssh_url":"git@github.com:mipengine/mip2-extensions.git","clone_url":"https://github.com/mipengine/mip2-extensions.git","svn_url":"https://github.com/mipengine/mip2-extensions","homepage":null,"size":737,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"archived":false,"open_issues_count":49,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":24,"open_issues":49,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/239"},"html":{"href":"https://github.com/mipengine/mip2-extensions/pull/239"},"issue":{"href":"https://api.github.com/repos/mipengine/mip2-extensions/issues/239"},"comments":{"href":"https://api.github.com/repos/mipengine/mip2-extensions/issues/239/comments"},"review_comments":{"href":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/239/comments"},"review_comment":{"href":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mipengine/mip2-extensions/pulls/239/commits"},"statuses":{"href":"https://api.github.com/repos/mipengine/mip2-extensions/statuses/190c1a89f6f3527bba9030ad4a5a88a5dc2a2dad"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Espoir-L"}}