1var waitTime = 3000 2 3var excludeURL 4var eventLocalStorage = 'eventActivity' 5var searchLocalStorage = 'searchActivity' 6var summaryPageLocalStorage = 'summaryPageActivity' 7 8var PAGE_VIEW = 'PAGE_VIEW' 9var DOWNLOAD = 'DOC_DOWNLOAD' 10var SEARCH = 'K_SEARCH' 11var extension = ['zip', 'bin', 'exe', 'htm', 'html', 'pdf', 'txt', 'text'] 12var iconData = new Map() 13var loginIndex = 0 14//b25319 added for testing 15var appName = '' 16var recommendTitle = '' 17var APP_ACTIVITY = 'APP_ACTIVITY' 18var AUTH_CKE_NAME = 'AuthCookie' 19var USE_PER_AUTH = 'UsePerAuth' 20iconData.set('Devices', 'icon-part') 21iconData.set('Software', 'icon-tools') 22iconData.set('RDSP', 'icon-tools') 23iconData.set('Tools', 'icon-tools') 24iconData.set('Designs', 'icon-tools') 25iconData.set('TSP', 'icon-tools') 26 27iconData.set('Data Sheet', 'icon-datasheet') 28iconData.set('Selector Guide', 'icon-file222') 29iconData.set('Quick Reference Guide', 'icon-file222') 30iconData.set('Fact Sheet', 'icon-datasheet') 31iconData.set('Trainings', 'icon-graduation') 32iconData.set('Application Note', 'icon-tree3') 33iconData.set('Videos', 'icon-play') 34 35iconData.set('PAGE_VIEW', 'icon-globe') 36iconData.set('K_SEARCH', 'icon-search') 37iconData.set('DOC_DOWNLOAD', 'icon-datasheet') 38 39var wa_all_domains = [ 40 'uat.nxp.jp', 41 'www.nxp.jp', 42 'uat.nxp.co.kr', 43 'www.nxp.co.kr', 44 'uat.freescale.com', 45 'uat.nxp.com', 46 'www.nxp.com', 47 'uat.nxp.com.cn', 48 'www.nxp.com.cn', 49 'store-uat.nxp.com', 50 'store.nxp.com' 51] 52 53function checkAllDomains (currentDomain) { 54 var len = wa_all_domains.length 55 for (i = 0; i < len; i++) { 56 if (currentDomain == wa_all_domains[i]) { 57 return true 58 } 59 } 60 return false 61} 62 63function trackSoftwareDownloadUserActivity () { 64 $(document).on('click', '.btn-download,.downloadBtn', function (event) { 65 setTimeout(function () { 66 if (typeof getDocDownloadType == 'function') { 67 downloadURL = digitalData.eventInfo.targetURL 68 var downloadType = getDocDownloadType(downloadURL) 69 if (downloadType != 'Not Applicable') { 70 var marketLeveraged = isMarketLeveraged_UA(downloadURL) 71 if ( 72 downloadType == 'Non-Secured' || 73 downloadType == 'Moderated' || 74 downloadType == 'Registered' || 75 marketLeveraged 76 ) { 77 var assetId = fetchColCodeFromURL(downloadURL) 78 var language = fetchDocLang(downloadURL) 79 var map = fetchDownloadMetaData() 80 downloadURL = new URL(downloadURL).pathname 81 map.set('Title', '') 82 map.set('url', '') 83 map.set( 84 'Asset Id', 85 downloadType == 'Non-Secured' ? downloadURL : assetId 86 ) 87 map.set('language', language) 88 var eventActivityJson = formJsonObj(map, '') 89 90 trackDocumentAndSummaryPages(eventActivityJson) 91 } 92 } else { 93 if (location.href.includes('app-distynet')) { 94 var assetId = fetchColCodeFromURL(downloadURL) 95 var language = fetchDocLang(downloadURL) 96 var map = fetchDownloadMetaData() 97 map.set('Title', '') 98 map.set('url', '') 99 map.set('Asset Id', assetId) 100 map.set('language', language) 101 map.set('Application', 'distynet') 102 trackSecureDocDownloadUserActivity(map) 103 } 104 console.log('Secured Doc') 105 } 106 } 107 }, 2000) 108 }) 109} 110 111function eventClick (event, func) { 112 if (typeof window[func] == 'function' && document.body) { 113 if (document.body.addEventListener) { 114 document.body.addEventListener(event, window[func], true) 115 } else if (document.body.attachEvent) { 116 document.body.attachEvent('on' + event, window[func]) 117 } 118 } 119} 120 121//This function executes onRightClick of Anchor Tag 122//it checks whether download has been clicked or not by left clicking of mouse 123function trackDownloadLeftClick (evt) { 124 var $anchor_link 125 evt = evt || window.event || '' 126 if (evt && (typeof evt.which != 'number' || evt.which == 1)) { 127 var e = anchorEvt_UA(evt, 'A') 128 if ( 129 typeof e.href == 'undefined' || 130 !e.href || 131 !e.hostname || 132 typeof e.hostname == 'undefined' 133 ) 134 return 135 var href_url = e.href 136 if (typeof getDocDownloadType == 'function') { 137 var downloadType = getDocDownloadType(href_url) 138 if (downloadType != 'Not Applicable') { 139 var marketLeveraged = false 140 if (typeof jQuery != 'undefined') { 141 $anchor_link = $(e)
142 marketLeveraged = isMarketLeveraged_UA($anchor_link) 143 } 144 //var pth=e.pathname?((e.pathname.indexOf("/")!=0)?"/"+e.pathname:e.pathname):"/"; 145 if (downloadType == 'Non-Secured' && !marketLeveraged) { 146 trackDocumentWithLinkURL(e) 147 } else if ( 148 downloadType == 'Moderated' || 149 downloadType == 'Registered' || 150 marketLeveraged 151 ) { 152 trackPublicOrMarketingLeverageDownloadActivity(e, marketLeveraged) 153 } else { 154 console.log('Secured Doc') 155 } 156 } else if ( 157 /* typeof s != 'undefined' && 158 s.linkInternalFilters && 159 !s.linkInternalFilters.includes(e.hostname)*/ 160 typeof wa_internalDomainList != 'undefined' && !wa_internalDomainList.includes(e.hostname) 161 ) { 162 // For Captuing exit links 163 trackExitLinkActivity(e) 164 } 165 } 166 } 167} 168 169//This function executes onRightClick of Anchor Tag 170//it checks whether download has been clicked or not by right clicking of mouse 171function trackDownloadRightClick (evt) { 172 var $anchor_link 173 evt = evt || window.event || '' 174 if (evt) { 175 var btn = evt.which || evt.button 176 if (btn != 1 || navigator.userAgent.indexOf('Safari') != -1) { 177 e = anchorEvt_UA(evt, 'A') 178 if ( 179 typeof e.href == 'undefined' || 180 !e.href || 181 typeof e.protocol == 'undefined' || 182 !e.protocol || 183 e.protocol.indexOf('http') == -1 || 184 !e.hostname || 185 typeof e.hostname == 'undefined' 186 ) 187 return 188 var href_url = e.href 189 if (typeof getDocDownloadType == 'function') { 190 var downloadType = getDocDownloadType(href_url) 191 if (downloadType != 'Not Applicable') { 192 var marketLeveraged = false 193 if (typeof jQuery != 'undefined') { 194 $anchor_link = $(e) 195 marketLeveraged = isMarketLeveraged_UA($anchor_link) 196 } 197 //var pth=e.pathname?((e.pathname.indexOf("/")!=0)?"/"+e.pathname:e.pathname):"/"; 198 if (downloadType == 'Non-Secured' && !marketLeveraged) { 199 trackDocumentWithLinkURL(e) 200 } else if ( 201 downloadType == 'Moderated' || 202 downloadType == 'Registered' || 203 marketLeveraged 204 ) { 205 trackPublicOrMarketingLeverageDownloadActivity(e, marketLeveraged) 206 } else { 207 console.log('Secured Doc') 208 } 209 } else if ( 210 /* typeof s != 'undefined' && 211 s.linkInternalFilters && 212 !s.linkInternalFilters.includes(e.hostname)*/ 213 typeof wa_internalDomainList != 'undefined' && !wa_internalDomainList.includes(e.hostname) 214 ) { 215 // For Captuing exit links 216 trackExitLinkActivity(e) 217 } 218 } 219 } 220 } 221} 222 223//Function called for trackuserActivity 224function trackUserActivity (eventActivityJson) { 225 handlingLocalStorage(eventActivityJson, true) 226} 227 228//To track the user activity, logic differs for logged in and non-logged-in user based on Cookie 229function trackPageViewUserActivity () { 230 if (isExcludeURL()) { 231 var eventActivityJson = formJsonObj(fetchPageViewMetaData(), '') 232 if (!document.title.includes('(404)')) { 233 if ( 234 $("meta[name='Asset_Type']").attr('content') != undefined && 235 $("meta[name='Asset Id']").attr('content') != undefined 236 ) { 237 trackDocumentAndSummaryPages(eventActivityJson) 238 } else { 239 trackUserActivity(eventActivityJson) 240 } 241 } 242 } 243} 244 245//To track recommendations in Product Advisor and DistyNet //b25319 246function trackPageResultUserActivity (application, title) { 247 recommendTitle = title 248 appName = application 249 var eventActivityJson = formJsonObj(fetchMetaData(APP_ACTIVITY), '') 250 handlingLocalStorage(eventActivityJson, true) 251} 252 253//To track the Secured Doc Download activity. 254function trackSecureDocDownloadUserActivity (map) { 255 if (satTrackFlag) { 256 var eventActivityJson = formJsonObj(map, '') 257 trackDocumentAndSummaryPages(eventActivityJson) 258 } 259} 260 261function fetchPageViewMetaData () { 262 return fetchMetaData(PAGE_VIEW) 263} 264 265function fetchDocLang (url) { 266 if ( 267 url.includes('/zh/') || 268 url.includes('/cn/') || 269 url.includes('/zh-Hans/') || 270 url.includes('lang_cd=zh') || 271 url.includes('lang_cd=cn') || 272 url.includes('lang_cd=zh-Hans') || 273 url.includes('docLang=zh') || 274 url.includes('docLang=cn') || 275 url.includes('docLang=zh-Hans') 276 ) { 277 return 'zh' 278 } else if ( 279 url.includes('/ja/') || 280 url.includes('/jp/') || 281 url.includes('lang_cd=ja') || 282 url.includes('lang_cd=jp') || 283 url.includes('docLang=jp') || 284 url.includes('docLang=ja') 285 ) { 286 return 'ja' 287 } else if ( 288 url.includes('/kr/') || 289 url.includes('/ko/') || 290 url.includes('lang_cd=kr') || 291 url.includes('lang_cd=ko') || 292 url.includes('docLang=kr') || 293 url.includes('docLang=ko') 294 ) { 295 return 'ko' 296 } else { 297 return 'en' 298 } 299} 300 301function fetchColCodeFromURL (url) { 302 var colCode = '' 303 if (extension.includes(url.split('.').pop())) { 304 colCode = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')) 305 } else if ( 306 url.includes('/webapp/Download') || 307 url.includes('/mod_download.jsp') || 308 url.includes('/multiDownload.sp') 309 ) { 310 colCode = getUrlVars(url)['colCode'] 311 } 312 return colCode != undefined ? colCode : '' 313} 314 315//To track the Public or Marketing leverage document download activity. 316function trackPublicOrMarketingLeverageDownloadActivity ( 317 a, 318 marketingLeveraged 319) { 320 var title, url, version, language, type, assetId 321 url = a.href 322 title = a.innerText 323 //version = a.nextSibling.innerText==undefined?"":a.nextSibling.innerText; 324 if (marketingLeveraged) { 325 assetId = a.attributes['data-collateral-code'].value 326 } else { 327 assetId = fetchColCodeFromURL(url) 328 } 329 language = fetchDocLang(url) 330 331 if (assetId != undefined && assetId.length > 0) { 332 var map = fetchDownloadMetaData() 333 map.set('Title', '') 334 map.set('url', '') 335 map.set('Asset Id', assetId) 336 map.set('language', language) 337 338 var eventActivityJson = formJsonObj(map, '') 339 trackDocumentAndSummaryPages(eventActivityJson) 340 } else if ( 341/* typeof s != 'undefined' && 342 s.linkInternalFilters && 343 !s.linkInternalFilters.includes(a.hostname)*/ 344 typeof wa_internalDomainList != 'undefined' && !wa_internalDomainList.includes(e.hostname) 345 ) { 346 // For External documents eg: doc-store 347 trackExitLinkActivity(a) 348 } 349} 350 351//To track the document using LINK URL 352function trackDocumentWithLinkURL (a) { 353 var title, url, version, language, type, assetId 354 url = a.href 355 title = a.innerText 356 language = fetchDocLang(url) 357 358 var map = fetchDownloadMetaData() 359 map.set('Title', '') 360 map.set('url', a.pathname) 361 map.set('Asset Id', a.pathname) 362 map.set('language', language) 363 364 var eventActivityJson = formJsonObj(map, '') 365 trackDocumentAndSummaryPages(eventActivityJson) 366} 367 368function trackExitLinkActivity (a) { 369 var title, url, version, language, type, assetId 370 url = a.href 371 title = a.innerText 372 language = fetchDocLang(url) 373 374 var map = fetchDownloadMetaData() 375 map.set('Title', '') 376 map.set('url', url) 377 map.set('Asset Id', url) 378 map.set('language', language) 379 380 var eventActivityJson = formJsonObj(map, '') 381 trackDocumentAndSummaryPages(eventActivityJson) 382} 383 384//function to fetch download Meta Data 385function fetchDownloadMetaData () { 386 return fetchMetaData(DOWNLOAD) 387} 388 389//function to fetch the data from Meta Tags 390function fetchMetaData (activityType) { 391 var map = new Map() 392 const securedApps = ['app-distynet'] 393 var isSecure = false 394 395 securedApps.forEach(item => { 396 if (window.location.href.includes(item)) { 397 isSecure = true 398 } 399 }) 400 map.set('activityType', activityType) 401 if ( 402 $("meta[name='Asset_Type']").attr('content') == undefined || 403 $("meta[name='Asset Id']").attr('content') == undefined 404 ) { 405 var title = $(document).attr('title') 406 if(title=='' || title== null){ 407 var title = $('ul.docstore').find('h2').text() 408 map.set('Title', title) 409 } 410 map.set('Title', title) 411 if (window.location.search.includes('partnerId') || window.location.href.includes('/sd/collateral/')) { 412 map.set('url', window.location.pathname + window.location.search) 413 if (window.location.search.includes('offeringId')){
414 const urlParams = new URLSearchParams(window.location.search); 415 416 var offeringId = decodeURIComponent(urlParams.get('offeringId')); 417 var partnerId = decodeURIComponent(urlParams.get('partnerId')); 418 const parentTag = $("li[offeringid= " + offeringId + "]").parent(); 419 var offeringType = $(parentTag).attr("offeringtype"); 420 map.set('partnerId', partnerId); 421 map.set('offeringId', offeringId); 422 const ele = $("li[offeringid= " + offeringId + "]"); 423 var type = $(ele).find(".item-signpost").text(); 424 var offeringTitle = $(ele).find(".item-title").text(); 425 var offeringDesc = $(ele).find(".item-content-description").text(); 426 var partnerImg = $("#partner-image").attr('src'); 427 var partnerTier = $("#partner-tier").text(); 428 var partnerName = $("#hero-title").text(); 429 map.set('offeringType', offeringType); 430 map.set('offeringDesc', offeringDesc); 431 map.set('offeringTitle', offeringTitle); 432 map.set('partnerImg', partnerImg); 433 map.set('partnerTier', partnerTier); 434 map.set('partnerName', partnerName); 435 map.set('Asset_Type',type); 436 437 438 } 439 } else { 440 map.set( 441 'url', 442 window.location.pathname + window.location.hash == '/' 443 ? window.location.href 444 : window.location.pathname + window.location.hash 445 ) 446 } 447 448 map.set('Asset Id', 'NA') 449 } else { 450 if (activityType == SEARCH) { 451 map.set('Asset Id', 'NA') 452 } else if (isSecure) { 453 var code = window.location.href.split('/').pop() 454 map.set('Asset Id', code) 455 map.set('Application', 'distynet') 456 457 if (code.length < 1) { 458 code = window.location.href.substring( 459 window.location.href.lastIndexOf(':') + 1, 460 window.location.href.lastIndexOf('#') 461 ) 462 map.set('Asset Id', code) 463 } 464 } else { 465 map.set('Asset Id', $("meta[name='Asset Id']").attr('content')) 466 } 467 if (activityType == APP_ACTIVITY) { 468 //b25319 469 map.set('Title', recommendTitle) 470 var urlPath = window.location.hash 471 if ( 472 urlPath == null || 473 typeof urlPath == undefined || 474 urlPath.length == 0 475 ) { 476 urlPath = window.location.search 477 } 478 map.set('url', window.location.pathname + urlPath) 479 map.set('Application', appName) 480 } 481 if (activityType == PAGE_VIEW) { 482 map.set('Asset_Type', $("meta[name='Asset_Type']").attr('content')) 483 } 484 } 485 var language = digitalData.siteInfo.lang 486 if (typeof language == 'undefined' || language == '') { 487 if (typeof lang == 'undefined' || lang == '') { 488 language = 489 typeof $('meta[name="DCSext.language_option"]').attr('content') == 490 'undefined' 491 ? 'en' 492 : $('meta[name="DCSext.language_option"]').attr('content') 493 } else { 494 language = lang 495 } 496 } 497 map.set('lang', language) 498 return map 499} 500 501function filterJSONObject (eventVar) { 502 ;(function filter (obj) { 503 $.each(obj, function (key, value) { 504 if (value === '' || value === null || value === undefined) { 505 delete obj[key] 506 } else if (Object.prototype.toString.call(value) === '[object Object]') { 507 filter(value) 508 } else if ($.isArray(value)) { 509 $.each(value, function (k, v) { 510 filter(v) 511 }) 512 } 513 }) 514 })(eventVar) 515 console.log(eventVar) 516} 517 518//function to form the JSON in the requested format 519function formJsonObj (map, activityType) { 520 var tmLoc = new Date() 521 //The offset is in minutes -- convert it to ms searchKeyword 522 var dateTime = tmLoc.getTime() 523 var assetVar = { 524 id: map.get('Asset Id'), 525 type: map.get('Asset_Type'), 526 lang: map.get('language') == null ? '' : map.get('language'), 527 title: map.get('Title'), 528 url: map.get('url'), 529 offeringId: map.get('offeringId'), 530 offeringType: map.get('offeringType'), 531 offeringTitle: map.get('offeringTitle'), 532 offeringDesc: map.get('offeringDesc'), 533 partnerImg: map.get('partnerImg'), 534 partnerName: map.get('partnerName'), 535 partnerTier: map.get('partnerTier'), 536 partnerId: map.get('partnerId') 537 538 } 539 if (activityType == SEARCH) { 540 assetVar = {} 541 } 542 var searchVar = { 543 keyword: map.get('searchKeyword') == null ? '' : map.get('searchKeyword') 544 } 545 var eventVar = { 546 dbFlag: 'false', 547 a_type: map.get('activityType'), 548 domain: $(location).attr('hostname'), 549 lang: map.get('lang') == null ? '' : map.get('lang'), 550 ts: dateTime, 551 application: map.get('Application') == null ? '' : map.get('Application'), 552 asset: assetVar, 553 search: searchVar 554 } 555 filterJSONObject(eventVar) 556 return eventVar 557} 558 559//Function to handle search localStorage 560function handlingEventActivityLS (eventActivityJson) { 561 var eventLS = localStorage.getItem(eventLocalStorage) 562 if (eventLS != null) { 563 var arr = JSON.parse(eventLS) 564 if (eventActivityJson != '') { 565 if ( 566 typeof eventActivityJson.asset.isRestricted != 'undefined' && 567 eventActivityJson.asset.isRestricted == 'true' 568 ) { 569 delete eventActivityJson.asset.title 570 delete eventActivityJson.asset.url 571 } 572 arr.push(eventActivityJson) 573 574 localStorage.setItem(eventLocalStorage, JSON.stringify(arr)) 575 } 576 return arr 577 } else { 578 var arr = [] 579 if (eventActivityJson != '') { 580 arr.push(eventActivityJson) 581 localStorage.setItem(eventLocalStorage, JSON.stringify(arr)) 582 } 583 return arr 584 } 585} 586 587 588//Function to handle SummaryPageActivity localStorage 589function handlingSummaryPageActivityLS (eventActivityJson) { 590 var summaryPageLS = localStorage.getItem(summaryPageLocalStorage) 591 if (summaryPageLS != null) { 592 var arr = JSON.parse(summaryPageLS) 593 if (eventActivityJson != '') { 594 if ( typeof eventActivityJson.asset.isRestricted != 'undefined' && 595 eventActivityJson.asset.isRestricted == 'true' 596 ) { 597 delete eventActivityJson.asset.title 598 delete eventActivityJson.asset.url 599 } 600 arr.push(eventActivityJson) 601 602 localStorage.setItem(summaryPageLocalStorage, JSON.stringify(arr)) 603 } 604 return arr 605 } else { 606 var arr = [] 607 if (eventActivityJson != '') { 608 arr.push(eventActivityJson) 609 localStorage.setItem(summaryPageLocalStorage, JSON.stringify(arr)) 610 } 611 return arr 612 } 613} 614 615 616 617//Function to handle search localStorage 618function handlingSearchActivityLS (eventActivityJson) { 619 var searchLS = localStorage.getItem(searchLocalStorage) 620 if (searchLS != null) { 621 var arr = JSON.parse(searchLS) 622 if (eventActivityJson != '') { 623 arr.push(eventActivityJson) 624 localStorage.setItem(searchLocalStorage, JSON.stringify(arr)) 625 } 626 return arr 627 } else { 628 var arr = [] 629 if (eventActivityJson != '') { 630 arr.push(eventActivityJson) 631 localStorage.setItem(searchLocalStorage, JSON.stringify(arr)) 632 } 633 return arr 634 } 635} 636 637//Function to fetch event and search localStorage value. 638function fetchLocalStorage () { 639 var searchLS = localStorage.getItem(searchLocalStorage) 640 var eventLS = localStorage.getItem(eventLocalStorage) 641 var summaryPageLS = localStorage.getItem(summaryPageLocalStorage) 642 var searchArr = [] 643 var eventArr = [] 644 var summaryPageArr 645 if (searchLS != null) searchArr = JSON.parse(searchLS) 646 if (eventLS != null) eventArr = JSON.parse(eventLS) 647 if (summaryPageLS != null) summaryPageArr = JSON.parse(summaryPageLS) 648 return $.merge(eventArr, searchArr, summaryPageArr) 649 650} 651 652//Function to handle local Storage for user Activity 653function handlingLocalStorage (eventActivityJson, syncFlag) { 654 if (checkSession() || checkPersistentCookie()) { 655 var arr = [] 656 if (eventActivityJson != '') { 657 var activityType = eventActivityJson.a_type 658 if (activityType == SEARCH) { 659 arr = handlingSearchActivityLS(eventActivityJson) 660 } else { 661 arr = handlingEventActivityLS(eventActivityJson) 662 //add the condition 663 var assetType = eventActivityJson.asset.type 664 if(assetType == 'Designs' || assetType == 'RDSP' || assetType == 'Tools' || 665 assetType == 'Devices' || assetType == 'TSP') 666 { 667 handlingSummaryPageActivityLS(eventActivityJson) 668 } 669 } 670 } else { 671 arr = fetchLocalStorage() 672 } 673 // Call only if arr is not null and not empty 674 if (arr && arr.length > 0) { 675 activitiesPostCall(arr, syncFlag) 676 } 677 } else { 678 updateLSForNonLoginUser(eventActivityJson) 679 } 680} 681 682//Update LocalStorage for Non Login User 683function updateLSForNonLoginUser (eventActivityJson) { 684 var arr = [] 685 if (eventActivityJson != '') { 686 var activityType = eventActivityJson.a_type 687 if (activityType == SEARCH) { 688 if (localStorage.getItem(searchLocalStorage) != null) { 689 arr = JSON.parse(localStorage.getItem(searchLocalStorage)) 690 if (arr.length > 50) { 691 arr = [] 692 } 693 } 694 arr.push(eventActivityJson) 695 if (arr.length > 0) mergeOrUpdateLS(arr) 696 //localStorage.setItem(searchLocalStorage, JSON.stringify(arr)); 697 } else { 698 if (localStorage.getItem(eventLocalStorage) != null) { 699 arr = JSON.parse(localStorage.getItem(eventLocalStorage)) 700 if (arr.length > 50) { 701 arr = [] 702 } 703 } 704 arr.push(eventActivityJson) 705 if (arr.length > 0) mergeOrUpdateLS(arr) 706 //localStorage.setItem(eventLocalStorage, JSON.stringify(arr)); 707 } 708 } 709} 710//Clear url path if ticket param is there 711function cleanPartialUrl(partialPath, baseDomain) { 712 try { 713 const fullUrl = new URL(partialPath, baseDomain); 714 const params = fullUrl.searchParams; 715 716 //delete ticket query from url 717 params.delete('ticket'); 718 719 const cleanedQuery = params.toString(); 720 721 // Final cleaned URL 722 return `${fullUrl.pathname}
722${cleanedQuery ? '?' + cleanedQuery : ''}`; 723 } catch (error) { 724 return null; 725 } 726} 727 728//Update LocalStorage dbFlag to true means it is activity captured 729function mergeOrUpdateLS (arr) { 730 var pageViewDownloadArr = [] 731 var searchKeywordArr = [] 732 var summaryPageArr = [] 733 // Remove duplicates based on asset.id and asset.code 734 function removeDuplicates(array) { 735 const seen = new Set(); 736 const result = []; 737 for (let i = array.length - 1; i >= 0; i--) { 738 const item = array[i]; 739 let key = ''; 740 if (item.a_type === 'K_SEARCH') { 741 key = 'search_' + (item.search?.keyword || item.ts); 742 } else if (item.asset?.id === 'NA' || !item.asset?.id) { 743 const cleanedUrl = cleanPartialUrl(item.asset?.url, window.location.origin); 744 key = cleanedUrl? item.asset?.title + '_' + cleanedUrl : item.asset?.title; 745 } else if(!item.asset?.code) { 746 key = item.asset?.id + '_' + item.asset?.title; 747 } else { 748 key = item.asset?.id + '_' + item.asset?.code; 749 } 750 if (!seen.has(key)) { 751 seen.add(key); 752 result.unshift(item); 753 } 754 } 755 return result; 756 } 757 // Deduplicate incoming array 758 const dedupedArr = removeDuplicates(arr); 759 sortLSValueAsPerTimeStamp(dedupedArr).forEach(function (item) { 760 if (checkSession() || checkPersistentCookie()) { 761 item.dbFlag = 'true' 762 } 763 if ( 764 item.a_type == PAGE_VIEW || 765 item.a_type == DOWNLOAD || 766 item.a_type == APP_ACTIVITY 767 ) { 768 if (pageViewDownloadArr.length < 20) pageViewDownloadArr.pu
768sh(item) 769 } 770 if( item.a_type == PAGE_VIEW && (item.asset.type == 'Designs' || item.asset.type == 'RDSP' || 771 item.asset.type == 'Tools' || item.asset.type == 'Devices' || 772 item.asset.type == 'TSP') ){ 773 if (summaryPageArr.length < 4) summaryPageArr.push(item) 774 } 775 if (item.a_type == SEARCH) { 776 if (searchKeywordArr.length < 10) searchKeywordArr.push(item) 777 } 778 }) 779 if (pageViewDownloadArr.length > 0) 780 localStorage.setItem(eventLocalStorage, JSON.stringify(pageViewDownloadArr)) 781 if (summaryPageArr.length > 0) 782 localStorage.setItem(summaryPageLocalStorage, JSON.stringify(summaryPageArr)) 783 if (searchKeywordArr.length > 0) 784 localStorage.setItem(searchLocalStorage, JSON.stringify(searchKeywordArr)) 785} 786 787function sortLSValueAsPerTimeStamp (arr) { 788 return arr.sort(function (a, b) { 789 var c = new Date(a.ts) 790 var d = new Date(b.ts) 791 return d - c 792 }) 793} 794 795//function to post the json object which contains user data to the controller 796function activitiesPostCall (userActivity, syncFlag) { 797 if (userActivity.length > 0) { 798 var postActivity = userActivity.filter(function (obj) { 799 return obj.dbFlag === 'false' 800 }) 801 postActivity.forEach(function (item) { 802 if ( 803 (item.a_type === DOWNLOAD || item.a_type === PAGE_VIEW) && 804 item.asset.id != 'NA' 805 ) { 806 item.asset.title = '' 807 item.asset.url = '' 808 item.asset.type = '' 809 //Comment or remove the below line to save the version to DB. 810 item.asset.version = '' 811 if (item.asset.code != undefined) delete item.asset.code 812 if (item.asset.isMarketingLevaraged != undefined) 813 delete item.asset.isMarketingLevaraged 814 } 815 }) 816 817 var urlPersistent = ''; 818 if(checkSession()) 819 { 820 urlPersistent = '/secured-rest/secureapi/activities'; 821 } 822 else if(checkPersistentCookie()){ 823 urlPersistent = '/secured-rest/persistent/secureapi/activities'; 824 } 825 826 if(postActivity && postActivity.length > 0){ 827 $.ajax({
828 url: NXP.megaMenuUrl + urlPersistent, 829 type: 'POST', 830 async: syncFlag, 831 xhrFields: { 832 withCredentials: true 833 }, 834 data: JSON.stringify(postActivity), 835 cache: false, 836 dataType: 'json', 837 contentType: 'application/json; charset=utf-8', 838 success: function (response) { 839 if (response == 'SUCCESS') { 840 mergeOrUpdateLS(fetchLocalStorage()) 841 } 842 if (localStorage.getItem('loginFlow') != null) { 843 localStorage.removeItem(eventLocalStorage) 844 localStorage.removeItem(searchLocalStorage) 845 localStorage.removeItem('loginFlow') 846 } 847 }, 848 error: function (e) { 849 console.log('failure' + e) 850 } 851 }) 852 } 853 } 854} 855function fetchUserRecentActivities () { 856if (checkSession() || checkPersistentCookie()) { 857 if ( 858 localStorage.getItem(eventLocalStorage) == null || 859 localStorage.getItem(searchLocalStorage) == null 860 ) { 861 activitiesGetCall() 862 } else if (!validateActivityDataToSession() && 863 !validateActivityDataToPersistentSession()) { 864 localStorage.removeItem(eventLocalStorage) 865 localStorage.removeItem(searchLocalStorage) 866 activitiesGetCall() 867 } 868 } 869} 870 871//function to fetch the user activities from the DB 872function activitiesGetCall () { 873 var fetchUrl = '/webapp/activities/recent/fetch?fetchType=partial&offset=0'; 874 if(!checkSession() && checkPersistentCookie()) 875 { 876 fetchUrl = '/webapp/persistent/activities/recent/fetch?fetchType=partial&offset=0'; 877 } 878 $.ajax({ 879 url: 880 NXP.megaMenuUrl + fetchUrl, 881 type: 'GET', 882 async: true, 883 xhrFields: { 884 withCredentials: true 885 }, 886 dataType: 'json', 887 cache: false, 888 success: function (response) { 889 if (response.status == 'SUCCESS') { 890 var eventActivity = response.eventActivity 891 var searchActivity = response.searchActivity 892 var summaryPageActivity = response.summaryPageActivity 893 894 var eventArr = JSON.parse(localStorage.getItem(eventLocalStorage)) 895 if (eventArr != null) { 896 eventArr = eventArr.filter(function (item) { 897 return item.dbFlag !== 'true' 898 }) 899 mergeOrUpdateLS($.merge(eventArr, response.eventActivity)) 900 } else { 901 localStorage.setItem( 902 eventLocalStorage, 903 JSON.stringify(response.eventActivity) 904 ) 905 } 906 var searchArr = JSON.parse(localStorage.getItem(searchLocalStorage)) 907 if (searchArr != null) { 908 searchArr = searchArr.filter(function (item) { 909 return item.dbFlag !== 'true' 910 }) 911 mergeOrUpdateLS($.merge(searchArr, response.searchActivity)) 912 } else { 913 localStorage.setItem( 914 searchLocalStorage, 915 JSON.stringify(response.searchActivity) 916 ) 917 } 918 var summaryPageArr = JSON.parse(localStorage.getItem(summaryPageLocalStorage)) 919 if (summaryPageArr != null) { 920 summaryPageArr = summaryPageArr.filter(function (item) { 921 return item.dbFlag !== 'true' 922 }) 923 mergeOrUpdateLS($.merge(summaryPageArr, response.summaryPageActivity)) 924 } else { 925 localStorage.setItem( 926 summaryPageLocalStorage, 927 JSON.stringify(response.summaryPageActivity) 928 ) 929 } 930 931 mapActivitesToSession(); 932 mapActivitesToPersistentSession(); 933 } else { 934 } 935 }, 936 error: function (e) { 937 console.log('failure' + e) 938 } 939 }) 940} 941 942function fetchKeywordSearchMetaData () { 943 var map = fetchMetaData(SEARCH) 944 map.set('searchKeyword', $('#parts').val() || $('#search-input').val()) 945 return map 946} 947 948function checkRecentKeywordSearch (partsVal) { 949 var arr = JSON.parse(localStorage.getItem(searchLocalStorage)) 950 var flag = true 951 var index = [] 952 if (arr != null) { 953 jQuery.each(arr, function (i, val) { 954 var t = (new Date().getTime() - val.ts) / 86400000
955 if (val.search.keyword === partsVal && t < 1) { 956 // delete index 957 console.log(i) 958 index.push(i) 959 } 960 }) 961 index.forEach(function (j) { 962 arr.splice(j, 1) 963 }) 964 localStorage.setItem(searchLocalStorage, JSON.stringify(arr)) 965 } 966} 967 968function trackSearchKeyWordUserActivity () { 969 $(document).on('click', '#suggestion-list', function (event) { 970 stepsToTrackSearchKeyWord() 971 console.log('keywordSearch') 972 }) 973} 974 975function stepsToTrackSearchKeyWord (kw) { 976 fetchUserRecentActivities() 977 var partsVal = kw || $('#parts').val() || $('#search-input').val() 978 if (partsVal != '') { 979 checkRecentKeywordSearch(partsVal) 980 var map = fetchKeywordSearchMetaData() 981 map.set('searchKeyword', partsVal) 982 var eventActivityJson = formJsonObj(map, SEARCH) 983 trackUserActivity(eventActivityJson) 984 } 985} 986 987function fetchUserActivityFromMyHeader () { 988 /*$('.secondary-nav-link').click(function(e, from){ 989 if(from==undefined){ 990 loginIndex=0; 991 } 992 if(loginIndex==0){ 993 fetchUserRecentActivities(); 994 loginIndex=1; 995 } 996 });*/ 997 $('.secondary-nav-link').click(function () { 998 setTimeout(function () { 999 NXP.loginBlock() 1000 }, 300) 1001 }) 1002} 1003 1004function getActivityIconDuplicate (assetType, activityType) { 1005 var icon = '' 1006 var iconName = 1007 assetType != '' && assetType != undefined 1008 ? iconData.get(assetType) 1009 : getIconVal(activityType) 1010 icon = '<span class=' + iconName + " style='font-size: 14px'></span> " 1011 return icon 1012} 1013 1014function getIconVal (activityType) { 1015 var iconType = '' 1016 if (activityType === 'PAGE_VIEW') { 1017 iconType = iconData.get('PAGE_VIEW') 1018 } else if (activityType === 'K_SEARCH') { 1019 iconType = iconData.get('K_SEARCH') 1020 } else if (activityType === 'DOC_DOWNLOAD') { 1021 iconType = iconData.get('DOC_DOWNLOAD') 1022 } else { 1023 iconType = iconData.get('') 1024 } 1025 return iconType 1026} 1027 1028//Read JSON From URL exclusion 1029function readJsonForUrlExClusion () { 1030 var json = (function () { 1031 var json = null 1032 $.ajax({
1033 async: false, 1034 type: 'GET', 1035 global: false, 1036 url: '/resources/scripts/analytics/exclusionList.json', 1037 dataType: 'json', 1038 success: function (data) { 1039 excludeUrl = data 1040 } 1041 }) 1042 return json 1043 })() 1044} 1045 1046//to compare the json list with the current URL 1047function isExcludeURL () { 1048 var flag = true 1049 readJsonForUrlExClusion() 1050 $.map(excludeUrl, function (elem, index) { 1051 if (window.location.pathname.includes(elem.url)) flag = false 1052 }) 1053 1054 // Do not track on Tab change on summary pages 1055 if (flag) { 1056 var currentUrl = [ 1057 location.protocol, 1058 '//', 1059 location.host, 1060 location.pathname 1061 ].join('') 1062 1063 flag = !( 1064 typeof assetType != 'undefined' && 1065 window.location.search.includes('tab') && 1066 document.referrer.includes(currentUrl) 1067 ) 1068 } 1069 1070 //check for Ecommerce 1071 if ( 1072 flag && 1073 document.location.hostname.includes('store') && 1074 !( 1075 document.location.pathname.includes( 1076 '/webapp/ecommerce.add_item.framework' 1077 ) || 1078 document.location.pathname.includes( 1079 'webapp/ecommerce.show_cart.framework' 1080 ) 1081 ) 1082 ) { 1083 flag = false 1084 } 1085 1086 return flag 1087} 1088 1089function anchorEvt_UA (evt, tag) { 1090 var e = evt.target || evt.srcElement 1091 while (e.tagName && e.tagName != tag) { 1092 e = e.parentElement || e.parentNode 1093 } 1094 return e 1095} 1096 1097function getDocDownloadType (url) { 1098 var searchQuery = getUrlVars(url) 1099 1100 var href = remProtocolFrmUrl_UA(url) 1101 href_path = href.split('/') 1102 var baseHref = href.split('?')[0] 1103 baseHref = href.split('#')[0] 1104 1105 // Check based on the query param 1106 if (searchQuery != undefined && searchQuery.appType != undefined) { 1107 if (searchQuery.appType.toLocaleLowerCase().includes('license')) { 1108 return 'Licensed' 1109 } else { 1110 return 'Registered' 1111 } 1112 } 1113 1114 // Check based on URL 1115 if (baseHref.indexOf('/download/mod_download.jsp') > -1) { 1116 return 'Registered' 1117 } else if (baseHref.indexOf('/webapp/Download') > -1) { 1118 return 'Registered' 1119 } else if (baseHref.indexOf('/download/license.jsp') > -1) { 1120 return 'Licensed' 1121 } else if ( 1122 baseHref.indexOf('/secured/assets/documents/') > -1 || 1123 baseHref.indexOf('/secured/assets/downloads/') > -1 1124 ) { 1125 return 'Secured Type' 1126 } 1127 1128 if (href_path[1] == 'docs' || href_path[1] == 'downloads') { 1129 return 'Non-Secured' 1130 } 1131 1132 return 'Not Applicable' 1133} 1134 1135function isMarketLeveraged_UA ($anchorlink) { 1136 if (typeof $anchorlink != 'undefined') { 1137 if (typeof $anchorlink.hasClass == 'function') 1138 if ($anchorlink.hasClass('progressiveProfiling')) return true 1139 } 1140 return false 1141} 1142 1143function remProtocolFrmUrl_UA (strUrl) { 1144 var str1 = strUrl 1145 var patt = /[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU|cn)/ 1146 var res = patt.test(str1) 1147 if (res == true) { 1148 var wotprotocol = /^((https?|ftp):\/\/|\/\/|\/)/ 1149 var res = str1.replace(wotprotocol, '') 1150 return res 1151 } else { 1152 var host = window.location.host + str1 1153 return host 1154 } 1155} 1156 1157function trackDocumentAndSummaryPages (eventActivityJson) { 1158 if (eventActivityJson.a_type == PAGE_VIEW) { 1159 getPageViewTaxoFromMetaData(eventActivityJson); 1160 } else { 1161 fetchTaxoData(JSON.stringify(eventActivityJson)) 1162 } 1163} 1164 1165function getSafeValue(value, fallback) { 1166 return (value == null || value === '' || value === 'undefined') ? fallback : value; 1167} 1168 1169function getPageViewTaxoFromMetaData(eventActivityJson){ 1170 eventActivityJson.asset.id == getSafeValue($("meta[name='Asset Id']").attr('content'),""); 1171 eventActivityJson.asset.title = getSafeValue(unescape($("meta[name='og:title']").attr('content')), document.title); 1172 eventActivityJson.asset.openGraphImage = getSafeValue($("meta[name='og:image']").attr('content'), ""); 1173 eventActivityJson.asset.code = getSafeValue($("meta[name='Code']").attr('content'),""); 1174 eventActivityJson.asset.type = getSafeValue($("meta[name='og:type']").attr('content'), getSafeValue($("meta[name='Asset_Type']").attr('content'),"")); 1175 eventActivityJson.asset.url = getSafeValue($("meta[name='og:url']").attr('content'),window.location.href); 1176 1177 trackUserActivity(eventActivityJson) 1178} 1179 1180function fetchTaxoData (map) { 1181 var arr = JSON.parse(map) 1182 var inputData = { 1183 a_type: arr.a_type, 1184 lang: 1185 typeof arr.asset.lang == 'undefined' 1186 ? typeof arr.lang == 'undefined' 1187 ? 'en' 1188 : arr.lang 1189 : arr.asset.lang, 1190 assetId: arr.asset.id, 1191 fetchType: 'taxoData' 1192 } 1193 1194 $.ajax({
1195 url: NXP.megaMenuUrl + '/webapp/taxonomy/getAssets', 1196 type: 'POST', 1197 async: true, 1198 dataType: 'json', 1199 data: JSON.stringify(inputData), 1200 contentType: 'application/json; charset=utf-8', 1201 success: function (response) { 1202 if (arr.a_type == DOWNLOAD) { 1203 var colBeanList = response.colBeanList 1204 if (colBeanList.length > 0) { 1205 arr.asset.title = unescape(colBeanList[0].assetName) 1206 arr.asset.type = colBeanList[0].docType 1207 arr.asset.url = colBeanList[0].url 1208 arr.asset.version = colBeanList[0].revisedCount 1209 arr.asset.id = 1210 colBeanList[0].collateralID != undefined && 1211 colBeanList[0].collateralID.length > 0 1212 ? colBeanList[0].collateralID 1213 : arr.asset.id 1214 var marketingLeveraged = colBeanList[0].marketingLeveraged 1215 if (marketingLeveraged != null && marketingLeveraged == 'Y') { 1216 arr.asset.id = colBeanList[0].collateralID 1217 arr.asset.code = colBeanList[0].productCode 1218 arr.asset.isMarketingLevaraged = marketingLeveraged 1219 } 1220 var restrictedCollateral = colBeanList[0].isRestricted 1221 if (restrictedCollateral != null && restrictedCollateral == 'true') { 1222 arr.asset.isRestricted = restrictedCollateral 1223 } 1224 trackUserActivity(arr) 1225 } else console.log('No Collateral Data For Download') 1226 } 1227 }, 1228 error: function (status, error) { 1229 console.log('error') 1230 } 1231 }) 1232} 1233 1234function handleLocalStorageAfterLogin () { 1235 if ((checkSession() || checkPersistentCookie()) && ( !validateActivityDataToPersistentSession()||!validateActivityDataToSession())) { 1236 1237 setTimeout(function () { 1238 handlingLocalStorage('', true) 1239 fetchUserRecentActivities() 1240 }, 0) 1241 1242 } 1243} 1244 1245function getUrlVars (url) { 1246 var vars = {} 1247 var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) { 1248 vars[key] = value 1249 }) 1250 return vars 1251} 1252 1253function checkSession () { 1254 if ($.cookie != undefined) { 1255 return $.cookie('SessID') != undefined && $.cookie('SessID') != '' 1256 } 1257} 1258 1259function mapActivitesToSession () { 1260 localStorage.setItem('activities_sess', $.cookie('SessID')) 1261} 1262 1263function mapActivitesToPersistentSession () { 1264 if(checkPersistentCookie() && !checkSession()){ 1265 localStorage.setItem('activities_sess', $.cookie(USE_PER_AUTH)) 1266 } 1267} 1268 1269function validateActivityDataToSession () { 1270 return ( 1271 $.cookie('SessID') == 1272 localStorage.getItem('activities_sess', $.cookie('SessID')) 1273 ) 1274} 1275 1276function validateActivityDataToPersistentSession () { 1277 return ( 1278 !checkSession() && $.cookie(USE_PER_AUTH) == 1279 localStorage.getItem('activities_sess', $.cookie(USE_PER_AUTH)) 1280 ) 1281} 1282 1283function trackUserActivityLoginFlow () { 1284 console.log('login flow triggered') 1285 //localStorage.setItem("loginFlow",true); 1286} 1287 1288function clearUserActivityforGDPR () { 1289 if (!satTrackFlag) { 1290 // Clear local storage 1291 localStorage.removeItem(eventLocalStorage) 1292 localStorage.removeItem(searchLocalStorage) 1293 1294 //Clear activity in DB for logged-in users 1295 remDbActivities() 1296 } 1297} 1298 1299function remDbActivities () { 1300 var clearUrl = '/secured-rest/secureapi/clearActivities'; 1301 if( !checkSession() && checkPersistentCookie()) 1302 { 1303 clearUrl = '/secured-rest/persistent/secureapi/clearActivities'; 1304 } 1305 $.ajax({ 1306 url: 1307 clearUrl + 1308 '?' + 1309 $.param({ clearCount: 0 }), 1310 type: 'post', 1311 cache: false, 1312 dataType: 'json', 1313 success: function (response) { 1314 // No Action 1315 }, 1316 error: function (e) { 1317 console.log('failure' + e) 1318 } 1319 }) 1320} 1321 1322function logSearchActivity (kw) { 1323 stepsToTrackSearchKeyWord(kw) 1324} 1325 1326function fetchAppSpecificActivity (appName) { 1327 var eventData = JSON.parse(localStorage.getItem('eventActivity')) 1328 var arr = [] 1329 if (eventData !== null && eventData !== undefined && eventData !== '') { 1330 eventData.map(function (item) { 1331 if (item.a_type == 'APP_ACTIVITY' && item.application == appName) { 1332 arr.push(item) 1333 } 1334 }) 1335 } 1336 return arr 1337} 1338function populateActivity (jsonData) { 1339 $.ajax({
1340 url: '/secured-rest/secureapi/SAMRecentActivity', 1341 type: 'post', 1342 dataType: 'text', 1343 contentType: 'application/json', 1344 data: jsonData, 1345 success: function (data) { 1346 processJSONData(data) 1347 clearData() 1348 }, 1349 error: function (error) { 1350 clearData() 1351 } 1352 }) 1353} 1354function processJSONData (data) { 1355 const activities = JSON.parse(data) 1356 var idPrefix = 'act_' 1357 if (typeof activities != 'undefined') { 1358 Object.keys(activities).forEach(function (key) { 1359 var activitiesData = activities[key] 1360 var metaId = key 1361 const activitiesDataString = JSON.stringify(activitiesData) 1362 const activitiesDataJson = JSON.parse(activitiesDataString) 1363 var tagId = idPrefix.concat(metaId) 1364 if ($('#'.concat(tagId)).length > 0) { 1365 var title = activitiesDataJson['title'] 1366 var url = activitiesDataJson['url'] 1367 var rev = activitiesDataJson['rev'] 1368 if ( 1369 rev != '' && 1370 typeof rev != 'undefined' && 1371 rev != null && 1372 title != '' && 1373 typeof title != 'undefined' && 1374 title != null 1375 ) { 1376 title = title + '<sup>' + 'Rev(' + rev + ')</sup>' 1377 } 1378 var anchorid = $('[id^=' + tagId + ']') 1379 if (anchorid.length > 0) { 1380 for (i = 0; i < anchorid.length; i++) { 1381 var application = anchorid[i].getAttribute('application') 1382 if ( 1383 application == 'distynet' && 1384 title != '' && 1385 typeof title != 'undefined' && 1386 title != null 1387 ) { 1388 var newTitle = '' 1389 newTitle = title + ' | DistyNet' 1390 } 1391 anchorid[i].setAttribute('class', 'dtmcustomrulelink') 1392 anchorid[i].setAttribute( 1393 'data-dtmaction', 1394 'Header: My NXP - Recent Activity - Link Click' 1395 ) 1396 anchorid[i].setAttribute('data-dtmsubaction', title) 1397 anchorid[i].innerHTML = newTitle 1398 anchorid[i].href = url 1399 } 1400 } 1401 } 1402 }) 1403 } 1404} 1405function clearData () { 1406 var countTitle = $("[id^='act_']") 1407 for (j = 0; j < countTitle.length; j++) { 1408 if ( 1409 countTitle[j].innerHTML == '' || 1410 countTitle[j].innerHTML == 'undefined' 1411 ) { 1412 countTitle[j].remove() 1413 //$('[id='+metaId+']').remove(); 1414 } 1415 } 1416} 1417 1418/* Sends localStorage activity to DB after login: async-friendly */ 1419async function activitiesPostLogInAsync () { 1420 var userActivity = fetchLocalStorage() 1421 if ((checkSession() || checkPersistentCookie()) && userActivity && ( !validateActivityDataToPersistentSession()||!validateActivityDataToSession())) { 1422 var postActivity = userActivity.filter(function (obj) { 1423 return obj.dbFlag === 'false' 1424 }) 1425 if (postActivity && postActivity.length > 0) { 1426 postActivity.forEach(function (item) { 1427 if ( 1428 (item.a_type === DOWNLOAD || item.a_type === PAGE_VIEW) && 1429 item.asset.id !== 'NA' 1430 ) { 1431 item.asset.title = '' 1432 item.asset.url = '' 1433 item.asset.type = '' 1434 //Comment or remove the below line to save the version to DB. 1435 item.asset.version = '' 1436 if (item.asset.code !== undefined) { 1437 delete item.asset.code 1438 } 1439 if (item.asset.isMarketingLevaraged !== undefined) { 1440 delete item.asset.isMarketingLevaraged 1441 } 1442 } 1443 }) 1444 var dataReady = JSON.stringify(postActivity) 1445 var urlPersistent = ''; 1446 if(checkSession()) 1447 { 1448 urlPersistent = '/secured-rest/secureapi/activities?test=true'; 1449 } 1450 else if(checkPersistentCookie()){ 1451 urlPersistent = '/secured-rest/persistent/secureapi/activities?test=true'; 1452 }
1453 try { 1454 var response = await fetch( 1455 NXP.megaMenuUrl + urlPersistent, 1456 { 1457 method: 'POST', 1458 headers: { 1459 'Content-Type': 'application/json' 1460 }, 1461 credentials: 'same-origin', 1462 cache: 'no-cache', 1463 body: dataReady 1464 } 1465 ) 1466 if (response == 'SUCCESS') { 1467 mergeOrUpdateLS(fetchLocalStorage()) 1468 } 1469 if (localStorage.getItem('loginFlow') !== null) { 1470 localStorage.removeItem(eventLocalStorage) 1471 localStorage.removeItem(searchLocalStorage) 1472 localStorage.removeItem('loginFlow') 1473 } 1474 return true 1475 } catch (e) { 1476 console.error('Failure async activities', e) 1477 return false 1478 } 1479 } 1480 return '' 1481 } 1482 return '' 1483} 1484 1485//#it adds as part PERSISTENT RECENT-ACTIVITIES 1486function checkPersistentCookie () { 1487 if ($.cookie != undefined) { 1488 return $.cookie(USE_PER_AUTH) != null && $.cookie(USE_PER_AUTH) != undefined && $.cookie(USE_PER_AUTH) != '' 1489 } 1490} 1491//# sourceURL=activity.js 1492 1493function activityHandler () { 1494 setTimeout(function () { 1495 if (checkAllDomains(document.domain)) { 1496 // dirty fix (blocking : login.DefaultController) to resolve registration to login issue, this will be worked on for a proper and clean fix 1497 if ( 1498 satTrackFlag && 1499 window.location.pathname.indexOf( 1500 'security/public/login.DefaultController.sp' 1501 ) == -1 1502 ) { 1503 if (window.location.pathname.indexOf('/app-distynet/') == -1 && window.location.pathname.indexOf('/app-salesnet/') == -1) { 1504 setTimeout(function () { 1505 trackPageViewUserActivity() 1506 }, waitTime) 1507 } 1508 if (!window.location.pathname.includes('/mynxp/activity')) { 1509 var downloadClick = 1510 navigator.appVersion.indexOf('MSIE') != -1 ? 'click' : 'mousedown' 1511 eventClick(downloadClick, 'trackDownloadLeftClick') 1512 eventClick('contextmenu', 'trackDownloadRightClick') 1513 } 1514 fetchUserActivityFromMyHeader() 1515 trackSearchKeyWordUserActivity() 1516 trackSoftwareDownloadUserActivity() 1517 handleLocalStorageAfterLogin() 1518 } else { 1519 clearUserActivityforGDPR() 1520 } 1521 } 1522 }, waitTime) 1523} 1524 1525if (document.readyState !== 'loading') { 1526 activityHandler() 1527} else { 1528 document.addEventListener('DOMContentLoaded', activityHandler) 1529}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.