Authored by 沈志敏

增加 曝光事件

Showing 1 changed file with 48 additions and 29 deletions
@@ -475,12 +475,7 @@ _yas.sendAppLogs = function(json, asyncindx) { @@ -475,12 +475,7 @@ _yas.sendAppLogs = function(json, asyncindx) {
475 } 475 }
476 } 476 }
477 477
478 -// 监听app加载的deviceready事件  
479 -ev.addEventHandler(document, 'deviceready', function(e) {  
480 - window._yasloaded = false;  
481 - window.fromApp = true;  
482 -  
483 - window.yohoInterface.triggerEvent(function(data) { 478 +function appPageOpen(data, actionUrl) {
484 window.indx = data.indx; 479 window.indx = data.indx;
485 window.baseLogs = { 480 window.baseLogs = {
486 device: { 481 device: {
@@ -504,37 +499,41 @@ ev.addEventHandler(document, 'deviceready', function(e) { @@ -504,37 +499,41 @@ ev.addEventHandler(document, 'deviceready', function(e) {
504 param: JSON.stringify({ 499 param: JSON.stringify({
505 C_ID: window.qs.yh_channel || util.getChannel() || 1, 500 C_ID: window.qs.yh_channel || util.getChannel() || 1,
506 PAGE_URL: location.href, 501 PAGE_URL: location.href,
507 - PAGE_NAME: window.qs.title || document.title 502 + PAGE_NAME: window.qs.title || document.title,
  503 + ACTION_URL: actionUrl
508 }) 504 })
509 }, false); 505 }, false);
510 - }, nullFun, {  
511 - method: 'get.analyticAppData'  
512 - }); 506 +}
513 507
514 - // 同步indx  
515 - var timer = setInterval(function() {  
516 - if (window._yasloaded) {  
517 - clearInterval(timer);  
518 - window.yohoInterface.triggerEvent(nullFun, nullFun, {  
519 - method: 'set.analyticEventIndex',  
520 - arguments: {  
521 - indx: window.indx  
522 - }  
523 - });  
524 - }  
525 - }, 500); 508 +// 监听app加载的deviceready事件
  509 +ev.addEventHandler(document, 'deviceready', function(e) {
  510 + window._yasloaded = false;
  511 + window.fromApp = true;
526 512
527 - if ('feature.yoho.cn' === document.domain) {  
528 - // feature.yoho.cn场合  
529 - var aDom = document.getElementsByTagName("a"); 513 + var actionUrl = [];
  514 + var aDom = document.getElementsByTagName("a"); //获取页面所有a标签
  515 +
  516 + for(var i = 0; i < aDom.length; i++) {
  517 + var href = aDom[i].getAttribute('href');
  518 + href && actionUrl.push(href);
530 519
531 - for(var i = 0; i < aDom.length; i++){  
532 ev.addEventHandler(aDom[i], 'click', function(e) { 520 ev.addEventHandler(aDom[i], 'click', function(e) {
533 - var operid = e.target.getAttribute('operid'); 521 + // 上报曝光事件
  522 + _yas.sendAppLogs({
  523 + appop: 'YB_H5_PAGE_FLR_C',
  524 + param: JSON.stringify({
  525 + C_ID: window.qs.yh_channel || util.getChannel() || 1,
  526 + PAGE_URL: location.href,
  527 + PAGE_NAME: window.qs.title || document.title,
  528 + F_URL: e.currentTarget.getAttribute('href')
  529 + })
  530 + }, true);
534 531
  532 + if ('feature.yoho.cn' === document.domain) { // feature.yoho.cn场合
  533 + var operid = e.currentTarget.getAttribute('operid');
535 if (operid) { 534 if (operid) {
536 - var param = e.target.getAttribute('param');  
537 - var needcid = e.target.getAttribute('needcid'); 535 + var param = e.currentTarget.getAttribute('param');
  536 + var needcid = e.currentTarget.getAttribute('needcid');
538 537
539 if (needcid) { 538 if (needcid) {
540 param = JSON.parse(param); 539 param = JSON.parse(param);
@@ -547,9 +546,29 @@ ev.addEventHandler(document, 'deviceready', function(e) { @@ -547,9 +546,29 @@ ev.addEventHandler(document, 'deviceready', function(e) {
547 param: param 546 param: param
548 }, true); 547 }, true);
549 } 548 }
  549 + }
  550 + });
  551 + }
  552 +
  553 + window.yohoInterface.triggerEvent(function(data){
  554 + appPageOpen(data, actionUrl);
  555 + }, nullFun, {
  556 + method: 'get.analyticAppData'
550 }); 557 });
  558 +
  559 + // 同步indx(需延迟处理)
  560 + var timer = setInterval(function() {
  561 + if (window._yasloaded) {
  562 + clearInterval(timer);
  563 + window.yohoInterface.triggerEvent(nullFun, nullFun, {
  564 + method: 'set.analyticEventIndex',
  565 + arguments: {
  566 + indx: window.indx
551 } 567 }
  568 + });
552 } 569 }
  570 + }, 500);
  571 +
553 }); 572 });
554 573
555 module.exports = _yas; 574 module.exports = _yas;