@kameleoon/javascript-sdk-core 4.0.0 → 4.1.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/CHANGELOG.md +22 -0
- package/dist/clientConfiguration/clientConfiguration.js +1 -1
- package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
- package/dist/clientConfiguration/constants.js +1 -1
- package/dist/clientConfiguration/constants.js.map +1 -1
- package/dist/clientConfiguration/types.d.ts +1 -1
- package/dist/clientConfiguration/types.js.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/kameleoonClient.d.ts +2 -1
- package/dist/kameleoonClient.js +1 -1
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonClientInterface.d.ts +2 -2
- package/dist/kameleoonClientInterface.js.map +1 -1
- package/dist/kameleoonData/applicationVersion.d.ts +0 -9
- package/dist/kameleoonData/applicationVersion.js.map +1 -1
- package/dist/kameleoonData/browser.d.ts +3 -12
- package/dist/kameleoonData/browser.js +1 -1
- package/dist/kameleoonData/browser.js.map +1 -1
- package/dist/kameleoonData/conversion.d.ts +11 -13
- package/dist/kameleoonData/conversion.js +1 -1
- package/dist/kameleoonData/conversion.js.map +1 -1
- package/dist/kameleoonData/cookie.d.ts +0 -9
- package/dist/kameleoonData/cookie.js.map +1 -1
- package/dist/kameleoonData/customData.d.ts +3 -13
- package/dist/kameleoonData/customData.js +1 -1
- package/dist/kameleoonData/customData.js.map +1 -1
- package/dist/kameleoonData/dataManager.d.ts +11 -5
- package/dist/kameleoonData/dataManager.js +1 -1
- package/dist/kameleoonData/dataManager.js.map +1 -1
- package/dist/kameleoonData/dataProcessor.d.ts +13 -6
- package/dist/kameleoonData/dataProcessor.js +1 -1
- package/dist/kameleoonData/dataProcessor.js.map +1 -1
- package/dist/kameleoonData/device.d.ts +3 -12
- package/dist/kameleoonData/device.js +1 -1
- package/dist/kameleoonData/device.js.map +1 -1
- package/dist/kameleoonData/geolocation.d.ts +3 -12
- package/dist/kameleoonData/geolocation.js +1 -1
- package/dist/kameleoonData/geolocation.js.map +1 -1
- package/dist/kameleoonData/index.d.ts +1 -0
- package/dist/kameleoonData/index.js +1 -1
- package/dist/kameleoonData/index.js.map +1 -1
- package/dist/kameleoonData/kameleoonConversionScore.d.ts +15 -0
- package/dist/kameleoonData/kameleoonConversionScore.js +2 -0
- package/dist/kameleoonData/kameleoonConversionScore.js.map +1 -0
- package/dist/kameleoonData/operatingSystem.d.ts +3 -12
- package/dist/kameleoonData/operatingSystem.js +1 -1
- package/dist/kameleoonData/operatingSystem.js.map +1 -1
- package/dist/kameleoonData/pageView.d.ts +4 -13
- package/dist/kameleoonData/pageView.js +1 -1
- package/dist/kameleoonData/pageView.js.map +1 -1
- package/dist/kameleoonData/types.d.ts +54 -11
- package/dist/kameleoonData/types.js +1 -1
- package/dist/kameleoonData/types.js.map +1 -1
- package/dist/kameleoonData/userAgent.d.ts +0 -9
- package/dist/kameleoonData/userAgent.js.map +1 -1
- package/dist/kameleoonData/visitProcessor.d.ts +34 -0
- package/dist/kameleoonData/visitProcessor.js +2 -0
- package/dist/kameleoonData/visitProcessor.js.map +1 -0
- package/dist/kameleoonData/visitsData.d.ts +7 -21
- package/dist/kameleoonData/visitsData.js +1 -1
- package/dist/kameleoonData/visitsData.js.map +1 -1
- package/dist/requester/constants.d.ts +1 -3
- package/dist/requester/constants.js +1 -1
- package/dist/requester/constants.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.d.ts +2 -6
- package/dist/requester/requester.js +1 -1
- package/dist/requester/requester.js.map +1 -1
- package/dist/requester/types.d.ts +24 -2
- package/dist/requester/types.js +1 -1
- package/dist/requester/types.js.map +1 -1
- package/dist/requester/urlProvider.d.ts +17 -0
- package/dist/requester/urlProvider.js +2 -0
- package/dist/requester/urlProvider.js.map +1 -0
- package/dist/storage/storage.js +1 -1
- package/dist/targeting/conditions/browser.js +1 -1
- package/dist/targeting/conditions/browser.js.map +1 -1
- package/dist/targeting/conditions/conditionFactory.js +1 -1
- package/dist/targeting/conditions/conditionFactory.js.map +1 -1
- package/dist/targeting/conditions/conversionLikelihood.d.ts +12 -0
- package/dist/targeting/conditions/conversionLikelihood.js +2 -0
- package/dist/targeting/conditions/conversionLikelihood.js.map +1 -0
- package/dist/targeting/conditions/firstVisit.js +1 -1
- package/dist/targeting/conditions/firstVisit.js.map +1 -1
- package/dist/targeting/conditions/geolocation.js +1 -1
- package/dist/targeting/conditions/geolocation.js.map +1 -1
- package/dist/targeting/conditions/index.d.ts +1 -0
- package/dist/targeting/conditions/index.js +1 -1
- package/dist/targeting/conditions/index.js.map +1 -1
- package/dist/targeting/conditions/lastVisit.js +1 -1
- package/dist/targeting/conditions/lastVisit.js.map +1 -1
- package/dist/targeting/conditions/newVisitor.js +1 -1
- package/dist/targeting/conditions/newVisitor.js.map +1 -1
- package/dist/targeting/conditions/sameDayVisits.js +1 -1
- package/dist/targeting/conditions/sameDayVisits.js.map +1 -1
- package/dist/targeting/conditions/targetFeatureFlag.js +1 -1
- package/dist/targeting/conditions/types.d.ts +3 -0
- package/dist/targeting/conditions/types.js.map +1 -1
- package/dist/targeting/conditions/visits.js +1 -1
- package/dist/targeting/conditions/visits.js.map +1 -1
- package/dist/targeting/index.d.ts +2 -2
- package/dist/targeting/index.js +1 -1
- package/dist/targeting/index.js.map +1 -1
- package/dist/targeting/types.d.ts +4 -0
- package/dist/targeting/types.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.js.map +1 -1
- package/dist/utilities/types.d.ts +6 -1
- package/dist/utilities/types.js.map +1 -1
- package/dist/utilities/utilities.d.ts +1 -1
- package/dist/utilities/utilities.js +1 -1
- package/dist/utilities/utilities.js.map +1 -1
- package/dist/variationConfiguration/types.d.ts +1 -1
- package/dist/variationConfiguration/types.js.map +1 -1
- package/package.json +6 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewVisitor=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_kameleoonError=require("../../kameleoonError"),_types=require("../types");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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class NewVisitor{constructor(a){let{visitorType:b}=a;_defineProperty(this,"visitorType",void 0),this.visitorType=b}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.VisitsData];if(!c||!this.visitorType)return(0,_tsRes.Ok)(!1);const{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewVisitor=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_kameleoonError=require("../../kameleoonError"),_types=require("../types");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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class NewVisitor{constructor(a){let{visitorType:b}=a;_defineProperty(this,"visitorType",void 0),this.visitorType=b}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.VisitsData];if(!c||!this.visitorType)return(0,_tsRes.Ok)(!1);const{visits:d}=c,e=!d.length;switch(this.visitorType){case _types.VisitorType.NEW:return(0,_tsRes.Ok)(e);case _types.VisitorType.RETURNING:return(0,_tsRes.Ok)(!e);default:(0,_kameleoonError.exhaustCheck)(this.visitorType)}}}exports.NewVisitor=NewVisitor;
|
|
2
2
|
//# sourceMappingURL=newVisitor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"newVisitor.js","names":["NewVisitor","constructor","a","visitorType","_defineProperty","evaluate","targetingData","visitsData","KameleoonData","VisitsData","Ok","
|
|
1
|
+
{"version":3,"file":"newVisitor.js","names":["NewVisitor","constructor","a","visitorType","_defineProperty","evaluate","targetingData","visitsData","KameleoonData","VisitsData","Ok","visits","isNewVisitor","length","VisitorType","NEW","RETURNING","exhaustCheck","exports"],"sources":["../../../src/targeting/conditions/newVisitor.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { exhaustCheck, KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType, VisitorType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class NewVisitor implements ICondition {\n private visitorType?: VisitorType | null;\n\n constructor({ visitorType }: ConditionDataType) {\n this.visitorType = visitorType;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const visitsData = targetingData?.[KameleoonData.VisitsData];\n\n if (!visitsData || !this.visitorType) {\n return Ok(false);\n }\n\n const { visits } = visitsData;\n\n // --- Note ---\n // Second case handles situation when user didn't use `addData` that\n // creates new current visit\n const isNewVisitor = !visits.length;\n\n switch (this.visitorType) {\n case VisitorType.NEW:\n return Ok(isNewVisitor);\n case VisitorType.RETURNING:\n return Ok(!isNewVisitor);\n default:\n exhaustCheck(this.visitorType);\n }\n }\n}\n"],"mappings":"uvBAMO,KAAM,CAAAA,UAAiC,CAG5CC,WAAWA,CAAAC,CAAA,CAAqC,IAApC,CAAEC,WAAW,CAAXA,CAA+B,CAAC,CAAAD,CAAA,CAAAE,eAAA,4BAC5C,IAAI,CAACD,WAAW,CAAGA,CACrB,CAEOE,QAAQA,CAAAH,CAAA,CAEyC,IAFxC,CACdI,aAAa,CAAbA,CACkB,CAAC,CAAAJ,CAAA,CACnB,KAAM,CAAAK,CAAU,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,UAAU,CAAC,CAE5D,GAAI,CAACF,CAAU,EAAI,CAAC,IAAI,CAACJ,WAAW,CAClC,MAAO,GAAAO,SAAE,IAAM,CAAC,CACjB,KAEK,CAAEC,MAAM,CAANA,CAAO,CAAC,CAAGJ,CAAU,CAKvBK,CAAY,CAAG,CAACD,CAAM,CAACE,MAAM,CAEnC,OAAQ,IAAI,CAACV,WAAW,EACtB,IAAK,CAAAW,kBAAW,CAACC,GAAG,CAClB,MAAO,GAAAL,SAAE,EAACE,CAAY,CAAC,CACzB,IAAK,CAAAE,kBAAW,CAACE,SAAS,CACxB,MAAO,GAAAN,SAAE,EAAC,CAACE,CAAY,CAAC,CAC1B,QACE,GAAAK,4BAAY,EAAC,IAAI,CAACd,WAAW,CACjC,CACF,CACF,CAACe,OAAA,CAAAlB,UAAA,CAAAA,UAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SameDayVisits=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_types=require("../types");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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class SameDayVisits{constructor(a){let{matchType:b,visitCount:c}=a;_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=b,this.conditionValue=c}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.VisitsData];if(!c)return(0,_tsRes.Ok)(!1);let d=0;const e=new Date().setHours(0,0,0,0),{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SameDayVisits=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_types=require("../types");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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class SameDayVisits{constructor(a){let{matchType:b,visitCount:c}=a;_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=b,this.conditionValue=c}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.VisitsData];if(!c)return(0,_tsRes.Ok)(!1);let d=0;const e=new Date().setHours(0,0,0,0),{visits:f}=c;return f.forEach(a=>{a>e&&d++}),d+=1,(0,_tsRes.Ok)(this.checkCondition(d))}checkCondition(a){if(!this.matchType||"number"!=typeof this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.EQUAL:return a===this.conditionValue;case _types.MatchType.GREATER:return a>this.conditionValue;case _types.MatchType.LOWER:return a<this.conditionValue;default:return!1}}}exports.SameDayVisits=SameDayVisits;
|
|
2
2
|
//# sourceMappingURL=sameDayVisits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sameDayVisits.js","names":["SameDayVisits","constructor","a","matchType","visitCount","_defineProperty","conditionValue","evaluate","targetingData","visitsData","KameleoonData","VisitsData","Ok","todayVisits","todayTimestamp","Date","setHours","
|
|
1
|
+
{"version":3,"file":"sameDayVisits.js","names":["SameDayVisits","constructor","a","matchType","visitCount","_defineProperty","conditionValue","evaluate","targetingData","visitsData","KameleoonData","VisitsData","Ok","todayVisits","todayTimestamp","Date","setHours","visits","forEach","timestamp","checkCondition","todayVisitsAmount","MatchType","EQUAL","GREATER","LOWER","exports"],"sources":["../../../src/targeting/conditions/sameDayVisits.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class SameDayVisits implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: number | null;\n\n constructor({ matchType, visitCount }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = visitCount;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const visitsData = targetingData?.[KameleoonData.VisitsData];\n\n if (!visitsData) {\n return Ok(false);\n }\n\n let todayVisits = 0;\n\n const todayTimestamp = new Date().setHours(0, 0, 0, 0);\n const { visits } = visitsData;\n\n visits.forEach((timestamp) => {\n if (timestamp > todayTimestamp) {\n todayVisits++;\n }\n });\n\n // --- Note ---\n // +1 is current visit\n todayVisits += 1;\n\n return Ok(this.checkCondition(todayVisits));\n }\n\n private checkCondition(todayVisitsAmount: number): boolean {\n if (!this.matchType || typeof this.conditionValue !== 'number') {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.EQUAL:\n return todayVisitsAmount === this.conditionValue;\n case MatchType.GREATER:\n return todayVisitsAmount > this.conditionValue;\n case MatchType.LOWER:\n return todayVisitsAmount < this.conditionValue;\n default:\n return false;\n }\n }\n}\n"],"mappings":"0sBAMO,KAAM,CAAAA,aAAoC,CAI/CC,WAAWA,CAAAC,CAAA,CAA+C,IAA9C,CAAEC,SAAS,CAATA,CAAS,CAAEC,UAAU,CAAVA,CAA8B,CAAC,CAAAF,CAAA,CAAAG,eAAA,0BAAAA,eAAA,+BACtD,IAAI,CAACF,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACG,cAAc,CAAGF,CACxB,CAEOG,QAAQA,CAAAL,CAAA,CAEyC,IAFxC,CACdM,aAAa,CAAbA,CACkB,CAAC,CAAAN,CAAA,CACnB,KAAM,CAAAO,CAAU,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,UAAU,CAAC,CAE5D,GAAI,CAACF,CAAU,CACb,MAAO,GAAAG,SAAE,IAAM,CAAC,CAGlB,GAAI,CAAAC,CAAW,CAAG,CAAC,CAAC,KAEd,CAAAC,CAAc,CAAG,GAAI,CAAAC,IAAI,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAAE,CAAC,CAAE,CAAC,CAAE,CAAC,CAAC,CAChD,CAAEC,MAAM,CAANA,CAAO,CAAC,CAAGR,CAAU,CAY7B,MAVA,CAAAQ,CAAM,CAACC,OAAO,CAAEC,CAAS,EAAK,CACxBA,CAAS,CAAGL,CAAc,EAC5BD,CAAW,EAEf,CAAC,CAAC,CAIFA,CAAW,EAAI,CAAC,CAET,GAAAD,SAAE,EAAC,IAAI,CAACQ,cAAc,CAACP,CAAW,CAAC,CAC5C,CAEQO,cAAcA,CAACC,CAAyB,CAAW,CACzD,GAAI,CAAC,IAAI,CAAClB,SAAS,EAAmC,QAAQ,EAAvC,MAAO,KAAI,CAACG,cAA2B,CAC5D,SAGF,OAAQ,IAAI,CAACH,SAAS,EACpB,IAAK,CAAAmB,gBAAS,CAACC,KAAK,CAClB,MAAO,CAAAF,CAAiB,GAAK,IAAI,CAACf,cAAc,CAClD,IAAK,CAAAgB,gBAAS,CAACE,OAAO,CACpB,MAAO,CAAAH,CAAiB,CAAG,IAAI,CAACf,cAAc,CAChD,IAAK,CAAAgB,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAAJ,CAAiB,CAAG,IAAI,CAACf,cAAc,CAChD,QACE,QACJ,CACF,CACF,CAACoB,OAAA,CAAA1B,aAAA,CAAAA,aAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _tsRes=require("ts-res");Object.defineProperty(exports,"__esModule",{value:!0}),exports.TargetFeatureFlag=void 0;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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class TargetFeatureFlag{constructor(a){let{featureFlagId:b,variationKey:c,ruleId:d}=a;_defineProperty(this,"featureId",void 0),_defineProperty(this,"ruleId",void 0),_defineProperty(this,"variationKey",void 0),this.featureId=b,this.ruleId=d,this.variationKey=c}evaluate(a){let{variationData:b,ruleMap:c}=a;if(!this.featureId||!c)return(0,_tsRes.Ok)(!1);if(this.featureId&&!this.ruleId&&!this.variationKey){for(const[a
|
|
1
|
+
"use strict";var _tsRes=require("ts-res");Object.defineProperty(exports,"__esModule",{value:!0}),exports.TargetFeatureFlag=void 0;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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class TargetFeatureFlag{constructor(a){let{featureFlagId:b,variationKey:c,ruleId:d}=a;_defineProperty(this,"featureId",void 0),_defineProperty(this,"ruleId",void 0),_defineProperty(this,"variationKey",void 0),this.featureId=b,this.ruleId=d,this.variationKey=c}evaluate(a){let{variationData:b,ruleMap:c}=a;if(!this.featureId||!c)return(0,_tsRes.Ok)(!1);if(this.featureId&&!this.ruleId&&!this.variationKey){for(const[_,a]of c){var d;const{featureId:c,experimentId:e}=a;if(c===this.featureId&&"number"==typeof(null===(d=b[e])||void 0===d?void 0:d.variationId))return(0,_tsRes.Ok)(!0)}return(0,_tsRes.Ok)(!1)}if(this.featureId&&this.ruleId){var e;const a=c.get(this.ruleId);if(!a)return(0,_tsRes.Ok)(!1);const{experimentId:d,variations:g}=a;if(this.variationKey){var f;const a=g.get(this.variationKey);return(0,_tsRes.Ok)(!!a&&(null===(f=b[d])||void 0===f?void 0:f.variationId)===a)}return(0,_tsRes.Ok)(null!==(e=b[a.experimentId])&&void 0!==e&&e.variationId)}if(this.featureId&&!this.ruleId&&this.variationKey)for(const[_,a]of c){const{featureId:c,experimentId:d,variations:e}=a;if(c===this.featureId&&e.has(this.variationKey)){var g;const a=e.get(this.variationKey);return(0,_tsRes.Ok)(!!a&&(null===(g=b[d])||void 0===g?void 0:g.variationId)===a)}}return(0,_tsRes.Ok)(!1)}}exports.TargetFeatureFlag=TargetFeatureFlag;
|
|
2
2
|
//# sourceMappingURL=targetFeatureFlag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/targeting/conditions/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { SdkLanguageType } from 'src/constants';\nimport { BrowserType, DeviceType } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport {\n EvaluationDataType,\n MatchType,\n MatchTypeTest,\n MatchTypeVariation,\n NameMatchType,\n TargetingType,\n ValueMatchType,\n VersionMatchType,\n VisitorType,\n} from 'src/targeting/types';\nimport { OperatingSystemType } from 'src/kameleoonData/types';\nimport { TimeUnit } from 'src/utilities';\n\nexport interface ICondition {\n evaluate: (data: EvaluationDataType) => Result<boolean, KameleoonError>;\n}\n\nexport type ConditionType = ICondition;\n\nexport type ConditionDataType = {\n id: number;\n targetingType: TargetingType;\n isInclude: boolean | null;\n weight: number;\n customDataIndex?: string | null;\n pageCount?: number | null;\n value?: string | null;\n valueMatchType?: ValueMatchType | null;\n experiment?: number | null;\n variation?: number | null;\n visitCount?: number | null;\n variationKey?: string | null;\n featureFlagId?: number | null;\n ruleId?: number | null;\n variationMatchType?: MatchTypeVariation | null;\n testMatchType?: MatchTypeTest | null;\n matchType?: MatchType | null;\n device?: DeviceType | null;\n browser?: BrowserType | null;\n os?: OperatingSystemType | null;\n name?: string | null;\n nameMatchType?: NameMatchType | null;\n country?: string | null;\n region?: string | null;\n city?: string | null;\n segmentId?: number | null;\n version?: string | null;\n versionMatchType?: VersionMatchType | null;\n visitorType?: VisitorType | null;\n count?: number | null;\n unitOfTime?: TimeUnit | null;\n title?: string | null;\n url?: string | null;\n goalId?: number | null;\n sdkLanguage?: SdkLanguageType | null;\n visitorCode?: string | null;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/targeting/conditions/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { SdkLanguageType } from 'src/constants';\nimport { BrowserType, DeviceType } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport {\n EvaluationDataType,\n MatchType,\n MatchTypeTest,\n MatchTypeVariation,\n NameMatchType,\n TargetingType,\n ValueMatchType,\n VersionMatchType,\n VisitorType,\n} from 'src/targeting/types';\nimport { OperatingSystemType } from 'src/kameleoonData/types';\nimport { TimeUnit } from 'src/utilities';\n\nexport interface ICondition {\n evaluate: (data: EvaluationDataType) => Result<boolean, KameleoonError>;\n}\n\nexport type ConditionType = ICondition;\n\nexport type ConditionDataType = {\n id: number;\n targetingType: TargetingType;\n isInclude: boolean | null;\n weight: number;\n customDataIndex?: string | null;\n pageCount?: number | null;\n value?: string | null;\n valueMatchType?: ValueMatchType | null;\n experiment?: number | null;\n variation?: number | null;\n visitCount?: number | null;\n variationKey?: string | null;\n featureFlagId?: number | null;\n ruleId?: number | null;\n variationMatchType?: MatchTypeVariation | null;\n testMatchType?: MatchTypeTest | null;\n matchType?: MatchType | null;\n device?: DeviceType | null;\n browser?: BrowserType | null;\n os?: OperatingSystemType | null;\n name?: string | null;\n nameMatchType?: NameMatchType | null;\n country?: string | null;\n region?: string | null;\n city?: string | null;\n segmentId?: number | null;\n version?: string | null;\n versionMatchType?: VersionMatchType | null;\n visitorType?: VisitorType | null;\n count?: number | null;\n unitOfTime?: TimeUnit | null;\n title?: string | null;\n url?: string | null;\n goalId?: number | null;\n sdkLanguage?: SdkLanguageType | null;\n visitorCode?: string | null;\n lowerBound?: number;\n upperBound?: number;\n keyMomentId?: number;\n};\n"],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Visits=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_types=require("../types");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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class Visits{constructor(a){let{matchType:b,visitCount:c}=a;_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=b,this.conditionValue=c}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.VisitsData];if(!c)return(0,_tsRes.Ok)(!1);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Visits=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_types=require("../types");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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class Visits{constructor(a){let{matchType:b,visitCount:c}=a;_defineProperty(this,"matchType",void 0),_defineProperty(this,"conditionValue",void 0),this.matchType=b,this.conditionValue=c}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.VisitsData];if(!c)return(0,_tsRes.Ok)(!1);const d=c.visits.length+1;return(0,_tsRes.Ok)(this.checkCondition(d))}checkCondition(a){if(!this.matchType||"number"!=typeof this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.EQUAL:return a===this.conditionValue;case _types.MatchType.GREATER:return a>this.conditionValue;case _types.MatchType.LOWER:return a<this.conditionValue;default:return!1}}}exports.Visits=Visits;
|
|
2
2
|
//# sourceMappingURL=visits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visits.js","names":["Visits","constructor","a","matchType","visitCount","_defineProperty","conditionValue","evaluate","targetingData","visitsData","KameleoonData","VisitsData","Ok","visits","
|
|
1
|
+
{"version":3,"file":"visits.js","names":["Visits","constructor","a","matchType","visitCount","_defineProperty","conditionValue","evaluate","targetingData","visitsData","KameleoonData","VisitsData","Ok","visits","length","checkCondition","visitsAmount","MatchType","EQUAL","GREATER","LOWER","exports"],"sources":["../../../src/targeting/conditions/visits.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class Visits implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: number | null;\n\n constructor({ matchType, visitCount }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = visitCount;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const visitsData = targetingData?.[KameleoonData.VisitsData];\n\n if (!visitsData) {\n return Ok(false);\n }\n\n // --- Note ---\n // +1 is current visit\n const visits = visitsData.visits.length + 1;\n\n return Ok(this.checkCondition(visits));\n }\n\n private checkCondition(visitsAmount: number): boolean {\n if (!this.matchType || typeof this.conditionValue !== 'number') {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.EQUAL:\n return visitsAmount === this.conditionValue;\n case MatchType.GREATER:\n return visitsAmount > this.conditionValue;\n case MatchType.LOWER:\n return visitsAmount < this.conditionValue;\n default:\n return false;\n }\n }\n}\n"],"mappings":"msBAMO,KAAM,CAAAA,MAA6B,CAIxCC,WAAWA,CAAAC,CAAA,CAA+C,IAA9C,CAAEC,SAAS,CAATA,CAAS,CAAEC,UAAU,CAAVA,CAA8B,CAAC,CAAAF,CAAA,CAAAG,eAAA,0BAAAA,eAAA,+BACtD,IAAI,CAACF,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACG,cAAc,CAAGF,CACxB,CAEOG,QAAQA,CAAAL,CAAA,CAEyC,IAFxC,CACdM,aAAa,CAAbA,CACkB,CAAC,CAAAN,CAAA,CACnB,KAAM,CAAAO,CAAU,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,UAAU,CAAC,CAE5D,GAAI,CAACF,CAAU,CACb,MAAO,GAAAG,SAAE,IAAM,CAAC,CAKlB,KAAM,CAAAC,CAAM,CAAGJ,CAAU,CAACI,MAAM,CAACC,MAAM,CAAG,CAAC,CAE3C,MAAO,GAAAF,SAAE,EAAC,IAAI,CAACG,cAAc,CAACF,CAAM,CAAC,CACvC,CAEQE,cAAcA,CAACC,CAAoB,CAAW,CACpD,GAAI,CAAC,IAAI,CAACb,SAAS,EAAmC,QAAQ,EAAvC,MAAO,KAAI,CAACG,cAA2B,CAC5D,SAGF,OAAQ,IAAI,CAACH,SAAS,EACpB,IAAK,CAAAc,gBAAS,CAACC,KAAK,CAClB,MAAO,CAAAF,CAAY,GAAK,IAAI,CAACV,cAAc,CAC7C,IAAK,CAAAW,gBAAS,CAACE,OAAO,CACpB,MAAO,CAAAH,CAAY,CAAG,IAAI,CAACV,cAAc,CAC3C,IAAK,CAAAW,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAAJ,CAAY,CAAG,IAAI,CAACV,cAAc,CAC3C,QACE,QACJ,CACF,CACF,CAACe,OAAA,CAAArB,MAAA,CAAAA,MAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Tree } from './tree';
|
|
2
|
-
export { Operator, TargetingType, SegmentType, TargetingDataType, EvaluationDataType, ValueMatchType, MatchTypeVariation, MatchType, VersionMatchType, } from './types';
|
|
3
|
-
export { CustomData, ExclusiveCampaign, Browser, PageUrl, PageTitle, Conversion, VisitorCode, SdkLanguage, Device, PreviousPage, VisitedPages, ConditionFactory, TargetFeatureFlag, Cookie, GeolocationCondition, OperatingSystem, Segment, FirstVisit, LastVisit, SameDayVisits, Visits, NewVisitor, } from './conditions';
|
|
2
|
+
export { Operator, TargetingType, SegmentType, TargetingDataType, EvaluationDataType, ValueMatchType, MatchTypeVariation, MatchType, VersionMatchType, VisitorReference, DereferencedTargetingDataType, } from './types';
|
|
3
|
+
export { CustomData, ExclusiveCampaign, Browser, PageUrl, PageTitle, Conversion, VisitorCode, SdkLanguage, Device, PreviousPage, VisitedPages, ConditionFactory, TargetFeatureFlag, Cookie, GeolocationCondition, OperatingSystem, Segment, FirstVisit, LastVisit, SameDayVisits, Visits, ConversionLikelihood, NewVisitor, } from './conditions';
|
package/dist/targeting/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function(){return _conditions.Browser}}),Object.defineProperty(exports,"ConditionFactory",{enumerable:!0,get:function(){return _conditions.ConditionFactory}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function(){return _conditions.Conversion}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function(){return _conditions.Cookie}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function(){return _conditions.CustomData}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function(){return _conditions.Device}}),Object.defineProperty(exports,"EvaluationDataType",{enumerable:!0,get:function(){return _types.EvaluationDataType}}),Object.defineProperty(exports,"ExclusiveCampaign",{enumerable:!0,get:function(){return _conditions.ExclusiveCampaign}}),Object.defineProperty(exports,"FirstVisit",{enumerable:!0,get:function(){return _conditions.FirstVisit}}),Object.defineProperty(exports,"GeolocationCondition",{enumerable:!0,get:function(){return _conditions.GeolocationCondition}}),Object.defineProperty(exports,"LastVisit",{enumerable:!0,get:function(){return _conditions.LastVisit}}),Object.defineProperty(exports,"MatchType",{enumerable:!0,get:function(){return _types.MatchType}}),Object.defineProperty(exports,"MatchTypeVariation",{enumerable:!0,get:function(){return _types.MatchTypeVariation}}),Object.defineProperty(exports,"NewVisitor",{enumerable:!0,get:function(){return _conditions.NewVisitor}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function(){return _conditions.OperatingSystem}}),Object.defineProperty(exports,"Operator",{enumerable:!0,get:function(){return _types.Operator}}),Object.defineProperty(exports,"PageTitle",{enumerable:!0,get:function(){return _conditions.PageTitle}}),Object.defineProperty(exports,"PageUrl",{enumerable:!0,get:function(){return _conditions.PageUrl}}),Object.defineProperty(exports,"PreviousPage",{enumerable:!0,get:function(){return _conditions.PreviousPage}}),Object.defineProperty(exports,"SameDayVisits",{enumerable:!0,get:function(){return _conditions.SameDayVisits}}),Object.defineProperty(exports,"SdkLanguage",{enumerable:!0,get:function(){return _conditions.SdkLanguage}}),Object.defineProperty(exports,"Segment",{enumerable:!0,get:function(){return _conditions.Segment}}),Object.defineProperty(exports,"SegmentType",{enumerable:!0,get:function(){return _types.SegmentType}}),Object.defineProperty(exports,"TargetFeatureFlag",{enumerable:!0,get:function(){return _conditions.TargetFeatureFlag}}),Object.defineProperty(exports,"TargetingDataType",{enumerable:!0,get:function(){return _types.TargetingDataType}}),Object.defineProperty(exports,"TargetingType",{enumerable:!0,get:function(){return _types.TargetingType}}),Object.defineProperty(exports,"Tree",{enumerable:!0,get:function(){return _tree.Tree}}),Object.defineProperty(exports,"ValueMatchType",{enumerable:!0,get:function(){return _types.ValueMatchType}}),Object.defineProperty(exports,"VersionMatchType",{enumerable:!0,get:function(){return _types.VersionMatchType}}),Object.defineProperty(exports,"VisitedPages",{enumerable:!0,get:function(){return _conditions.VisitedPages}}),Object.defineProperty(exports,"VisitorCode",{enumerable:!0,get:function(){return _conditions.VisitorCode}}),Object.defineProperty(exports,"Visits",{enumerable:!0,get:function(){return _conditions.Visits}});var _tree=require("./tree"),_types=require("./types"),_conditions=require("./conditions");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function(){return _conditions.Browser}}),Object.defineProperty(exports,"ConditionFactory",{enumerable:!0,get:function(){return _conditions.ConditionFactory}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function(){return _conditions.Conversion}}),Object.defineProperty(exports,"ConversionLikelihood",{enumerable:!0,get:function(){return _conditions.ConversionLikelihood}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function(){return _conditions.Cookie}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function(){return _conditions.CustomData}}),Object.defineProperty(exports,"DereferencedTargetingDataType",{enumerable:!0,get:function(){return _types.DereferencedTargetingDataType}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function(){return _conditions.Device}}),Object.defineProperty(exports,"EvaluationDataType",{enumerable:!0,get:function(){return _types.EvaluationDataType}}),Object.defineProperty(exports,"ExclusiveCampaign",{enumerable:!0,get:function(){return _conditions.ExclusiveCampaign}}),Object.defineProperty(exports,"FirstVisit",{enumerable:!0,get:function(){return _conditions.FirstVisit}}),Object.defineProperty(exports,"GeolocationCondition",{enumerable:!0,get:function(){return _conditions.GeolocationCondition}}),Object.defineProperty(exports,"LastVisit",{enumerable:!0,get:function(){return _conditions.LastVisit}}),Object.defineProperty(exports,"MatchType",{enumerable:!0,get:function(){return _types.MatchType}}),Object.defineProperty(exports,"MatchTypeVariation",{enumerable:!0,get:function(){return _types.MatchTypeVariation}}),Object.defineProperty(exports,"NewVisitor",{enumerable:!0,get:function(){return _conditions.NewVisitor}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function(){return _conditions.OperatingSystem}}),Object.defineProperty(exports,"Operator",{enumerable:!0,get:function(){return _types.Operator}}),Object.defineProperty(exports,"PageTitle",{enumerable:!0,get:function(){return _conditions.PageTitle}}),Object.defineProperty(exports,"PageUrl",{enumerable:!0,get:function(){return _conditions.PageUrl}}),Object.defineProperty(exports,"PreviousPage",{enumerable:!0,get:function(){return _conditions.PreviousPage}}),Object.defineProperty(exports,"SameDayVisits",{enumerable:!0,get:function(){return _conditions.SameDayVisits}}),Object.defineProperty(exports,"SdkLanguage",{enumerable:!0,get:function(){return _conditions.SdkLanguage}}),Object.defineProperty(exports,"Segment",{enumerable:!0,get:function(){return _conditions.Segment}}),Object.defineProperty(exports,"SegmentType",{enumerable:!0,get:function(){return _types.SegmentType}}),Object.defineProperty(exports,"TargetFeatureFlag",{enumerable:!0,get:function(){return _conditions.TargetFeatureFlag}}),Object.defineProperty(exports,"TargetingDataType",{enumerable:!0,get:function(){return _types.TargetingDataType}}),Object.defineProperty(exports,"TargetingType",{enumerable:!0,get:function(){return _types.TargetingType}}),Object.defineProperty(exports,"Tree",{enumerable:!0,get:function(){return _tree.Tree}}),Object.defineProperty(exports,"ValueMatchType",{enumerable:!0,get:function(){return _types.ValueMatchType}}),Object.defineProperty(exports,"VersionMatchType",{enumerable:!0,get:function(){return _types.VersionMatchType}}),Object.defineProperty(exports,"VisitedPages",{enumerable:!0,get:function(){return _conditions.VisitedPages}}),Object.defineProperty(exports,"VisitorCode",{enumerable:!0,get:function(){return _conditions.VisitorCode}}),Object.defineProperty(exports,"VisitorReference",{enumerable:!0,get:function(){return _types.VisitorReference}}),Object.defineProperty(exports,"Visits",{enumerable:!0,get:function(){return _conditions.Visits}});var _tree=require("./tree"),_types=require("./types"),_conditions=require("./conditions");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/targeting/index.ts"],"sourcesContent":["export { Tree } from './tree';\nexport {\n Operator,\n TargetingType,\n SegmentType,\n TargetingDataType,\n EvaluationDataType,\n ValueMatchType,\n MatchTypeVariation,\n MatchType,\n VersionMatchType,\n} from './types';\nexport {\n CustomData,\n ExclusiveCampaign,\n Browser,\n PageUrl,\n PageTitle,\n Conversion,\n VisitorCode,\n SdkLanguage,\n Device,\n PreviousPage,\n VisitedPages,\n ConditionFactory,\n TargetFeatureFlag,\n Cookie,\n GeolocationCondition,\n OperatingSystem,\n Segment,\n FirstVisit,\n LastVisit,\n SameDayVisits,\n Visits,\n NewVisitor,\n} from './conditions';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/targeting/index.ts"],"sourcesContent":["export { Tree } from './tree';\nexport {\n Operator,\n TargetingType,\n SegmentType,\n TargetingDataType,\n EvaluationDataType,\n ValueMatchType,\n MatchTypeVariation,\n MatchType,\n VersionMatchType,\n VisitorReference,\n DereferencedTargetingDataType,\n} from './types';\nexport {\n CustomData,\n ExclusiveCampaign,\n Browser,\n PageUrl,\n PageTitle,\n Conversion,\n VisitorCode,\n SdkLanguage,\n Device,\n PreviousPage,\n VisitedPages,\n ConditionFactory,\n TargetFeatureFlag,\n Cookie,\n GeolocationCondition,\n OperatingSystem,\n Segment,\n FirstVisit,\n LastVisit,\n SameDayVisits,\n Visits,\n ConversionLikelihood,\n NewVisitor,\n} from './conditions';\n"],"mappings":""}
|
|
@@ -40,7 +40,11 @@ export type GroupedSegmentsType = {
|
|
|
40
40
|
topLevelOperators: Operator[];
|
|
41
41
|
nestedConditions: NestedConditionGroupType[];
|
|
42
42
|
};
|
|
43
|
+
export type VisitorReference = string;
|
|
43
44
|
export type TargetingDataType = {
|
|
45
|
+
[visitorCode: string]: KameleoonVisitorDataType | VisitorReference;
|
|
46
|
+
};
|
|
47
|
+
export type DereferencedTargetingDataType = {
|
|
44
48
|
[visitorCode: string]: KameleoonVisitorDataType;
|
|
45
49
|
};
|
|
46
50
|
export type EvaluationDataType = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["Operator","exports","And","Or","ValueMatchType","TRUE","FALSE","EXACT","CONTAINS","REGULAR_EXPRESSION","EQUAL","LOWER","GREATER","UNDEFINED","AMONG_VALUES","VisitorType","NEW","RETURNING","MatchTypeVariation","ANY","MatchTypeTest","ALL","TEST","PERSO","MatchType","VersionMatchType","NameMatchType","OPTIONAL","TargetingType","PAGE_URL","PAGE_TITLE","LANDING_PAGE","ORIGIN","ORIGIN_TYPE","REFERRERS","NEW_VISITORS","INTERESTS","BROWSER_LANGUAGE","GEOLOCATION","DEVICE_TYPE","SCREEN_DIMENSION","VISITOR_IP","AD_BLOCKER","PREVIOUS_PAGE","KEY_PAGES","PAGE_VIEWS","FIRST_VISIT","LAST_VISIT","ACTIVE_SESSION","TIME_SINCE_PAGE_LOAD","SAME_DAY_VISITS","VISITS","VISITS_BY_PAGE","VISITOR_CODE","SDK_LANGUAGE","INTERNAL_SEARCH_KEYWORDS","TABS_ON_SITE","CONVERSION_PROBABILITY","HEAT_SLICE","SKY_STATUS","TEMPERATURE","DAY_NIGHT","FORECAST_SKY_STATUS","FORECAST_TEMPERATURE","DAY_OF_WEEK","TIME_RANGE","HOUR_MINUTE_RANGE","JS_CODE","COOKIE","EVENT","BROWSER","OPERATING_SYSTEM","DOM_ELEMENT","MOUSE_OUT","TARGET_EXPERIMENT","TARGET_FEATURE_FLAG","TARGET_PERSONALIZATION","EXCLUSIVE_EXPERIMENT","EXCLUSIVE_FEATURE_FLAG","CONVERSIONS","CUSTOM_DATUM","YSANCE_SEGMENT","SEGMENT","YSANCE_ATTRIBUT","TEALIUM_BADGE","TEALIUM_AUDIENCE","PRICE_OF_DISPLAYED_PAGE","NUMBER_OF_VISITED_PAGES","VISITED_PAGES","CUSTOM","EXPLICIT_TRIGGER","APPLICATION_VERSION"],"sources":["../../src/targeting/types.ts"],"sourcesContent":["import { MappedRuleType } from 'src/clientConfiguration/types';\nimport { KameleoonVisitorDataType } from 'src/kameleoonData/types';\nimport { FeatureFlagVariationsType } from 'src/storage/types';\nimport { ExternalPackageInfoType } from 'src/types';\nimport { ConditionDataType, ConditionType } from './conditions';\nimport { Node } from './node';\nimport { Tree } from './tree';\n\nexport enum Operator {\n And = 'AND',\n Or = 'OR',\n}\n\nexport type NonLeafNodeType = {\n left: Node;\n right: Node;\n value: Operator;\n};\n\nexport type LeafNodeType = {\n left: undefined;\n right: undefined;\n value: ConditionType;\n};\n\nexport type NodeValueType = ConditionType | Operator;\n\nexport type ConditionLevelType = {\n orOperators: boolean[];\n conditions: ConditionDataType[];\n};\n\nexport type SegmentType = {\n id: string;\n name: string;\n conditionsData: {\n firstLevelOrOperators: boolean[];\n firstLevel: ConditionLevelType[];\n };\n};\n\nexport type NestedConditionGroupType = {\n operators: Operator[];\n conditions: ConditionDataType[];\n};\n\nexport type GroupedSegmentsType = {\n topLevelOperators: Operator[];\n nestedConditions: NestedConditionGroupType[];\n};\n\nexport type TargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType;\n};\n\nexport type EvaluationDataType = {\n targetingData?: KameleoonVisitorDataType;\n variationData: FeatureFlagVariationsType;\n ruleMap?: Map<number, MappedRuleType>;\n sdkInfo: ExternalPackageInfoType;\n experimentId: number | null;\n visitorCode: string;\n segments?: Map<string, SegmentType>;\n trees?: Map<string, Tree>;\n};\n\nexport enum ValueMatchType {\n TRUE = 'TRUE',\n FALSE = 'FALSE',\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n GREATER = 'GREATER',\n UNDEFINED = 'UNDEFINED',\n AMONG_VALUES = 'AMONG_VALUES',\n}\n\nexport enum VisitorType {\n NEW = 'NEW',\n RETURNING = 'RETURNING',\n}\n\nexport enum MatchTypeVariation {\n ANY = 'ANY',\n EXACT = 'EXACT',\n}\n\nexport enum MatchTypeTest {\n ALL = 'ALL',\n TEST = 'TEST',\n PERSO = 'PERSO',\n}\n\n// --- Note ---\n// Starting the merge of `matchType` with the release of new conditions\n// Now it contains a couple of sub types, in future API version all match types\n// will be accumulated in this enum\nexport enum MatchType {\n // -- Sub Type One\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n // -- Sub Type Two\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum VersionMatchType {\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum NameMatchType {\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n OPTIONAL = 'OPTIONAL',\n}\n\nexport enum TargetingType {\n PAGE_URL = 'PAGE_URL',\n PAGE_TITLE = 'PAGE_TITLE',\n LANDING_PAGE = 'LANDING_PAGE',\n ORIGIN = 'ORIGIN',\n ORIGIN_TYPE = 'ORIGIN_TYPE',\n REFERRERS = 'REFERRERS',\n NEW_VISITORS = 'NEW_VISITORS',\n INTERESTS = 'INTERESTS',\n BROWSER_LANGUAGE = 'BROWSER_LANGUAGE',\n GEOLOCATION = 'GEOLOCATION',\n DEVICE_TYPE = 'DEVICE_TYPE',\n SCREEN_DIMENSION = 'SCREEN_DIMENSION',\n VISITOR_IP = 'VISITOR_IP',\n AD_BLOCKER = 'AD_BLOCKER',\n PREVIOUS_PAGE = 'PREVIOUS_PAGE',\n KEY_PAGES = 'KEY_PAGES',\n PAGE_VIEWS = 'PAGE_VIEWS',\n FIRST_VISIT = 'FIRST_VISIT',\n LAST_VISIT = 'LAST_VISIT',\n ACTIVE_SESSION = 'ACTIVE_SESSION',\n TIME_SINCE_PAGE_LOAD = 'TIME_SINCE_PAGE_LOAD',\n SAME_DAY_VISITS = 'SAME_DAY_VISITS',\n VISITS = 'VISITS',\n VISITS_BY_PAGE = 'VISITS_BY_PAGE',\n VISITOR_CODE = 'VISITOR_CODE',\n SDK_LANGUAGE = 'SDK_LANGUAGE',\n INTERNAL_SEARCH_KEYWORDS = 'INTERNAL_SEARCH_KEYWORDS',\n TABS_ON_SITE = 'TABS_ON_SITE',\n CONVERSION_PROBABILITY = 'CONVERSION_PROBABILITY',\n HEAT_SLICE = 'HEAT_SLICE',\n SKY_STATUS = 'SKY_STATUS',\n TEMPERATURE = 'TEMPERATURE',\n DAY_NIGHT = 'DAY_NIGHT',\n FORECAST_SKY_STATUS = 'FORECAST_SKY_STATUS',\n FORECAST_TEMPERATURE = 'FORECAST_TEMPERATURE',\n DAY_OF_WEEK = 'DAY_OF_WEEK',\n TIME_RANGE = 'TIME_RANGE',\n HOUR_MINUTE_RANGE = 'HOUR_MINUTE_RANGE',\n JS_CODE = 'JS_CODE',\n COOKIE = 'COOKIE',\n EVENT = 'EVENT',\n BROWSER = 'BROWSER',\n OPERATING_SYSTEM = 'OPERATING_SYSTEM',\n DOM_ELEMENT = 'DOM_ELEMENT',\n MOUSE_OUT = 'MOUSE_OUT',\n TARGET_EXPERIMENT = 'TARGET_EXPERIMENT',\n TARGET_FEATURE_FLAG = 'TARGET_FEATURE_FLAG',\n TARGET_PERSONALIZATION = 'TARGET_PERSONALIZATION',\n EXCLUSIVE_EXPERIMENT = 'EXCLUSIVE_EXPERIMENT',\n EXCLUSIVE_FEATURE_FLAG = 'EXCLUSIVE_FEATURE_FLAG',\n CONVERSIONS = 'CONVERSIONS',\n CUSTOM_DATUM = 'CUSTOM_DATUM',\n YSANCE_SEGMENT = 'YSANCE_SEGMENT',\n SEGMENT = 'SEGMENT',\n YSANCE_ATTRIBUT = 'YSANCE_ATTRIBUT',\n TEALIUM_BADGE = 'TEALIUM_BADGE',\n TEALIUM_AUDIENCE = 'TEALIUM_AUDIENCE',\n PRICE_OF_DISPLAYED_PAGE = 'PRICE_OF_DISPLAYED_PAGE',\n NUMBER_OF_VISITED_PAGES = 'NUMBER_OF_VISITED_PAGES',\n VISITED_PAGES = 'VISITED_PAGES',\n CUSTOM = 'CUSTOM',\n EXPLICIT_TRIGGER = 'EXPLICIT_TRIGGER',\n APPLICATION_VERSION = 'APPLICATION_VERSION',\n}\n"],"mappings":"kRAQY,CAAAA,QAAQ,CAAAC,OAAA,CAAAD,QAAA,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAE,GAAA,OAARF,CAAQ,CAAAG,EAAA,MAARH,CAAQ,
|
|
1
|
+
{"version":3,"file":"types.js","names":["Operator","exports","And","Or","ValueMatchType","TRUE","FALSE","EXACT","CONTAINS","REGULAR_EXPRESSION","EQUAL","LOWER","GREATER","UNDEFINED","AMONG_VALUES","VisitorType","NEW","RETURNING","MatchTypeVariation","ANY","MatchTypeTest","ALL","TEST","PERSO","MatchType","VersionMatchType","NameMatchType","OPTIONAL","TargetingType","PAGE_URL","PAGE_TITLE","LANDING_PAGE","ORIGIN","ORIGIN_TYPE","REFERRERS","NEW_VISITORS","INTERESTS","BROWSER_LANGUAGE","GEOLOCATION","DEVICE_TYPE","SCREEN_DIMENSION","VISITOR_IP","AD_BLOCKER","PREVIOUS_PAGE","KEY_PAGES","PAGE_VIEWS","FIRST_VISIT","LAST_VISIT","ACTIVE_SESSION","TIME_SINCE_PAGE_LOAD","SAME_DAY_VISITS","VISITS","VISITS_BY_PAGE","VISITOR_CODE","SDK_LANGUAGE","INTERNAL_SEARCH_KEYWORDS","TABS_ON_SITE","CONVERSION_PROBABILITY","HEAT_SLICE","SKY_STATUS","TEMPERATURE","DAY_NIGHT","FORECAST_SKY_STATUS","FORECAST_TEMPERATURE","DAY_OF_WEEK","TIME_RANGE","HOUR_MINUTE_RANGE","JS_CODE","COOKIE","EVENT","BROWSER","OPERATING_SYSTEM","DOM_ELEMENT","MOUSE_OUT","TARGET_EXPERIMENT","TARGET_FEATURE_FLAG","TARGET_PERSONALIZATION","EXCLUSIVE_EXPERIMENT","EXCLUSIVE_FEATURE_FLAG","CONVERSIONS","CUSTOM_DATUM","YSANCE_SEGMENT","SEGMENT","YSANCE_ATTRIBUT","TEALIUM_BADGE","TEALIUM_AUDIENCE","PRICE_OF_DISPLAYED_PAGE","NUMBER_OF_VISITED_PAGES","VISITED_PAGES","CUSTOM","EXPLICIT_TRIGGER","APPLICATION_VERSION"],"sources":["../../src/targeting/types.ts"],"sourcesContent":["import { MappedRuleType } from 'src/clientConfiguration/types';\nimport { KameleoonVisitorDataType } from 'src/kameleoonData/types';\nimport { FeatureFlagVariationsType } from 'src/storage/types';\nimport { ExternalPackageInfoType } from 'src/types';\nimport { ConditionDataType, ConditionType } from './conditions';\nimport { Node } from './node';\nimport { Tree } from './tree';\n\nexport enum Operator {\n And = 'AND',\n Or = 'OR',\n}\n\nexport type NonLeafNodeType = {\n left: Node;\n right: Node;\n value: Operator;\n};\n\nexport type LeafNodeType = {\n left: undefined;\n right: undefined;\n value: ConditionType;\n};\n\nexport type NodeValueType = ConditionType | Operator;\n\nexport type ConditionLevelType = {\n orOperators: boolean[];\n conditions: ConditionDataType[];\n};\n\nexport type SegmentType = {\n id: string;\n name: string;\n conditionsData: {\n firstLevelOrOperators: boolean[];\n firstLevel: ConditionLevelType[];\n };\n};\n\nexport type NestedConditionGroupType = {\n operators: Operator[];\n conditions: ConditionDataType[];\n};\n\nexport type GroupedSegmentsType = {\n topLevelOperators: Operator[];\n nestedConditions: NestedConditionGroupType[];\n};\n\nexport type VisitorReference = string;\n\nexport type TargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType | VisitorReference;\n};\n\nexport type DereferencedTargetingDataType = {\n [visitorCode: string]: KameleoonVisitorDataType;\n};\n\nexport type EvaluationDataType = {\n targetingData?: KameleoonVisitorDataType;\n variationData: FeatureFlagVariationsType;\n ruleMap?: Map<number, MappedRuleType>;\n sdkInfo: ExternalPackageInfoType;\n experimentId: number | null;\n visitorCode: string;\n segments?: Map<string, SegmentType>;\n trees?: Map<string, Tree>;\n};\n\nexport enum ValueMatchType {\n TRUE = 'TRUE',\n FALSE = 'FALSE',\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n GREATER = 'GREATER',\n UNDEFINED = 'UNDEFINED',\n AMONG_VALUES = 'AMONG_VALUES',\n}\n\nexport enum VisitorType {\n NEW = 'NEW',\n RETURNING = 'RETURNING',\n}\n\nexport enum MatchTypeVariation {\n ANY = 'ANY',\n EXACT = 'EXACT',\n}\n\nexport enum MatchTypeTest {\n ALL = 'ALL',\n TEST = 'TEST',\n PERSO = 'PERSO',\n}\n\n// --- Note ---\n// Starting the merge of `matchType` with the release of new conditions\n// Now it contains a couple of sub types, in future API version all match types\n// will be accumulated in this enum\nexport enum MatchType {\n // -- Sub Type One\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n // -- Sub Type Two\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum VersionMatchType {\n GREATER = 'GREATER',\n EQUAL = 'EQUAL',\n LOWER = 'LOWER',\n}\n\nexport enum NameMatchType {\n EXACT = 'EXACT',\n CONTAINS = 'CONTAINS',\n REGULAR_EXPRESSION = 'REGULAR_EXPRESSION',\n OPTIONAL = 'OPTIONAL',\n}\n\nexport enum TargetingType {\n PAGE_URL = 'PAGE_URL',\n PAGE_TITLE = 'PAGE_TITLE',\n LANDING_PAGE = 'LANDING_PAGE',\n ORIGIN = 'ORIGIN',\n ORIGIN_TYPE = 'ORIGIN_TYPE',\n REFERRERS = 'REFERRERS',\n NEW_VISITORS = 'NEW_VISITORS',\n INTERESTS = 'INTERESTS',\n BROWSER_LANGUAGE = 'BROWSER_LANGUAGE',\n GEOLOCATION = 'GEOLOCATION',\n DEVICE_TYPE = 'DEVICE_TYPE',\n SCREEN_DIMENSION = 'SCREEN_DIMENSION',\n VISITOR_IP = 'VISITOR_IP',\n AD_BLOCKER = 'AD_BLOCKER',\n PREVIOUS_PAGE = 'PREVIOUS_PAGE',\n KEY_PAGES = 'KEY_PAGES',\n PAGE_VIEWS = 'PAGE_VIEWS',\n FIRST_VISIT = 'FIRST_VISIT',\n LAST_VISIT = 'LAST_VISIT',\n ACTIVE_SESSION = 'ACTIVE_SESSION',\n TIME_SINCE_PAGE_LOAD = 'TIME_SINCE_PAGE_LOAD',\n SAME_DAY_VISITS = 'SAME_DAY_VISITS',\n VISITS = 'VISITS',\n VISITS_BY_PAGE = 'VISITS_BY_PAGE',\n VISITOR_CODE = 'VISITOR_CODE',\n SDK_LANGUAGE = 'SDK_LANGUAGE',\n INTERNAL_SEARCH_KEYWORDS = 'INTERNAL_SEARCH_KEYWORDS',\n TABS_ON_SITE = 'TABS_ON_SITE',\n CONVERSION_PROBABILITY = 'CONVERSION_PROBABILITY',\n HEAT_SLICE = 'HEAT_SLICE',\n SKY_STATUS = 'SKY_STATUS',\n TEMPERATURE = 'TEMPERATURE',\n DAY_NIGHT = 'DAY_NIGHT',\n FORECAST_SKY_STATUS = 'FORECAST_SKY_STATUS',\n FORECAST_TEMPERATURE = 'FORECAST_TEMPERATURE',\n DAY_OF_WEEK = 'DAY_OF_WEEK',\n TIME_RANGE = 'TIME_RANGE',\n HOUR_MINUTE_RANGE = 'HOUR_MINUTE_RANGE',\n JS_CODE = 'JS_CODE',\n COOKIE = 'COOKIE',\n EVENT = 'EVENT',\n BROWSER = 'BROWSER',\n OPERATING_SYSTEM = 'OPERATING_SYSTEM',\n DOM_ELEMENT = 'DOM_ELEMENT',\n MOUSE_OUT = 'MOUSE_OUT',\n TARGET_EXPERIMENT = 'TARGET_EXPERIMENT',\n TARGET_FEATURE_FLAG = 'TARGET_FEATURE_FLAG',\n TARGET_PERSONALIZATION = 'TARGET_PERSONALIZATION',\n EXCLUSIVE_EXPERIMENT = 'EXCLUSIVE_EXPERIMENT',\n EXCLUSIVE_FEATURE_FLAG = 'EXCLUSIVE_FEATURE_FLAG',\n CONVERSIONS = 'CONVERSIONS',\n CUSTOM_DATUM = 'CUSTOM_DATUM',\n YSANCE_SEGMENT = 'YSANCE_SEGMENT',\n SEGMENT = 'SEGMENT',\n YSANCE_ATTRIBUT = 'YSANCE_ATTRIBUT',\n TEALIUM_BADGE = 'TEALIUM_BADGE',\n TEALIUM_AUDIENCE = 'TEALIUM_AUDIENCE',\n PRICE_OF_DISPLAYED_PAGE = 'PRICE_OF_DISPLAYED_PAGE',\n NUMBER_OF_VISITED_PAGES = 'NUMBER_OF_VISITED_PAGES',\n VISITED_PAGES = 'VISITED_PAGES',\n CUSTOM = 'CUSTOM',\n EXPLICIT_TRIGGER = 'EXPLICIT_TRIGGER',\n APPLICATION_VERSION = 'APPLICATION_VERSION',\n}\n"],"mappings":"kRAQY,CAAAA,QAAQ,CAAAC,OAAA,CAAAD,QAAA,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAE,GAAA,OAARF,CAAQ,CAAAG,EAAA,MAARH,CAAQ,MAgERI,cAAc,CAAAH,OAAA,CAAAG,cAAA,UAAdA,CAAc,QAAd,CAAAA,CAAc,CAAAC,IAAA,QAAdD,CAAc,CAAAE,KAAA,SAAdF,CAAc,CAAAG,KAAA,SAAdH,CAAc,CAAAI,QAAA,YAAdJ,CAAc,CAAAK,kBAAA,sBAAdL,CAAc,CAAAM,KAAA,SAAdN,CAAc,CAAAO,KAAA,SAAdP,CAAc,CAAAQ,OAAA,WAAdR,CAAc,CAAAS,SAAA,aAAdT,CAAc,CAAAU,YAAA,gBAAdV,CAAc,MAadW,WAAW,CAAAd,OAAA,CAAAc,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,GAAA,OAAXD,CAAW,CAAAE,SAAA,aAAXF,CAAW,MAKXG,kBAAkB,CAAAjB,OAAA,CAAAiB,kBAAA,UAAlBA,CAAkB,QAAlB,CAAAA,CAAkB,CAAAC,GAAA,OAAlBD,CAAkB,CAAAX,KAAA,SAAlBW,CAAkB,MAKlBE,aAAa,CAAAnB,OAAA,CAAAmB,aAAA,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,GAAA,OAAbD,CAAa,CAAAE,IAAA,QAAbF,CAAa,CAAAG,KAAA,SAAbH,CAAa,MAUbI,SAAS,CAAAvB,OAAA,CAAAuB,SAAA,UAATA,CAAS,QAAT,CAAAA,CAAS,CAAAjB,KAAA,SAATiB,CAAS,CAAAhB,QAAA,YAATgB,CAAS,CAAAf,kBAAA,sBAATe,CAAS,CAAAZ,OAAA,WAATY,CAAS,CAAAd,KAAA,SAATc,CAAS,CAAAb,KAAA,SAATa,CAAS,MAWTC,gBAAgB,CAAAxB,OAAA,CAAAwB,gBAAA,UAAhBA,CAAgB,QAAhB,CAAAA,CAAgB,CAAAb,OAAA,WAAhBa,CAAgB,CAAAf,KAAA,SAAhBe,CAAgB,CAAAd,KAAA,SAAhBc,CAAgB,MAMhBC,aAAa,CAAAzB,OAAA,CAAAyB,aAAA,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAnB,KAAA,SAAbmB,CAAa,CAAAlB,QAAA,YAAbkB,CAAa,CAAAjB,kBAAA,sBAAbiB,CAAa,CAAAC,QAAA,YAAbD,CAAa,MAObE,aAAa,CAAA3B,OAAA,CAAA2B,aAAA,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,QAAA,YAAbD,CAAa,CAAAE,UAAA,cAAbF,CAAa,CAAAG,YAAA,gBAAbH,CAAa,CAAAI,MAAA,UAAbJ,CAAa,CAAAK,WAAA,eAAbL,CAAa,CAAAM,SAAA,aAAbN,CAAa,CAAAO,YAAA,gBAAbP,CAAa,CAAAQ,SAAA,aAAbR,CAAa,CAAAS,gBAAA,oBAAbT,CAAa,CAAAU,WAAA,eAAbV,CAAa,CAAAW,WAAA,eAAbX,CAAa,CAAAY,gBAAA,oBAAbZ,CAAa,CAAAa,UAAA,cAAbb,CAAa,CAAAc,UAAA,cAAbd,CAAa,CAAAe,aAAA,iBAAbf,CAAa,CAAAgB,SAAA,aAAbhB,CAAa,CAAAiB,UAAA,cAAbjB,CAAa,CAAAkB,WAAA,eAAblB,CAAa,CAAAmB,UAAA,cAAbnB,CAAa,CAAAoB,cAAA,kBAAbpB,CAAa,CAAAqB,oBAAA,wBAAbrB,CAAa,CAAAsB,eAAA,mBAAbtB,CAAa,CAAAuB,MAAA,UAAbvB,CAAa,CAAAwB,cAAA,kBAAbxB,CAAa,CAAAyB,YAAA,gBAAbzB,CAAa,CAAA0B,YAAA,gBAAb1B,CAAa,CAAA2B,wBAAA,4BAAb3B,CAAa,CAAA4B,YAAA,gBAAb5B,CAAa,CAAA6B,sBAAA,0BAAb7B,CAAa,CAAA8B,UAAA,cAAb9B,CAAa,CAAA+B,UAAA,cAAb/B,CAAa,CAAAgC,WAAA,eAAbhC,CAAa,CAAAiC,SAAA,aAAbjC,CAAa,CAAAkC,mBAAA,uBAAblC,CAAa,CAAAmC,oBAAA,wBAAbnC,CAAa,CAAAoC,WAAA,eAAbpC,CAAa,CAAAqC,UAAA,cAAbrC,CAAa,CAAAsC,iBAAA,qBAAbtC,CAAa,CAAAuC,OAAA,WAAbvC,CAAa,CAAAwC,MAAA,UAAbxC,CAAa,CAAAyC,KAAA,SAAbzC,CAAa,CAAA0C,OAAA,WAAb1C,CAAa,CAAA2C,gBAAA,oBAAb3C,CAAa,CAAA4C,WAAA,eAAb5C,CAAa,CAAA6C,SAAA,aAAb7C,CAAa,CAAA8C,iBAAA,qBAAb9C,CAAa,CAAA+C,mBAAA,uBAAb/C,CAAa,CAAAgD,sBAAA,0BAAbhD,CAAa,CAAAiD,oBAAA,wBAAbjD,CAAa,CAAAkD,sBAAA,0BAAblD,CAAa,CAAAmD,WAAA,eAAbnD,CAAa,CAAAoD,YAAA,gBAAbpD,CAAa,CAAAqD,cAAA,kBAAbrD,CAAa,CAAAsD,OAAA,WAAbtD,CAAa,CAAAuD,eAAA,mBAAbvD,CAAa,CAAAwD,aAAA,iBAAbxD,CAAa,CAAAyD,gBAAA,oBAAbzD,CAAa,CAAA0D,uBAAA,2BAAb1D,CAAa,CAAA2D,uBAAA,2BAAb3D,CAAa,CAAA4D,aAAA,iBAAb5D,CAAa,CAAA6D,MAAA,UAAb7D,CAAa,CAAA8D,gBAAA,oBAAb9D,CAAa,CAAA+D,mBAAA,uBAAb/D,CAAa"}
|
package/dist/types.d.ts
CHANGED
|
@@ -141,11 +141,13 @@ export type TrackConversionParamsType = {
|
|
|
141
141
|
* @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
|
|
142
142
|
* @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`
|
|
143
143
|
* @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved
|
|
144
|
+
* @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`
|
|
144
145
|
* */
|
|
145
146
|
export type RemoteVisitorDataParamsType = {
|
|
146
147
|
visitorCode: string;
|
|
147
148
|
shouldAddData?: boolean;
|
|
148
149
|
filters?: VisitorDataFiltersType;
|
|
150
|
+
isUniqueIdentifier?: boolean;
|
|
149
151
|
};
|
|
150
152
|
export type FeatureFlagType = {
|
|
151
153
|
id: number;
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["Environment","exports","Production","Staging","Development","VariableType","BOOLEAN","NUMBER","STRING","JSON","Milliseconds","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import { ConfigurationDataType, JSONType } from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSource } from './eventSource';\nimport { IExternalRequestDispatcher } from './requester';\nimport { IExternalStorage } from './storage';\nimport { VisitorDataFiltersType } from './utilities';\nimport { IVisitorCodeManager } from './visitorCodeManager';\n\n/**\n * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute\n * @defaultvalue 60\n *\n * @param {Environment} environment - feature flag environment\n * @defaultvalue Environment.Production\n *\n * @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute\n * Note: if not specified, default value will be used\n * @defaultvalue\n * - JavaScript SDK: `undefined` (no cleanup)\n * - React/React Native SDK: `undefined` (no cleanup)\n * - NodeJS SDK: `30`\n *\n * @param {string | undefined} domain - domain which cookie belongs to\n * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests\n * @defaultvalue `10_000` (10 seconds)\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n requestTimeout?: number;\n domain?: string;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType>} configuration - client's configuration\n * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK\n * */\nexport type SDKCoreParameters = {\n siteCode: string;\n configuration?: Partial<SDKConfigurationType>;\n internalConfiguration: InternalSDKConfigurationType;\n};\n\n/**\n * @param {SdkLanguageType} type - type of the SDK\n * @param {string} version - version of the package\n * */\nexport type ExternalPackageInfoType = {\n type: SdkLanguageType;\n version: string;\n};\n\n/**\n * @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization\n * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation\n * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name\n * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration\n * @param {IExternalRequestDispatcher} externalRequestDispatcher - external request dispatcher, used to track data or get data\n * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code\n * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute\n * */\nexport type InternalSDKConfigurationType = {\n externalStorage: IExternalStorage;\n externalEventSource: IExternalEventSource;\n externalVisitorCodeManager: IVisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequestDispatcher: IExternalRequestDispatcher;\n externalClientConfiguration?: ConfigurationDataType;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field\n * */\nexport enum Environment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of feature variable types\n * */\nexport enum VariableType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n STRING = 'STRING',\n JSON = 'JSON',\n}\n\nexport type BooleanVariableType = {\n key: string;\n type: VariableType.BOOLEAN;\n value: boolean;\n};\n\nexport type NumberVariableType = {\n key: string;\n type: VariableType.NUMBER;\n value: number;\n};\n\nexport type StringVariableType = {\n key: string;\n type: VariableType.STRING;\n value: string;\n};\n\nexport type JSONVariableType = {\n key: string;\n type: VariableType.JSON;\n value: JSONType;\n};\n\n/**\n * @type FeatureVariableResultType - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureVariableResultType =\n | BooleanVariableType\n | NumberVariableType\n | StringVariableType\n | JSONVariableType;\n\n/**\n * @type FeatureFlagVariableType - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;\n\n/**\n * @readonly\n * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.\n * Month is considered in average of 30 days\n * */\nexport enum Milliseconds {\n Second = 1000,\n Minute = 60 * Milliseconds.Second,\n Hour = 60 * Milliseconds.Minute,\n Day = 24 * Milliseconds.Hour,\n Week = 7 * Milliseconds.Day,\n Month = 30 * Milliseconds.Day,\n}\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type TrackConversionParamsType = {\n visitorCode: string;\n goalId: number;\n revenue?: number;\n isUniqueIdentifier?: boolean;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n * @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved\n * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform\n * @param {string} variableKey - key of the variable to be found for a feature flag with provided `featureKey`, can be found on Kameleoon Platform\n * */\nexport type GetFeatureFlagVariableParamsType = {\n visitorCode: string;\n featureKey: string;\n variableKey: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} customDataIndex - index of the custom data in the warehouse audience\n * @param {string | undefined} warehouseKey - unique key to identify the warehouse data (usually internal user ID)\n * If not specified, the `visitorCode` will be used as a `warehouseKey`\n * */\nexport type GetVisitorWarehouseAudienceParamsType = {\n visitorCode: string;\n customDataIndex: number;\n warehouseKey?: string;\n};\n\nexport type WarehouseAudienceType = {\n // --- Note ---\n // Using `unknown` type here because we don't care about the type of the value\n warehouseAudiences: Record<string, unknown>;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\n};\n\nexport type SetDataCallbackParametersType = {\n visitorCode: string;\n maxAge: number;\n path: string;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * */\nexport type SetUserConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n setData: ({\n visitorCode,\n maxAge,\n path,\n }: SetDataCallbackParametersType) => void;\n};\n"],"mappings":"4IA4EY,CAAAA,WAAW,CAAAC,OAAA,CAAAD,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAE,UAAA,cAAXF,CAAW,CAAAG,OAAA,WAAXH,CAAW,CAAAI,WAAA,eAAXJ,CAAW,MAUXK,YAAY,CAAAJ,OAAA,CAAAI,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAC,OAAA,WAAZD,CAAY,CAAAE,MAAA,UAAZF,CAAY,CAAAG,MAAA,UAAZH,CAAY,CAAAI,IAAA,QAAZJ,CAAY,MAkDZK,YAAY,CAAAT,OAAA,CAAAS,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAC,MAAA,gBAAZD,CAAY,CAAZA,CAAY,CAAAE,MAAA,CAEb,EAAE,CAAGF,CAAY,CAACC,MAAM,WAFvBD,CAAY,CAAZA,CAAY,CAAAG,IAAA,CAGf,EAAE,CAAGH,CAAY,CAACE,MAAM,SAHrBF,CAAY,CAAZA,CAAY,CAAAI,GAAA,CAIhB,EAAE,CAAGJ,CAAY,CAACG,IAAI,QAJlBH,CAAY,CAAZA,CAAY,CAAAK,IAAA,CAKf,CAAC,CAAGL,CAAY,CAACI,GAAG,SALjBJ,CAAY,CAAZA,CAAY,CAAAM,KAAA,CAMd,EAAE,CAAGN,CAAY,CAACI,GAAG,UANnBJ,CAAY"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["Environment","exports","Production","Staging","Development","VariableType","BOOLEAN","NUMBER","STRING","JSON","Milliseconds","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import { ConfigurationDataType, JSONType } from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSource } from './eventSource';\nimport { IExternalRequestDispatcher } from './requester';\nimport { IExternalStorage } from './storage';\nimport { VisitorDataFiltersType } from './utilities';\nimport { IVisitorCodeManager } from './visitorCodeManager';\n\n/**\n * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute\n * @defaultvalue 60\n *\n * @param {Environment} environment - feature flag environment\n * @defaultvalue Environment.Production\n *\n * @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute\n * Note: if not specified, default value will be used\n * @defaultvalue\n * - JavaScript SDK: `undefined` (no cleanup)\n * - React/React Native SDK: `undefined` (no cleanup)\n * - NodeJS SDK: `30`\n *\n * @param {string | undefined} domain - domain which cookie belongs to\n * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests\n * @defaultvalue `10_000` (10 seconds)\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n requestTimeout?: number;\n domain?: string;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType>} configuration - client's configuration\n * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK\n * */\nexport type SDKCoreParameters = {\n siteCode: string;\n configuration?: Partial<SDKConfigurationType>;\n internalConfiguration: InternalSDKConfigurationType;\n};\n\n/**\n * @param {SdkLanguageType} type - type of the SDK\n * @param {string} version - version of the package\n * */\nexport type ExternalPackageInfoType = {\n type: SdkLanguageType;\n version: string;\n};\n\n/**\n * @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization\n * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation\n * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name\n * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration\n * @param {IExternalRequestDispatcher} externalRequestDispatcher - external request dispatcher, used to track data or get data\n * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code\n * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute\n * */\nexport type InternalSDKConfigurationType = {\n externalStorage: IExternalStorage;\n externalEventSource: IExternalEventSource;\n externalVisitorCodeManager: IVisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequestDispatcher: IExternalRequestDispatcher;\n externalClientConfiguration?: ConfigurationDataType;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field\n * */\nexport enum Environment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of feature variable types\n * */\nexport enum VariableType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n STRING = 'STRING',\n JSON = 'JSON',\n}\n\nexport type BooleanVariableType = {\n key: string;\n type: VariableType.BOOLEAN;\n value: boolean;\n};\n\nexport type NumberVariableType = {\n key: string;\n type: VariableType.NUMBER;\n value: number;\n};\n\nexport type StringVariableType = {\n key: string;\n type: VariableType.STRING;\n value: string;\n};\n\nexport type JSONVariableType = {\n key: string;\n type: VariableType.JSON;\n value: JSONType;\n};\n\n/**\n * @type FeatureVariableResultType - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureVariableResultType =\n | BooleanVariableType\n | NumberVariableType\n | StringVariableType\n | JSONVariableType;\n\n/**\n * @type FeatureFlagVariableType - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;\n\n/**\n * @readonly\n * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.\n * Month is considered in average of 30 days\n * */\nexport enum Milliseconds {\n Second = 1000,\n Minute = 60 * Milliseconds.Second,\n Hour = 60 * Milliseconds.Minute,\n Day = 24 * Milliseconds.Hour,\n Week = 7 * Milliseconds.Day,\n Month = 30 * Milliseconds.Day,\n}\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type TrackConversionParamsType = {\n visitorCode: string;\n goalId: number;\n revenue?: number;\n isUniqueIdentifier?: boolean;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n * @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n isUniqueIdentifier?: boolean;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform\n * @param {string} variableKey - key of the variable to be found for a feature flag with provided `featureKey`, can be found on Kameleoon Platform\n * */\nexport type GetFeatureFlagVariableParamsType = {\n visitorCode: string;\n featureKey: string;\n variableKey: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} customDataIndex - index of the custom data in the warehouse audience\n * @param {string | undefined} warehouseKey - unique key to identify the warehouse data (usually internal user ID)\n * If not specified, the `visitorCode` will be used as a `warehouseKey`\n * */\nexport type GetVisitorWarehouseAudienceParamsType = {\n visitorCode: string;\n customDataIndex: number;\n warehouseKey?: string;\n};\n\nexport type WarehouseAudienceType = {\n // --- Note ---\n // Using `unknown` type here because we don't care about the type of the value\n warehouseAudiences: Record<string, unknown>;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\n};\n\nexport type SetDataCallbackParametersType = {\n visitorCode: string;\n maxAge: number;\n path: string;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * */\nexport type SetUserConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n setData: ({\n visitorCode,\n maxAge,\n path,\n }: SetDataCallbackParametersType) => void;\n};\n"],"mappings":"4IA4EY,CAAAA,WAAW,CAAAC,OAAA,CAAAD,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAE,UAAA,cAAXF,CAAW,CAAAG,OAAA,WAAXH,CAAW,CAAAI,WAAA,eAAXJ,CAAW,MAUXK,YAAY,CAAAJ,OAAA,CAAAI,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAC,OAAA,WAAZD,CAAY,CAAAE,MAAA,UAAZF,CAAY,CAAAG,MAAA,UAAZH,CAAY,CAAAI,IAAA,QAAZJ,CAAY,MAkDZK,YAAY,CAAAT,OAAA,CAAAS,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAC,MAAA,gBAAZD,CAAY,CAAZA,CAAY,CAAAE,MAAA,CAEb,EAAE,CAAGF,CAAY,CAACC,MAAM,WAFvBD,CAAY,CAAZA,CAAY,CAAAG,IAAA,CAGf,EAAE,CAAGH,CAAY,CAACE,MAAM,SAHrBF,CAAY,CAAZA,CAAY,CAAAI,GAAA,CAIhB,EAAE,CAAGJ,CAAY,CAACG,IAAI,QAJlBH,CAAY,CAAZA,CAAY,CAAAK,IAAA,CAKf,CAAC,CAAGL,CAAY,CAACI,GAAG,SALjBJ,CAAY,CAAZA,CAAY,CAAAM,KAAA,CAMd,EAAE,CAAGN,CAAY,CAACI,GAAG,UANnBJ,CAAY"}
|
|
@@ -13,7 +13,7 @@ export type CheckTargetingParametersType = {
|
|
|
13
13
|
experimentId: number | null;
|
|
14
14
|
visitorCode: string;
|
|
15
15
|
packageInfo: ExternalPackageInfoType;
|
|
16
|
-
targetingData
|
|
16
|
+
targetingData?: KameleoonVisitorDataType;
|
|
17
17
|
clientConfiguration: ClientConfiguration;
|
|
18
18
|
variationConfiguration?: VariationConfiguration;
|
|
19
19
|
dataManager: DataManager;
|
|
@@ -38,9 +38,11 @@ export type ParseVisitorDataParametersType = {
|
|
|
38
38
|
data: GetVisitorDataResultType;
|
|
39
39
|
filters: VisitorDataFiltersType;
|
|
40
40
|
visitorCode: string;
|
|
41
|
+
dataManager: DataManager;
|
|
41
42
|
variationConfiguration: VariationConfiguration;
|
|
42
43
|
};
|
|
43
44
|
export type ParseVisitorDataResultType = {
|
|
45
|
+
storageVisitorData: KameleoonDataType[];
|
|
44
46
|
visitorData: KameleoonDataType[];
|
|
45
47
|
visitsData?: KameleoonDataType;
|
|
46
48
|
};
|
|
@@ -125,6 +127,8 @@ export type GetVariationDataUrlParametersType = {
|
|
|
125
127
|
* *Default*: `false`.
|
|
126
128
|
* @param {boolean} experiments - If true, experiment data will be retrieved.
|
|
127
129
|
* *Default*: `false`.
|
|
130
|
+
* @param {boolean} kcs - If true, Kameleoon Conversion Score data will be retrieved.
|
|
131
|
+
* *Default*: `false`.
|
|
128
132
|
* */
|
|
129
133
|
export type VisitorDataFiltersType = {
|
|
130
134
|
previousVisitAmount?: number;
|
|
@@ -137,4 +141,5 @@ export type VisitorDataFiltersType = {
|
|
|
137
141
|
customData?: boolean;
|
|
138
142
|
conversions?: boolean;
|
|
139
143
|
experiments?: boolean;
|
|
144
|
+
kcs?: boolean;
|
|
140
145
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["TimeUnit","exports","Minute","Hour","Day","Week","Month","Order","Ascending","Descending"],"sources":["../../src/utilities/types.ts"],"sourcesContent":["import { CacheManager } from 'src/cacheManager';\nimport { ClientConfiguration } from 'src/clientConfiguration';\nimport { DataManager } from 'src/kameleoonData';\nimport {\n KameleoonDataType,\n KameleoonVisitorDataType,\n} from 'src/kameleoonData/types';\nimport { Requester } from 'src/requester';\nimport {\n GetVisitorDataResultType,\n TrackDataParamsType,\n TrackExperimentParamsType,\n} from 'src/requester/types';\nimport { IStorage, OfflineTracking } from 'src/storage/types';\nimport { SegmentType } from 'src/targeting';\nimport { ExternalPackageInfoType, TrackingCacheItemType } from 'src/types';\nimport {\n VariationConfiguration,\n FeatureFlagVariationType,\n} from 'src/variationConfiguration';\n\nexport type CheckTargetingParametersType = {\n segment: SegmentType | null;\n experimentId: number | null;\n visitorCode: string;\n packageInfo: ExternalPackageInfoType;\n targetingData
|
|
1
|
+
{"version":3,"file":"types.js","names":["TimeUnit","exports","Minute","Hour","Day","Week","Month","Order","Ascending","Descending"],"sources":["../../src/utilities/types.ts"],"sourcesContent":["import { CacheManager } from 'src/cacheManager';\nimport { ClientConfiguration } from 'src/clientConfiguration';\nimport { DataManager } from 'src/kameleoonData';\nimport {\n KameleoonDataType,\n KameleoonVisitorDataType,\n} from 'src/kameleoonData/types';\nimport { Requester } from 'src/requester';\nimport {\n GetVisitorDataResultType,\n TrackDataParamsType,\n TrackExperimentParamsType,\n} from 'src/requester/types';\nimport { IStorage, OfflineTracking } from 'src/storage/types';\nimport { SegmentType } from 'src/targeting';\nimport { ExternalPackageInfoType, TrackingCacheItemType } from 'src/types';\nimport {\n VariationConfiguration,\n FeatureFlagVariationType,\n} from 'src/variationConfiguration';\n\nexport type CheckTargetingParametersType = {\n segment: SegmentType | null;\n experimentId: number | null;\n visitorCode: string;\n packageInfo: ExternalPackageInfoType;\n targetingData?: KameleoonVisitorDataType;\n clientConfiguration: ClientConfiguration;\n variationConfiguration?: VariationConfiguration;\n dataManager: DataManager;\n};\n\nexport enum TimeUnit {\n Minute = 'MINUTE',\n Hour = 'HOUR',\n Day = 'DAY',\n Week = 'WEEK',\n Month = 'MONTH',\n}\n\nexport enum Order {\n Ascending = 'asc',\n Descending = 'desc',\n}\n\nexport type InsertInOrderedListParametersType = {\n list: number[];\n element: number;\n order: Order;\n};\n\nexport type ParseVisitorDataParametersType = {\n data: GetVisitorDataResultType;\n filters: VisitorDataFiltersType;\n visitorCode: string;\n dataManager: DataManager;\n variationConfiguration: VariationConfiguration;\n};\n\nexport type ParseVisitorDataResultType = {\n storageVisitorData: KameleoonDataType[];\n visitorData: KameleoonDataType[];\n visitsData?: KameleoonDataType;\n};\n\nexport type TrackRuleParametersType = {\n featureFlagVariation: FeatureFlagVariationType;\n dataManager: DataManager;\n visitorCode: string;\n requester: Requester;\n isConsentProvided: boolean;\n userAgent?: string;\n isOfflineModeOn?: boolean;\n offlineTrackingStorage: IStorage<OfflineTracking>;\n variationConfiguration: VariationConfiguration;\n};\n\nexport type ManageCacheParametersType = {\n cacheManager: CacheManager<TrackingCacheItemType>;\n visitorCode: string;\n experimentId: number;\n variationId: number;\n};\n\nexport type TrackDataParametersType = {\n visitorCode: string;\n dataManager: DataManager;\n requester: Requester;\n isConsentProvided: boolean;\n isOfflineModeOn?: boolean;\n offlineTrackingStorage: IStorage<OfflineTracking>;\n isMappingIdentifier?: boolean;\n};\n\nexport type TrackExperimentParametersType = {\n clientConfiguration: ClientConfiguration;\n visitorCode: string;\n requester: Requester;\n variationId: number;\n experimentId: number;\n isUnallocated: boolean;\n isOfflineModeOn?: boolean;\n offlineTrackingStorage: IStorage<OfflineTracking>;\n};\n\nexport type AddToOfflineTrackingParametersType = {\n item: TrackExperimentParamsType | TrackDataParamsType;\n isExperiment: boolean;\n storage: IStorage<OfflineTracking>;\n onSuccess?: () => void;\n};\n\nexport type SendOfflineTrackingParametersType = {\n storage: IStorage<OfflineTracking>;\n requester: Requester;\n};\n\nexport type DeleteFromOfflineTrackingParametersType = {\n timestamps: number[];\n storage: IStorage<OfflineTracking>;\n};\n\nexport type GetDataUrlParametersType = {\n visitorCode: string;\n dataManager: DataManager;\n isConsentProvided: boolean;\n};\n\nexport type GetVariationDataUrlParametersType = {\n visitorCode: string;\n isConsentProvided: boolean;\n variationConfiguration: VariationConfiguration;\n};\n\n/**\n * @param {number} previousVisitAmount - Number of previous visits to retrieve data from. Number between `1` and `25`\n * *Default*: `1`.\n * @param {number} currentVisit - If true, current visit data will be retrieved.\n * *Default*: `true`.\n * @param {boolean} customData - If true, custom data will be retrieved.\n * *Default*: `true`.\n * @param {boolean} pageViews - If true, page data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} geolocation - If true, geolocation data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} device - If true, device data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} browser - If true, browser data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} operatingSystem - If true, operating system data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} conversions - If true, conversion data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} experiments - If true, experiment data will be retrieved.\n * *Default*: `false`.\n * @param {boolean} kcs - If true, Kameleoon Conversion Score data will be retrieved.\n * *Default*: `false`.\n * */\nexport type VisitorDataFiltersType = {\n previousVisitAmount?: number;\n currentVisit?: boolean;\n pageViews?: boolean;\n geolocation?: boolean;\n device?: boolean;\n browser?: boolean;\n operatingSystem?: boolean;\n customData?: boolean;\n conversions?: boolean;\n experiments?: boolean;\n kcs?: boolean;\n};\n"],"mappings":"6GAgCY,CAAAA,QAAQ,CAAAC,OAAA,CAAAD,QAAA,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAE,MAAA,UAARF,CAAQ,CAAAG,IAAA,QAARH,CAAQ,CAAAI,GAAA,OAARJ,CAAQ,CAAAK,IAAA,QAARL,CAAQ,CAAAM,KAAA,SAARN,CAAQ,MAQRO,KAAK,CAAAN,OAAA,CAAAM,KAAA,UAALA,CAAK,QAAL,CAAAA,CAAK,CAAAC,SAAA,OAALD,CAAK,CAAAE,UAAA,QAALF,CAAK"}
|
|
@@ -14,7 +14,7 @@ export declare class Utilities {
|
|
|
14
14
|
static trackFeatureExperiment({ featureFlagVariation, dataManager, visitorCode, requester, isOfflineModeOn, isConsentProvided, offlineTrackingStorage, variationConfiguration, }: TrackRuleParametersType): Promise<void>;
|
|
15
15
|
static convertTimeUnit(time: number, timeUnit: TimeUnit): number;
|
|
16
16
|
static parseFeatureVariable(variable: FeatureVariableType): Result<FeatureVariableResultType, KameleoonError>;
|
|
17
|
-
static parseVisitorData({ data, filters, visitorCode, variationConfiguration, }: ParseVisitorDataParametersType): ParseVisitorDataResultType;
|
|
17
|
+
static parseVisitorData({ data, filters, visitorCode, dataManager, variationConfiguration, }: ParseVisitorDataParametersType): ParseVisitorDataResultType;
|
|
18
18
|
static parseRegExp(value: string): RegExp;
|
|
19
19
|
static getUserAgent(visitorCode: string, dataManager: DataManager): string | undefined;
|
|
20
20
|
static isCustomData(dataItem: KameleoonDataType): dataItem is CustomData;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const _excluded=["timestamp","isExperiment"];Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utilities=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),_kameleoonData=require("../kameleoonData"),_constants=require("../constants"),_requester=require("../requester"),_targeting=require("../targeting"),_constants2=require("./constants"),_types2=require("./types");function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return 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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class Utilities{static checkTargeting(a){let{segment:b,visitorCode:c,targetingData:d,experimentId:e,variationConfiguration:f,clientConfiguration:g,packageInfo:h,dataManager:i}=a;if(!b||!b.conditionsData.firstLevel.length)return(0,_tsRes.Ok)(!0);if(!f)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));let j={};const k=f.getStoredVariations(c);k.ok&&(j=k.data);const l=i.getTree(b);let m,n,o;l.hasTargetingType(_targeting.TargetingType.SEGMENT)&&(m=i.trees,n=g.segments),l.hasTargetingType(_targeting.TargetingType.TARGET_FEATURE_FLAG)&&(o=g.ruleMap);const p=l.evaluate({variationData:j,sdkInfo:h,segments:n,ruleMap:o,trees:m,targetingData:d,experimentId:e,visitorCode:c});return p}static validateVisitorCode(a){return 0===a.length?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeEmpty)):a.length>_constants2.VISITOR_CODE_MAX_LENGTH?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeMaxLength)):(0,_tsRes.Ok)()}static getDataUrl(a){function b(a){if(!a.url)return;const b=a.data.type===_kameleoonData.KameleoonData.Conversion;if(e||b){const c=b?"":_requester.UrlParameter.Nonce+Utilities.getNonce();g.push(a.url+c+"\n")}}let{visitorCode:c,dataManager:d,isConsentProvided:e}=a;const f=d.getUnsentData(c),g=[];if(!f||!f.size)return"";for(const c of f.values())Array.isArray(c)?c.forEach(a=>b(a)):b(c);return g.join("")}static getVariationDataUrlAndSentExperimentIds(a){let{visitorCode:b,isConsentProvided:c,variationConfiguration:d}=a;const e=[],f=new Set,g=d.getUnsentData(b);g.ok&&g.data.length&&g.data.forEach(a=>{(a.isTargetedRule||c)&&(e.push(_requester.UrlEventType.Experiment+_requester.UrlParameter.Id+a.experimentId+_requester.UrlParameter.VariationId+a.variationId+_requester.UrlParameter.Nonce+Utilities.getNonce()+"\n"),f.add(a.experimentId+""))});const h=e.join(""),i=Array.from(f);return[h,i]}static async trackFeatureExperiment(a){let{featureFlagVariation:b,dataManager:c,visitorCode:d,requester:e,isOfflineModeOn:f,isConsentProvided:g,offlineTrackingStorage:h,variationConfiguration:i}=a;const{variationId:j,rule:k}=b,l=this.getUserAgent(d,c),m=this.getDataUrl({visitorCode:d,dataManager:c,isConsentProvided:g}),n=k?k.experimentId:0,[o,p]=this.getVariationDataUrlAndSentExperimentIds({visitorCode:d,isConsentProvided:g,variationConfiguration:i});if(!g&&!m&&!k)return;const q={visitorCode:d,dataUrl:m,variationDataUrl:o,experimentId:n,variationId:j||0,userAgent:l,isUnallocated:null===j},r=await e.trackExperiment(q);r.ok&&(g?c.clearUnsentData(d):c.clearUnsentDataByKey(d,_kameleoonData.KameleoonData.Conversion),p.forEach(a=>{i.markUnsentDataAsSent(d,a)})),!r.ok&&f&&this.addItemToOfflineTracking({item:q,storage:h,isExperiment:!0})}static convertTimeUnit(a,b){const c={[_types2.TimeUnit.Minute]:_types.Milliseconds.Minute,[_types2.TimeUnit.Hour]:_types.Milliseconds.Hour,[_types2.TimeUnit.Day]:_types.Milliseconds.Day,[_types2.TimeUnit.Week]:_types.Milliseconds.Week,[_types2.TimeUnit.Month]:_types.Milliseconds.Month};return a/c[b]}static parseFeatureVariable(a){const{key:b,type:c,value:d}=a;switch(c){case _types.VariableType.BOOLEAN:return(0,_tsRes.Ok)({key:b,type:c,value:!!d});case _types.VariableType.STRING:return(0,_tsRes.Ok)({key:b,type:c,value:d+""});case _types.VariableType.NUMBER:const e=+d;return Number.isNaN(e)?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NumberParse,d+"")):(0,_tsRes.Ok)({key:b,type:c,value:e});case _types.VariableType.JSON:try{const d=JSON.parse(a.value+"");return(0,_tsRes.Ok)({key:b,type:c,value:d})}catch(a){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a))}default:(0,_kameleoonError.exhaustCheck)(c)}}static parseVisitorData(a){let{data:b,filters:c,visitorCode:d,variationConfiguration:e}=a;const{currentVisit:f,previousVisits:g}=b,{browser:h,customData:i,operatingSystem:j,conversions:k,device:l,geolocation:m,experiments:n,pageViews:o}=c;let p=[];f&&p.push(f),g&&p.push(...g);const q=[];if(o){const a=_kameleoonData.PageView._listFromVisits(p);a.length&&q.push(...a)}if(h){const a=_kameleoonData.Browser._fromVisits(p);a&&q.push(a)}if(n){const a={};for(let b=p.length-1;0<=b;b--){const c=p[b];if(c.experimentEvents)for(const b of c.experimentEvents){const{id:c,variationId:d}=b.data;a[c]={variationId:d,isTargetedRule:!1,isSent:!1}}}e.updateStoredVariations(d,a)}if(l){const a=_kameleoonData.Device._fromVisits(p);a&&q.push(a)}if(m){const a=_kameleoonData.GeolocationData._fromVisits(p);a&&q.push(a)}if(i&&q.push(..._kameleoonData.CustomData._listFromVisits(p)),j){const a=_kameleoonData.OperatingSystem._fromVisits(p);a&&q.push(a)}k&&q.push(..._kameleoonData.Conversion._listFromVisits(p));let r;const s=_kameleoonData.VisitsData._fromRemoteVisits(p,!!f);return s&&(r=s),{visitorData:q,visitsData:r}}static parseRegExp(a){if("/"===a[0]){const[b,c,d]=a.split("/");return new RegExp(c,d)}return new RegExp(a)}static getUserAgent(a,b){const c=b.storedTargetingData,d=c&&c[a];if(d){const a=d[_kameleoonData.KameleoonData.UserAgent];if(a)return a.value}}static isCustomData(a){return a.data.type===_kameleoonData.KameleoonData.CustomData}static insertInOrderedListMutably(a){let{list:b,element:c,order:d}=a;if(!b.includes(c)){const a=b.findIndex(a=>d===_types2.Order.Ascending?a>=c:a<=c);-1===a?b.push(c):b.splice(a,0,c)}}static updateCache(a){let{cacheManager:b,visitorCode:c,experimentId:d,variationId:e}=a;const f=b.getAliveItem(c),g=f?_objectSpread({},f):{};g[d]={variationId:e,expirationTime:Date.now()+_constants.CACHE_ITEM_LIFETIME*_types.Milliseconds.Second},b.add({key:c,data:g,lifetime:_constants.CACHE_ITEM_LIFETIME})}static getTrackingCode(a,b){let c="window.kameleoonQueue=window.kameleoonQueue||[];";const d=a.getAliveItem(b);if(!d)return c;const e={};return Object.entries(d).forEach(a=>{let[b,{variationId:d,expirationTime:f}]=a;f>Date.now()&&(c+="window.kameleoonQueue.push(['Experiments.assignVariation',".concat(b,",").concat(d,"]);"),c+="window.kameleoonQueue.push(['Experiments.trigger',".concat(b,",true]);"),e[+b]={variationId:d,expirationTime:f})}),a.add({key:b,data:e,lifetime:_constants.CACHE_ITEM_LIFETIME}),c}static async trackData(a){let{visitorCode:b,dataManager:c,requester:d,isOfflineModeOn:e,offlineTrackingStorage:f,isConsentProvided:g,isMappingIdentifier:h}=a;await this.sendOfflineTracking({requester:d,storage:f});const i=this.getDataUrl({visitorCode:b,dataManager:c,isConsentProvided:g});if(!g&&!i)return;const j=this.getUserAgent(b,c),k={visitorCode:b,body:i,userAgent:j,isMappingIdentifier:h},l=await d.trackData(k),m=()=>g?c.clearUnsentData(b):c.clearUnsentDataByKey(b,_kameleoonData.KameleoonData.Conversion);l.ok&&m(),!l.ok&&e&&this.addItemToOfflineTracking({item:k,storage:f,isExperiment:!1,onSuccess:m})}static getNonce(){const a=_constants2.HEX_CHARACTERS.length;let b="";for(let c=0;c<a;c++){const c=Math.floor(Math.random()*a);b+=_constants2.HEX_CHARACTERS.substring(c,c+1)}return b}static compareSemVer(a){let{version:b,compareVersion:c,operator:d}=a;const e=this.validateVersion(b),f=this.validateVersion(c);if(!e.ok)return(0,_tsRes.Err)(e.error);if(!f.ok)return(0,_tsRes.Err)(f.error);const[g,h,i]=e.data,[j,k,l]=f.data,[m,n,o]=[g===j,h===k,i===l];switch(d){case _targeting.VersionMatchType.EQUAL:return(0,_tsRes.Ok)(m&&n&&o);case _targeting.VersionMatchType.GREATER:return(0,_tsRes.Ok)(g>j||m&&h>k||m&&n&&i>l);case _targeting.VersionMatchType.LOWER:return(0,_tsRes.Ok)(g<j||m&&h<k||m&&n&&i<l);default:(0,_kameleoonError.exhaustCheck)(d)}}static generateRandomString(a){const b="abcdefghijklmnopqrstuvwxyz0123456789",c=[];if(0>a)return"";for(let d=0;d<a;d++)c.push(b[Math.floor(Math.random()*b.length)]);return c.join("")}static async sendOfflineTracking(a){let{requester:b,storage:c}=a;const d=c.read();if(d.ok&&d.data.requestParameters){const{requestParameters:a}=d.data,e=[];for(const c of a){const{timestamp:a,isExperiment:d}=c,f=_objectWithoutProperties(c,_excluded);let g;g=d?await b.trackExperiment(f):await b.trackData(f),g.ok&&g.data&&e.push(a)}this.deleteFromOfflineTracking({storage:c,timestamps:e})}}static addItemToOfflineTracking(a){let{item:b,isExperiment:c,storage:d,onSuccess:e}=a;const f=d.read(),g=f.ok?f.data:{},{requestParameters:h}=g,i=_objectSpread(_objectSpread({},b),{},{timestamp:new Date().getTime(),isExperiment:c}),j=h?[...h,i]:[i],k=d.write({requestParameters:j});k.ok&&e&&e()}static deleteFromOfflineTracking(a){let{timestamps:b,storage:c}=a;const d=c.read();if(d.ok){const{requestParameters:a}=d.data,e=null===a||void 0===a?void 0:a.filter(a=>!b.includes(a.timestamp));c.write({requestParameters:e})}}static validateVersion(a){const b=a.split(".").map(a=>parseInt(a,10));for(;3>b.length;)b.push(0);return b.some(a=>isNaN(a))?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.SemanticVersionParse,a)):(0,_tsRes.Ok)(b.slice(0,3))}}exports.Utilities=Utilities;
|
|
1
|
+
"use strict";const _excluded=["timestamp","isExperiment"];Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utilities=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),_kameleoonData=require("../kameleoonData"),_constants=require("../constants"),_requester=require("../requester"),_targeting=require("../targeting"),_visitProcessor=require("../kameleoonData/visitProcessor"),_constants2=require("./constants"),_types2=require("./types");function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return 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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class Utilities{static checkTargeting(a){let{segment:b,visitorCode:c,targetingData:d,experimentId:e,variationConfiguration:f,clientConfiguration:g,packageInfo:h,dataManager:i}=a;if(!b||!b.conditionsData.firstLevel.length)return(0,_tsRes.Ok)(!0);if(!f)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));let j={};const k=f.getStoredVariations(c);k.ok&&(j=k.data);const l=i.getTree(b);let m,n,o;l.hasTargetingType(_targeting.TargetingType.SEGMENT)&&(m=i.trees,n=g.segments),l.hasTargetingType(_targeting.TargetingType.TARGET_FEATURE_FLAG)&&(o=g.ruleMap);const p=l.evaluate({variationData:j,sdkInfo:h,segments:n,ruleMap:o,trees:m,targetingData:d,experimentId:e,visitorCode:c});return p}static validateVisitorCode(a){return 0===a.length?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeEmpty)):a.length>_constants2.VISITOR_CODE_MAX_LENGTH?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeMaxLength)):(0,_tsRes.Ok)()}static getDataUrl(a){function b(a){if(!a.url)return;const b=a.data.type===_kameleoonData.KameleoonData.Conversion;if(e||b){const c=b?"":_requester.UrlParameter.Nonce+Utilities.getNonce();g.push(a.url+c+"\n")}}let{visitorCode:c,dataManager:d,isConsentProvided:e}=a;const f=d.getUnsentData(c),g=[];if(!f||!f.size)return"";for(const c of f.values())Array.isArray(c)?c.forEach(a=>b(a)):b(c);return g.join("")}static getVariationDataUrlAndSentExperimentIds(a){let{visitorCode:b,isConsentProvided:c,variationConfiguration:d}=a;const e=[],f=new Set,g=d.getUnsentData(b);g.ok&&g.data.length&&g.data.forEach(a=>{(a.isTargetedRule||c)&&(e.push(_requester.UrlEventType.Experiment+_requester.UrlParameter.Id+a.experimentId+_requester.UrlParameter.VariationId+a.variationId+_requester.UrlParameter.Nonce+Utilities.getNonce()+"\n"),f.add(a.experimentId+""))});const h=e.join(""),i=Array.from(f);return[h,i]}static async trackFeatureExperiment(a){let{featureFlagVariation:b,dataManager:c,visitorCode:d,requester:e,isOfflineModeOn:f,isConsentProvided:g,offlineTrackingStorage:h,variationConfiguration:i}=a;const{variationId:j,rule:k}=b,l=this.getUserAgent(d,c),m=this.getDataUrl({visitorCode:d,dataManager:c,isConsentProvided:g}),n=k?k.experimentId:0,[o,p]=this.getVariationDataUrlAndSentExperimentIds({visitorCode:d,isConsentProvided:g,variationConfiguration:i});if(!g&&!m&&!k)return;const q={visitorCode:d,dataUrl:m,variationDataUrl:o,experimentId:n,variationId:j||0,userAgent:l,isUnallocated:null===j},r=await e.trackExperiment(q);r.ok&&(g?c.clearUnsentData(d):c.clearUnsentDataByKey(d,_kameleoonData.KameleoonData.Conversion),p.forEach(a=>{i.markUnsentDataAsSent(d,a)})),!r.ok&&f&&this.addItemToOfflineTracking({item:q,storage:h,isExperiment:!0})}static convertTimeUnit(a,b){const c={[_types2.TimeUnit.Minute]:_types.Milliseconds.Minute,[_types2.TimeUnit.Hour]:_types.Milliseconds.Hour,[_types2.TimeUnit.Day]:_types.Milliseconds.Day,[_types2.TimeUnit.Week]:_types.Milliseconds.Week,[_types2.TimeUnit.Month]:_types.Milliseconds.Month};return a/c[b]}static parseFeatureVariable(a){const{key:b,type:c,value:d}=a;switch(c){case _types.VariableType.BOOLEAN:return(0,_tsRes.Ok)({key:b,type:c,value:!!d});case _types.VariableType.STRING:return(0,_tsRes.Ok)({key:b,type:c,value:d+""});case _types.VariableType.NUMBER:const e=+d;return Number.isNaN(e)?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NumberParse,d+"")):(0,_tsRes.Ok)({key:b,type:c,value:e});case _types.VariableType.JSON:try{const d=JSON.parse(a.value+"");return(0,_tsRes.Ok)({key:b,type:c,value:d})}catch(a){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a))}default:(0,_kameleoonError.exhaustCheck)(c)}}static parseVisitorData(a){let{data:b,filters:c,visitorCode:d,dataManager:e,variationConfiguration:f}=a;const g=new _visitProcessor.VisitProcessor(c,e),{currentVisit:h,previousVisits:i,kcs:j}=b;let k=[];const l=c.kcs&&!c.currentVisit;if(h&&!l&&k.push(h),i&&k.push(...i),!k.length&&!l)return{visitorData:[],storageVisitorData:[]};k.forEach(a=>{g.processVisit(a)}),g.processKcs(j),g.processMultipleDataTypes();const{visitorData:m,storageVisitorData:n,visitsData:o,experimentData:p}=g.data;return f.updateStoredVariations(d,p),{visitorData:m,storageVisitorData:n,visitsData:o}}static parseRegExp(a){if("/"===a[0]){const[_,b,c]=a.split("/");return new RegExp(b,c)}return new RegExp(a)}static getUserAgent(a,b){const c=b.getTargetingData(a);if(c){const a=c[_kameleoonData.KameleoonData.UserAgent];if(a)return a.value}}static isCustomData(a){return a.data.type===_kameleoonData.KameleoonData.CustomData}static insertInOrderedListMutably(a){let{list:b,element:c,order:d}=a;if(!b.includes(c)){const a=b.findIndex(a=>d===_types2.Order.Ascending?a>=c:a<=c);-1===a?b.push(c):b.splice(a,0,c)}}static updateCache(a){let{cacheManager:b,visitorCode:c,experimentId:d,variationId:e}=a;const f=b.getAliveItem(c),g=f?_objectSpread({},f):{};g[d]={variationId:e,expirationTime:Date.now()+_constants.CACHE_ITEM_LIFETIME*_types.Milliseconds.Second},b.add({key:c,data:g,lifetime:_constants.CACHE_ITEM_LIFETIME})}static getTrackingCode(a,b){let c="window.kameleoonQueue=window.kameleoonQueue||[];";const d=a.getAliveItem(b);if(!d)return c;const e={};return Object.entries(d).forEach(a=>{let[b,{variationId:d,expirationTime:f}]=a;f>Date.now()&&(c+="window.kameleoonQueue.push(['Experiments.assignVariation',".concat(b,",").concat(d,"]);"),c+="window.kameleoonQueue.push(['Experiments.trigger',".concat(b,",true]);"),e[+b]={variationId:d,expirationTime:f})}),a.add({key:b,data:e,lifetime:_constants.CACHE_ITEM_LIFETIME}),c}static async trackData(a){let{visitorCode:b,dataManager:c,requester:d,isOfflineModeOn:e,offlineTrackingStorage:f,isConsentProvided:g,isMappingIdentifier:h}=a;await this.sendOfflineTracking({requester:d,storage:f});const i=this.getDataUrl({visitorCode:b,dataManager:c,isConsentProvided:g});if(!g&&!i)return;const j=this.getUserAgent(b,c),k={visitorCode:b,body:i,userAgent:j,isMappingIdentifier:h},l=await d.trackData(k),m=()=>g?c.clearUnsentData(b):c.clearUnsentDataByKey(b,_kameleoonData.KameleoonData.Conversion);l.ok&&m(),!l.ok&&e&&this.addItemToOfflineTracking({item:k,storage:f,isExperiment:!1,onSuccess:m})}static getNonce(){const a=_constants2.HEX_CHARACTERS.length;let b="";for(let c=0;c<a;c++){const c=Math.floor(Math.random()*a);b+=_constants2.HEX_CHARACTERS.substring(c,c+1)}return b}static compareSemVer(a){let{version:b,compareVersion:c,operator:d}=a;const e=this.validateVersion(b),f=this.validateVersion(c);if(!e.ok)return(0,_tsRes.Err)(e.error);if(!f.ok)return(0,_tsRes.Err)(f.error);const[g,h,i]=e.data,[j,k,l]=f.data,[m,n,o]=[g===j,h===k,i===l];switch(d){case _targeting.VersionMatchType.EQUAL:return(0,_tsRes.Ok)(m&&n&&o);case _targeting.VersionMatchType.GREATER:return(0,_tsRes.Ok)(g>j||m&&h>k||m&&n&&i>l);case _targeting.VersionMatchType.LOWER:return(0,_tsRes.Ok)(g<j||m&&h<k||m&&n&&i<l);default:(0,_kameleoonError.exhaustCheck)(d)}}static generateRandomString(a){const b="abcdefghijklmnopqrstuvwxyz0123456789",c=[];if(0>a)return"";for(let d=0;d<a;d++)c.push(b[Math.floor(Math.random()*b.length)]);return c.join("")}static async sendOfflineTracking(a){let{requester:b,storage:c}=a;const d=c.read();if(d.ok&&d.data.requestParameters){const{requestParameters:a}=d.data,e=[];for(const c of a){const{timestamp:a,isExperiment:d}=c,f=_objectWithoutProperties(c,_excluded);let g;g=d?await b.trackExperiment(f):await b.trackData(f),g.ok&&g.data&&e.push(a)}this.deleteFromOfflineTracking({storage:c,timestamps:e})}}static addItemToOfflineTracking(a){let{item:b,isExperiment:c,storage:d,onSuccess:e}=a;const f=d.read(),g=f.ok?f.data:{},{requestParameters:h}=g,i=_objectSpread(_objectSpread({},b),{},{timestamp:new Date().getTime(),isExperiment:c}),j=h?[...h,i]:[i],k=d.write({requestParameters:j});k.ok&&e&&e()}static deleteFromOfflineTracking(a){let{timestamps:b,storage:c}=a;const d=c.read();if(d.ok){const{requestParameters:a}=d.data,e=null===a||void 0===a?void 0:a.filter(a=>!b.includes(a.timestamp));c.write({requestParameters:e})}}static validateVersion(a){const b=a.split(".").map(a=>parseInt(a,10));for(;3>b.length;)b.push(0);return b.some(a=>isNaN(a))?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.SemanticVersionParse,a)):(0,_tsRes.Ok)(b.slice(0,3))}}exports.Utilities=Utilities;
|
|
2
2
|
//# sourceMappingURL=utilities.js.map
|