@kameleoon/javascript-sdk-core 3.5.0 → 3.6.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/dist/kameleoonUtils.d.ts +2 -1
- package/dist/kameleoonUtils.js +1 -1
- package/dist/kameleoonUtils.js.map +1 -1
- package/dist/requester/index.d.ts +1 -1
- package/dist/requester/index.js +1 -1
- package/dist/requester/index.js.map +1 -1
- package/dist/requester/requester.js +1 -1
- package/package.json +1 -1
package/dist/kameleoonUtils.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Environment } from './types';
|
|
1
2
|
/**
|
|
2
3
|
* @abstract
|
|
3
4
|
* KameleoonUtils - an abstract class for extending kameleoon utils with pre-defined method signatures
|
|
4
5
|
* */
|
|
5
6
|
export declare abstract class KameleoonUtils {
|
|
6
|
-
protected getClientConfigurationUrl(siteCode: string): string;
|
|
7
|
+
protected getClientConfigurationUrl(siteCode: string, environment?: Environment): string;
|
|
7
8
|
}
|
package/dist/kameleoonUtils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _requester=require("./requester");Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonUtils=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var KameleoonUtils=function(){function a(){_classCallCheck(this,a)}return _createClass(a,[{key:"getClientConfigurationUrl",value:function getClientConfigurationUrl(a){return _requester.URL.CLIENT_CONFIGURATION+a}}]),a}();exports.KameleoonUtils=KameleoonUtils;
|
|
1
|
+
"use strict";var _requester=require("./requester");Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonUtils=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var KameleoonUtils=function(){function a(){_classCallCheck(this,a)}return _createClass(a,[{key:"getClientConfigurationUrl",value:function getClientConfigurationUrl(a,b){return b?_requester.URL.CLIENT_CONFIGURATION+a+_requester.UrlFirstParameter.Environment+b:_requester.URL.CLIENT_CONFIGURATION+a}}]),a}();exports.KameleoonUtils=KameleoonUtils;
|
|
2
2
|
//# sourceMappingURL=kameleoonUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kameleoonUtils.js","names":["_requester","require","Object","defineProperty","exports","value","KameleoonUtils","_typeof","a","Symbol","iterator","constructor","prototype","_classCallCheck","b","TypeError","_defineProperties","c","d","length","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","call","String","Number","getClientConfigurationUrl","siteCode","URL","CLIENT_CONFIGURATION"],"sources":["../src/kameleoonUtils.ts"],"sourcesContent":["import { URL } from './requester';\n\n/**\n * @abstract\n * KameleoonUtils - an abstract class for extending kameleoon utils with pre-defined method signatures\n * */\nexport abstract class KameleoonUtils {\n protected getClientConfigurationUrl(siteCode: string): string {\n return URL.CLIENT_CONFIGURATION + siteCode;\n }\n}\n"],"mappings":"aAAA,IAAAA,UAAA,CAAAC,OAAA,
|
|
1
|
+
{"version":3,"file":"kameleoonUtils.js","names":["_requester","require","Object","defineProperty","exports","value","KameleoonUtils","_typeof","a","Symbol","iterator","constructor","prototype","_classCallCheck","b","TypeError","_defineProperties","c","d","length","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","call","String","Number","getClientConfigurationUrl","siteCode","environment","URL","CLIENT_CONFIGURATION","UrlFirstParameter","Environment"],"sources":["../src/kameleoonUtils.ts"],"sourcesContent":["import { URL, UrlFirstParameter } from './requester';\nimport { Environment } from './types';\n\n/**\n * @abstract\n * KameleoonUtils - an abstract class for extending kameleoon utils with pre-defined method signatures\n * */\nexport abstract class KameleoonUtils {\n protected getClientConfigurationUrl(\n siteCode: string,\n environment?: Environment,\n ): string {\n if (environment) {\n return (\n URL.CLIENT_CONFIGURATION +\n siteCode +\n UrlFirstParameter.Environment +\n environment\n );\n }\n\n return URL.CLIENT_CONFIGURATION + siteCode;\n }\n}\n"],"mappings":"aAAA,IAAAA,UAAA,CAAAC,OAAA,gBAAqDC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,cAAA,iBAAAC,QAAAC,CAAA,mCAAAD,OAAA,oBAAAE,MAAA,mBAAAA,MAAA,CAAAC,QAAA,UAAAF,CAAA,gBAAAA,CAAA,WAAAA,CAAA,SAAAA,CAAA,qBAAAC,MAAA,EAAAD,CAAA,CAAAG,WAAA,GAAAF,MAAA,EAAAD,CAAA,GAAAC,MAAA,CAAAG,SAAA,iBAAAJ,CAAA,EAAAD,OAAA,CAAAC,CAAA,WAAAK,gBAAAL,CAAA,CAAAM,CAAA,OAAAN,CAAA,YAAAM,CAAA,YAAAC,SAAA,+CAAAC,kBAAAR,CAAA,CAAAM,CAAA,UAAAG,CAAA,CAAAC,CAAA,GAAAA,CAAA,CAAAJ,CAAA,CAAAK,MAAA,CAAAD,CAAA,GAAAD,CAAA,CAAAH,CAAA,CAAAI,CAAA,EAAAD,CAAA,CAAAG,UAAA,CAAAH,CAAA,CAAAG,UAAA,KAAAH,CAAA,CAAAI,YAAA,cAAAJ,CAAA,GAAAA,CAAA,CAAAK,QAAA,KAAApB,MAAA,CAAAC,cAAA,CAAAK,CAAA,CAAAe,cAAA,CAAAN,CAAA,CAAAO,GAAA,EAAAP,CAAA,WAAAQ,aAAAjB,CAAA,CAAAM,CAAA,CAAAG,CAAA,SAAAH,CAAA,EAAAE,iBAAA,CAAAR,CAAA,CAAAI,SAAA,CAAAE,CAAA,EAAAG,CAAA,EAAAD,iBAAA,CAAAR,CAAA,CAAAS,CAAA,EAAAf,MAAA,CAAAC,cAAA,CAAAK,CAAA,cAAAc,QAAA,MAAAd,CAAA,UAAAe,eAAAf,CAAA,MAAAM,CAAA,CAAAY,YAAA,CAAAlB,CAAA,4BAAAD,OAAA,CAAAO,CAAA,EAAAA,CAAA,CAAAA,CAAA,aAAAY,aAAAlB,CAAA,CAAAM,CAAA,gBAAAP,OAAA,CAAAC,CAAA,UAAAA,CAAA,QAAAA,CAAA,KAAAS,CAAA,CAAAT,CAAA,CAAAC,MAAA,CAAAkB,WAAA,KAAAV,CAAA,eAAAC,CAAA,CAAAD,CAAA,CAAAW,IAAA,CAAApB,CAAA,CAAAM,CAAA,2BAAAP,OAAA,CAAAW,CAAA,SAAAA,CAAA,WAAAH,SAAA,mEAAAD,CAAA,CAAAe,MAAA,CAAAC,MAAA,EAAAtB,CAAA,KAO/B,CAAAF,cAAc,qBAAAE,EAAA,EAAAK,eAAA,MAAAL,CAAA,SAAAiB,YAAA,CAAAjB,CAAA,GAAAgB,GAAA,6BAAAnB,KAAA,CAClC,SAAA0B,0BACEC,CAAgB,CAChBC,CAAyB,CACjB,OACJ,CAAAA,CAAW,CAEXC,cAAG,CAACC,oBAAoB,CACxBH,CAAQ,CACRI,4BAAiB,CAACC,WAAW,CAC7BJ,CAAW,CAIRC,cAAG,CAACC,oBAAoB,CAAGH,CACpC,CAAC,IAAAxB,CAAA,IAAAJ,OAAA,CAAAE,cAAA,CAAAA,cAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Requester } from './requester';
|
|
2
|
-
export { URL, DEFAULT_REQUEST_TIMEOUT, NUMBER_OF_RETRIES, RETRIES_DELAY, UrlQuery, UrlEventType, UrlParameter, Header, } from './constants';
|
|
2
|
+
export { URL, DEFAULT_REQUEST_TIMEOUT, NUMBER_OF_RETRIES, RETRIES_DELAY, UrlQuery, UrlEventType, UrlParameter, UrlFirstParameter, Header, } from './constants';
|
|
3
3
|
export { HttpMethod, HeadersType, VisitType, TrackParametersType, StaticDataEventType, TrackExperimentParamsType, TrackDataParamsType, IExternalRequestDispatcher, GetVisitorDataResultType, } from './types';
|
package/dist/requester/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"DEFAULT_REQUEST_TIMEOUT",{enumerable:!0,get:function get(){return _constants.DEFAULT_REQUEST_TIMEOUT}}),Object.defineProperty(exports,"GetVisitorDataResultType",{enumerable:!0,get:function get(){return _types.GetVisitorDataResultType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function get(){return _constants.Header}}),Object.defineProperty(exports,"HeadersType",{enumerable:!0,get:function get(){return _types.HeadersType}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function get(){return _types.HttpMethod}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function get(){return _types.IExternalRequestDispatcher}}),Object.defineProperty(exports,"NUMBER_OF_RETRIES",{enumerable:!0,get:function get(){return _constants.NUMBER_OF_RETRIES}}),Object.defineProperty(exports,"RETRIES_DELAY",{enumerable:!0,get:function get(){return _constants.RETRIES_DELAY}}),Object.defineProperty(exports,"Requester",{enumerable:!0,get:function get(){return _requester.Requester}}),Object.defineProperty(exports,"StaticDataEventType",{enumerable:!0,get:function get(){return _types.StaticDataEventType}}),Object.defineProperty(exports,"TrackDataParamsType",{enumerable:!0,get:function get(){return _types.TrackDataParamsType}}),Object.defineProperty(exports,"TrackExperimentParamsType",{enumerable:!0,get:function get(){return _types.TrackExperimentParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function get(){return _types.TrackParametersType}}),Object.defineProperty(exports,"URL",{enumerable:!0,get:function get(){return _constants.URL}}),Object.defineProperty(exports,"UrlEventType",{enumerable:!0,get:function get(){return _constants.UrlEventType}}),Object.defineProperty(exports,"UrlParameter",{enumerable:!0,get:function get(){return _constants.UrlParameter}}),Object.defineProperty(exports,"UrlQuery",{enumerable:!0,get:function get(){return _constants.UrlQuery}}),Object.defineProperty(exports,"VisitType",{enumerable:!0,get:function get(){return _types.VisitType}});var _requester=require("./requester"),_constants=require("./constants"),_types=require("./types");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"DEFAULT_REQUEST_TIMEOUT",{enumerable:!0,get:function get(){return _constants.DEFAULT_REQUEST_TIMEOUT}}),Object.defineProperty(exports,"GetVisitorDataResultType",{enumerable:!0,get:function get(){return _types.GetVisitorDataResultType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function get(){return _constants.Header}}),Object.defineProperty(exports,"HeadersType",{enumerable:!0,get:function get(){return _types.HeadersType}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function get(){return _types.HttpMethod}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function get(){return _types.IExternalRequestDispatcher}}),Object.defineProperty(exports,"NUMBER_OF_RETRIES",{enumerable:!0,get:function get(){return _constants.NUMBER_OF_RETRIES}}),Object.defineProperty(exports,"RETRIES_DELAY",{enumerable:!0,get:function get(){return _constants.RETRIES_DELAY}}),Object.defineProperty(exports,"Requester",{enumerable:!0,get:function get(){return _requester.Requester}}),Object.defineProperty(exports,"StaticDataEventType",{enumerable:!0,get:function get(){return _types.StaticDataEventType}}),Object.defineProperty(exports,"TrackDataParamsType",{enumerable:!0,get:function get(){return _types.TrackDataParamsType}}),Object.defineProperty(exports,"TrackExperimentParamsType",{enumerable:!0,get:function get(){return _types.TrackExperimentParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function get(){return _types.TrackParametersType}}),Object.defineProperty(exports,"URL",{enumerable:!0,get:function get(){return _constants.URL}}),Object.defineProperty(exports,"UrlEventType",{enumerable:!0,get:function get(){return _constants.UrlEventType}}),Object.defineProperty(exports,"UrlFirstParameter",{enumerable:!0,get:function get(){return _constants.UrlFirstParameter}}),Object.defineProperty(exports,"UrlParameter",{enumerable:!0,get:function get(){return _constants.UrlParameter}}),Object.defineProperty(exports,"UrlQuery",{enumerable:!0,get:function get(){return _constants.UrlQuery}}),Object.defineProperty(exports,"VisitType",{enumerable:!0,get:function get(){return _types.VisitType}});var _requester=require("./requester"),_constants=require("./constants"),_types=require("./types");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/requester/index.ts"],"sourcesContent":["export { Requester } from './requester';\nexport {\n URL,\n DEFAULT_REQUEST_TIMEOUT,\n NUMBER_OF_RETRIES,\n RETRIES_DELAY,\n UrlQuery,\n UrlEventType,\n UrlParameter,\n Header,\n} from './constants';\nexport {\n HttpMethod,\n HeadersType,\n VisitType,\n TrackParametersType,\n StaticDataEventType,\n TrackExperimentParamsType,\n TrackDataParamsType,\n IExternalRequestDispatcher,\n GetVisitorDataResultType,\n} from './types';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/requester/index.ts"],"sourcesContent":["export { Requester } from './requester';\nexport {\n URL,\n DEFAULT_REQUEST_TIMEOUT,\n NUMBER_OF_RETRIES,\n RETRIES_DELAY,\n UrlQuery,\n UrlEventType,\n UrlParameter,\n UrlFirstParameter,\n Header,\n} from './constants';\nexport {\n HttpMethod,\n HeadersType,\n VisitType,\n TrackParametersType,\n StaticDataEventType,\n TrackExperimentParamsType,\n TrackDataParamsType,\n IExternalRequestDispatcher,\n GetVisitorDataResultType,\n} from './types';\n"],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Requester=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_utilities=require("../utilities"),_constants=require("./constants");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Requester=function(){function a(b){var c=b.siteCode,d=b.environment,e=b.packageInfo,f=b.requestDispatcher;_classCallCheck(this,a),_defineProperty(this,"siteCode",void 0),_defineProperty(this,"environment",void 0),_defineProperty(this,"requestDispatcher",void 0),_defineProperty(this,"packageInfo",void 0),this.requestDispatcher=f,this.siteCode=c,this.environment=d,this.packageInfo=e}return _createClass(a,[{key:"getClientConfiguration",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h;return _regeneratorRuntime().wrap(function i(b){for(;1;)switch(b.prev=b.next){case 0:return d=this.environment?_constants.UrlFirstParameter.Environment+this.environment:"",e="",a&&(d?e=_constants.UrlParameter.Ts+a:e=_constants.UrlFirstParameter.Ts+a),f=_constants.URL.CLIENT_CONFIGURATION+this.siteCode+d+e,g=(c={},_defineProperty(c,_constants.Header.SdkType,this.packageInfo.type.toLowerCase()),_defineProperty(c,_constants.Header.SdkVersion,this.packageInfo.version),c),b.prev=5,b.next=8,this.requestDispatcher.getClientConfiguration(f,g);case 8:if(h=b.sent,!h){b.next=11;break}return b.abrupt("return",(0,_tsRes.Ok)(h));case 11:return b.abrupt("return",(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.MaximumRetriesReached)));case 14:return b.prev=14,b.t0=b["catch"](5),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 17:case"end":return b.stop();}},b,this,[[5,14]])}));return a}()},{key:"getRemoteData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d;return _regeneratorRuntime().wrap(function e(b){for(;1;)switch(b.prev=b.next){case 0:return c=_constants.URL.DATA_MAP+this.siteCode+_constants.UrlParameter.Key+encodeURI(a),b.prev=1,b.next=4,this.requestDispatcher.getRemoteData(c);case 4:return d=b.sent,b.abrupt("return",(0,_tsRes.Ok)(d));case 8:return b.prev=8,b.t0=b["catch"](1),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 11:case"end":return b.stop();}},b,this,[[1,8]])}));return a}()},{key:"getVisitorData",value:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function c(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;return _regeneratorRuntime().wrap(function w(c){for(;1;)switch(c.prev=c.next){case 0:return d=b.customData,e=b.previousVisitAmount,f=b.currentVisit,g=b.conversions,h=b.geolocation,i=b.experiments,j=b.pageViews,k=b.device,l=b.browser,m=b.operatingSystem,n=d?_constants.UrlParameter.CustomData+!0:"",o=g?_constants.UrlParameter.Conversion+!0:"",p=h?_constants.UrlParameter.Geolocation+!0:"",q=i?_constants.UrlParameter.Experiment+!0:"",r=j?_constants.UrlParameter.Page+!0:"",s=k||l||m?_constants.UrlParameter.StaticData+!0:"",t=f?_constants.UrlParameter.CurrentVisit+!0:"",u=_constants.URL.VISIT_DATA+this.siteCode+_constants.UrlParameter.VisitorCode+a+_constants.UrlParameter.MaxNumberPreviousVisits+e+n+o+p+q+r+s+t,c.prev=9,c.next=12,this.requestDispatcher.getRemoteData(u);case 12:return v=c.sent,c.abrupt("return",(0,_tsRes.Ok)(v));case 16:return c.prev=16,c.t0=c["catch"](9),c.abrupt("return",(0,_tsRes.Err)(c.t0));case 19:case"end":return c.stop();}},c,this,[[9,16]])}));return a}()},{key:"trackExperiment",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m;return _regeneratorRuntime().wrap(function n(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.dataUrl,e=a.variationDataUrl,f=a.userAgent,g=a.isUnallocated,h=this.getTrackingUrl(c),i=d?"":_constants.UrlEventType.Activity+_constants.UrlParameter.Nonce+_utilities.Utilities.getNonce(),j=g?i:e,k=j?d+"\n"+j:d,l=f?_defineProperty({},_constants.Header.UserAgent,f):void 0,b.prev=6,b.next=9,this.requestDispatcher.track({url:h,headers:l,body:k});case 9:return m=b.sent,b.abrupt("return",(0,_tsRes.Ok)(m));case 13:return b.prev=13,b.t0=b["catch"](6),b.abrupt("return",(0,_tsRes.Err)());case 16:case"end":return b.stop();}},b,this,[[6,13]])}));return a}()},{key:"trackData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j;return _regeneratorRuntime().wrap(function k(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.body,e=a.userAgent,f=a.isMappingIdentifier,g=this.getTrackingUrl(c,f),h=d||_constants.UrlEventType.Activity+_constants.UrlParameter.Nonce+_utilities.Utilities.getNonce(),i=e?_defineProperty({},_constants.Header.UserAgent,e):void 0,b.prev=4,b.next=7,this.requestDispatcher.track({url:g,headers:i,body:h});case 7:return j=b.sent,b.abrupt("return",(0,_tsRes.Ok)(j));case 11:return b.prev=11,b.t0=b["catch"](4),b.abrupt("return",(0,_tsRes.Err)());case 14:case"end":return b.stop();}},b,this,[[4,11]])}));return a}()},{key:"getTrackingUrl",value:function getTrackingUrl(a,b){var c=this.packageInfo,d=c.type,e=c.version,f=encodeURIComponent("".concat(e,"/").concat("3.5.0")),g=b?_constants.UrlParameter.MappingValue:_constants.UrlParameter.VisitorCode;return _constants.URL.VISIT_EVENT+this.siteCode+g+a+_constants.UrlParameter.SdkName+d.toLowerCase()+_constants.UrlParameter.SdkVersion+f}}]),a}();exports.Requester=Requester;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Requester=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_utilities=require("../utilities"),_constants=require("./constants");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Requester=function(){function a(b){var c=b.siteCode,d=b.environment,e=b.packageInfo,f=b.requestDispatcher;_classCallCheck(this,a),_defineProperty(this,"siteCode",void 0),_defineProperty(this,"environment",void 0),_defineProperty(this,"requestDispatcher",void 0),_defineProperty(this,"packageInfo",void 0),this.requestDispatcher=f,this.siteCode=c,this.environment=d,this.packageInfo=e}return _createClass(a,[{key:"getClientConfiguration",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h;return _regeneratorRuntime().wrap(function i(b){for(;1;)switch(b.prev=b.next){case 0:return d=this.environment?_constants.UrlFirstParameter.Environment+this.environment:"",e="",a&&(d?e=_constants.UrlParameter.Ts+a:e=_constants.UrlFirstParameter.Ts+a),f=_constants.URL.CLIENT_CONFIGURATION+this.siteCode+d+e,g=(c={},_defineProperty(c,_constants.Header.SdkType,this.packageInfo.type.toLowerCase()),_defineProperty(c,_constants.Header.SdkVersion,this.packageInfo.version),c),b.prev=5,b.next=8,this.requestDispatcher.getClientConfiguration(f,g);case 8:if(h=b.sent,!h){b.next=11;break}return b.abrupt("return",(0,_tsRes.Ok)(h));case 11:return b.abrupt("return",(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.MaximumRetriesReached)));case 14:return b.prev=14,b.t0=b["catch"](5),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 17:case"end":return b.stop();}},b,this,[[5,14]])}));return a}()},{key:"getRemoteData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d;return _regeneratorRuntime().wrap(function e(b){for(;1;)switch(b.prev=b.next){case 0:return c=_constants.URL.DATA_MAP+this.siteCode+_constants.UrlParameter.Key+encodeURI(a),b.prev=1,b.next=4,this.requestDispatcher.getRemoteData(c);case 4:return d=b.sent,b.abrupt("return",(0,_tsRes.Ok)(d));case 8:return b.prev=8,b.t0=b["catch"](1),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 11:case"end":return b.stop();}},b,this,[[1,8]])}));return a}()},{key:"getVisitorData",value:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function c(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;return _regeneratorRuntime().wrap(function w(c){for(;1;)switch(c.prev=c.next){case 0:return d=b.customData,e=b.previousVisitAmount,f=b.currentVisit,g=b.conversions,h=b.geolocation,i=b.experiments,j=b.pageViews,k=b.device,l=b.browser,m=b.operatingSystem,n=d?_constants.UrlParameter.CustomData+!0:"",o=g?_constants.UrlParameter.Conversion+!0:"",p=h?_constants.UrlParameter.Geolocation+!0:"",q=i?_constants.UrlParameter.Experiment+!0:"",r=j?_constants.UrlParameter.Page+!0:"",s=k||l||m?_constants.UrlParameter.StaticData+!0:"",t=f?_constants.UrlParameter.CurrentVisit+!0:"",u=_constants.URL.VISIT_DATA+this.siteCode+_constants.UrlParameter.VisitorCode+a+_constants.UrlParameter.MaxNumberPreviousVisits+e+n+o+p+q+r+s+t,c.prev=9,c.next=12,this.requestDispatcher.getRemoteData(u);case 12:return v=c.sent,c.abrupt("return",(0,_tsRes.Ok)(v));case 16:return c.prev=16,c.t0=c["catch"](9),c.abrupt("return",(0,_tsRes.Err)(c.t0));case 19:case"end":return c.stop();}},c,this,[[9,16]])}));return a}()},{key:"trackExperiment",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m;return _regeneratorRuntime().wrap(function n(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.dataUrl,e=a.variationDataUrl,f=a.userAgent,g=a.isUnallocated,h=this.getTrackingUrl(c),i=d?"":_constants.UrlEventType.Activity+_constants.UrlParameter.Nonce+_utilities.Utilities.getNonce(),j=g?i:e,k=j?d+"\n"+j:d,l=f?_defineProperty({},_constants.Header.UserAgent,f):void 0,b.prev=6,b.next=9,this.requestDispatcher.track({url:h,headers:l,body:k});case 9:return m=b.sent,b.abrupt("return",(0,_tsRes.Ok)(m));case 13:return b.prev=13,b.t0=b["catch"](6),b.abrupt("return",(0,_tsRes.Err)());case 16:case"end":return b.stop();}},b,this,[[6,13]])}));return a}()},{key:"trackData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j;return _regeneratorRuntime().wrap(function k(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.body,e=a.userAgent,f=a.isMappingIdentifier,g=this.getTrackingUrl(c,f),h=d||_constants.UrlEventType.Activity+_constants.UrlParameter.Nonce+_utilities.Utilities.getNonce(),i=e?_defineProperty({},_constants.Header.UserAgent,e):void 0,b.prev=4,b.next=7,this.requestDispatcher.track({url:g,headers:i,body:h});case 7:return j=b.sent,b.abrupt("return",(0,_tsRes.Ok)(j));case 11:return b.prev=11,b.t0=b["catch"](4),b.abrupt("return",(0,_tsRes.Err)());case 14:case"end":return b.stop();}},b,this,[[4,11]])}));return a}()},{key:"getTrackingUrl",value:function getTrackingUrl(a,b){var c=this.packageInfo,d=c.type,e=c.version,f=encodeURIComponent("".concat(e,"/").concat("3.6.0")),g=b?_constants.UrlParameter.MappingValue:_constants.UrlParameter.VisitorCode;return _constants.URL.VISIT_EVENT+this.siteCode+g+a+_constants.UrlParameter.SdkName+d.toLowerCase()+_constants.UrlParameter.SdkVersion+f}}]),a}();exports.Requester=Requester;
|
|
2
2
|
//# sourceMappingURL=requester.js.map
|