ba-js-rt 1.0.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/lib/rt.js +1 -1
  2. package/package.json +8 -4
package/lib/rt.js CHANGED
@@ -1 +1 @@
1
- var BA=BA||{},getRFromRequest=function getRFromRequest(){var s="";top.location&&(s=top.location.href);var r="unset",found=s.match(/[&\?]r=([^&]*)/);return found&&found.length>1&&(r=escape(found[1])),r},setCookie=function setCookie(name,value,expires,path,domain,secure){var today=new Date;today.setTime(today.getTime()),expires&&(expires*=864e5);var expires_date=new Date(today.getTime()+expires);document.cookie=name+"="+escape(value)+(expires?";expires="+expires_date.toGMTString():"")+(path?";path="+path:"")+(domain?";domain="+domain:"")+(secure?";secure":"")},getPDomain=function getPDomain(hostname){for(var i=0,domain=document.domain,p=domain.split("."),s="_gd"+new Date().getTime();i<p.length-1&&-1==document.cookie.indexOf(s+"="+s);)domain=p.slice(-1-++i).join("."),document.cookie=s+"="+s+";domain="+domain+";";return document.cookie=s+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain="+domain+";",domain};!function registerRForSite(){var r=getRFromRequest();if(r&&"null"!=r&&"unset"!=r&&""!=r){var cDom=getPDomain(window.location.hostname);setCookie("r",escape(r),0,"/",cDom),setCookie("ra",escape(r),365,"/",cDom)}}();
1
+ var BA=window.BA||{};function e(e,n,o,t,c,a){var r,i=new Date;i.setTime(i.getTime()),o&&(r=864e5*o);var s=new Date(i.getTime()+r);document.cookie="".concat(e,"=").concat(escape(n)).concat(r?";expires=".concat(s.toGMTString()):"").concat(t?";path=".concat(t):"").concat(c?";domain=".concat(c):"").concat(a?";secure":"")}function n(e){for(var n=document.cookie.split(";"),o="",t="",c="",a=0;a<n.length;a+=1){if((o=n[a].split("="))[0].replace(/^\s+|\s+$/g,"")===e)return o.length>1&&(c=unescape(o[1].replace(/^\s+|\s+$/g,""))),c;o=null}return null}function o(){var e=BA.measurementIds,n=BA.gaId,o=BA.gaAnonymiseIp;return e?{accounts:{measurementIds:e}}:n?{accounts:{hotel:{name:"hotel",trackingId:n,anonymizeIp:o}}}:void 0}!function(){var n,o,t,c=(n="",top.location&&(n=top.location.href),o="unset",(t=n.match(/[&?]r=([^&]*)/))&&t.length>1&&(o=escape(t[1])),o);if(c&&"null"!==c&&"unset"!==c&&""!==c){var a=function(){for(var e=0,n=document.domain,o=n.split("."),t="_gd".concat(new Date().getTime());e<o.length-1&&-1===document.cookie.indexOf("".concat(t,"=").concat(t));)e+=1,n=o.slice(-1-e).join("."),document.cookie="".concat(t,"=").concat(t,";domain=").concat(n,";");return document.cookie="".concat(t,"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=").concat(n,";"),n}(window.location.hostname);e("r",escape(c),0,"/",a),e("ra",escape(c),365,"/",a)}}();var t=new Promise(function(e,t){var c="https://unpkg.com/ba-js-tracker@gtag",a=document.createElement("script");a.src=c,document.head.appendChild(a),a.addEventListener("load",function(){var t={},c=o();if(c){var a=BA.gaConsent,r=BA.gaWaitForConsent,i=BA.gdpr,s=BA.showBanner;("no"===i||"no"===s||!("boolean"!=typeof r||r)||+n("cookie-consent")&a)&&(t={GoogleAnalytics:c})}var d=window.baJsTracker.default({trackers:t}),l=BA.hotel_id,u=BA.hotelId,g=BA.guide_id,f=BA.guideId,p=BA.hotel_group_id,m=BA.userLanguage,h=function e(n){return Object.keys(n).forEach(function(o){var t,c=n[o],a=void 0===c?"undefined":c&&"undefined"!=typeof Symbol&&c.constructor===Symbol?"symbol":typeof c;"object"===a?(e(c),Object.keys(c).length||delete n[o]):"undefined"===a&&delete n[o]}),n}({context:{hotel:{hotelId:l||u,guideId:g||f,cgGroupId:p,cookiePolicyUrl:BA.cookiePolicyUrl},userLanguage:m,client:"CookieBanner"}});return d.event=d.event.bind(null,h),e(d)}),a.addEventListener("error",function(){t(Error("".concat(c," failed to load.")))})});t.then(function(e){var t=o();if(t&&!e.getTrackers().find(function(e){return"GoogleAnalytics"===e}))var c=setInterval(function(){+n("cookie-consent")&BA.gaConsent&&(clearInterval(c),e.addTrackers({GoogleAnalytics:t}),e.event({event:{type:"pageView",whitelist:["GoogleAnalytics"]}}).catch(function(e){console.error(e)}))},250)}).catch(function(e){console.error(e)}),BA.baJsTracker=t;
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "ba-js-rt",
3
- "version": "1.0.0",
3
+ "version": "2.0.1",
4
4
  "scripts": {
5
- "build": "swc ./src -d lib",
5
+ "clean": "rimraf lib",
6
+ "build": "yarn clean && swc ./src -d lib",
6
7
  "lint": "eslint --ext js src --fix",
7
8
  "prepublishOnly": "yarn build",
8
9
  "prepare": "husky install"
9
10
  },
10
- "files": ["lib"],
11
+ "files": [
12
+ "lib"
13
+ ],
11
14
  "main": "./lib/rt.js",
12
15
  "devDependencies": {
13
16
  "@swc/cli": "^0.1.57",
@@ -19,7 +22,8 @@
19
22
  "eslint-plugin-prettier": "^4.2.1",
20
23
  "husky": ">=6",
21
24
  "lint-staged": ">=10",
22
- "prettier": "^2.7.1"
25
+ "prettier": "^2.7.1",
26
+ "rimraf": "^3.0.2"
23
27
  },
24
28
  "lint-staged": {
25
29
  "*.js": "eslint --cache --fix"