Authored by 沈志敏

增加 曝光事件

Showing 1 changed file with 73 additions and 54 deletions
... ... @@ -79,7 +79,7 @@ var nullFun = function() {};
//入口方法
var _yas = function(initTime, version, tid, uid, geo, selector) {
window.qs = util.queryString();
custInfo.ak = tid;
appInfo.sv = version;
custInfo.ud = uid ? uid : '';
... ... @@ -475,43 +475,88 @@ _yas.sendAppLogs = function(json, asyncindx) {
}
}
function appPageOpen(data, actionUrl) {
window.indx = data.indx;
window.baseLogs = {
device: {
ak: data.ak,
udid: data.udid,
},
status: [{
av: data.av,
udid: data.udid,
sid: data.sid,
}],
events: [{
uid: data.uid,
sid: data.sid
}]
}
// 上报页面打开事件
_yas.sendAppLogs({
appop: 'YB_H5_PAGE_OPEN_L',
param: JSON.stringify({
C_ID: window.qs.yh_channel || util.getChannel() || 1,
PAGE_URL: location.href,
PAGE_NAME: window.qs.title || document.title,
ACTION_URL: actionUrl
})
}, false);
}
// 监听app加载的deviceready事件
ev.addEventHandler(document, 'deviceready', function(e) {
window._yasloaded = false;
window.fromApp = true;
window.yohoInterface.triggerEvent(function(data) {
window.indx = data.indx;
window.baseLogs = {
device: {
ak: data.ak,
udid: data.udid,
},
status: [{
av: data.av,
udid: data.udid,
sid: data.sid,
}],
events: [{
uid: data.uid,
sid: data.sid
}]
}
var actionUrl = [];
var aDom = document.getElementsByTagName("a"); //获取页面所有a标签
for(var i = 0; i < aDom.length; i++) {
var href = aDom[i].getAttribute('href');
href && actionUrl.push(href);
ev.addEventHandler(aDom[i], 'click', function(e) {
// 上报曝光事件
_yas.sendAppLogs({
appop: 'YB_H5_PAGE_FLR_C',
param: JSON.stringify({
C_ID: window.qs.yh_channel || util.getChannel() || 1,
PAGE_URL: location.href,
PAGE_NAME: window.qs.title || document.title,
F_URL: e.currentTarget.getAttribute('href')
})
}, true);
if ('feature.yoho.cn' === document.domain) { // feature.yoho.cn场合
var operid = e.currentTarget.getAttribute('operid');
if (operid) {
var param = e.currentTarget.getAttribute('param');
var needcid = e.currentTarget.getAttribute('needcid');
if (needcid) {
param = JSON.parse(param);
param.C_ID = window.qs.yh_channel;
param = JSON.stringify(param);
}
_yas.sendAppLogs({
appop: operid,
param: param
}, true);
}
}
});
}
// 上报页面打开事件
_yas.sendAppLogs({
appop: 'YB_H5_PAGE_OPEN_L',
param: JSON.stringify({
C_ID: window.qs.yh_channel || util.getChannel() || 1,
PAGE_URL: location.href,
PAGE_NAME: window.qs.title || document.title
})
}, false);
window.yohoInterface.triggerEvent(function(data){
appPageOpen(data, actionUrl);
}, nullFun, {
method: 'get.analyticAppData'
});
// 同步indx
// 同步indx(需延迟处理)
var timer = setInterval(function() {
if (window._yasloaded) {
clearInterval(timer);
... ... @@ -523,33 +568,7 @@ ev.addEventHandler(document, 'deviceready', function(e) {
});
}
}, 500);
if ('feature.yoho.cn' === document.domain) {
// feature.yoho.cn场合
var aDom = document.getElementsByTagName("a");
for(var i = 0; i < aDom.length; i++){
ev.addEventHandler(aDom[i], 'click', function(e) {
var operid = e.target.getAttribute('operid');
if (operid) {
var param = e.target.getAttribute('param');
var needcid = e.target.getAttribute('needcid');
if (needcid) {
param = JSON.parse(param);
param.C_ID = window.qs.yh_channel;
param = JSON.stringify(param);
}
_yas.sendAppLogs({
appop: operid,
param: param
}, true);
}
});
}
}
});
module.exports = _yas;
\ No newline at end of file
... ...