|
@@ -1,5 +1,5 @@
|
|
|
import Track from './core/index'
|
|
|
-import {loadJS} from './module/utils'
|
|
|
+import {getPlatform, loadJS} from './module/utils'
|
|
|
|
|
|
/**
|
|
|
* 更简易地注入荟聚埋点统计
|
|
@@ -52,8 +52,7 @@ class EasyUse {
|
|
|
jyEventTrack.$subscribe.$on('CLICK-TRACK', function (transformedData, pageInfo) {
|
|
|
if (_this.checkHasClabTracker()) {
|
|
|
try {
|
|
|
- const customInfo = window.jy_tarck_info || {}
|
|
|
- clab_tracker.track('c_jyclick', {
|
|
|
+ clab_tracker.track('c_jyclick', Object.assign({
|
|
|
c_breakername: transformedData.data.content.substr(0, 15),
|
|
|
c_pagename: pageInfo.href.title,
|
|
|
c_platform: pageInfo.platform,
|
|
@@ -64,7 +63,7 @@ class EasyUse {
|
|
|
c_desc: '',
|
|
|
c_title: pageInfo.href.title,
|
|
|
date: new Date(transformedData.data.event_time)
|
|
|
- }, _this.getNowPageInfo('click'), customInfo)
|
|
|
+ }, _this.getNowPageInfo('click')))
|
|
|
} catch (e) {
|
|
|
console.warn('!! Check Track JS Error 001 !!')
|
|
|
}
|
|
@@ -94,19 +93,31 @@ class EasyUse {
|
|
|
*/
|
|
|
addPageChangeListener() {
|
|
|
window.addEventListener("popstate", (e) => {
|
|
|
- try {
|
|
|
- const params = this.getNowPageInfo('popstate')
|
|
|
- clab_tracker.ready(function () {
|
|
|
- this.push({"pageType":"web"});
|
|
|
- this.track("open_page", params);
|
|
|
- clab_tracker.setEnableAutoTrackExitPage(false)
|
|
|
- })
|
|
|
- } catch (e) {
|
|
|
- console.warn('!! Check Track JS Error 003 !!')
|
|
|
- }
|
|
|
+ this.upPageInfo()
|
|
|
}, false)
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 上报页面信息
|
|
|
+ */
|
|
|
+ upPageInfo () {
|
|
|
+ const params = this.getNowPageInfo('popstate')
|
|
|
+ try {
|
|
|
+ clab_tracker.ready(function () {
|
|
|
+ this.push({"pageType":"web"});
|
|
|
+ this.track("open_page", params);
|
|
|
+ clab_tracker.setEnableAutoTrackExitPage(false)
|
|
|
+ })
|
|
|
+ } catch (e) {
|
|
|
+ console.warn('!! Check Track JS Error 003 !!')
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ clab_tracker.track('c_jy_open_page', params)
|
|
|
+ } catch (e) {
|
|
|
+ console.warn('!! Check Track JS Error 004 !!')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取当前页面参数
|
|
|
* @param type - 事件类型
|
|
@@ -119,6 +130,24 @@ class EasyUse {
|
|
|
this.params.identityType = "c_uid"
|
|
|
this.params.identityValue = this.getCookie('ud_safe')
|
|
|
}
|
|
|
+ // 页面信息
|
|
|
+ this.params.c_title = document.title
|
|
|
+ this.params.c_platform = getPlatform()
|
|
|
+ const pageInfo = this.tryFindInfo()
|
|
|
+ if (pageInfo) {
|
|
|
+ if (pageInfo['页面ID']) {
|
|
|
+ this.params.c_pageid = pageInfo['页面ID']
|
|
|
+ }
|
|
|
+ if (pageInfo['页面名称']) {
|
|
|
+ this.params.c_pagename = pageInfo['页面名称']
|
|
|
+ }
|
|
|
+ if (pageInfo['产品名称']) {
|
|
|
+ this.params.c_productname = pageInfo['产品名称']
|
|
|
+ }
|
|
|
+ if (pageInfo['页面功能简述']) {
|
|
|
+ this.params.c_desc = pageInfo['页面功能简述']
|
|
|
+ }
|
|
|
+ }
|
|
|
return Object.assign({}, this.params, customInfo)
|
|
|
}
|
|
|
|
|
@@ -128,7 +157,7 @@ class EasyUse {
|
|
|
* @returns {{}}
|
|
|
*/
|
|
|
tryFindInfo (url = location.href) {
|
|
|
- let result = {}
|
|
|
+ let result = false
|
|
|
for (let i =0;i<this.json.length;i++) {
|
|
|
const item = this.json[i]
|
|
|
const matchLink = decodeURIComponent(item['页面URL'])
|
|
@@ -153,6 +182,7 @@ class EasyUse {
|
|
|
this.getJSON(this.config.dataSource, (data) => {
|
|
|
if (Array.isArray(data)) {
|
|
|
this.json = [].concat(data)
|
|
|
+ this.upPageInfo()
|
|
|
}
|
|
|
})
|
|
|
}
|