Authored by 沈志敏

增加 曝光事件

Showing 1 changed file with 48 additions and 29 deletions
... ... @@ -475,12 +475,7 @@ _yas.sendAppLogs = function(json, asyncindx) {
}
}
// 监听app加载的deviceready事件
ev.addEventHandler(document, 'deviceready', function(e) {
window._yasloaded = false;
window.fromApp = true;
window.yohoInterface.triggerEvent(function(data) {
function appPageOpen(data, actionUrl) {
window.indx = data.indx;
window.baseLogs = {
device: {
... ... @@ -504,37 +499,41 @@ ev.addEventHandler(document, 'deviceready', function(e) {
param: JSON.stringify({
C_ID: window.qs.yh_channel || util.getChannel() || 1,
PAGE_URL: location.href,
PAGE_NAME: window.qs.title || document.title
PAGE_NAME: window.qs.title || document.title,
ACTION_URL: actionUrl
})
}, false);
}, nullFun, {
method: 'get.analyticAppData'
});
}
// 同步indx
var timer = setInterval(function() {
if (window._yasloaded) {
clearInterval(timer);
window.yohoInterface.triggerEvent(nullFun, nullFun, {
method: 'set.analyticEventIndex',
arguments: {
indx: window.indx
}
});
}
}, 500);
// 监听app加载的deviceready事件
ev.addEventHandler(document, 'deviceready', function(e) {
window._yasloaded = false;
window.fromApp = true;
if ('feature.yoho.cn' === document.domain) {
// feature.yoho.cn场合
var aDom = document.getElementsByTagName("a");
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);
for(var i = 0; i < aDom.length; i++){
ev.addEventHandler(aDom[i], 'click', function(e) {
var operid = e.target.getAttribute('operid');
// 上报曝光事件
_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.target.getAttribute('param');
var needcid = e.target.getAttribute('needcid');
var param = e.currentTarget.getAttribute('param');
var needcid = e.currentTarget.getAttribute('needcid');
if (needcid) {
param = JSON.parse(param);
... ... @@ -547,9 +546,29 @@ ev.addEventHandler(document, 'deviceready', function(e) {
param: param
}, true);
}
}
});
}
window.yohoInterface.triggerEvent(function(data){
appPageOpen(data, actionUrl);
}, nullFun, {
method: 'get.analyticAppData'
});
// 同步indx(需延迟处理)
var timer = setInterval(function() {
if (window._yasloaded) {
clearInterval(timer);
window.yohoInterface.triggerEvent(nullFun, nullFun, {
method: 'set.analyticEventIndex',
arguments: {
indx: window.indx
}
});
}
}, 500);
});
module.exports = _yas;
\ No newline at end of file
... ...