@mate-academy/sourcebuster 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sourcebuster.js +87 -9
- package/dist/sourcebuster.min.js +2 -2
- package/package.json +1 -1
- package/public/js/sourcebuster.min.js +2 -2
- package/publish_current_version_to_webflow.sh +13 -0
- package/src/js/data.js +30 -5
- package/src/js/init.js +56 -4
- package/src/js/sourcebuster.js +1 -1
package/dist/sourcebuster.js
CHANGED
|
@@ -13,6 +13,7 @@ var sbjs = {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
module.exports = sbjs;
|
|
16
|
+
|
|
16
17
|
},{"./init":6}],2:[function(_dereq_,module,exports){
|
|
17
18
|
"use strict";
|
|
18
19
|
|
|
@@ -61,7 +62,8 @@ var data = {
|
|
|
61
62
|
|
|
62
63
|
session: {
|
|
63
64
|
pages_seen: 'pgs',
|
|
64
|
-
current_page: 'cpg'
|
|
65
|
+
current_page: 'cpg',
|
|
66
|
+
session_id: 'sid'
|
|
65
67
|
},
|
|
66
68
|
|
|
67
69
|
udata: {
|
|
@@ -92,6 +94,21 @@ var data = {
|
|
|
92
94
|
);
|
|
93
95
|
},
|
|
94
96
|
|
|
97
|
+
unpack: function(str) {
|
|
98
|
+
var sbjs = {};
|
|
99
|
+
var parts = str.split('|||');
|
|
100
|
+
|
|
101
|
+
parts.forEach(function(part) {
|
|
102
|
+
var keyValue = part.split('=');
|
|
103
|
+
var key = keyValue[0];
|
|
104
|
+
var value = keyValue[1];
|
|
105
|
+
|
|
106
|
+
sbjs[key] = value;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return sbjs;
|
|
110
|
+
},
|
|
111
|
+
|
|
95
112
|
extra: function(timezone_offset) {
|
|
96
113
|
return (
|
|
97
114
|
data.aliases.extra.fire_date + '=' + utils.setDate(new Date, timezone_offset) + data.delimiter +
|
|
@@ -108,11 +125,20 @@ var data = {
|
|
|
108
125
|
);
|
|
109
126
|
},
|
|
110
127
|
|
|
111
|
-
session: function(pages) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
128
|
+
session: function(pages, session_id) {
|
|
129
|
+
var session = (
|
|
130
|
+
data.aliases.session.pages_seen + '=' + pages + data.delimiter +
|
|
131
|
+
data.aliases.session.current_page + '=' + document.location.href
|
|
115
132
|
);
|
|
133
|
+
|
|
134
|
+
if (session_id) {
|
|
135
|
+
return (
|
|
136
|
+
session + data.delimiter +
|
|
137
|
+
data.aliases.session.session_id + '=' + session_id
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return session;
|
|
116
142
|
},
|
|
117
143
|
|
|
118
144
|
promo: function(promo) {
|
|
@@ -402,23 +428,61 @@ module.exports = function(prefs) {
|
|
|
402
428
|
)
|
|
403
429
|
);
|
|
404
430
|
|
|
431
|
+
var current_data;
|
|
432
|
+
var new_data;
|
|
433
|
+
var is_utm_changed = false;
|
|
434
|
+
|
|
405
435
|
if (isGetParamsContainsUtm) {
|
|
406
436
|
setFirstAndCurrentExtraData();
|
|
407
437
|
sbjs_data = getData(terms.traffic.utm);
|
|
438
|
+
current_data = parsedCurrent;
|
|
439
|
+
new_data = data.pack.unpack(sbjs_data);
|
|
440
|
+
|
|
441
|
+
is_utm_changed = checkIsUtmChanged(current_data, new_data);
|
|
408
442
|
} else if (shouldOverrideWithOrganic) {
|
|
409
443
|
setFirstAndCurrentExtraData();
|
|
410
444
|
sbjs_data = getData(terms.traffic.organic);
|
|
445
|
+
|
|
446
|
+
current_data = parsedCurrent;
|
|
447
|
+
new_data = data.pack.unpack(sbjs_data);
|
|
448
|
+
|
|
449
|
+
is_utm_changed = checkIsUtmChanged(current_data, new_data);
|
|
411
450
|
} else if (!cookies.get(data.containers.session) && checkReferer(terms.traffic.referral)) {
|
|
412
451
|
setFirstAndCurrentExtraData();
|
|
413
452
|
sbjs_data = getData(terms.traffic.referral);
|
|
453
|
+
|
|
454
|
+
is_utm_changed = true;
|
|
414
455
|
} else if (!cookies.get(data.containers.first) && !cookies.get(data.containers.current)) {
|
|
415
456
|
setFirstAndCurrentExtraData();
|
|
416
457
|
sbjs_data = getData(terms.traffic.typein);
|
|
458
|
+
|
|
459
|
+
is_utm_changed = true;
|
|
417
460
|
} else {
|
|
418
|
-
|
|
461
|
+
|
|
462
|
+
return {
|
|
463
|
+
data: cookies.get(data.containers.current),
|
|
464
|
+
is_utm_changed: is_utm_changed
|
|
465
|
+
};
|
|
419
466
|
}
|
|
420
467
|
|
|
421
|
-
return
|
|
468
|
+
return {
|
|
469
|
+
data: sbjs_data,
|
|
470
|
+
is_utm_changed: is_utm_changed
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function checkIsUtmChanged(
|
|
475
|
+
current_data,
|
|
476
|
+
new_data
|
|
477
|
+
) {
|
|
478
|
+
return (
|
|
479
|
+
current_data[data.aliases.main.type] !== new_data[data.aliases.main.type] ||
|
|
480
|
+
current_data[data.aliases.main.source] !== new_data[data.aliases.main.source] ||
|
|
481
|
+
current_data[data.aliases.main.medium] !== new_data[data.aliases.main.medium] ||
|
|
482
|
+
current_data[data.aliases.main.campaign] !== new_data[data.aliases.main.campaign] ||
|
|
483
|
+
current_data[data.aliases.main.content] !== new_data[data.aliases.main.content] ||
|
|
484
|
+
current_data[data.aliases.main.term] !== new_data[data.aliases.main.term]
|
|
485
|
+
);
|
|
422
486
|
}
|
|
423
487
|
|
|
424
488
|
function getData(type) {
|
|
@@ -697,9 +761,10 @@ module.exports = function(prefs) {
|
|
|
697
761
|
}
|
|
698
762
|
|
|
699
763
|
(function setData() {
|
|
764
|
+
var sbjs_data = mainData();
|
|
700
765
|
|
|
701
766
|
// Main data
|
|
702
|
-
cookies.set(data.containers.current,
|
|
767
|
+
cookies.set(data.containers.current, sbjs_data.data, lifetime, domain, isolate);
|
|
703
768
|
if (!cookies.get(data.containers.first)) {
|
|
704
769
|
cookies.set(data.containers.first, cookies.get(data.containers.current), lifetime, domain, isolate);
|
|
705
770
|
}
|
|
@@ -718,13 +783,26 @@ module.exports = function(prefs) {
|
|
|
718
783
|
|
|
719
784
|
// Session
|
|
720
785
|
var pages_count;
|
|
786
|
+
var session_id;
|
|
787
|
+
|
|
721
788
|
if (!cookies.get(data.containers.session)) {
|
|
722
789
|
pages_count = 1;
|
|
723
790
|
} else {
|
|
724
791
|
pages_count = parseInt(cookies.parse(data.containers.session)[cookies.unsbjs(data.containers.session)][data.aliases.session.pages_seen]) || 1;
|
|
725
792
|
pages_count += 1;
|
|
726
793
|
}
|
|
727
|
-
|
|
794
|
+
|
|
795
|
+
if (!cookies.get(data.containers.session) || sbjs_data.is_utm_changed) {
|
|
796
|
+
session_id = new Date().getTime();
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
cookies.set(
|
|
800
|
+
data.containers.session,
|
|
801
|
+
data.pack.session(pages_count, session_id),
|
|
802
|
+
p.session_length,
|
|
803
|
+
domain,
|
|
804
|
+
isolate
|
|
805
|
+
);
|
|
728
806
|
|
|
729
807
|
// Promocode
|
|
730
808
|
if (p.promocode && !cookies.get(data.containers.promocode)) {
|
package/dist/sourcebuster.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** @mate-academy/sourcebuster v1.2.
|
|
2
|
-
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sbjs=e()}}(function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var p=r[o]={exports:{}};t[o][0].call(p.exports,function(e){var r=t[o][1][e];return i(r?r:e)},p,p.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}({1:[function(e,t,r){"use strict";var n=e("./init"),i={init:function(e){this.get=n(e),e&&e.callback&&"function"==typeof e.callback&&e.callback(this.get)}};t.exports=i},{"./init":6}],2:[function(e,t,r){"use strict";var n=e("./terms"),i=e("./helpers/utils"),a={containers:{current:"sbjs_current",current_extra:"sbjs_current_add",first:"sbjs_first",first_extra:"sbjs_first_add",session:"sbjs_session",udata:"sbjs_udata",promocode:"sbjs_promo"},service:{migrations:"sbjs_migrations"},delimiter:"|||",aliases:{main:{type:"typ",source:"src",medium:"mdm",campaign:"cmp",content:"cnt",term:"trm",account_id:"ac_id",campaign_id:"cmp_id",ad_group_id:"adg_id",ad_id:"ad_id",term_id:"trm_id"},extra:{fire_date:"fd",entrance_point:"ep",referer:"rf"},session:{pages_seen:"pgs",current_page:"cpg"},udata:{visits:"vst",ip:"uip",agent:"uag"},promo:"code"},pack:{main:function(e){return a.aliases.main.type+"="+e.type+a.delimiter+a.aliases.main.source+"="+e.source+a.delimiter+a.aliases.main.medium+"="+e.medium+a.delimiter+a.aliases.main.campaign+"="+e.campaign+a.delimiter+a.aliases.main.content+"="+e.content+a.delimiter+a.aliases.main.term+"="+e.term+a.delimiter+a.aliases.main.account_id+"="+e.account_id+a.delimiter+a.aliases.main.campaign_id+"="+e.campaign_id+a.delimiter+a.aliases.main.ad_group_id+"="+e.ad_group_id+a.delimiter+a.aliases.main.ad_id+"="+e.ad_id+a.delimiter+a.aliases.main.term_id+"="+e.term_id},extra:function(e){return a.aliases.extra.fire_date+"="+i.setDate(new Date,e)+a.delimiter+a.aliases.extra.entrance_point+"="+document.location.href+a.delimiter+a.aliases.extra.referer+"="+(document.referrer||n.none)},user:function(e,t){return a.aliases.udata.visits+"="+e+a.delimiter+a.aliases.udata.ip+"="+t+a.delimiter+a.aliases.udata.agent+"="+navigator.userAgent},session:function(e){return a.aliases.session.pages_seen+"="+e+a.delimiter+a.aliases.session.current_page+"="+document.location.href},promo:function(e){return a.aliases.promo+"="+i.setLeadingZeroToInt(i.randomInt(e.min,e.max),e.max.toString().length)}}};t.exports=a},{"./helpers/utils":5,"./terms":9}],3:[function(e,t,r){"use strict";var n=e("../data").delimiter;t.exports={encodeData:function(e){return encodeURIComponent(e).replace(/\!/g,"%21").replace(/\~/g,"%7E").replace(/\*/g,"%2A").replace(/\'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")},decodeData:function(e){try{return decodeURIComponent(e).replace(/\%21/g,"!").replace(/\%7E/g,"~").replace(/\%2A/g,"*").replace(/\%27/g,"'").replace(/\%28/g,"(").replace(/\%29/g,")")}catch(t){try{return unescape(e)}catch(r){return""}}},set:function(e,t,r,n,i){var a,o;if(r){var s=new Date;s.setTime(s.getTime()+60*r*1e3),a="; expires="+s.toGMTString()}else a="";o=n&&!i?";domain=."+n:"",document.cookie=this.encodeData(e)+"="+this.encodeData(t)+a+o+"; path=/"},get:function(e){for(var t=this.encodeData(e)+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var i=r[n];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return this.decodeData(i.substring(t.length,i.length))}return null},destroy:function(e,t,r){this.set(e,"",-1,t,r)},parse:function(e){var t=[],r={};if("string"==typeof e)t.push(e);else for(var i in e)e.hasOwnProperty(i)&&t.push(e[i]);for(var a=0;a<t.length;a++){var o;r[this.unsbjs(t[a])]={},o=this.get(t[a])?this.get(t[a]).split(n):[];for(var s=0;s<o.length;s++){var c=o[s].split("="),u=c.splice(0,1);u.push(c.join("=")),r[this.unsbjs(t[a])][u[0]]=this.decodeData(u[1])}}return r},unsbjs:function(e){return e.replace("sbjs_","")}}},{"../data":2}],4:[function(e,t,r){"use strict";t.exports={parse:function(e){for(var t=this.parseOptions,r=t.parser[t.strictMode?"strict":"loose"].exec(e),n={},i=14;i--;)n[t.key[i]]=r[i]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,function(e,r,i){r&&(n[t.q.name][r]=i)}),n},parseOptions:{strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},getParam:function(e){for(var t={},r=e?e:window.location.search.substring(1),n=r.split("&"),i=0;i<n.length;i++){var a=n[i].split("=");if("undefined"==typeof t[a[0]])t[a[0]]=a[1];else if("string"==typeof t[a[0]]){var o=[t[a[0]],a[1]];t[a[0]]=o}else t[a[0]].push(a[1])}return t},getHost:function(e){return this.parse(e).host.replace("www.","")}}},{}],5:[function(e,t,r){"use strict";t.exports={escapeRegexp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},setDate:function(e,t){var r=e.getTimezoneOffset()/60,n=e.getHours(),i=t||0===t?t:-r;e.setHours(n+r+i);var a=e.getFullYear(),o=this.setLeadingZeroToInt(e.getMonth()+1,2),s=this.setLeadingZeroToInt(e.getDate(),2),c=this.setLeadingZeroToInt(e.getHours(),2),u=this.setLeadingZeroToInt(e.getMinutes(),2),p=this.setLeadingZeroToInt(e.getSeconds(),2);return a+"-"+o+"-"+s+" "+c+":"+u+":"+p},setLeadingZeroToInt:function(e,t){for(var r=e+"";r.length<t;)r="0"+r;return r},randomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e}}},{}],6:[function(e,t,r){"use strict";var n=e("./data"),i=e("./terms"),a=e("./helpers/cookies"),o=e("./helpers/uri"),s=e("./helpers/utils"),c=e("./params"),u=e("./migrations");t.exports=function(e){function t(){var e,t="undefined"!=typeof _.utm_source||"undefined"!=typeof _.utm_medium||"undefined"!=typeof _.utm_campaign||"undefined"!=typeof _.utm_content||"undefined"!=typeof _.utm_term||"undefined"!=typeof _.utm_ac_id||"undefined"!=typeof _.utm_id||"undefined"!=typeof _.utm_ad_group_id||"undefined"!=typeof _.utm_ad_id||"undefined"!=typeof _.utm_term_id||"undefined"!=typeof _.gclid||"undefined"!=typeof _.yclid||"undefined"!=typeof _[h.campaign_param]||"undefined"!=typeof _[h.term_param]||"undefined"!=typeof _[h.content_param],o=a.parse(n.containers),s=o[a.unsbjs(n.containers.current)],c=o[a.unsbjs(n.containers.current_extra)],u=new Date(c[n.aliases.extra.fire_date]).getTime(),p=864e5,f=(new Date).getTime(),m=f-u,l=d(i.traffic.organic),y=s[n.aliases.main.type]===i.traffic.utm,v=l&&(!y||m>45*p);if(t)g(),e=r(i.traffic.utm);else if(v)g(),e=r(i.traffic.organic);else if(!a.get(n.containers.session)&&d(i.traffic.referral))g(),e=r(i.traffic.referral);else{if(a.get(n.containers.first)||a.get(n.containers.current))return a.get(n.containers.current);g(),e=r(i.traffic.typein)}return e}function r(e){switch(e){case i.traffic.utm:b=i.traffic.utm,k="undefined"!=typeof _.utm_source?_.utm_source:"undefined"!=typeof _.gclid?"google":"undefined"!=typeof _.yclid?"yandex":i.none,w="undefined"!=typeof _.utm_medium?_.utm_medium:"undefined"!=typeof _.gclid?"cpc":"undefined"!=typeof _.yclid?"cpc":i.none,q="undefined"!=typeof _.utm_campaign?_.utm_campaign:"undefined"!=typeof _[h.campaign_param]?_[h.campaign_param]:"undefined"!=typeof _.gclid?"google_cpc":"undefined"!=typeof _.yclid?"yandex_cpc":i.none,I="undefined"!=typeof _.utm_content?_.utm_content:"undefined"!=typeof _[h.content_param]?_[h.content_param]:i.none,j="undefined"!=typeof _.utm_term?_.utm_term:"undefined"!=typeof _[h.term_param]?_[h.term_param]:p()||i.none,R="undefined"!=typeof _.utm_ac_id?_.utm_ac_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,D="undefined"!=typeof _.utm_id?_.utm_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,H="undefined"!=typeof _.utm_ad_group_id?_.utm_ad_group_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,T="undefined"!=typeof _.utm_ad_id?_.utm_ad_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,E="undefined"!=typeof _.utm_term_id?_.utm_term_id:"undefined"!=typeof _.gclid?"google_cpc":i.none;break;case i.traffic.organic:b=i.traffic.organic,k=k||o.getHost(document.referrer),w=i.referer.organic,q=i.none,I=i.none,j=i.none,R=i.none,D=i.none,H=i.none,T=i.none,E=i.none;break;case i.traffic.referral:b=i.traffic.referral,k=k||o.getHost(document.referrer),w=w||i.referer.referral,q=i.none,I=o.parse(document.referrer).path,j=i.none,R=i.none,D=i.none,H=i.none,T=i.none,E=i.none;break;case i.traffic.typein:b=i.traffic.typein,k=h.typein_attributes.source,w=h.typein_attributes.medium,q=i.none,I=i.none,j=i.none,R=i.none,D=i.none,H=i.none,T=i.none,E=i.none;break;default:b=i.oops,k=i.oops,w=i.oops,q=i.oops,I=i.oops,j=i.oops,R=i.oops,D=i.oops,H=i.oops,T=i.oops,E=i.oops}var t={type:b,source:k,medium:w,campaign:q,content:I,term:j,account_id:R,campaign_id:D,ad_group_id:H,ad_id:T,term_id:E};return n.pack.main(t)}function p(){var e=document.referrer;if(_.utm_term)return _.utm_term;if(!(e&&o.parse(e).host&&o.parse(e).host.match(/^(?:.*\.)?yandex\..{2,9}$/i)))return!1;try{return o.getParam(o.parse(document.referrer).query).text}catch(t){return!1}}function d(e){var t=document.referrer;switch(e){case i.traffic.organic:return!!t&&f(t)&&m(t);case i.traffic.referral:return!!t&&f(t)&&l(t);default:return!1}}function f(e){if(h.domain){if(v)return o.getHost(e)!==o.getHost(y);var t=new RegExp("^(?:.*\\.)?"+s.escapeRegexp(y)+"$","i");return!o.getHost(e).match(t)}return o.getHost(e)!==o.getHost(document.location.href)}function m(e){var t="yandex",r="text",n="google",i=new RegExp("^(?:.*\\.)?"+s.escapeRegexp(t)+"\\..{2,9}$"),a=new RegExp(".*"+s.escapeRegexp(r)+"=.*"),c=new RegExp("^(?:www\\.)?"+s.escapeRegexp(n)+"\\..{2,9}$");if(o.parse(e).query&&o.parse(e).host.match(i)&&o.parse(e).query.match(a))return k=t,!0;if(o.parse(e).host.match(c))return k=n,!0;if(!o.parse(e).query)return!1;for(var u=0;u<h.organics.length;u++){if(o.parse(e).host.match(new RegExp("^(?:.*\\.)?"+s.escapeRegexp(h.organics[u].host)+"$","i"))&&o.parse(e).query.match(new RegExp(".*"+s.escapeRegexp(h.organics[u].param)+"=.*","i")))return k=h.organics[u].display||h.organics[u].host,!0;if(u+1===h.organics.length)return!1}}function l(e){if(!(h.referrals.length>0))return k=o.getHost(e),!0;for(var t=0;t<h.referrals.length;t++){if(o.parse(e).host.match(new RegExp("^(?:.*\\.)?"+s.escapeRegexp(h.referrals[t].host)+"$","i")))return k=h.referrals[t].display||h.referrals[t].host,w=h.referrals[t].medium||i.referer.referral,!0;if(t+1===h.referrals.length)return k=o.getHost(e),!0}}function g(){a.set(n.containers.current_extra,n.pack.extra(h.timezone_offset),x,y,v),a.get(n.containers.first_extra)||a.set(n.containers.first_extra,n.pack.extra(h.timezone_offset),x,y,v)}var h=c.fetch(e),_=o.getParam(),y=h.domain.host,v=h.domain.isolate,x=h.lifetime;u.go(x,y,v);var b,k,w,q,I,j,R,D,H,T,E;return function(){a.set(n.containers.current,t(),x,y,v),a.get(n.containers.first)||a.set(n.containers.first,a.get(n.containers.current),x,y,v);var e,r;a.get(n.containers.udata)?(e=parseInt(a.parse(n.containers.udata)[a.unsbjs(n.containers.udata)][n.aliases.udata.visits])||1,e=a.get(n.containers.session)?e:e+1,r=n.pack.user(e,h.user_ip)):(e=1,r=n.pack.user(e,h.user_ip)),a.set(n.containers.udata,r,x,y,v);var i;a.get(n.containers.session)?(i=parseInt(a.parse(n.containers.session)[a.unsbjs(n.containers.session)][n.aliases.session.pages_seen])||1,i+=1):i=1,a.set(n.containers.session,n.pack.session(i),h.session_length,y,v),h.promocode&&!a.get(n.containers.promocode)&&a.set(n.containers.promocode,n.pack.promo(h.promocode),x,y,v)}(),a.parse(n.containers)}},{"./data":2,"./helpers/cookies":3,"./helpers/uri":4,"./helpers/utils":5,"./migrations":7,"./params":8,"./terms":9}],7:[function(e,t,r){"use strict";var n=e("./data"),i=e("./helpers/cookies");t.exports={go:function(e,t,r){var a,o=this.migrations,s={l:e,d:t,i:r};if(i.get(n.containers.first)||i.get(n.service.migrations)){if(!i.get(n.service.migrations))for(a=0;a<o.length;a++)o[a].go(o[a].id,s)}else{var c=[];for(a=0;a<o.length;a++)c.push(o[a].id);var u="";for(a=0;a<c.length;a++)u+=c[a]+"=1",a<c.length-1&&(u+=n.delimiter);i.set(n.service.migrations,u,s.l,s.d,s.i)}},migrations:[{id:"1418474375998",version:"1.0.0-beta",go:function(e,t){var r=e+"=1",a=e+"=0",o=function(e,t,r){return t||r?e:n.delimiter};try{var s=[];for(var c in n.containers)n.containers.hasOwnProperty(c)&&s.push(n.containers[c]);for(var u=0;u<s.length;u++)if(i.get(s[u])){var p=i.get(s[u]).replace(/(\|)?\|(\|)?/g,o);i.destroy(s[u],t.d,t.i),i.destroy(s[u],t.d,!t.i),i.set(s[u],p,t.l,t.d,t.i)}i.get(n.containers.session)&&i.set(n.containers.session,n.pack.session(0),t.l,t.d,t.i),i.set(n.service.migrations,r,t.l,t.d,t.i)}catch(d){i.set(n.service.migrations,a,t.l,t.d,t.i)}}}]}},{"./data":2,"./helpers/cookies":3}],8:[function(e,t,r){"use strict";var n=e("./terms"),i=e("./helpers/uri");t.exports={fetch:function(e){var t=e||{},r={};if(r.lifetime=this.validate.checkFloat(t.lifetime)||6,r.lifetime=parseInt(30*r.lifetime*24*60),r.session_length=this.validate.checkInt(t.session_length)||30,r.timezone_offset=this.validate.checkInt(t.timezone_offset),r.campaign_param=t.campaign_param||!1,r.term_param=t.term_param||!1,r.content_param=t.content_param||!1,r.user_ip=t.user_ip||n.none,t.promocode?(r.promocode={},r.promocode.min=parseInt(t.promocode.min)||1e5,r.promocode.max=parseInt(t.promocode.max)||999999):r.promocode=!1,t.typein_attributes&&t.typein_attributes.source&&t.typein_attributes.medium?(r.typein_attributes={},r.typein_attributes.source=t.typein_attributes.source,r.typein_attributes.medium=t.typein_attributes.medium):r.typein_attributes={source:"(direct)",medium:"(none)"},t.domain&&this.validate.isString(t.domain)?r.domain={host:t.domain,isolate:!1}:t.domain&&t.domain.host?r.domain=t.domain:r.domain={host:i.getHost(document.location.hostname),isolate:!1},r.referrals=[],t.referrals&&t.referrals.length>0)for(var a=0;a<t.referrals.length;a++)t.referrals[a].host&&r.referrals.push(t.referrals[a]);if(r.organics=[],t.organics&&t.organics.length>0)for(var o=0;o<t.organics.length;o++)t.organics[o].host&&t.organics[o].param&&r.organics.push(t.organics[o]);return r.organics.push({host:"bing.com",param:"q",display:"bing"}),r.organics.push({host:"yahoo.com",param:"p",display:"yahoo"}),r.organics.push({host:"about.com",param:"q",display:"about"}),r.organics.push({host:"aol.com",param:"q",display:"aol"}),r.organics.push({host:"ask.com",param:"q",display:"ask"}),r.organics.push({host:"globososo.com",param:"q",display:"globo"}),r.organics.push({host:"go.mail.ru",param:"q",display:"go.mail.ru"}),r.organics.push({host:"rambler.ru",param:"query",display:"rambler"}),r.organics.push({host:"tut.by",param:"query",display:"tut.by"}),r.referrals.push({host:"t.co",display:"twitter.com"}),r.referrals.push({host:"plus.url.google.com",display:"plus.google.com"}),r},validate:{checkFloat:function(e){return!(!e||!this.isNumeric(parseFloat(e)))&&parseFloat(e)},checkInt:function(e){return!(!e||!this.isNumeric(parseInt(e)))&&parseInt(e)},isNumeric:function(e){return!isNaN(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)}}}},{"./helpers/uri":4,"./terms":9}],9:[function(e,t,r){"use strict";t.exports={traffic:{utm:"utm",organic:"organic",referral:"referral",typein:"typein"},referer:{referral:"referral",organic:"organic",social:"social"},none:"(none)",oops:"(Houston, we have a problem)"}},{}]},{},[1])(1)});
|
|
1
|
+
/** @mate-academy/sourcebuster v1.2.5 **/
|
|
2
|
+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sbjs=e()}}(function(){return function e(t,r,n){function i(s,o){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!o&&c)return c(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var p=r[s]={exports:{}};t[s][0].call(p.exports,function(e){var r=t[s][1][e];return i(r?r:e)},p,p.exports,e,t,r,n)}return r[s].exports}for(var a="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,r){"use strict";var n=e("./init"),i={init:function(e){this.get=n(e),e&&e.callback&&"function"==typeof e.callback&&e.callback(this.get)}};t.exports=i},{"./init":6}],2:[function(e,t,r){"use strict";var n=e("./terms"),i=e("./helpers/utils"),a={containers:{current:"sbjs_current",current_extra:"sbjs_current_add",first:"sbjs_first",first_extra:"sbjs_first_add",session:"sbjs_session",udata:"sbjs_udata",promocode:"sbjs_promo"},service:{migrations:"sbjs_migrations"},delimiter:"|||",aliases:{main:{type:"typ",source:"src",medium:"mdm",campaign:"cmp",content:"cnt",term:"trm",account_id:"ac_id",campaign_id:"cmp_id",ad_group_id:"adg_id",ad_id:"ad_id",term_id:"trm_id"},extra:{fire_date:"fd",entrance_point:"ep",referer:"rf"},session:{pages_seen:"pgs",current_page:"cpg",session_id:"sid"},udata:{visits:"vst",ip:"uip",agent:"uag"},promo:"code"},pack:{main:function(e){return a.aliases.main.type+"="+e.type+a.delimiter+a.aliases.main.source+"="+e.source+a.delimiter+a.aliases.main.medium+"="+e.medium+a.delimiter+a.aliases.main.campaign+"="+e.campaign+a.delimiter+a.aliases.main.content+"="+e.content+a.delimiter+a.aliases.main.term+"="+e.term+a.delimiter+a.aliases.main.account_id+"="+e.account_id+a.delimiter+a.aliases.main.campaign_id+"="+e.campaign_id+a.delimiter+a.aliases.main.ad_group_id+"="+e.ad_group_id+a.delimiter+a.aliases.main.ad_id+"="+e.ad_id+a.delimiter+a.aliases.main.term_id+"="+e.term_id},unpack:function(e){var t={},r=e.split("|||");return r.forEach(function(e){var r=e.split("="),n=r[0],i=r[1];t[n]=i}),t},extra:function(e){return a.aliases.extra.fire_date+"="+i.setDate(new Date,e)+a.delimiter+a.aliases.extra.entrance_point+"="+document.location.href+a.delimiter+a.aliases.extra.referer+"="+(document.referrer||n.none)},user:function(e,t){return a.aliases.udata.visits+"="+e+a.delimiter+a.aliases.udata.ip+"="+t+a.delimiter+a.aliases.udata.agent+"="+navigator.userAgent},session:function(e,t){var r=a.aliases.session.pages_seen+"="+e+a.delimiter+a.aliases.session.current_page+"="+document.location.href;return t?r+a.delimiter+a.aliases.session.session_id+"="+t:r},promo:function(e){return a.aliases.promo+"="+i.setLeadingZeroToInt(i.randomInt(e.min,e.max),e.max.toString().length)}}};t.exports=a},{"./helpers/utils":5,"./terms":9}],3:[function(e,t,r){"use strict";var n=e("../data").delimiter;t.exports={encodeData:function(e){return encodeURIComponent(e).replace(/\!/g,"%21").replace(/\~/g,"%7E").replace(/\*/g,"%2A").replace(/\'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")},decodeData:function(e){try{return decodeURIComponent(e).replace(/\%21/g,"!").replace(/\%7E/g,"~").replace(/\%2A/g,"*").replace(/\%27/g,"'").replace(/\%28/g,"(").replace(/\%29/g,")")}catch(t){try{return unescape(e)}catch(r){return""}}},set:function(e,t,r,n,i){var a,s;if(r){var o=new Date;o.setTime(o.getTime()+60*r*1e3),a="; expires="+o.toGMTString()}else a="";s=n&&!i?";domain=."+n:"",document.cookie=this.encodeData(e)+"="+this.encodeData(t)+a+s+"; path=/"},get:function(e){for(var t=this.encodeData(e)+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var i=r[n];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return this.decodeData(i.substring(t.length,i.length))}return null},destroy:function(e,t,r){this.set(e,"",-1,t,r)},parse:function(e){var t=[],r={};if("string"==typeof e)t.push(e);else for(var i in e)e.hasOwnProperty(i)&&t.push(e[i]);for(var a=0;a<t.length;a++){var s;r[this.unsbjs(t[a])]={},s=this.get(t[a])?this.get(t[a]).split(n):[];for(var o=0;o<s.length;o++){var c=s[o].split("="),u=c.splice(0,1);u.push(c.join("=")),r[this.unsbjs(t[a])][u[0]]=this.decodeData(u[1])}}return r},unsbjs:function(e){return e.replace("sbjs_","")}}},{"../data":2}],4:[function(e,t,r){"use strict";t.exports={parse:function(e){for(var t=this.parseOptions,r=t.parser[t.strictMode?"strict":"loose"].exec(e),n={},i=14;i--;)n[t.key[i]]=r[i]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,function(e,r,i){r&&(n[t.q.name][r]=i)}),n},parseOptions:{strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},getParam:function(e){for(var t={},r=e?e:window.location.search.substring(1),n=r.split("&"),i=0;i<n.length;i++){var a=n[i].split("=");if("undefined"==typeof t[a[0]])t[a[0]]=a[1];else if("string"==typeof t[a[0]]){var s=[t[a[0]],a[1]];t[a[0]]=s}else t[a[0]].push(a[1])}return t},getHost:function(e){return this.parse(e).host.replace("www.","")}}},{}],5:[function(e,t,r){"use strict";t.exports={escapeRegexp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},setDate:function(e,t){var r=e.getTimezoneOffset()/60,n=e.getHours(),i=t||0===t?t:-r;e.setHours(n+r+i);var a=e.getFullYear(),s=this.setLeadingZeroToInt(e.getMonth()+1,2),o=this.setLeadingZeroToInt(e.getDate(),2),c=this.setLeadingZeroToInt(e.getHours(),2),u=this.setLeadingZeroToInt(e.getMinutes(),2),p=this.setLeadingZeroToInt(e.getSeconds(),2);return a+"-"+s+"-"+o+" "+c+":"+u+":"+p},setLeadingZeroToInt:function(e,t){for(var r=e+"";r.length<t;)r="0"+r;return r},randomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e}}},{}],6:[function(e,t,r){"use strict";var n=e("./data"),i=e("./terms"),a=e("./helpers/cookies"),s=e("./helpers/uri"),o=e("./helpers/utils"),c=e("./params"),u=e("./migrations");t.exports=function(e){function t(){var e,t,s,o="undefined"!=typeof y.utm_source||"undefined"!=typeof y.utm_medium||"undefined"!=typeof y.utm_campaign||"undefined"!=typeof y.utm_content||"undefined"!=typeof y.utm_term||"undefined"!=typeof y.utm_ac_id||"undefined"!=typeof y.utm_id||"undefined"!=typeof y.utm_ad_group_id||"undefined"!=typeof y.utm_ad_id||"undefined"!=typeof y.utm_term_id||"undefined"!=typeof y.gclid||"undefined"!=typeof y.yclid||"undefined"!=typeof y[_.campaign_param]||"undefined"!=typeof y[_.term_param]||"undefined"!=typeof y[_.content_param],c=a.parse(n.containers),u=c[a.unsbjs(n.containers.current)],d=c[a.unsbjs(n.containers.current_extra)],m=new Date(d[n.aliases.extra.fire_date]).getTime(),l=864e5,g=(new Date).getTime(),v=g-m,x=f(i.traffic.organic),b=u[n.aliases.main.type]===i.traffic.utm,k=x&&(!b||v>45*l),w=!1;if(o)h(),e=p(i.traffic.utm),t=u,s=n.pack.unpack(e),w=r(t,s);else if(k)h(),e=p(i.traffic.organic),t=u,s=n.pack.unpack(e),w=r(t,s);else if(!a.get(n.containers.session)&&f(i.traffic.referral))h(),e=p(i.traffic.referral),w=!0;else{if(a.get(n.containers.first)||a.get(n.containers.current))return{data:a.get(n.containers.current),is_utm_changed:w};h(),e=p(i.traffic.typein),w=!0}return{data:e,is_utm_changed:w}}function r(e,t){return e[n.aliases.main.type]!==t[n.aliases.main.type]||e[n.aliases.main.source]!==t[n.aliases.main.source]||e[n.aliases.main.medium]!==t[n.aliases.main.medium]||e[n.aliases.main.campaign]!==t[n.aliases.main.campaign]||e[n.aliases.main.content]!==t[n.aliases.main.content]||e[n.aliases.main.term]!==t[n.aliases.main.term]}function p(e){switch(e){case i.traffic.utm:k=i.traffic.utm,w="undefined"!=typeof y.utm_source?y.utm_source:"undefined"!=typeof y.gclid?"google":"undefined"!=typeof y.yclid?"yandex":i.none,q="undefined"!=typeof y.utm_medium?y.utm_medium:"undefined"!=typeof y.gclid?"cpc":"undefined"!=typeof y.yclid?"cpc":i.none,I="undefined"!=typeof y.utm_campaign?y.utm_campaign:"undefined"!=typeof y[_.campaign_param]?y[_.campaign_param]:"undefined"!=typeof y.gclid?"google_cpc":"undefined"!=typeof y.yclid?"yandex_cpc":i.none,j="undefined"!=typeof y.utm_content?y.utm_content:"undefined"!=typeof y[_.content_param]?y[_.content_param]:i.none,D="undefined"!=typeof y.utm_term?y.utm_term:"undefined"!=typeof y[_.term_param]?y[_.term_param]:d()||i.none,R="undefined"!=typeof y.utm_ac_id?y.utm_ac_id:"undefined"!=typeof y.gclid?"google_cpc":i.none,H="undefined"!=typeof y.utm_id?y.utm_id:"undefined"!=typeof y.gclid?"google_cpc":i.none,T="undefined"!=typeof y.utm_ad_group_id?y.utm_ad_group_id:"undefined"!=typeof y.gclid?"google_cpc":i.none,E="undefined"!=typeof y.utm_ad_id?y.utm_ad_id:"undefined"!=typeof y.gclid?"google_cpc":i.none,O="undefined"!=typeof y.utm_term_id?y.utm_term_id:"undefined"!=typeof y.gclid?"google_cpc":i.none;break;case i.traffic.organic:k=i.traffic.organic,w=w||s.getHost(document.referrer),q=i.referer.organic,I=i.none,j=i.none,D=i.none,R=i.none,H=i.none,T=i.none,E=i.none,O=i.none;break;case i.traffic.referral:k=i.traffic.referral,w=w||s.getHost(document.referrer),q=q||i.referer.referral,I=i.none,j=s.parse(document.referrer).path,D=i.none,R=i.none,H=i.none,T=i.none,E=i.none,O=i.none;break;case i.traffic.typein:k=i.traffic.typein,w=_.typein_attributes.source,q=_.typein_attributes.medium,I=i.none,j=i.none,D=i.none,R=i.none,H=i.none,T=i.none,E=i.none,O=i.none;break;default:k=i.oops,w=i.oops,q=i.oops,I=i.oops,j=i.oops,D=i.oops,R=i.oops,H=i.oops,T=i.oops,E=i.oops,O=i.oops}var t={type:k,source:w,medium:q,campaign:I,content:j,term:D,account_id:R,campaign_id:H,ad_group_id:T,ad_id:E,term_id:O};return n.pack.main(t)}function d(){var e=document.referrer;if(y.utm_term)return y.utm_term;if(!(e&&s.parse(e).host&&s.parse(e).host.match(/^(?:.*\.)?yandex\..{2,9}$/i)))return!1;try{return s.getParam(s.parse(document.referrer).query).text}catch(t){return!1}}function f(e){var t=document.referrer;switch(e){case i.traffic.organic:return!!t&&m(t)&&l(t);case i.traffic.referral:return!!t&&m(t)&&g(t);default:return!1}}function m(e){if(_.domain){if(x)return s.getHost(e)!==s.getHost(v);var t=new RegExp("^(?:.*\\.)?"+o.escapeRegexp(v)+"$","i");return!s.getHost(e).match(t)}return s.getHost(e)!==s.getHost(document.location.href)}function l(e){var t="yandex",r="text",n="google",i=new RegExp("^(?:.*\\.)?"+o.escapeRegexp(t)+"\\..{2,9}$"),a=new RegExp(".*"+o.escapeRegexp(r)+"=.*"),c=new RegExp("^(?:www\\.)?"+o.escapeRegexp(n)+"\\..{2,9}$");if(s.parse(e).query&&s.parse(e).host.match(i)&&s.parse(e).query.match(a))return w=t,!0;if(s.parse(e).host.match(c))return w=n,!0;if(!s.parse(e).query)return!1;for(var u=0;u<_.organics.length;u++){if(s.parse(e).host.match(new RegExp("^(?:.*\\.)?"+o.escapeRegexp(_.organics[u].host)+"$","i"))&&s.parse(e).query.match(new RegExp(".*"+o.escapeRegexp(_.organics[u].param)+"=.*","i")))return w=_.organics[u].display||_.organics[u].host,!0;if(u+1===_.organics.length)return!1}}function g(e){if(!(_.referrals.length>0))return w=s.getHost(e),!0;for(var t=0;t<_.referrals.length;t++){if(s.parse(e).host.match(new RegExp("^(?:.*\\.)?"+o.escapeRegexp(_.referrals[t].host)+"$","i")))return w=_.referrals[t].display||_.referrals[t].host,q=_.referrals[t].medium||i.referer.referral,!0;if(t+1===_.referrals.length)return w=s.getHost(e),!0}}function h(){a.set(n.containers.current_extra,n.pack.extra(_.timezone_offset),b,v,x),a.get(n.containers.first_extra)||a.set(n.containers.first_extra,n.pack.extra(_.timezone_offset),b,v,x)}var _=c.fetch(e),y=s.getParam(),v=_.domain.host,x=_.domain.isolate,b=_.lifetime;u.go(b,v,x);var k,w,q,I,j,D,R,H,T,E,O;return function(){var e=t();a.set(n.containers.current,e.data,b,v,x),a.get(n.containers.first)||a.set(n.containers.first,a.get(n.containers.current),b,v,x);var r,i;a.get(n.containers.udata)?(r=parseInt(a.parse(n.containers.udata)[a.unsbjs(n.containers.udata)][n.aliases.udata.visits])||1,r=a.get(n.containers.session)?r:r+1,i=n.pack.user(r,_.user_ip)):(r=1,i=n.pack.user(r,_.user_ip)),a.set(n.containers.udata,i,b,v,x);var s,o;a.get(n.containers.session)?(s=parseInt(a.parse(n.containers.session)[a.unsbjs(n.containers.session)][n.aliases.session.pages_seen])||1,s+=1):s=1,a.get(n.containers.session)&&!e.is_utm_changed||(o=(new Date).getTime()),a.set(n.containers.session,n.pack.session(s,o),_.session_length,v,x),_.promocode&&!a.get(n.containers.promocode)&&a.set(n.containers.promocode,n.pack.promo(_.promocode),b,v,x)}(),a.parse(n.containers)}},{"./data":2,"./helpers/cookies":3,"./helpers/uri":4,"./helpers/utils":5,"./migrations":7,"./params":8,"./terms":9}],7:[function(e,t,r){"use strict";var n=e("./data"),i=e("./helpers/cookies");t.exports={go:function(e,t,r){var a,s=this.migrations,o={l:e,d:t,i:r};if(i.get(n.containers.first)||i.get(n.service.migrations)){if(!i.get(n.service.migrations))for(a=0;a<s.length;a++)s[a].go(s[a].id,o)}else{var c=[];for(a=0;a<s.length;a++)c.push(s[a].id);var u="";for(a=0;a<c.length;a++)u+=c[a]+"=1",a<c.length-1&&(u+=n.delimiter);i.set(n.service.migrations,u,o.l,o.d,o.i)}},migrations:[{id:"1418474375998",version:"1.0.0-beta",go:function(e,t){var r=e+"=1",a=e+"=0",s=function(e,t,r){return t||r?e:n.delimiter};try{var o=[];for(var c in n.containers)n.containers.hasOwnProperty(c)&&o.push(n.containers[c]);for(var u=0;u<o.length;u++)if(i.get(o[u])){var p=i.get(o[u]).replace(/(\|)?\|(\|)?/g,s);i.destroy(o[u],t.d,t.i),i.destroy(o[u],t.d,!t.i),i.set(o[u],p,t.l,t.d,t.i)}i.get(n.containers.session)&&i.set(n.containers.session,n.pack.session(0),t.l,t.d,t.i),i.set(n.service.migrations,r,t.l,t.d,t.i)}catch(d){i.set(n.service.migrations,a,t.l,t.d,t.i)}}}]}},{"./data":2,"./helpers/cookies":3}],8:[function(e,t,r){"use strict";var n=e("./terms"),i=e("./helpers/uri");t.exports={fetch:function(e){var t=e||{},r={};if(r.lifetime=this.validate.checkFloat(t.lifetime)||6,r.lifetime=parseInt(30*r.lifetime*24*60),r.session_length=this.validate.checkInt(t.session_length)||30,r.timezone_offset=this.validate.checkInt(t.timezone_offset),r.campaign_param=t.campaign_param||!1,r.term_param=t.term_param||!1,r.content_param=t.content_param||!1,r.user_ip=t.user_ip||n.none,t.promocode?(r.promocode={},r.promocode.min=parseInt(t.promocode.min)||1e5,r.promocode.max=parseInt(t.promocode.max)||999999):r.promocode=!1,t.typein_attributes&&t.typein_attributes.source&&t.typein_attributes.medium?(r.typein_attributes={},r.typein_attributes.source=t.typein_attributes.source,r.typein_attributes.medium=t.typein_attributes.medium):r.typein_attributes={source:"(direct)",medium:"(none)"},t.domain&&this.validate.isString(t.domain)?r.domain={host:t.domain,isolate:!1}:t.domain&&t.domain.host?r.domain=t.domain:r.domain={host:i.getHost(document.location.hostname),isolate:!1},r.referrals=[],t.referrals&&t.referrals.length>0)for(var a=0;a<t.referrals.length;a++)t.referrals[a].host&&r.referrals.push(t.referrals[a]);if(r.organics=[],t.organics&&t.organics.length>0)for(var s=0;s<t.organics.length;s++)t.organics[s].host&&t.organics[s].param&&r.organics.push(t.organics[s]);return r.organics.push({host:"bing.com",param:"q",display:"bing"}),r.organics.push({host:"yahoo.com",param:"p",display:"yahoo"}),r.organics.push({host:"about.com",param:"q",display:"about"}),r.organics.push({host:"aol.com",param:"q",display:"aol"}),r.organics.push({host:"ask.com",param:"q",display:"ask"}),r.organics.push({host:"globososo.com",param:"q",display:"globo"}),r.organics.push({host:"go.mail.ru",param:"q",display:"go.mail.ru"}),r.organics.push({host:"rambler.ru",param:"query",display:"rambler"}),r.organics.push({host:"tut.by",param:"query",display:"tut.by"}),r.referrals.push({host:"t.co",display:"twitter.com"}),r.referrals.push({host:"plus.url.google.com",display:"plus.google.com"}),r},validate:{checkFloat:function(e){return!(!e||!this.isNumeric(parseFloat(e)))&&parseFloat(e)},checkInt:function(e){return!(!e||!this.isNumeric(parseInt(e)))&&parseInt(e)},isNumeric:function(e){return!isNaN(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)}}}},{"./helpers/uri":4,"./terms":9}],9:[function(e,t,r){"use strict";t.exports={traffic:{utm:"utm",organic:"organic",referral:"referral",typein:"typein"},referer:{referral:"referral",organic:"organic",social:"social"},none:"(none)",oops:"(Houston, we have a problem)"}},{}]},{},[1])(1)});
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** @mate-academy/sourcebuster v1.2.
|
|
2
|
-
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sbjs=e()}}(function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var p=r[o]={exports:{}};t[o][0].call(p.exports,function(e){var r=t[o][1][e];return i(r?r:e)},p,p.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}({1:[function(e,t,r){"use strict";var n=e("./init"),i={init:function(e){this.get=n(e),e&&e.callback&&"function"==typeof e.callback&&e.callback(this.get)}};t.exports=i},{"./init":6}],2:[function(e,t,r){"use strict";var n=e("./terms"),i=e("./helpers/utils"),a={containers:{current:"sbjs_current",current_extra:"sbjs_current_add",first:"sbjs_first",first_extra:"sbjs_first_add",session:"sbjs_session",udata:"sbjs_udata",promocode:"sbjs_promo"},service:{migrations:"sbjs_migrations"},delimiter:"|||",aliases:{main:{type:"typ",source:"src",medium:"mdm",campaign:"cmp",content:"cnt",term:"trm",account_id:"ac_id",campaign_id:"cmp_id",ad_group_id:"adg_id",ad_id:"ad_id",term_id:"trm_id"},extra:{fire_date:"fd",entrance_point:"ep",referer:"rf"},session:{pages_seen:"pgs",current_page:"cpg"},udata:{visits:"vst",ip:"uip",agent:"uag"},promo:"code"},pack:{main:function(e){return a.aliases.main.type+"="+e.type+a.delimiter+a.aliases.main.source+"="+e.source+a.delimiter+a.aliases.main.medium+"="+e.medium+a.delimiter+a.aliases.main.campaign+"="+e.campaign+a.delimiter+a.aliases.main.content+"="+e.content+a.delimiter+a.aliases.main.term+"="+e.term+a.delimiter+a.aliases.main.account_id+"="+e.account_id+a.delimiter+a.aliases.main.campaign_id+"="+e.campaign_id+a.delimiter+a.aliases.main.ad_group_id+"="+e.ad_group_id+a.delimiter+a.aliases.main.ad_id+"="+e.ad_id+a.delimiter+a.aliases.main.term_id+"="+e.term_id},extra:function(e){return a.aliases.extra.fire_date+"="+i.setDate(new Date,e)+a.delimiter+a.aliases.extra.entrance_point+"="+document.location.href+a.delimiter+a.aliases.extra.referer+"="+(document.referrer||n.none)},user:function(e,t){return a.aliases.udata.visits+"="+e+a.delimiter+a.aliases.udata.ip+"="+t+a.delimiter+a.aliases.udata.agent+"="+navigator.userAgent},session:function(e){return a.aliases.session.pages_seen+"="+e+a.delimiter+a.aliases.session.current_page+"="+document.location.href},promo:function(e){return a.aliases.promo+"="+i.setLeadingZeroToInt(i.randomInt(e.min,e.max),e.max.toString().length)}}};t.exports=a},{"./helpers/utils":5,"./terms":9}],3:[function(e,t,r){"use strict";var n=e("../data").delimiter;t.exports={encodeData:function(e){return encodeURIComponent(e).replace(/\!/g,"%21").replace(/\~/g,"%7E").replace(/\*/g,"%2A").replace(/\'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")},decodeData:function(e){try{return decodeURIComponent(e).replace(/\%21/g,"!").replace(/\%7E/g,"~").replace(/\%2A/g,"*").replace(/\%27/g,"'").replace(/\%28/g,"(").replace(/\%29/g,")")}catch(t){try{return unescape(e)}catch(r){return""}}},set:function(e,t,r,n,i){var a,o;if(r){var s=new Date;s.setTime(s.getTime()+60*r*1e3),a="; expires="+s.toGMTString()}else a="";o=n&&!i?";domain=."+n:"",document.cookie=this.encodeData(e)+"="+this.encodeData(t)+a+o+"; path=/"},get:function(e){for(var t=this.encodeData(e)+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var i=r[n];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return this.decodeData(i.substring(t.length,i.length))}return null},destroy:function(e,t,r){this.set(e,"",-1,t,r)},parse:function(e){var t=[],r={};if("string"==typeof e)t.push(e);else for(var i in e)e.hasOwnProperty(i)&&t.push(e[i]);for(var a=0;a<t.length;a++){var o;r[this.unsbjs(t[a])]={},o=this.get(t[a])?this.get(t[a]).split(n):[];for(var s=0;s<o.length;s++){var c=o[s].split("="),u=c.splice(0,1);u.push(c.join("=")),r[this.unsbjs(t[a])][u[0]]=this.decodeData(u[1])}}return r},unsbjs:function(e){return e.replace("sbjs_","")}}},{"../data":2}],4:[function(e,t,r){"use strict";t.exports={parse:function(e){for(var t=this.parseOptions,r=t.parser[t.strictMode?"strict":"loose"].exec(e),n={},i=14;i--;)n[t.key[i]]=r[i]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,function(e,r,i){r&&(n[t.q.name][r]=i)}),n},parseOptions:{strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},getParam:function(e){for(var t={},r=e?e:window.location.search.substring(1),n=r.split("&"),i=0;i<n.length;i++){var a=n[i].split("=");if("undefined"==typeof t[a[0]])t[a[0]]=a[1];else if("string"==typeof t[a[0]]){var o=[t[a[0]],a[1]];t[a[0]]=o}else t[a[0]].push(a[1])}return t},getHost:function(e){return this.parse(e).host.replace("www.","")}}},{}],5:[function(e,t,r){"use strict";t.exports={escapeRegexp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},setDate:function(e,t){var r=e.getTimezoneOffset()/60,n=e.getHours(),i=t||0===t?t:-r;e.setHours(n+r+i);var a=e.getFullYear(),o=this.setLeadingZeroToInt(e.getMonth()+1,2),s=this.setLeadingZeroToInt(e.getDate(),2),c=this.setLeadingZeroToInt(e.getHours(),2),u=this.setLeadingZeroToInt(e.getMinutes(),2),p=this.setLeadingZeroToInt(e.getSeconds(),2);return a+"-"+o+"-"+s+" "+c+":"+u+":"+p},setLeadingZeroToInt:function(e,t){for(var r=e+"";r.length<t;)r="0"+r;return r},randomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e}}},{}],6:[function(e,t,r){"use strict";var n=e("./data"),i=e("./terms"),a=e("./helpers/cookies"),o=e("./helpers/uri"),s=e("./helpers/utils"),c=e("./params"),u=e("./migrations");t.exports=function(e){function t(){var e,t="undefined"!=typeof _.utm_source||"undefined"!=typeof _.utm_medium||"undefined"!=typeof _.utm_campaign||"undefined"!=typeof _.utm_content||"undefined"!=typeof _.utm_term||"undefined"!=typeof _.utm_ac_id||"undefined"!=typeof _.utm_id||"undefined"!=typeof _.utm_ad_group_id||"undefined"!=typeof _.utm_ad_id||"undefined"!=typeof _.utm_term_id||"undefined"!=typeof _.gclid||"undefined"!=typeof _.yclid||"undefined"!=typeof _[h.campaign_param]||"undefined"!=typeof _[h.term_param]||"undefined"!=typeof _[h.content_param],o=a.parse(n.containers),s=o[a.unsbjs(n.containers.current)],c=o[a.unsbjs(n.containers.current_extra)],u=new Date(c[n.aliases.extra.fire_date]).getTime(),p=864e5,f=(new Date).getTime(),m=f-u,l=d(i.traffic.organic),y=s[n.aliases.main.type]===i.traffic.utm,v=l&&(!y||m>45*p);if(t)g(),e=r(i.traffic.utm);else if(v)g(),e=r(i.traffic.organic);else if(!a.get(n.containers.session)&&d(i.traffic.referral))g(),e=r(i.traffic.referral);else{if(a.get(n.containers.first)||a.get(n.containers.current))return a.get(n.containers.current);g(),e=r(i.traffic.typein)}return e}function r(e){switch(e){case i.traffic.utm:b=i.traffic.utm,k="undefined"!=typeof _.utm_source?_.utm_source:"undefined"!=typeof _.gclid?"google":"undefined"!=typeof _.yclid?"yandex":i.none,w="undefined"!=typeof _.utm_medium?_.utm_medium:"undefined"!=typeof _.gclid?"cpc":"undefined"!=typeof _.yclid?"cpc":i.none,q="undefined"!=typeof _.utm_campaign?_.utm_campaign:"undefined"!=typeof _[h.campaign_param]?_[h.campaign_param]:"undefined"!=typeof _.gclid?"google_cpc":"undefined"!=typeof _.yclid?"yandex_cpc":i.none,I="undefined"!=typeof _.utm_content?_.utm_content:"undefined"!=typeof _[h.content_param]?_[h.content_param]:i.none,j="undefined"!=typeof _.utm_term?_.utm_term:"undefined"!=typeof _[h.term_param]?_[h.term_param]:p()||i.none,R="undefined"!=typeof _.utm_ac_id?_.utm_ac_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,D="undefined"!=typeof _.utm_id?_.utm_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,H="undefined"!=typeof _.utm_ad_group_id?_.utm_ad_group_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,T="undefined"!=typeof _.utm_ad_id?_.utm_ad_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,E="undefined"!=typeof _.utm_term_id?_.utm_term_id:"undefined"!=typeof _.gclid?"google_cpc":i.none;break;case i.traffic.organic:b=i.traffic.organic,k=k||o.getHost(document.referrer),w=i.referer.organic,q=i.none,I=i.none,j=i.none,R=i.none,D=i.none,H=i.none,T=i.none,E=i.none;break;case i.traffic.referral:b=i.traffic.referral,k=k||o.getHost(document.referrer),w=w||i.referer.referral,q=i.none,I=o.parse(document.referrer).path,j=i.none,R=i.none,D=i.none,H=i.none,T=i.none,E=i.none;break;case i.traffic.typein:b=i.traffic.typein,k=h.typein_attributes.source,w=h.typein_attributes.medium,q=i.none,I=i.none,j=i.none,R=i.none,D=i.none,H=i.none,T=i.none,E=i.none;break;default:b=i.oops,k=i.oops,w=i.oops,q=i.oops,I=i.oops,j=i.oops,R=i.oops,D=i.oops,H=i.oops,T=i.oops,E=i.oops}var t={type:b,source:k,medium:w,campaign:q,content:I,term:j,account_id:R,campaign_id:D,ad_group_id:H,ad_id:T,term_id:E};return n.pack.main(t)}function p(){var e=document.referrer;if(_.utm_term)return _.utm_term;if(!(e&&o.parse(e).host&&o.parse(e).host.match(/^(?:.*\.)?yandex\..{2,9}$/i)))return!1;try{return o.getParam(o.parse(document.referrer).query).text}catch(t){return!1}}function d(e){var t=document.referrer;switch(e){case i.traffic.organic:return!!t&&f(t)&&m(t);case i.traffic.referral:return!!t&&f(t)&&l(t);default:return!1}}function f(e){if(h.domain){if(v)return o.getHost(e)!==o.getHost(y);var t=new RegExp("^(?:.*\\.)?"+s.escapeRegexp(y)+"$","i");return!o.getHost(e).match(t)}return o.getHost(e)!==o.getHost(document.location.href)}function m(e){var t="yandex",r="text",n="google",i=new RegExp("^(?:.*\\.)?"+s.escapeRegexp(t)+"\\..{2,9}$"),a=new RegExp(".*"+s.escapeRegexp(r)+"=.*"),c=new RegExp("^(?:www\\.)?"+s.escapeRegexp(n)+"\\..{2,9}$");if(o.parse(e).query&&o.parse(e).host.match(i)&&o.parse(e).query.match(a))return k=t,!0;if(o.parse(e).host.match(c))return k=n,!0;if(!o.parse(e).query)return!1;for(var u=0;u<h.organics.length;u++){if(o.parse(e).host.match(new RegExp("^(?:.*\\.)?"+s.escapeRegexp(h.organics[u].host)+"$","i"))&&o.parse(e).query.match(new RegExp(".*"+s.escapeRegexp(h.organics[u].param)+"=.*","i")))return k=h.organics[u].display||h.organics[u].host,!0;if(u+1===h.organics.length)return!1}}function l(e){if(!(h.referrals.length>0))return k=o.getHost(e),!0;for(var t=0;t<h.referrals.length;t++){if(o.parse(e).host.match(new RegExp("^(?:.*\\.)?"+s.escapeRegexp(h.referrals[t].host)+"$","i")))return k=h.referrals[t].display||h.referrals[t].host,w=h.referrals[t].medium||i.referer.referral,!0;if(t+1===h.referrals.length)return k=o.getHost(e),!0}}function g(){a.set(n.containers.current_extra,n.pack.extra(h.timezone_offset),x,y,v),a.get(n.containers.first_extra)||a.set(n.containers.first_extra,n.pack.extra(h.timezone_offset),x,y,v)}var h=c.fetch(e),_=o.getParam(),y=h.domain.host,v=h.domain.isolate,x=h.lifetime;u.go(x,y,v);var b,k,w,q,I,j,R,D,H,T,E;return function(){a.set(n.containers.current,t(),x,y,v),a.get(n.containers.first)||a.set(n.containers.first,a.get(n.containers.current),x,y,v);var e,r;a.get(n.containers.udata)?(e=parseInt(a.parse(n.containers.udata)[a.unsbjs(n.containers.udata)][n.aliases.udata.visits])||1,e=a.get(n.containers.session)?e:e+1,r=n.pack.user(e,h.user_ip)):(e=1,r=n.pack.user(e,h.user_ip)),a.set(n.containers.udata,r,x,y,v);var i;a.get(n.containers.session)?(i=parseInt(a.parse(n.containers.session)[a.unsbjs(n.containers.session)][n.aliases.session.pages_seen])||1,i+=1):i=1,a.set(n.containers.session,n.pack.session(i),h.session_length,y,v),h.promocode&&!a.get(n.containers.promocode)&&a.set(n.containers.promocode,n.pack.promo(h.promocode),x,y,v)}(),a.parse(n.containers)}},{"./data":2,"./helpers/cookies":3,"./helpers/uri":4,"./helpers/utils":5,"./migrations":7,"./params":8,"./terms":9}],7:[function(e,t,r){"use strict";var n=e("./data"),i=e("./helpers/cookies");t.exports={go:function(e,t,r){var a,o=this.migrations,s={l:e,d:t,i:r};if(i.get(n.containers.first)||i.get(n.service.migrations)){if(!i.get(n.service.migrations))for(a=0;a<o.length;a++)o[a].go(o[a].id,s)}else{var c=[];for(a=0;a<o.length;a++)c.push(o[a].id);var u="";for(a=0;a<c.length;a++)u+=c[a]+"=1",a<c.length-1&&(u+=n.delimiter);i.set(n.service.migrations,u,s.l,s.d,s.i)}},migrations:[{id:"1418474375998",version:"1.0.0-beta",go:function(e,t){var r=e+"=1",a=e+"=0",o=function(e,t,r){return t||r?e:n.delimiter};try{var s=[];for(var c in n.containers)n.containers.hasOwnProperty(c)&&s.push(n.containers[c]);for(var u=0;u<s.length;u++)if(i.get(s[u])){var p=i.get(s[u]).replace(/(\|)?\|(\|)?/g,o);i.destroy(s[u],t.d,t.i),i.destroy(s[u],t.d,!t.i),i.set(s[u],p,t.l,t.d,t.i)}i.get(n.containers.session)&&i.set(n.containers.session,n.pack.session(0),t.l,t.d,t.i),i.set(n.service.migrations,r,t.l,t.d,t.i)}catch(d){i.set(n.service.migrations,a,t.l,t.d,t.i)}}}]}},{"./data":2,"./helpers/cookies":3}],8:[function(e,t,r){"use strict";var n=e("./terms"),i=e("./helpers/uri");t.exports={fetch:function(e){var t=e||{},r={};if(r.lifetime=this.validate.checkFloat(t.lifetime)||6,r.lifetime=parseInt(30*r.lifetime*24*60),r.session_length=this.validate.checkInt(t.session_length)||30,r.timezone_offset=this.validate.checkInt(t.timezone_offset),r.campaign_param=t.campaign_param||!1,r.term_param=t.term_param||!1,r.content_param=t.content_param||!1,r.user_ip=t.user_ip||n.none,t.promocode?(r.promocode={},r.promocode.min=parseInt(t.promocode.min)||1e5,r.promocode.max=parseInt(t.promocode.max)||999999):r.promocode=!1,t.typein_attributes&&t.typein_attributes.source&&t.typein_attributes.medium?(r.typein_attributes={},r.typein_attributes.source=t.typein_attributes.source,r.typein_attributes.medium=t.typein_attributes.medium):r.typein_attributes={source:"(direct)",medium:"(none)"},t.domain&&this.validate.isString(t.domain)?r.domain={host:t.domain,isolate:!1}:t.domain&&t.domain.host?r.domain=t.domain:r.domain={host:i.getHost(document.location.hostname),isolate:!1},r.referrals=[],t.referrals&&t.referrals.length>0)for(var a=0;a<t.referrals.length;a++)t.referrals[a].host&&r.referrals.push(t.referrals[a]);if(r.organics=[],t.organics&&t.organics.length>0)for(var o=0;o<t.organics.length;o++)t.organics[o].host&&t.organics[o].param&&r.organics.push(t.organics[o]);return r.organics.push({host:"bing.com",param:"q",display:"bing"}),r.organics.push({host:"yahoo.com",param:"p",display:"yahoo"}),r.organics.push({host:"about.com",param:"q",display:"about"}),r.organics.push({host:"aol.com",param:"q",display:"aol"}),r.organics.push({host:"ask.com",param:"q",display:"ask"}),r.organics.push({host:"globososo.com",param:"q",display:"globo"}),r.organics.push({host:"go.mail.ru",param:"q",display:"go.mail.ru"}),r.organics.push({host:"rambler.ru",param:"query",display:"rambler"}),r.organics.push({host:"tut.by",param:"query",display:"tut.by"}),r.referrals.push({host:"t.co",display:"twitter.com"}),r.referrals.push({host:"plus.url.google.com",display:"plus.google.com"}),r},validate:{checkFloat:function(e){return!(!e||!this.isNumeric(parseFloat(e)))&&parseFloat(e)},checkInt:function(e){return!(!e||!this.isNumeric(parseInt(e)))&&parseInt(e)},isNumeric:function(e){return!isNaN(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)}}}},{"./helpers/uri":4,"./terms":9}],9:[function(e,t,r){"use strict";t.exports={traffic:{utm:"utm",organic:"organic",referral:"referral",typein:"typein"},referer:{referral:"referral",organic:"organic",social:"social"},none:"(none)",oops:"(Houston, we have a problem)"}},{}]},{},[1])(1)});
|
|
1
|
+
/** @mate-academy/sourcebuster v1.2.5 **/
|
|
2
|
+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sbjs=e()}}(function(){return function e(t,r,n){function i(s,o){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!o&&c)return c(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var p=r[s]={exports:{}};t[s][0].call(p.exports,function(e){var r=t[s][1][e];return i(r?r:e)},p,p.exports,e,t,r,n)}return r[s].exports}for(var a="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,r){"use strict";var n=e("./init"),i={init:function(e){this.get=n(e),e&&e.callback&&"function"==typeof e.callback&&e.callback(this.get)}};t.exports=i},{"./init":6}],2:[function(e,t,r){"use strict";var n=e("./terms"),i=e("./helpers/utils"),a={containers:{current:"sbjs_current",current_extra:"sbjs_current_add",first:"sbjs_first",first_extra:"sbjs_first_add",session:"sbjs_session",udata:"sbjs_udata",promocode:"sbjs_promo"},service:{migrations:"sbjs_migrations"},delimiter:"|||",aliases:{main:{type:"typ",source:"src",medium:"mdm",campaign:"cmp",content:"cnt",term:"trm",account_id:"ac_id",campaign_id:"cmp_id",ad_group_id:"adg_id",ad_id:"ad_id",term_id:"trm_id"},extra:{fire_date:"fd",entrance_point:"ep",referer:"rf"},session:{pages_seen:"pgs",current_page:"cpg",session_id:"sid"},udata:{visits:"vst",ip:"uip",agent:"uag"},promo:"code"},pack:{main:function(e){return a.aliases.main.type+"="+e.type+a.delimiter+a.aliases.main.source+"="+e.source+a.delimiter+a.aliases.main.medium+"="+e.medium+a.delimiter+a.aliases.main.campaign+"="+e.campaign+a.delimiter+a.aliases.main.content+"="+e.content+a.delimiter+a.aliases.main.term+"="+e.term+a.delimiter+a.aliases.main.account_id+"="+e.account_id+a.delimiter+a.aliases.main.campaign_id+"="+e.campaign_id+a.delimiter+a.aliases.main.ad_group_id+"="+e.ad_group_id+a.delimiter+a.aliases.main.ad_id+"="+e.ad_id+a.delimiter+a.aliases.main.term_id+"="+e.term_id},unpack:function(e){var t={},r=e.split("|||");return r.forEach(function(e){var r=e.split("="),n=r[0],i=r[1];t[n]=i}),t},extra:function(e){return a.aliases.extra.fire_date+"="+i.setDate(new Date,e)+a.delimiter+a.aliases.extra.entrance_point+"="+document.location.href+a.delimiter+a.aliases.extra.referer+"="+(document.referrer||n.none)},user:function(e,t){return a.aliases.udata.visits+"="+e+a.delimiter+a.aliases.udata.ip+"="+t+a.delimiter+a.aliases.udata.agent+"="+navigator.userAgent},session:function(e,t){var r=a.aliases.session.pages_seen+"="+e+a.delimiter+a.aliases.session.current_page+"="+document.location.href;return t?r+a.delimiter+a.aliases.session.session_id+"="+t:r},promo:function(e){return a.aliases.promo+"="+i.setLeadingZeroToInt(i.randomInt(e.min,e.max),e.max.toString().length)}}};t.exports=a},{"./helpers/utils":5,"./terms":9}],3:[function(e,t,r){"use strict";var n=e("../data").delimiter;t.exports={encodeData:function(e){return encodeURIComponent(e).replace(/\!/g,"%21").replace(/\~/g,"%7E").replace(/\*/g,"%2A").replace(/\'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")},decodeData:function(e){try{return decodeURIComponent(e).replace(/\%21/g,"!").replace(/\%7E/g,"~").replace(/\%2A/g,"*").replace(/\%27/g,"'").replace(/\%28/g,"(").replace(/\%29/g,")")}catch(t){try{return unescape(e)}catch(r){return""}}},set:function(e,t,r,n,i){var a,s;if(r){var o=new Date;o.setTime(o.getTime()+60*r*1e3),a="; expires="+o.toGMTString()}else a="";s=n&&!i?";domain=."+n:"",document.cookie=this.encodeData(e)+"="+this.encodeData(t)+a+s+"; path=/"},get:function(e){for(var t=this.encodeData(e)+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var i=r[n];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return this.decodeData(i.substring(t.length,i.length))}return null},destroy:function(e,t,r){this.set(e,"",-1,t,r)},parse:function(e){var t=[],r={};if("string"==typeof e)t.push(e);else for(var i in e)e.hasOwnProperty(i)&&t.push(e[i]);for(var a=0;a<t.length;a++){var s;r[this.unsbjs(t[a])]={},s=this.get(t[a])?this.get(t[a]).split(n):[];for(var o=0;o<s.length;o++){var c=s[o].split("="),u=c.splice(0,1);u.push(c.join("=")),r[this.unsbjs(t[a])][u[0]]=this.decodeData(u[1])}}return r},unsbjs:function(e){return e.replace("sbjs_","")}}},{"../data":2}],4:[function(e,t,r){"use strict";t.exports={parse:function(e){for(var t=this.parseOptions,r=t.parser[t.strictMode?"strict":"loose"].exec(e),n={},i=14;i--;)n[t.key[i]]=r[i]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,function(e,r,i){r&&(n[t.q.name][r]=i)}),n},parseOptions:{strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},getParam:function(e){for(var t={},r=e?e:window.location.search.substring(1),n=r.split("&"),i=0;i<n.length;i++){var a=n[i].split("=");if("undefined"==typeof t[a[0]])t[a[0]]=a[1];else if("string"==typeof t[a[0]]){var s=[t[a[0]],a[1]];t[a[0]]=s}else t[a[0]].push(a[1])}return t},getHost:function(e){return this.parse(e).host.replace("www.","")}}},{}],5:[function(e,t,r){"use strict";t.exports={escapeRegexp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},setDate:function(e,t){var r=e.getTimezoneOffset()/60,n=e.getHours(),i=t||0===t?t:-r;e.setHours(n+r+i);var a=e.getFullYear(),s=this.setLeadingZeroToInt(e.getMonth()+1,2),o=this.setLeadingZeroToInt(e.getDate(),2),c=this.setLeadingZeroToInt(e.getHours(),2),u=this.setLeadingZeroToInt(e.getMinutes(),2),p=this.setLeadingZeroToInt(e.getSeconds(),2);return a+"-"+s+"-"+o+" "+c+":"+u+":"+p},setLeadingZeroToInt:function(e,t){for(var r=e+"";r.length<t;)r="0"+r;return r},randomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e}}},{}],6:[function(e,t,r){"use strict";var n=e("./data"),i=e("./terms"),a=e("./helpers/cookies"),s=e("./helpers/uri"),o=e("./helpers/utils"),c=e("./params"),u=e("./migrations");t.exports=function(e){function t(){var e,t,s,o="undefined"!=typeof y.utm_source||"undefined"!=typeof y.utm_medium||"undefined"!=typeof y.utm_campaign||"undefined"!=typeof y.utm_content||"undefined"!=typeof y.utm_term||"undefined"!=typeof y.utm_ac_id||"undefined"!=typeof y.utm_id||"undefined"!=typeof y.utm_ad_group_id||"undefined"!=typeof y.utm_ad_id||"undefined"!=typeof y.utm_term_id||"undefined"!=typeof y.gclid||"undefined"!=typeof y.yclid||"undefined"!=typeof y[_.campaign_param]||"undefined"!=typeof y[_.term_param]||"undefined"!=typeof y[_.content_param],c=a.parse(n.containers),u=c[a.unsbjs(n.containers.current)],d=c[a.unsbjs(n.containers.current_extra)],m=new Date(d[n.aliases.extra.fire_date]).getTime(),l=864e5,g=(new Date).getTime(),v=g-m,x=f(i.traffic.organic),b=u[n.aliases.main.type]===i.traffic.utm,k=x&&(!b||v>45*l),w=!1;if(o)h(),e=p(i.traffic.utm),t=u,s=n.pack.unpack(e),w=r(t,s);else if(k)h(),e=p(i.traffic.organic),t=u,s=n.pack.unpack(e),w=r(t,s);else if(!a.get(n.containers.session)&&f(i.traffic.referral))h(),e=p(i.traffic.referral),w=!0;else{if(a.get(n.containers.first)||a.get(n.containers.current))return{data:a.get(n.containers.current),is_utm_changed:w};h(),e=p(i.traffic.typein),w=!0}return{data:e,is_utm_changed:w}}function r(e,t){return e[n.aliases.main.type]!==t[n.aliases.main.type]||e[n.aliases.main.source]!==t[n.aliases.main.source]||e[n.aliases.main.medium]!==t[n.aliases.main.medium]||e[n.aliases.main.campaign]!==t[n.aliases.main.campaign]||e[n.aliases.main.content]!==t[n.aliases.main.content]||e[n.aliases.main.term]!==t[n.aliases.main.term]}function p(e){switch(e){case i.traffic.utm:k=i.traffic.utm,w="undefined"!=typeof y.utm_source?y.utm_source:"undefined"!=typeof y.gclid?"google":"undefined"!=typeof y.yclid?"yandex":i.none,q="undefined"!=typeof y.utm_medium?y.utm_medium:"undefined"!=typeof y.gclid?"cpc":"undefined"!=typeof y.yclid?"cpc":i.none,I="undefined"!=typeof y.utm_campaign?y.utm_campaign:"undefined"!=typeof y[_.campaign_param]?y[_.campaign_param]:"undefined"!=typeof y.gclid?"google_cpc":"undefined"!=typeof y.yclid?"yandex_cpc":i.none,j="undefined"!=typeof y.utm_content?y.utm_content:"undefined"!=typeof y[_.content_param]?y[_.content_param]:i.none,D="undefined"!=typeof y.utm_term?y.utm_term:"undefined"!=typeof y[_.term_param]?y[_.term_param]:d()||i.none,R="undefined"!=typeof y.utm_ac_id?y.utm_ac_id:"undefined"!=typeof y.gclid?"google_cpc":i.none,H="undefined"!=typeof y.utm_id?y.utm_id:"undefined"!=typeof y.gclid?"google_cpc":i.none,T="undefined"!=typeof y.utm_ad_group_id?y.utm_ad_group_id:"undefined"!=typeof y.gclid?"google_cpc":i.none,E="undefined"!=typeof y.utm_ad_id?y.utm_ad_id:"undefined"!=typeof y.gclid?"google_cpc":i.none,O="undefined"!=typeof y.utm_term_id?y.utm_term_id:"undefined"!=typeof y.gclid?"google_cpc":i.none;break;case i.traffic.organic:k=i.traffic.organic,w=w||s.getHost(document.referrer),q=i.referer.organic,I=i.none,j=i.none,D=i.none,R=i.none,H=i.none,T=i.none,E=i.none,O=i.none;break;case i.traffic.referral:k=i.traffic.referral,w=w||s.getHost(document.referrer),q=q||i.referer.referral,I=i.none,j=s.parse(document.referrer).path,D=i.none,R=i.none,H=i.none,T=i.none,E=i.none,O=i.none;break;case i.traffic.typein:k=i.traffic.typein,w=_.typein_attributes.source,q=_.typein_attributes.medium,I=i.none,j=i.none,D=i.none,R=i.none,H=i.none,T=i.none,E=i.none,O=i.none;break;default:k=i.oops,w=i.oops,q=i.oops,I=i.oops,j=i.oops,D=i.oops,R=i.oops,H=i.oops,T=i.oops,E=i.oops,O=i.oops}var t={type:k,source:w,medium:q,campaign:I,content:j,term:D,account_id:R,campaign_id:H,ad_group_id:T,ad_id:E,term_id:O};return n.pack.main(t)}function d(){var e=document.referrer;if(y.utm_term)return y.utm_term;if(!(e&&s.parse(e).host&&s.parse(e).host.match(/^(?:.*\.)?yandex\..{2,9}$/i)))return!1;try{return s.getParam(s.parse(document.referrer).query).text}catch(t){return!1}}function f(e){var t=document.referrer;switch(e){case i.traffic.organic:return!!t&&m(t)&&l(t);case i.traffic.referral:return!!t&&m(t)&&g(t);default:return!1}}function m(e){if(_.domain){if(x)return s.getHost(e)!==s.getHost(v);var t=new RegExp("^(?:.*\\.)?"+o.escapeRegexp(v)+"$","i");return!s.getHost(e).match(t)}return s.getHost(e)!==s.getHost(document.location.href)}function l(e){var t="yandex",r="text",n="google",i=new RegExp("^(?:.*\\.)?"+o.escapeRegexp(t)+"\\..{2,9}$"),a=new RegExp(".*"+o.escapeRegexp(r)+"=.*"),c=new RegExp("^(?:www\\.)?"+o.escapeRegexp(n)+"\\..{2,9}$");if(s.parse(e).query&&s.parse(e).host.match(i)&&s.parse(e).query.match(a))return w=t,!0;if(s.parse(e).host.match(c))return w=n,!0;if(!s.parse(e).query)return!1;for(var u=0;u<_.organics.length;u++){if(s.parse(e).host.match(new RegExp("^(?:.*\\.)?"+o.escapeRegexp(_.organics[u].host)+"$","i"))&&s.parse(e).query.match(new RegExp(".*"+o.escapeRegexp(_.organics[u].param)+"=.*","i")))return w=_.organics[u].display||_.organics[u].host,!0;if(u+1===_.organics.length)return!1}}function g(e){if(!(_.referrals.length>0))return w=s.getHost(e),!0;for(var t=0;t<_.referrals.length;t++){if(s.parse(e).host.match(new RegExp("^(?:.*\\.)?"+o.escapeRegexp(_.referrals[t].host)+"$","i")))return w=_.referrals[t].display||_.referrals[t].host,q=_.referrals[t].medium||i.referer.referral,!0;if(t+1===_.referrals.length)return w=s.getHost(e),!0}}function h(){a.set(n.containers.current_extra,n.pack.extra(_.timezone_offset),b,v,x),a.get(n.containers.first_extra)||a.set(n.containers.first_extra,n.pack.extra(_.timezone_offset),b,v,x)}var _=c.fetch(e),y=s.getParam(),v=_.domain.host,x=_.domain.isolate,b=_.lifetime;u.go(b,v,x);var k,w,q,I,j,D,R,H,T,E,O;return function(){var e=t();a.set(n.containers.current,e.data,b,v,x),a.get(n.containers.first)||a.set(n.containers.first,a.get(n.containers.current),b,v,x);var r,i;a.get(n.containers.udata)?(r=parseInt(a.parse(n.containers.udata)[a.unsbjs(n.containers.udata)][n.aliases.udata.visits])||1,r=a.get(n.containers.session)?r:r+1,i=n.pack.user(r,_.user_ip)):(r=1,i=n.pack.user(r,_.user_ip)),a.set(n.containers.udata,i,b,v,x);var s,o;a.get(n.containers.session)?(s=parseInt(a.parse(n.containers.session)[a.unsbjs(n.containers.session)][n.aliases.session.pages_seen])||1,s+=1):s=1,a.get(n.containers.session)&&!e.is_utm_changed||(o=(new Date).getTime()),a.set(n.containers.session,n.pack.session(s,o),_.session_length,v,x),_.promocode&&!a.get(n.containers.promocode)&&a.set(n.containers.promocode,n.pack.promo(_.promocode),b,v,x)}(),a.parse(n.containers)}},{"./data":2,"./helpers/cookies":3,"./helpers/uri":4,"./helpers/utils":5,"./migrations":7,"./params":8,"./terms":9}],7:[function(e,t,r){"use strict";var n=e("./data"),i=e("./helpers/cookies");t.exports={go:function(e,t,r){var a,s=this.migrations,o={l:e,d:t,i:r};if(i.get(n.containers.first)||i.get(n.service.migrations)){if(!i.get(n.service.migrations))for(a=0;a<s.length;a++)s[a].go(s[a].id,o)}else{var c=[];for(a=0;a<s.length;a++)c.push(s[a].id);var u="";for(a=0;a<c.length;a++)u+=c[a]+"=1",a<c.length-1&&(u+=n.delimiter);i.set(n.service.migrations,u,o.l,o.d,o.i)}},migrations:[{id:"1418474375998",version:"1.0.0-beta",go:function(e,t){var r=e+"=1",a=e+"=0",s=function(e,t,r){return t||r?e:n.delimiter};try{var o=[];for(var c in n.containers)n.containers.hasOwnProperty(c)&&o.push(n.containers[c]);for(var u=0;u<o.length;u++)if(i.get(o[u])){var p=i.get(o[u]).replace(/(\|)?\|(\|)?/g,s);i.destroy(o[u],t.d,t.i),i.destroy(o[u],t.d,!t.i),i.set(o[u],p,t.l,t.d,t.i)}i.get(n.containers.session)&&i.set(n.containers.session,n.pack.session(0),t.l,t.d,t.i),i.set(n.service.migrations,r,t.l,t.d,t.i)}catch(d){i.set(n.service.migrations,a,t.l,t.d,t.i)}}}]}},{"./data":2,"./helpers/cookies":3}],8:[function(e,t,r){"use strict";var n=e("./terms"),i=e("./helpers/uri");t.exports={fetch:function(e){var t=e||{},r={};if(r.lifetime=this.validate.checkFloat(t.lifetime)||6,r.lifetime=parseInt(30*r.lifetime*24*60),r.session_length=this.validate.checkInt(t.session_length)||30,r.timezone_offset=this.validate.checkInt(t.timezone_offset),r.campaign_param=t.campaign_param||!1,r.term_param=t.term_param||!1,r.content_param=t.content_param||!1,r.user_ip=t.user_ip||n.none,t.promocode?(r.promocode={},r.promocode.min=parseInt(t.promocode.min)||1e5,r.promocode.max=parseInt(t.promocode.max)||999999):r.promocode=!1,t.typein_attributes&&t.typein_attributes.source&&t.typein_attributes.medium?(r.typein_attributes={},r.typein_attributes.source=t.typein_attributes.source,r.typein_attributes.medium=t.typein_attributes.medium):r.typein_attributes={source:"(direct)",medium:"(none)"},t.domain&&this.validate.isString(t.domain)?r.domain={host:t.domain,isolate:!1}:t.domain&&t.domain.host?r.domain=t.domain:r.domain={host:i.getHost(document.location.hostname),isolate:!1},r.referrals=[],t.referrals&&t.referrals.length>0)for(var a=0;a<t.referrals.length;a++)t.referrals[a].host&&r.referrals.push(t.referrals[a]);if(r.organics=[],t.organics&&t.organics.length>0)for(var s=0;s<t.organics.length;s++)t.organics[s].host&&t.organics[s].param&&r.organics.push(t.organics[s]);return r.organics.push({host:"bing.com",param:"q",display:"bing"}),r.organics.push({host:"yahoo.com",param:"p",display:"yahoo"}),r.organics.push({host:"about.com",param:"q",display:"about"}),r.organics.push({host:"aol.com",param:"q",display:"aol"}),r.organics.push({host:"ask.com",param:"q",display:"ask"}),r.organics.push({host:"globososo.com",param:"q",display:"globo"}),r.organics.push({host:"go.mail.ru",param:"q",display:"go.mail.ru"}),r.organics.push({host:"rambler.ru",param:"query",display:"rambler"}),r.organics.push({host:"tut.by",param:"query",display:"tut.by"}),r.referrals.push({host:"t.co",display:"twitter.com"}),r.referrals.push({host:"plus.url.google.com",display:"plus.google.com"}),r},validate:{checkFloat:function(e){return!(!e||!this.isNumeric(parseFloat(e)))&&parseFloat(e)},checkInt:function(e){return!(!e||!this.isNumeric(parseInt(e)))&&parseInt(e)},isNumeric:function(e){return!isNaN(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)}}}},{"./helpers/uri":4,"./terms":9}],9:[function(e,t,r){"use strict";t.exports={traffic:{utm:"utm",organic:"organic",referral:"referral",typein:"typein"},referer:{referral:"referral",organic:"organic",social:"social"},none:"(none)",oops:"(Houston, we have a problem)"}},{}]},{},[1])(1)});
|
|
@@ -43,4 +43,17 @@ then
|
|
|
43
43
|
exit 1
|
|
44
44
|
fi
|
|
45
45
|
|
|
46
|
+
paths=$(curl -s https://purge.jsdelivr.net/status/$request_id | jq -r '.paths')
|
|
47
|
+
|
|
48
|
+
echo "\nThrottled paths:"
|
|
49
|
+
echo $paths | jq -r 'to_entries[] | select(.value.throttled == true) | "\(.key) - throttling reset in \(.value.throttlingReset) seconds"'
|
|
50
|
+
|
|
51
|
+
are_throttled=$(echo $paths | jq -r 'to_entries[] | select(.value.throttled == true) | .key')
|
|
52
|
+
|
|
53
|
+
if [ -n "$are_throttled" ]
|
|
54
|
+
then
|
|
55
|
+
echo "\nERROR: You should wait for the throttling reset time and try again to clear the cache"
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
|
|
46
59
|
echo "\nSuccessfully cleared the cache on CDN for $package_name with the tag $tag"
|
package/src/js/data.js
CHANGED
|
@@ -45,7 +45,8 @@ var data = {
|
|
|
45
45
|
|
|
46
46
|
session: {
|
|
47
47
|
pages_seen: 'pgs',
|
|
48
|
-
current_page: 'cpg'
|
|
48
|
+
current_page: 'cpg',
|
|
49
|
+
session_id: 'sid'
|
|
49
50
|
},
|
|
50
51
|
|
|
51
52
|
udata: {
|
|
@@ -76,6 +77,21 @@ var data = {
|
|
|
76
77
|
);
|
|
77
78
|
},
|
|
78
79
|
|
|
80
|
+
unpack: function(str) {
|
|
81
|
+
var sbjs = {};
|
|
82
|
+
var parts = str.split('|||');
|
|
83
|
+
|
|
84
|
+
parts.forEach(function(part) {
|
|
85
|
+
var keyValue = part.split('=');
|
|
86
|
+
var key = keyValue[0];
|
|
87
|
+
var value = keyValue[1];
|
|
88
|
+
|
|
89
|
+
sbjs[key] = value;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return sbjs;
|
|
93
|
+
},
|
|
94
|
+
|
|
79
95
|
extra: function(timezone_offset) {
|
|
80
96
|
return (
|
|
81
97
|
data.aliases.extra.fire_date + '=' + utils.setDate(new Date, timezone_offset) + data.delimiter +
|
|
@@ -92,11 +108,20 @@ var data = {
|
|
|
92
108
|
);
|
|
93
109
|
},
|
|
94
110
|
|
|
95
|
-
session: function(pages) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
session: function(pages, session_id) {
|
|
112
|
+
var session = (
|
|
113
|
+
data.aliases.session.pages_seen + '=' + pages + data.delimiter +
|
|
114
|
+
data.aliases.session.current_page + '=' + document.location.href
|
|
99
115
|
);
|
|
116
|
+
|
|
117
|
+
if (session_id) {
|
|
118
|
+
return (
|
|
119
|
+
session + data.delimiter +
|
|
120
|
+
data.aliases.session.session_id + '=' + session_id
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return session;
|
|
100
125
|
},
|
|
101
126
|
|
|
102
127
|
promo: function(promo) {
|
package/src/js/init.js
CHANGED
|
@@ -70,23 +70,61 @@ module.exports = function(prefs) {
|
|
|
70
70
|
)
|
|
71
71
|
);
|
|
72
72
|
|
|
73
|
+
var current_data;
|
|
74
|
+
var new_data;
|
|
75
|
+
var is_utm_changed = false;
|
|
76
|
+
|
|
73
77
|
if (isGetParamsContainsUtm) {
|
|
74
78
|
setFirstAndCurrentExtraData();
|
|
75
79
|
sbjs_data = getData(terms.traffic.utm);
|
|
80
|
+
current_data = parsedCurrent;
|
|
81
|
+
new_data = data.pack.unpack(sbjs_data);
|
|
82
|
+
|
|
83
|
+
is_utm_changed = checkIsUtmChanged(current_data, new_data);
|
|
76
84
|
} else if (shouldOverrideWithOrganic) {
|
|
77
85
|
setFirstAndCurrentExtraData();
|
|
78
86
|
sbjs_data = getData(terms.traffic.organic);
|
|
87
|
+
|
|
88
|
+
current_data = parsedCurrent;
|
|
89
|
+
new_data = data.pack.unpack(sbjs_data);
|
|
90
|
+
|
|
91
|
+
is_utm_changed = checkIsUtmChanged(current_data, new_data);
|
|
79
92
|
} else if (!cookies.get(data.containers.session) && checkReferer(terms.traffic.referral)) {
|
|
80
93
|
setFirstAndCurrentExtraData();
|
|
81
94
|
sbjs_data = getData(terms.traffic.referral);
|
|
95
|
+
|
|
96
|
+
is_utm_changed = true;
|
|
82
97
|
} else if (!cookies.get(data.containers.first) && !cookies.get(data.containers.current)) {
|
|
83
98
|
setFirstAndCurrentExtraData();
|
|
84
99
|
sbjs_data = getData(terms.traffic.typein);
|
|
100
|
+
|
|
101
|
+
is_utm_changed = true;
|
|
85
102
|
} else {
|
|
86
|
-
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
data: cookies.get(data.containers.current),
|
|
106
|
+
is_utm_changed: is_utm_changed
|
|
107
|
+
};
|
|
87
108
|
}
|
|
88
109
|
|
|
89
|
-
return
|
|
110
|
+
return {
|
|
111
|
+
data: sbjs_data,
|
|
112
|
+
is_utm_changed: is_utm_changed
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function checkIsUtmChanged(
|
|
117
|
+
current_data,
|
|
118
|
+
new_data
|
|
119
|
+
) {
|
|
120
|
+
return (
|
|
121
|
+
current_data[data.aliases.main.type] !== new_data[data.aliases.main.type] ||
|
|
122
|
+
current_data[data.aliases.main.source] !== new_data[data.aliases.main.source] ||
|
|
123
|
+
current_data[data.aliases.main.medium] !== new_data[data.aliases.main.medium] ||
|
|
124
|
+
current_data[data.aliases.main.campaign] !== new_data[data.aliases.main.campaign] ||
|
|
125
|
+
current_data[data.aliases.main.content] !== new_data[data.aliases.main.content] ||
|
|
126
|
+
current_data[data.aliases.main.term] !== new_data[data.aliases.main.term]
|
|
127
|
+
);
|
|
90
128
|
}
|
|
91
129
|
|
|
92
130
|
function getData(type) {
|
|
@@ -365,9 +403,10 @@ module.exports = function(prefs) {
|
|
|
365
403
|
}
|
|
366
404
|
|
|
367
405
|
(function setData() {
|
|
406
|
+
var sbjs_data = mainData();
|
|
368
407
|
|
|
369
408
|
// Main data
|
|
370
|
-
cookies.set(data.containers.current,
|
|
409
|
+
cookies.set(data.containers.current, sbjs_data.data, lifetime, domain, isolate);
|
|
371
410
|
if (!cookies.get(data.containers.first)) {
|
|
372
411
|
cookies.set(data.containers.first, cookies.get(data.containers.current), lifetime, domain, isolate);
|
|
373
412
|
}
|
|
@@ -386,13 +425,26 @@ module.exports = function(prefs) {
|
|
|
386
425
|
|
|
387
426
|
// Session
|
|
388
427
|
var pages_count;
|
|
428
|
+
var session_id;
|
|
429
|
+
|
|
389
430
|
if (!cookies.get(data.containers.session)) {
|
|
390
431
|
pages_count = 1;
|
|
391
432
|
} else {
|
|
392
433
|
pages_count = parseInt(cookies.parse(data.containers.session)[cookies.unsbjs(data.containers.session)][data.aliases.session.pages_seen]) || 1;
|
|
393
434
|
pages_count += 1;
|
|
394
435
|
}
|
|
395
|
-
|
|
436
|
+
|
|
437
|
+
if (!cookies.get(data.containers.session) || sbjs_data.is_utm_changed) {
|
|
438
|
+
session_id = new Date().getTime();
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
cookies.set(
|
|
442
|
+
data.containers.session,
|
|
443
|
+
data.pack.session(pages_count, session_id),
|
|
444
|
+
p.session_length,
|
|
445
|
+
domain,
|
|
446
|
+
isolate
|
|
447
|
+
);
|
|
396
448
|
|
|
397
449
|
// Promocode
|
|
398
450
|
if (p.promocode && !cookies.get(data.containers.promocode)) {
|
package/src/js/sourcebuster.js
CHANGED