@mate-academy/sourcebuster 1.1.3 → 1.2.0
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/README.md +9 -6
- package/dist/sourcebuster.js +40 -18
- package/dist/sourcebuster.min.js +2 -2
- package/package.json +1 -1
- package/public/js/sourcebuster.min.js +2 -2
- package/src/js/init.js +40 -18
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Read [upgrade guide](UPGRADING.md) for details.
|
|
6
6
|
|
|
7
|
+
## Source
|
|
8
|
+
This package is a modified clone of [sourcebuster js functionality](https://github.com/alex35mil/sourcebuster-js).
|
|
9
|
+
|
|
7
10
|
## About
|
|
8
11
|
* Sourcebuster tracks the sources of your site’s visitors and stores the data in the cookies for further analysis.
|
|
9
12
|
* It handles sources-overriding just like Google Analytics does.
|
|
@@ -203,14 +206,14 @@ So by default the cookies are shared. However if you don't want to share them
|
|
|
203
206
|
|
|
204
207
|
Let’s take a look at further examples.
|
|
205
208
|
|
|
206
|
-
**No. 1**
|
|
209
|
+
**No. 1**
|
|
207
210
|
The first scenario. You have a site: **wow.com**. Also you have a blog on this site: **blog.wow.com**. And you don’t want to separate traffic between them. It means that when the visitor come from **blog.wow.com** to **wow.com**, it won’t be a new visit for **wow.com** (with **blog.wow.com** as Referral source), it will be a common inner click without source change (to sourcebuster.js this scenario will be equal to inner page change: from *wow.com/about* to *wow.com/contacts* for example). To achive this you have to add this line on both sites: **wow.com & blog.wow.com**.
|
|
208
211
|
|
|
209
212
|
```javascript
|
|
210
213
|
domain: 'wow.com'
|
|
211
214
|
```
|
|
212
215
|
|
|
213
|
-
**No. 2**
|
|
216
|
+
**No. 2**
|
|
214
217
|
That was simple. Now lets take a look at opposite scenario — you want to separate traffic between your subdomains and consider it as Referral. There is the main site — **wow.com**, and there is a blog on this site — **blog.wow.com**, which also has users subdomains — **alex.blog.wow.com** is one of them. You don’t want to separate traffic between **blog.wow.com** and **alex.blog.wow.com**, but you do want to separate it between all the blogs and the main site. Here’s how we can sort it out:
|
|
215
218
|
|
|
216
219
|
```javascript
|
|
@@ -220,7 +223,7 @@ domain: {
|
|
|
220
223
|
isolate: true
|
|
221
224
|
}
|
|
222
225
|
|
|
223
|
-
// and this on the blogs subdomains (blog.wow.com & alex.blog.wow.com)
|
|
226
|
+
// and this on the blogs subdomains (blog.wow.com & alex.blog.wow.com)
|
|
224
227
|
domain: 'blog.wow.com'
|
|
225
228
|
```
|
|
226
229
|
|
|
@@ -521,7 +524,7 @@ All data are stored in cookies. When the script is pushed to production, visitor
|
|
|
521
524
|
|
|
522
525
|
#### sbjs_current & sbjs_first
|
|
523
526
|
|
|
524
|
-
*Format*
|
|
527
|
+
*Format*
|
|
525
528
|
`typ=organic|||src=google|||mdm=organic|||cmp=(none)|||cnt=(none)|||trm=(none)`
|
|
526
529
|
|
|
527
530
|
*Examples*
|
|
@@ -546,7 +549,7 @@ typ=typein|||src=(direct)|||mdm=(none)|||cmp=(none)|||cnt=(none)|||trm=(none)
|
|
|
546
549
|
|
|
547
550
|
#### sbjs_current_add & sbjs_first_add
|
|
548
551
|
|
|
549
|
-
*Format*
|
|
552
|
+
*Format*
|
|
550
553
|
`fd=2014-06-11 17:28:26|||ep=http://statica.alexfedoseev.com/sourcebuster-js/|||rf=https://www.google.com`
|
|
551
554
|
|
|
552
555
|
|
|
@@ -558,7 +561,7 @@ typ=typein|||src=(direct)|||mdm=(none)|||cmp=(none)|||cnt=(none)|||trm=(none)
|
|
|
558
561
|
|
|
559
562
|
#### sbjs_udata
|
|
560
563
|
|
|
561
|
-
*Format*
|
|
564
|
+
*Format*
|
|
562
565
|
`vst=2|||uip=192.168.1.1|uag=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36`
|
|
563
566
|
|
|
564
567
|
|
package/dist/sourcebuster.js
CHANGED
|
@@ -364,26 +364,48 @@ module.exports = function(prefs) {
|
|
|
364
364
|
|
|
365
365
|
function mainData() {
|
|
366
366
|
var sbjs_data;
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
367
|
+
|
|
368
|
+
var isGetParamsContainsUtm = (
|
|
369
|
+
typeof get_param.utm_source !== 'undefined' ||
|
|
370
|
+
typeof get_param.utm_medium !== 'undefined' ||
|
|
371
|
+
typeof get_param.utm_campaign !== 'undefined' ||
|
|
372
|
+
typeof get_param.utm_content !== 'undefined' ||
|
|
373
|
+
typeof get_param.utm_term !== 'undefined' ||
|
|
374
|
+
typeof get_param.utm_ac_id !== 'undefined' ||
|
|
375
|
+
typeof get_param.utm_id !== 'undefined' ||
|
|
376
|
+
typeof get_param.utm_ad_group_id !== 'undefined' ||
|
|
377
|
+
typeof get_param.utm_ad_id !== 'undefined' ||
|
|
378
|
+
typeof get_param.utm_term_id !== 'undefined' ||
|
|
379
|
+
typeof get_param.gclid !== 'undefined' ||
|
|
380
|
+
typeof get_param.yclid !== 'undefined' ||
|
|
381
|
+
typeof get_param[p.campaign_param] !== 'undefined' ||
|
|
382
|
+
typeof get_param[p.term_param] !== 'undefined' ||
|
|
383
|
+
typeof get_param[p.content_param] !== 'undefined'
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
var parseContainer = cookies.parse(data.containers);
|
|
387
|
+
var parsedCurrent = parseContainer[cookies.unsbjs(data.containers.current)];
|
|
388
|
+
var parsedCurrentExtra = parseContainer[cookies.unsbjs(data.containers.current_extra)];
|
|
389
|
+
|
|
390
|
+
var fireTime = new Date(parsedCurrentExtra[data.aliases.extra.fire_date]).getTime();
|
|
391
|
+
var DAY = 24 * 60 * 60 * 1000;
|
|
392
|
+
var now = new Date().getTime();
|
|
393
|
+
var fireTimeDiff = now - fireTime;
|
|
394
|
+
|
|
395
|
+
var isOrganic = checkReferer(terms.traffic.organic);
|
|
396
|
+
var isCurrentContainerContainsUtm = parsedCurrent[data.aliases.main.type] === terms.traffic.utm;
|
|
397
|
+
|
|
398
|
+
var shouldOverrideWithOrganic = (
|
|
399
|
+
isOrganic && (
|
|
400
|
+
!isCurrentContainerContainsUtm ||
|
|
401
|
+
fireTimeDiff > 45 * DAY
|
|
402
|
+
)
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
if (isGetParamsContainsUtm) {
|
|
384
406
|
setFirstAndCurrentExtraData();
|
|
385
407
|
sbjs_data = getData(terms.traffic.utm);
|
|
386
|
-
} else if (
|
|
408
|
+
} else if (shouldOverrideWithOrganic) {
|
|
387
409
|
setFirstAndCurrentExtraData();
|
|
388
410
|
sbjs_data = getData(terms.traffic.organic);
|
|
389
411
|
} else if (!cookies.get(data.containers.session) && checkReferer(terms.traffic.referral)) {
|
package/dist/sourcebuster.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** @mate-academy/sourcebuster v1.
|
|
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;if("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])g(),e=r(i.traffic.utm);else if(d(i.traffic.organic))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,H="undefined"!=typeof _.utm_id?_.utm_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,D="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,H=i.none,D=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,H=i.none,D=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,H=i.none,D=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,H=i.oops,D=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:H,ad_group_id:D,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,H,D,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.0 **/
|
|
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)});
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** @mate-academy/sourcebuster v1.
|
|
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;if("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])g(),e=r(i.traffic.utm);else if(d(i.traffic.organic))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,H="undefined"!=typeof _.utm_id?_.utm_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,D="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,H=i.none,D=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,H=i.none,D=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,H=i.none,D=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,H=i.oops,D=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:H,ad_group_id:D,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,H,D,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.0 **/
|
|
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)});
|
package/src/js/init.js
CHANGED
|
@@ -32,26 +32,48 @@ module.exports = function(prefs) {
|
|
|
32
32
|
|
|
33
33
|
function mainData() {
|
|
34
34
|
var sbjs_data;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
|
|
36
|
+
var isGetParamsContainsUtm = (
|
|
37
|
+
typeof get_param.utm_source !== 'undefined' ||
|
|
38
|
+
typeof get_param.utm_medium !== 'undefined' ||
|
|
39
|
+
typeof get_param.utm_campaign !== 'undefined' ||
|
|
40
|
+
typeof get_param.utm_content !== 'undefined' ||
|
|
41
|
+
typeof get_param.utm_term !== 'undefined' ||
|
|
42
|
+
typeof get_param.utm_ac_id !== 'undefined' ||
|
|
43
|
+
typeof get_param.utm_id !== 'undefined' ||
|
|
44
|
+
typeof get_param.utm_ad_group_id !== 'undefined' ||
|
|
45
|
+
typeof get_param.utm_ad_id !== 'undefined' ||
|
|
46
|
+
typeof get_param.utm_term_id !== 'undefined' ||
|
|
47
|
+
typeof get_param.gclid !== 'undefined' ||
|
|
48
|
+
typeof get_param.yclid !== 'undefined' ||
|
|
49
|
+
typeof get_param[p.campaign_param] !== 'undefined' ||
|
|
50
|
+
typeof get_param[p.term_param] !== 'undefined' ||
|
|
51
|
+
typeof get_param[p.content_param] !== 'undefined'
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
var parseContainer = cookies.parse(data.containers);
|
|
55
|
+
var parsedCurrent = parseContainer[cookies.unsbjs(data.containers.current)];
|
|
56
|
+
var parsedCurrentExtra = parseContainer[cookies.unsbjs(data.containers.current_extra)];
|
|
57
|
+
|
|
58
|
+
var fireTime = new Date(parsedCurrentExtra[data.aliases.extra.fire_date]).getTime();
|
|
59
|
+
var DAY = 24 * 60 * 60 * 1000;
|
|
60
|
+
var now = new Date().getTime();
|
|
61
|
+
var fireTimeDiff = now - fireTime;
|
|
62
|
+
|
|
63
|
+
var isOrganic = checkReferer(terms.traffic.organic);
|
|
64
|
+
var isCurrentContainerContainsUtm = parsedCurrent[data.aliases.main.type] === terms.traffic.utm;
|
|
65
|
+
|
|
66
|
+
var shouldOverrideWithOrganic = (
|
|
67
|
+
isOrganic && (
|
|
68
|
+
!isCurrentContainerContainsUtm ||
|
|
69
|
+
fireTimeDiff > 45 * DAY
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (isGetParamsContainsUtm) {
|
|
52
74
|
setFirstAndCurrentExtraData();
|
|
53
75
|
sbjs_data = getData(terms.traffic.utm);
|
|
54
|
-
} else if (
|
|
76
|
+
} else if (shouldOverrideWithOrganic) {
|
|
55
77
|
setFirstAndCurrentExtraData();
|
|
56
78
|
sbjs_data = getData(terms.traffic.organic);
|
|
57
79
|
} else if (!cookies.get(data.containers.session) && checkReferer(terms.traffic.referral)) {
|