@kameleoon/javascript-sdk-core 5.0.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/targeting/conditions/pageTitle.js +1 -1
- package/dist/targeting/conditions/pageTitle.js.map +1 -1
- package/dist/targeting/conditions/pageUrl.js +1 -1
- package/dist/targeting/conditions/pageUrl.js.map +1 -1
- package/dist/targeting/conditions/utilities.d.ts +5 -0
- package/dist/targeting/conditions/utilities.js +2 -0
- package/dist/targeting/conditions/utilities.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 5.0.1 (2024-11-05)
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed an issue with the [`Page URL`][Targeting Conditions] and [`Page Title`][Targeting Conditions] targeting conditions, where the condition evaluated all previously visited URLs in the session instead of only the current URL, corresponding to the latest added `PageView`
|
|
8
|
+
NOTE: This change may impact your existing targeting. Please review your targeting conditions to ensure accuracy.
|
|
9
|
+
|
|
10
|
+
[Targeting Conditions]: https://developers.kameleoon.com/feature-management-and-experimentation/using-visit-history-in-feature-flags-and-experiments#benefits-of-calling-getremotevisitordata
|
|
11
|
+
|
|
3
12
|
## 5.0.0 (2024-10-03)
|
|
4
13
|
|
|
5
14
|
### Breaking Changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageTitle=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_utilities=require("../../utilities"),_types=require("../types");function _defineProperty(a,b,c){return(b=_toPropertyKey(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 PageTitle{constructor(a){let{matchType:b,title: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.PageView];return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageTitle=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_utilities=require("../../utilities"),_types=require("../types"),_utilities2=require("./utilities");function _defineProperty(a,b,c){return(b=_toPropertyKey(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 PageTitle{constructor(a){let{matchType:b,title: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.PageView];if(!c)return(0,_tsRes.Ok)(!1);const d=_utilities2.PageUtils.getLatest(c);return(0,_tsRes.Ok)(this.checkCondition(d.title))}checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types.MatchType.EXACT:return a===this.conditionValue;case _types.MatchType.REGULAR_EXPRESSION:return _utilities.Parser.parseRegExp(this.conditionValue).test(a);default:return!1}}}exports.PageTitle=PageTitle;
|
|
2
2
|
//# sourceMappingURL=pageTitle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageTitle.js","names":["PageTitle","constructor","a","matchType","title","_defineProperty","conditionValue","evaluate","targetingData","pageViewData","KameleoonData","PageView","Ok","
|
|
1
|
+
{"version":3,"file":"pageTitle.js","names":["PageTitle","constructor","a","matchType","title","_defineProperty","conditionValue","evaluate","targetingData","pageViewData","KameleoonData","PageView","Ok","latestPageView","PageUtils","getLatest","checkCondition","MatchType","CONTAINS","includes","EXACT","REGULAR_EXPRESSION","Parser","parseRegExp","test","exports"],"sources":["../../../src/targeting/conditions/pageTitle.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { Parser } from 'src/utilities';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\nimport { PageUtils } from './utilities';\n\nexport class PageTitle implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: string | null;\n\n constructor({ matchType, title }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = title;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const pageViewData = targetingData?.[KameleoonData.PageView];\n\n if (!pageViewData) {\n return Ok(false);\n }\n\n const latestPageView = PageUtils.getLatest(pageViewData);\n\n return Ok(this.checkCondition(latestPageView.title));\n }\n\n private checkCondition(title: string): boolean {\n if (!this.matchType || !this.conditionValue) {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.CONTAINS:\n return title.includes(this.conditionValue);\n case MatchType.EXACT:\n return title === this.conditionValue;\n case MatchType.REGULAR_EXPRESSION:\n return Parser.parseRegExp(this.conditionValue).test(title);\n default:\n return false;\n }\n }\n}\n"],"mappings":"6wBAQO,KAAM,CAAAA,SAAgC,CAI3CC,WAAWA,CAAAC,CAAA,CAA0C,IAAzC,CAAEC,SAAS,CAATA,CAAS,CAAEC,KAAK,CAALA,CAAyB,CAAC,CAAAF,CAAA,CAAAG,eAAA,0BAAAA,eAAA,+BACjD,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,CAAY,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,QAAQ,CAAC,CAE5D,GAAI,CAACF,CAAY,CACf,MAAO,GAAAG,SAAE,IAAM,CAAC,CAGlB,KAAM,CAAAC,CAAc,CAAGC,qBAAS,CAACC,SAAS,CAACN,CAAY,CAAC,CAExD,MAAO,GAAAG,SAAE,EAAC,IAAI,CAACI,cAAc,CAACH,CAAc,CAACT,KAAK,CAAC,CACrD,CAEQY,cAAcA,CAACZ,CAAa,CAAW,CAC7C,GAAI,CAAC,IAAI,CAACD,SAAS,EAAI,CAAC,IAAI,CAACG,cAAc,CACzC,SAGF,OAAQ,IAAI,CAACH,SAAS,EACpB,IAAK,CAAAc,gBAAS,CAACC,QAAQ,CACrB,MAAO,CAAAd,CAAK,CAACe,QAAQ,CAAC,IAAI,CAACb,cAAc,CAAC,CAC5C,IAAK,CAAAW,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAAhB,CAAK,GAAK,IAAI,CAACE,cAAc,CACtC,IAAK,CAAAW,gBAAS,CAACI,kBAAkB,CAC/B,MAAO,CAAAC,iBAAM,CAACC,WAAW,CAAC,IAAI,CAACjB,cAAc,CAAC,CAACkB,IAAI,CAACpB,CAAK,CAAC,CAC5D,QACE,QACJ,CACF,CACF,CAACqB,OAAA,CAAAzB,SAAA,CAAAA,SAAA","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageUrl=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_utilities=require("../../utilities"),_types=require("../types");function _defineProperty(a,b,c){return(b=_toPropertyKey(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 PageUrl{constructor(a){let{matchType:b,url: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.PageView];return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageUrl=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../../kameleoonData"),_utilities=require("../../utilities"),_types=require("../types"),_utilities2=require("./utilities");function _defineProperty(a,b,c){return(b=_toPropertyKey(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 PageUrl{constructor(a){let{matchType:b,url: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.PageView];if(!c)return(0,_tsRes.Ok)(!1);const d=_utilities2.PageUtils.getLatest(c);return(0,_tsRes.Ok)(this.checkCondition(d.urlAddress))}checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types.MatchType.EXACT:return a===this.conditionValue;case _types.MatchType.REGULAR_EXPRESSION:return _utilities.Parser.parseRegExp(this.conditionValue).test(a);default:return!1}}}exports.PageUrl=PageUrl;
|
|
2
2
|
//# sourceMappingURL=pageUrl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageUrl.js","names":["PageUrl","constructor","a","matchType","url","_defineProperty","conditionValue","evaluate","targetingData","pageViewData","KameleoonData","PageView","Ok","
|
|
1
|
+
{"version":3,"file":"pageUrl.js","names":["PageUrl","constructor","a","matchType","url","_defineProperty","conditionValue","evaluate","targetingData","pageViewData","KameleoonData","PageView","Ok","latestPageView","PageUtils","getLatest","checkCondition","urlAddress","MatchType","CONTAINS","includes","EXACT","REGULAR_EXPRESSION","Parser","parseRegExp","test","exports"],"sources":["../../../src/targeting/conditions/pageUrl.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { Parser } from 'src/utilities';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\nimport { PageUtils } from './utilities';\n\nexport class PageUrl implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: string | null;\n\n constructor({ matchType, url }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = url;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const pageViewData = targetingData?.[KameleoonData.PageView];\n\n if (!pageViewData) {\n return Ok(false);\n }\n\n const latestPageView = PageUtils.getLatest(pageViewData);\n\n return Ok(this.checkCondition(latestPageView.urlAddress));\n }\n\n private checkCondition(url: string): boolean {\n if (!this.matchType || !this.conditionValue) {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.CONTAINS:\n return url.includes(this.conditionValue);\n case MatchType.EXACT:\n return url === this.conditionValue;\n case MatchType.REGULAR_EXPRESSION:\n return Parser.parseRegExp(this.conditionValue).test(url);\n default:\n return false;\n }\n }\n}\n"],"mappings":"2wBAQO,KAAM,CAAAA,OAA8B,CAIzCC,WAAWA,CAAAC,CAAA,CAAwC,IAAvC,CAAEC,SAAS,CAATA,CAAS,CAAEC,GAAG,CAAHA,CAAuB,CAAC,CAAAF,CAAA,CAAAG,eAAA,0BAAAA,eAAA,+BAC/C,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,CAAY,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,QAAQ,CAAC,CAE5D,GAAI,CAACF,CAAY,CACf,MAAO,GAAAG,SAAE,IAAM,CAAC,CAGlB,KAAM,CAAAC,CAAc,CAAGC,qBAAS,CAACC,SAAS,CAACN,CAAY,CAAC,CAExD,MAAO,GAAAG,SAAE,EAAC,IAAI,CAACI,cAAc,CAACH,CAAc,CAACI,UAAU,CAAC,CAC1D,CAEQD,cAAcA,CAACZ,CAAW,CAAW,CAC3C,GAAI,CAAC,IAAI,CAACD,SAAS,EAAI,CAAC,IAAI,CAACG,cAAc,CACzC,SAGF,OAAQ,IAAI,CAACH,SAAS,EACpB,IAAK,CAAAe,gBAAS,CAACC,QAAQ,CACrB,MAAO,CAAAf,CAAG,CAACgB,QAAQ,CAAC,IAAI,CAACd,cAAc,CAAC,CAC1C,IAAK,CAAAY,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAAjB,CAAG,GAAK,IAAI,CAACE,cAAc,CACpC,IAAK,CAAAY,gBAAS,CAACI,kBAAkB,CAC/B,MAAO,CAAAC,iBAAM,CAACC,WAAW,CAAC,IAAI,CAAClB,cAAc,CAAC,CAACmB,IAAI,CAACrB,CAAG,CAAC,CAC1D,QACE,QACJ,CACF,CACF,CAACsB,OAAA,CAAA1B,OAAA,CAAAA,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PageViewDataType } from '../../kameleoonData';
|
|
2
|
+
import { KameleoonData, KameleoonVisitorDataType } from '../../kameleoonData/types';
|
|
3
|
+
export declare class PageUtils {
|
|
4
|
+
static getLatest(pageViewData: NonNullable<KameleoonVisitorDataType[KameleoonData.PageView]>): PageViewDataType;
|
|
5
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageUtils=void 0;class PageUtils{static getLatest(a){return Object.values(a).reduce((a,b)=>a.timestamps[a.timestamps.length-1].time>b.timestamps[b.timestamps.length-1].time?a:b)}}exports.PageUtils=PageUtils;
|
|
2
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.js","names":["PageUtils","getLatest","pageViewData","Object","values","reduce","latest","current","timestamps","length","time","exports"],"sources":["../../../src/targeting/conditions/utilities.ts"],"sourcesContent":["import { PageViewDataType } from 'src/kameleoonData';\nimport {\n KameleoonData,\n KameleoonVisitorDataType,\n} from 'src/kameleoonData/types';\n\nexport class PageUtils {\n public static getLatest(\n pageViewData: NonNullable<KameleoonVisitorDataType[KameleoonData.PageView]>,\n ): PageViewDataType {\n return Object.values(pageViewData).reduce((latest, current) =>\n latest.timestamps[latest.timestamps.length - 1].time >\n current.timestamps[current.timestamps.length - 1].time\n ? latest\n : current,\n );\n }\n}\n"],"mappings":"6FAMO,KAAM,CAAAA,SAAU,CACrB,MAAc,CAAAC,SAASA,CACrBC,CAA2E,CACzD,CAClB,MAAO,CAAAC,MAAM,CAACC,MAAM,CAACF,CAAY,CAAC,CAACG,MAAM,CAAC,CAACC,CAAM,CAAEC,CAAO,GACxDD,CAAM,CAACE,UAAU,CAACF,CAAM,CAACE,UAAU,CAACC,MAAM,CAAG,CAAC,CAAC,CAACC,IAAI,CACpDH,CAAO,CAACC,UAAU,CAACD,CAAO,CAACC,UAAU,CAACC,MAAM,CAAG,CAAC,CAAC,CAACC,IAAI,CAClDJ,CAAM,CACNC,CACN,CACF,CACF,CAACI,OAAA,CAAAX,SAAA,CAAAA,SAAA","ignoreList":[]}
|