|
@@ -13,7 +13,9 @@ class EasyUse {
|
|
|
const {
|
|
|
dataSourceBase = '//cdn-common.jianyu360.com/track/json/',
|
|
|
iframeSupportEnabled = true,
|
|
|
- iframeSupportLink = '/test/huiju'
|
|
|
+ iframeSupportLink = '/test/huiju',
|
|
|
+ selfTrackURL = '/personnel/statistics',
|
|
|
+ selfTrackSupportEnabled = true
|
|
|
} = options
|
|
|
|
|
|
// 默认配置文件、版本号读取
|
|
@@ -28,6 +30,8 @@ class EasyUse {
|
|
|
version,
|
|
|
iframeSupportEnabled,
|
|
|
iframeSupportLink,
|
|
|
+ selfTrackURL,
|
|
|
+ selfTrackSupportEnabled,
|
|
|
upWaitStep: 200
|
|
|
}, options)
|
|
|
this.json = []
|
|
@@ -140,6 +144,42 @@ class EasyUse {
|
|
|
const _this = this
|
|
|
const jyEventTrack = new Track()
|
|
|
jyEventTrack.$subscribe.$on('CLICK-TRACK', function (transformedData, pageInfo) {
|
|
|
+ if (_this.config.selfTrackSupportEnabled) {
|
|
|
+ try {
|
|
|
+ const params = Object.assign({
|
|
|
+ c_breakername: transformedData.data.content.substr(0, 15),
|
|
|
+ c_pagename: pageInfo.href.title,
|
|
|
+ c_platform: pageInfo.platform,
|
|
|
+ c_pageid: pageInfo.id,
|
|
|
+ c_url: pageInfo.href.href,
|
|
|
+ c_breakerid: transformedData.key,
|
|
|
+ c_productname: '',
|
|
|
+ c_desc: '',
|
|
|
+ c_title: pageInfo.href.title,
|
|
|
+ date: new Date(transformedData.data.event_time)
|
|
|
+ }, _this.getNowPageInfo('click'))
|
|
|
+ _this.sendSelfTrack({
|
|
|
+ action_id: 'c_jyclick',
|
|
|
+ action_type: 'events',
|
|
|
+ breaker_id: params.c_breakerid,
|
|
|
+ breaker_name: params.c_breakername,
|
|
|
+ product_name: params.c_productname,
|
|
|
+ page_id: params.c_pageid,
|
|
|
+ page_name: params.c_pagename,
|
|
|
+ desc: params.c_desc,
|
|
|
+ // other
|
|
|
+ platform: params.c_platform,
|
|
|
+ url: params.c_url,
|
|
|
+ title: params.c_title,
|
|
|
+ date: params.date,
|
|
|
+ source: '',
|
|
|
+ chain_name: 'data_analysis'
|
|
|
+ })
|
|
|
+ } catch (e) {
|
|
|
+ console.warn('!! Check Track JS Error 100 !!')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
const tracker = _this.useClabTracker()
|
|
|
if (tracker && tracker.track) {
|
|
|
try {
|
|
@@ -240,6 +280,24 @@ class EasyUse {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (this.config.selfTrackSupportEnabled) {
|
|
|
+ this.sendSelfTrack({
|
|
|
+ action_id: 'c_jy_open_page',
|
|
|
+ action_type: 'events',
|
|
|
+ product_name: params?.c_productname,
|
|
|
+ page_id: params?.c_pageid,
|
|
|
+ page_name: params?.c_pagename,
|
|
|
+ desc: params?.c_desc,
|
|
|
+ // other
|
|
|
+ platform: params.c_platform,
|
|
|
+ url: params.c_url,
|
|
|
+ title: params.c_title,
|
|
|
+ date: new Date(),
|
|
|
+ source: '',
|
|
|
+ chain_name: 'data_analysis'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
if (tracker && tracker.track) {
|
|
|
try {
|
|
|
tracker.track('c_jy_open_page', params)
|
|
@@ -353,6 +411,40 @@ class EasyUse {
|
|
|
xhr.send()
|
|
|
}
|
|
|
|
|
|
+ sendSelfTrack (params) {
|
|
|
+ this.sendSelfPostRequest(this.config.selfTrackURL, params, function () {})
|
|
|
+ }
|
|
|
+ sendSelfPostRequest (url, params, successCallback) {
|
|
|
+ var xhr = new XMLHttpRequest();
|
|
|
+ xhr.open("POST", url, true);
|
|
|
+ xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+ xhr.setRequestHeader("apiKey", "HhYvHgAGQV9fWxEDLw8HFw==");
|
|
|
+
|
|
|
+ // Convert the params object to a URL-encoded string
|
|
|
+ var paramsString = '';
|
|
|
+ for (var key in params) {
|
|
|
+ if (params.hasOwnProperty(key)) {
|
|
|
+ paramsString += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) + '&';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // Remove the trailing '&'
|
|
|
+ paramsString = paramsString.slice(0, -1);
|
|
|
+
|
|
|
+ xhr.onreadystatechange = function () {
|
|
|
+ if (xhr.readyState === 4) {
|
|
|
+ if (xhr.status === 200) {
|
|
|
+ // Call the success callback with the response text
|
|
|
+ successCallback(xhr.responseText);
|
|
|
+ } else {
|
|
|
+ // Handle error
|
|
|
+ console.warn("Request failed with status: " + xhr.status);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ xhr.send(paramsString);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据 name 获取 Cookie
|
|
|
* @param name
|