@kameleoon/javascript-sdk-core 2.10.1 → 3.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.
Files changed (263) hide show
  1. package/dist/cacheManager/cacheManager.js +1 -11
  2. package/dist/cacheManager/cacheManager.js.map +1 -1
  3. package/dist/clientConfiguration/clientConfiguration.d.ts +55 -0
  4. package/dist/clientConfiguration/clientConfiguration.js +2 -0
  5. package/dist/clientConfiguration/clientConfiguration.js.map +1 -0
  6. package/dist/clientConfiguration/constants.d.ts +2 -0
  7. package/dist/clientConfiguration/constants.js +2 -0
  8. package/dist/clientConfiguration/constants.js.map +1 -0
  9. package/dist/clientConfiguration/index.d.ts +2 -0
  10. package/dist/clientConfiguration/index.js +2 -0
  11. package/dist/clientConfiguration/index.js.map +1 -0
  12. package/dist/{campaignConfiguration → clientConfiguration}/types.d.ts +24 -57
  13. package/dist/clientConfiguration/types.js +2 -0
  14. package/dist/clientConfiguration/types.js.map +1 -0
  15. package/dist/clientSettings/clientSettings.js +1 -1
  16. package/dist/clientSettings/clientSettings.js.map +1 -1
  17. package/dist/constants.d.ts +3 -2
  18. package/dist/constants.js +1 -4
  19. package/dist/constants.js.map +1 -1
  20. package/dist/cookieManager/cookieManager.d.ts +16 -0
  21. package/dist/cookieManager/cookieManager.js +2 -0
  22. package/dist/cookieManager/cookieManager.js.map +1 -0
  23. package/dist/cookieManager/index.d.ts +1 -0
  24. package/dist/cookieManager/index.js +2 -0
  25. package/dist/cookieManager/index.js.map +1 -0
  26. package/dist/eventSource/externalEventSource.js +1 -1
  27. package/dist/eventSource/externalEventSource.js.map +1 -1
  28. package/dist/hasher/hasher.d.ts +2 -3
  29. package/dist/hasher/hasher.js +1 -6
  30. package/dist/hasher/hasher.js.map +1 -1
  31. package/dist/hasher/types.d.ts +3 -10
  32. package/dist/hasher/types.js.map +1 -1
  33. package/dist/index.d.ts +9 -7
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/kameleoonClient.d.ts +75 -80
  37. package/dist/kameleoonClient.js +1 -18
  38. package/dist/kameleoonClient.js.map +1 -1
  39. package/dist/kameleoonData/applicationVersion.d.ts +26 -0
  40. package/dist/kameleoonData/applicationVersion.js +2 -0
  41. package/dist/kameleoonData/applicationVersion.js.map +1 -0
  42. package/dist/kameleoonData/browser.d.ts +16 -1
  43. package/dist/kameleoonData/browser.js +1 -17
  44. package/dist/kameleoonData/browser.js.map +1 -1
  45. package/dist/kameleoonData/constants.d.ts +4 -0
  46. package/dist/kameleoonData/constants.js +2 -0
  47. package/dist/kameleoonData/constants.js.map +1 -0
  48. package/dist/kameleoonData/conversion.d.ts +14 -1
  49. package/dist/kameleoonData/conversion.js +1 -13
  50. package/dist/kameleoonData/conversion.js.map +1 -1
  51. package/dist/kameleoonData/cookie.d.ts +33 -0
  52. package/dist/kameleoonData/cookie.js +2 -0
  53. package/dist/kameleoonData/cookie.js.map +1 -0
  54. package/dist/kameleoonData/customData.d.ts +14 -1
  55. package/dist/kameleoonData/customData.js +1 -24
  56. package/dist/kameleoonData/customData.js.map +1 -1
  57. package/dist/kameleoonData/dataManager.d.ts +39 -0
  58. package/dist/kameleoonData/dataManager.js +2 -0
  59. package/dist/kameleoonData/dataManager.js.map +1 -0
  60. package/dist/kameleoonData/dataProcessor.d.ts +26 -0
  61. package/dist/kameleoonData/dataProcessor.js +2 -0
  62. package/dist/kameleoonData/dataProcessor.js.map +1 -0
  63. package/dist/kameleoonData/device.d.ts +14 -1
  64. package/dist/kameleoonData/device.js +1 -13
  65. package/dist/kameleoonData/device.js.map +1 -1
  66. package/dist/kameleoonData/geolocation.d.ts +52 -0
  67. package/dist/kameleoonData/geolocation.js +2 -0
  68. package/dist/kameleoonData/geolocation.js.map +1 -0
  69. package/dist/kameleoonData/helpers.d.ts +1 -0
  70. package/dist/kameleoonData/helpers.js +2 -0
  71. package/dist/kameleoonData/helpers.js.map +1 -0
  72. package/dist/kameleoonData/index.d.ts +10 -3
  73. package/dist/kameleoonData/index.js +1 -1
  74. package/dist/kameleoonData/index.js.map +1 -1
  75. package/dist/kameleoonData/operatingSystem.d.ts +34 -0
  76. package/dist/kameleoonData/operatingSystem.js +2 -0
  77. package/dist/kameleoonData/operatingSystem.js.map +1 -0
  78. package/dist/kameleoonData/pageView.d.ts +20 -1
  79. package/dist/kameleoonData/pageView.js +1 -13
  80. package/dist/kameleoonData/pageView.js.map +1 -1
  81. package/dist/kameleoonData/types.d.ts +118 -9
  82. package/dist/kameleoonData/types.js +1 -14
  83. package/dist/kameleoonData/types.js.map +1 -1
  84. package/dist/kameleoonData/userAgent.d.ts +6 -1
  85. package/dist/kameleoonData/userAgent.js +1 -8
  86. package/dist/kameleoonData/userAgent.js.map +1 -1
  87. package/dist/kameleoonData/visitsData.d.ts +34 -0
  88. package/dist/{variationConfiguration/variation.js → kameleoonData/visitsData.js} +2 -7
  89. package/dist/kameleoonData/visitsData.js.map +1 -0
  90. package/dist/kameleoonError/constants.d.ts +6 -4
  91. package/dist/kameleoonError/constants.js +1 -1
  92. package/dist/kameleoonError/constants.js.map +1 -1
  93. package/dist/kameleoonError/kameleoonError.d.ts +6 -4
  94. package/dist/kameleoonError/kameleoonError.js +1 -4
  95. package/dist/kameleoonError/kameleoonError.js.map +1 -1
  96. package/dist/kameleoonError/types.d.ts +9 -3
  97. package/dist/kameleoonError/types.js +1 -1
  98. package/dist/kameleoonError/types.js.map +1 -1
  99. package/dist/kameleoonUtils.d.ts +0 -6
  100. package/dist/kameleoonUtils.js +1 -4
  101. package/dist/kameleoonUtils.js.map +1 -1
  102. package/dist/requester/constants.d.ts +5 -3
  103. package/dist/requester/constants.js +1 -1
  104. package/dist/requester/constants.js.map +1 -1
  105. package/dist/requester/index.d.ts +2 -2
  106. package/dist/requester/index.js +1 -1
  107. package/dist/requester/index.js.map +1 -1
  108. package/dist/requester/requester.d.ts +8 -7
  109. package/dist/requester/requester.js +1 -1
  110. package/dist/requester/requester.js.map +1 -1
  111. package/dist/requester/types.d.ts +79 -12
  112. package/dist/requester/types.js +1 -1
  113. package/dist/requester/types.js.map +1 -1
  114. package/dist/storage/constants.d.ts +3 -1
  115. package/dist/storage/constants.js +1 -4
  116. package/dist/storage/constants.js.map +1 -1
  117. package/dist/storage/index.d.ts +1 -1
  118. package/dist/storage/index.js +1 -1
  119. package/dist/storage/index.js.map +1 -1
  120. package/dist/storage/types.d.ts +15 -9
  121. package/dist/storage/types.js.map +1 -1
  122. package/dist/targeting/conditions/applicationVersion.d.ts +10 -0
  123. package/dist/targeting/conditions/applicationVersion.js +2 -0
  124. package/dist/targeting/conditions/applicationVersion.js.map +1 -0
  125. package/dist/targeting/conditions/{browserCondition.d.ts → browser.d.ts} +1 -1
  126. package/dist/targeting/conditions/browser.js +2 -0
  127. package/dist/targeting/conditions/browser.js.map +1 -0
  128. package/dist/targeting/conditions/conditionFactory.js +1 -1
  129. package/dist/targeting/conditions/conditionFactory.js.map +1 -1
  130. package/dist/targeting/conditions/{conversionCondition.d.ts → conversion.d.ts} +1 -2
  131. package/dist/targeting/conditions/conversion.js +2 -0
  132. package/dist/targeting/conditions/conversion.js.map +1 -0
  133. package/dist/targeting/conditions/cookie.d.ts +15 -0
  134. package/dist/targeting/conditions/cookie.js +2 -0
  135. package/dist/targeting/conditions/cookie.js.map +1 -0
  136. package/dist/targeting/conditions/{customDataCondition.d.ts → customData.d.ts} +1 -1
  137. package/dist/targeting/conditions/customData.js +2 -0
  138. package/dist/targeting/conditions/customData.js.map +1 -0
  139. package/dist/targeting/conditions/{deviceCondition.d.ts → device.d.ts} +1 -1
  140. package/dist/targeting/conditions/{targetExperimentCondition.js → device.js} +2 -2
  141. package/dist/targeting/conditions/device.js.map +1 -0
  142. package/dist/targeting/conditions/{exclusiveExperimentCondition.d.ts → exclusiveCampaign.d.ts} +2 -2
  143. package/dist/targeting/conditions/exclusiveCampaign.js +2 -0
  144. package/dist/targeting/conditions/exclusiveCampaign.js.map +1 -0
  145. package/dist/targeting/conditions/firstVisit.d.ts +12 -0
  146. package/dist/targeting/conditions/firstVisit.js +2 -0
  147. package/dist/targeting/conditions/firstVisit.js.map +1 -0
  148. package/dist/targeting/conditions/geolocation.d.ts +11 -0
  149. package/dist/targeting/conditions/geolocation.js +2 -0
  150. package/dist/targeting/conditions/geolocation.js.map +1 -0
  151. package/dist/targeting/conditions/index.d.ts +22 -10
  152. package/dist/targeting/conditions/index.js +1 -1
  153. package/dist/targeting/conditions/index.js.map +1 -1
  154. package/dist/targeting/conditions/lastVisit.d.ts +12 -0
  155. package/dist/targeting/conditions/lastVisit.js +2 -0
  156. package/dist/targeting/conditions/lastVisit.js.map +1 -0
  157. package/dist/targeting/conditions/newVisitor.d.ts +9 -0
  158. package/dist/targeting/conditions/newVisitor.js +2 -0
  159. package/dist/targeting/conditions/newVisitor.js.map +1 -0
  160. package/dist/targeting/conditions/operatingSystem.d.ts +9 -0
  161. package/dist/targeting/conditions/{deviceCondition.js → operatingSystem.js} +2 -2
  162. package/dist/targeting/conditions/operatingSystem.js.map +1 -0
  163. package/dist/targeting/conditions/{pageTitleCondition.d.ts → pageTitle.d.ts} +1 -1
  164. package/dist/targeting/conditions/pageTitle.js +2 -0
  165. package/dist/targeting/conditions/pageTitle.js.map +1 -0
  166. package/dist/targeting/conditions/{pageUrlCondition.d.ts → pageUrl.d.ts} +1 -1
  167. package/dist/targeting/conditions/pageUrl.js +2 -0
  168. package/dist/targeting/conditions/pageUrl.js.map +1 -0
  169. package/dist/targeting/conditions/previousPage.d.ts +12 -0
  170. package/dist/targeting/conditions/previousPage.js +2 -0
  171. package/dist/targeting/conditions/previousPage.js.map +1 -0
  172. package/dist/targeting/conditions/sameDayVisits.d.ts +11 -0
  173. package/dist/targeting/conditions/sameDayVisits.js +2 -0
  174. package/dist/targeting/conditions/sameDayVisits.js.map +1 -0
  175. package/dist/targeting/conditions/{sdkLanguageCondition.d.ts → sdkLanguage.d.ts} +1 -4
  176. package/dist/targeting/conditions/sdkLanguage.js +2 -0
  177. package/dist/targeting/conditions/sdkLanguage.js.map +1 -0
  178. package/dist/targeting/conditions/segment.d.ts +9 -0
  179. package/dist/targeting/conditions/segment.js +2 -0
  180. package/dist/targeting/conditions/segment.js.map +1 -0
  181. package/dist/targeting/conditions/targetFeatureFlag.d.ts +11 -0
  182. package/dist/targeting/conditions/targetFeatureFlag.js +2 -0
  183. package/dist/targeting/conditions/targetFeatureFlag.js.map +1 -0
  184. package/dist/targeting/conditions/types.d.ts +20 -13
  185. package/dist/targeting/conditions/types.js.map +1 -1
  186. package/dist/targeting/conditions/visitedPages.d.ts +11 -0
  187. package/dist/targeting/conditions/visitedPages.js +2 -0
  188. package/dist/targeting/conditions/visitedPages.js.map +1 -0
  189. package/dist/targeting/conditions/{visitorCodeCondition.d.ts → visitorCode.d.ts} +1 -1
  190. package/dist/targeting/conditions/visitorCode.js +2 -0
  191. package/dist/targeting/conditions/visitorCode.js.map +1 -0
  192. package/dist/targeting/conditions/visits.d.ts +11 -0
  193. package/dist/targeting/conditions/visits.js +2 -0
  194. package/dist/targeting/conditions/visits.js.map +1 -0
  195. package/dist/targeting/index.d.ts +3 -3
  196. package/dist/targeting/index.js +1 -1
  197. package/dist/targeting/index.js.map +1 -1
  198. package/dist/targeting/{targetingNode.d.ts → node.d.ts} +7 -7
  199. package/dist/targeting/node.js +2 -0
  200. package/dist/targeting/node.js.map +1 -0
  201. package/dist/targeting/{targetingTree.d.ts → tree.d.ts} +6 -3
  202. package/dist/targeting/tree.js +2 -0
  203. package/dist/targeting/tree.js.map +1 -0
  204. package/dist/targeting/types.d.ts +30 -8
  205. package/dist/targeting/types.js +1 -1
  206. package/dist/targeting/types.js.map +1 -1
  207. package/dist/types.d.ts +61 -18
  208. package/dist/types.js +1 -41
  209. package/dist/types.js.map +1 -1
  210. package/dist/utilities/index.d.ts +1 -0
  211. package/dist/utilities/index.js +1 -1
  212. package/dist/utilities/index.js.map +1 -1
  213. package/dist/utilities/types.d.ts +71 -6
  214. package/dist/utilities/types.js +1 -1
  215. package/dist/utilities/types.js.map +1 -1
  216. package/dist/utilities/utilities.d.ts +30 -11
  217. package/dist/utilities/utilities.js +1 -1
  218. package/dist/utilities/utilities.js.map +1 -1
  219. package/dist/variationConfiguration/index.d.ts +1 -1
  220. package/dist/variationConfiguration/index.js +1 -1
  221. package/dist/variationConfiguration/index.js.map +1 -1
  222. package/dist/variationConfiguration/types.d.ts +6 -12
  223. package/dist/variationConfiguration/types.js.map +1 -1
  224. package/dist/variationConfiguration/variationConfiguration.d.ts +13 -21
  225. package/dist/variationConfiguration/variationConfiguration.js +1 -65
  226. package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
  227. package/package.json +1 -1
  228. package/dist/campaignConfiguration/campaignConfiguration.d.ts +0 -71
  229. package/dist/campaignConfiguration/campaignConfiguration.js +0 -24
  230. package/dist/campaignConfiguration/campaignConfiguration.js.map +0 -1
  231. package/dist/campaignConfiguration/constants.d.ts +0 -6
  232. package/dist/campaignConfiguration/constants.js +0 -4
  233. package/dist/campaignConfiguration/constants.js.map +0 -1
  234. package/dist/campaignConfiguration/index.d.ts +0 -3
  235. package/dist/campaignConfiguration/index.js +0 -2
  236. package/dist/campaignConfiguration/index.js.map +0 -1
  237. package/dist/campaignConfiguration/types.js +0 -2
  238. package/dist/campaignConfiguration/types.js.map +0 -1
  239. package/dist/targeting/conditions/browserCondition.js +0 -2
  240. package/dist/targeting/conditions/browserCondition.js.map +0 -1
  241. package/dist/targeting/conditions/conversionCondition.js +0 -4
  242. package/dist/targeting/conditions/conversionCondition.js.map +0 -1
  243. package/dist/targeting/conditions/customDataCondition.js +0 -8
  244. package/dist/targeting/conditions/customDataCondition.js.map +0 -1
  245. package/dist/targeting/conditions/deviceCondition.js.map +0 -1
  246. package/dist/targeting/conditions/exclusiveExperimentCondition.js +0 -2
  247. package/dist/targeting/conditions/exclusiveExperimentCondition.js.map +0 -1
  248. package/dist/targeting/conditions/pageTitleCondition.js +0 -2
  249. package/dist/targeting/conditions/pageTitleCondition.js.map +0 -1
  250. package/dist/targeting/conditions/pageUrlCondition.js +0 -2
  251. package/dist/targeting/conditions/pageUrlCondition.js.map +0 -1
  252. package/dist/targeting/conditions/sdkLanguageCondition.js +0 -2
  253. package/dist/targeting/conditions/sdkLanguageCondition.js.map +0 -1
  254. package/dist/targeting/conditions/targetExperimentCondition.d.ts +0 -12
  255. package/dist/targeting/conditions/targetExperimentCondition.js.map +0 -1
  256. package/dist/targeting/conditions/visitorCodeCondition.js +0 -2
  257. package/dist/targeting/conditions/visitorCodeCondition.js.map +0 -1
  258. package/dist/targeting/targetingNode.js +0 -2
  259. package/dist/targeting/targetingNode.js.map +0 -1
  260. package/dist/targeting/targetingTree.js +0 -35
  261. package/dist/targeting/targetingTree.js.map +0 -1
  262. package/dist/variationConfiguration/variation.d.ts +0 -13
  263. package/dist/variationConfiguration/variation.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"externalEventSource.js","names":["ExternalEventSource","a","siteCode","externalEventSource","_classCallCheck","_defineProperty","url","URL","SERVER_SENT_EVENTS","UrlQuery","Sse","eventSource","initialize","_createClass","key","value","open","onEvent","eventType","REAL_TIME_EVENT","close","exports"],"sources":["../../src/eventSource/externalEventSource.ts"],"sourcesContent":["import { URL } from 'src/requester';\nimport { UrlQuery } from 'src/requester/constants';\nimport { REAL_TIME_EVENT } from './constants';\nimport { IExternalEventSource, IExternalEventSourceConstructor } from './types';\n\nexport interface IEventSource {\n open: (onEvent: (timestamp: number) => void) => void;\n close: () => void;\n}\n\nexport class ExternalEventSource implements IEventSource {\n private eventSource: IExternalEventSource;\n private siteCode: string;\n\n constructor(\n siteCode: string,\n externalEventSource: IExternalEventSourceConstructor,\n ) {\n const url = URL.SERVER_SENT_EVENTS + UrlQuery.Sse + siteCode;\n const eventSource = externalEventSource.initialize(url);\n\n this.eventSource = eventSource;\n this.siteCode = siteCode;\n }\n\n public open(onEvent: (timestamp: number) => void): void {\n this.eventSource.open({\n onEvent,\n siteCode: this.siteCode,\n eventType: REAL_TIME_EVENT,\n });\n }\n\n public close(): void {\n this.eventSource.close();\n }\n}\n"],"mappings":"08CAUa,CAAAA,mBAAmB,yBAI9B,SAAAC,EACEC,CAAgB,CAChBC,CAAoD,CACpD,CAAAC,eAAA,MAAAH,CAAA,EAAAI,eAAA,4BAAAA,eAAA,4BACM,CAAAC,CAAG,CAAGC,cAAG,CAACC,kBAAkB,CAAGC,mBAAQ,CAACC,GAAG,CAAGR,CAAQ,CACtDS,CAAW,CAAGR,CAAmB,CAACS,UAAU,CAACN,CAAG,CAAC,CAEvD,IAAI,CAACK,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACT,QAAQ,CAAGA,CAClB,CAAC,OAAAW,YAAA,CAAAZ,CAAA,GAAAa,GAAA,QAAAC,KAAA,CAED,SAAAC,KAAYC,CAAoC,CAAQ,CACtD,IAAI,CAACN,WAAW,CAACK,IAAI,CAAC,CACpBC,OAAO,CAAPA,CAAO,CACPf,QAAQ,CAAE,IAAI,CAACA,QAAQ,CACvBgB,SAAS,CAAEC,2BACb,CAAC,CACH,CAAC,GAAAL,GAAA,SAAAC,KAAA,CAED,SAAAK,MAAA,CAAqB,CACnB,IAAI,CAACT,WAAW,CAACS,KAAK,EACxB,CAAC,IAAAnB,CAAA,IAAAoB,OAAA,CAAArB,mBAAA,CAAAA,mBAAA"}
1
+ {"version":3,"file":"externalEventSource.js","names":["ExternalEventSource","a","siteCode","externalEventSource","_classCallCheck","_defineProperty","url","URL","SERVER_SENT_EVENTS","UrlQuery","Sse","eventSource","initialize","_createClass","key","value","open","onEvent","eventType","REAL_TIME_EVENT","close","exports"],"sources":["../../src/eventSource/externalEventSource.ts"],"sourcesContent":["import { URL } from 'src/requester';\nimport { UrlQuery } from 'src/requester/constants';\nimport { REAL_TIME_EVENT } from './constants';\nimport { IExternalEventSource, IExternalEventSourceConstructor } from './types';\n\nexport interface IEventSource {\n open: (onEvent: (timestamp: number) => void) => void;\n close: () => void;\n}\n\nexport class ExternalEventSource implements IEventSource {\n private eventSource: IExternalEventSource;\n private siteCode: string;\n\n constructor(\n siteCode: string,\n externalEventSource: IExternalEventSourceConstructor,\n ) {\n const url = URL.SERVER_SENT_EVENTS + UrlQuery.Sse + siteCode;\n const eventSource = externalEventSource.initialize(url);\n\n this.eventSource = eventSource;\n this.siteCode = siteCode;\n }\n\n public open(onEvent: (timestamp: number) => void): void {\n this.eventSource.open({\n onEvent,\n siteCode: this.siteCode,\n eventType: REAL_TIME_EVENT,\n });\n }\n\n public close(): void {\n this.eventSource.close();\n }\n}\n"],"mappings":"08CAUa,CAAAA,mBAAmB,YAI9B,SAAAC,EACEC,CAAgB,CAChBC,CAAoD,CACpD,CAAAC,eAAA,MAAAH,CAAA,EAAAI,eAAA,4BAAAA,eAAA,4BACM,CAAAC,CAAG,CAAGC,cAAG,CAACC,kBAAkB,CAAGC,mBAAQ,CAACC,GAAG,CAAGR,CAAQ,CACtDS,CAAW,CAAGR,CAAmB,CAACS,UAAU,CAACN,CAAG,CAAC,CAEvD,IAAI,CAACK,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACT,QAAQ,CAAGA,CAClB,CAAC,OAAAW,YAAA,CAAAZ,CAAA,GAAAa,GAAA,QAAAC,KAAA,CAED,SAAAC,KAAYC,CAAoC,CAAQ,CACtD,IAAI,CAACN,WAAW,CAACK,IAAI,CAAC,CACpBC,OAAO,CAAPA,CAAO,CACPf,QAAQ,CAAE,IAAI,CAACA,QAAQ,CACvBgB,SAAS,CAAEC,2BACb,CAAC,CACH,CAAC,GAAAL,GAAA,SAAAC,KAAA,CAED,SAAAK,MAAA,CAAqB,CACnB,IAAI,CAACT,WAAW,CAACS,KAAK,EACxB,CAAC,IAAAnB,CAAA,IAAAoB,OAAA,CAAArB,mBAAA,CAAAA,mBAAA"}
@@ -1,6 +1,5 @@
1
- import { ObtainExperimentHashDoubleParamsType, ObtainFeatureFlagHashDoubleParamsType } from './types';
1
+ import { GetHashDoubleParamsType } from './types';
2
2
  export declare class Hasher {
3
- static obtainExperimentHashDouble({ visitorCode, campaignId, respoolTime, }: ObtainExperimentHashDoubleParamsType): number;
4
- static obtainFeatureFlagHashDouble({ visitorCode, campaignId, respoolTime, }: ObtainFeatureFlagHashDoubleParamsType): number;
3
+ static getHashDouble({ visitorCode, id, respoolTime, }: GetHashDoubleParamsType): number;
5
4
  static calculateHash(seed: string): number;
6
5
  }
@@ -1,7 +1,2 @@
1
- "use strict";var _sha=_interopRequireDefault(require("crypto-js/sha256"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.Hasher=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Hasher=/*#__PURE__*/function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"obtainExperimentHashDouble",value:function obtainExperimentHashDouble(a){var b=a.visitorCode,c=a.campaignId,d=a.respoolTime,e="";return d.length&&d.forEach(function(a){e+=a.value+""}),this.calculateHash(b+c+e)}},{key:"obtainFeatureFlagHashDouble",value:function obtainFeatureFlagHashDouble(a){var b=a.visitorCode,c=a.campaignId,d=a.respoolTime,e="";return d&&(e+=d+""),this.calculateHash(b+c+e)}// --- Note ---
2
- // `hashDouble` is a seeded pseudo-random number between 0 and 1
3
- // used for deciding what variation to assign
4
- // `calculateHash` algorithm is consistent between every SDK
5
- // and will always provide same pseudo-random value for the same input parameters
6
- },{key:"calculateHash",value:function calculateHash(a){var b=(0,_sha.default)(a).toString();return parseInt(b,16)/Math.pow(2,256)}}]),a}();exports.Hasher=Hasher;
1
+ "use strict";var _sha=_interopRequireDefault(require("crypto-js/sha256"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.Hasher=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Hasher=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"getHashDouble",value:function getHashDouble(a){var b=a.visitorCode,c=a.id,d=a.respoolTime,e="";return d&&(e+=d+""),this.calculateHash(b+c+e)}},{key:"calculateHash",value:function calculateHash(a){var b=(0,_sha.default)(a).toString();return parseInt(b,16)/Math.pow(2,256)}}]),a}();exports.Hasher=Hasher;
7
2
  //# sourceMappingURL=hasher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hasher.js","names":["_sha","_interopRequireDefault","require","Object","defineProperty","exports","value","Hasher","a","__esModule","default","_typeof","Symbol","iterator","constructor","prototype","_classCallCheck","b","TypeError","_defineProperties","c","d","length","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","call","String","Number","obtainExperimentHashDouble","visitorCode","campaignId","respoolTime","respoolTimeString","forEach","respoolObject","calculateHash","obtainFeatureFlagHashDouble","suffix","seed","hashDigest","sha256","toString","parseInt","Math","pow"],"sources":["../../src/hasher/hasher.ts"],"sourcesContent":["import sha256 from 'crypto-js/sha256';\nimport {\n ObtainExperimentHashDoubleParamsType,\n ObtainFeatureFlagHashDoubleParamsType,\n} from './types';\n\nexport class Hasher {\n static obtainExperimentHashDouble({\n visitorCode,\n campaignId,\n respoolTime,\n }: ObtainExperimentHashDoubleParamsType): number {\n let respoolTimeString = '';\n\n if (respoolTime.length) {\n respoolTime.forEach((respoolObject) => {\n respoolTimeString += String(respoolObject.value);\n });\n }\n\n return this.calculateHash(visitorCode + campaignId + respoolTimeString);\n }\n\n static obtainFeatureFlagHashDouble({\n visitorCode,\n campaignId,\n respoolTime,\n }: ObtainFeatureFlagHashDoubleParamsType): number {\n let suffix = '';\n\n if (respoolTime) {\n suffix += String(respoolTime);\n }\n\n return this.calculateHash(visitorCode + campaignId + suffix);\n }\n\n // --- Note ---\n // `hashDouble` is a seeded pseudo-random number between 0 and 1\n // used for deciding what variation to assign\n // `calculateHash` algorithm is consistent between every SDK\n // and will always provide same pseudo-random value for the same input parameters\n static calculateHash(seed: string): number {\n const hashDigest = sha256(seed).toString();\n\n return parseInt(hashDigest, 16) / Math.pow(2, 256);\n }\n}\n"],"mappings":"aAAA,IAAAA,IAAA,CAAAC,sBAAA,CAAAC,OAAA,sBAAsCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,MAAA,iBAAAN,uBAAAO,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,EAAAE,OAAA,CAAAF,CAAA,WAAAG,QAAAH,CAAA,mCAAAG,OAAA,oBAAAC,MAAA,mBAAAA,MAAA,CAAAC,QAAA,UAAAL,CAAA,gBAAAA,CAAA,WAAAA,CAAA,SAAAA,CAAA,qBAAAI,MAAA,EAAAJ,CAAA,CAAAM,WAAA,GAAAF,MAAA,EAAAJ,CAAA,GAAAI,MAAA,CAAAG,SAAA,iBAAAP,CAAA,EAAAG,OAAA,CAAAH,CAAA,WAAAQ,gBAAAR,CAAA,CAAAS,CAAA,OAAAT,CAAA,YAAAS,CAAA,YAAAC,SAAA,+CAAAC,kBAAAX,CAAA,CAAAS,CAAA,UAAAG,CAAA,CAAAC,CAAA,GAAAA,CAAA,CAAAJ,CAAA,CAAAK,MAAA,CAAAD,CAAA,GAAAD,CAAA,CAAAH,CAAA,CAAAI,CAAA,EAAAD,CAAA,CAAAG,UAAA,CAAAH,CAAA,CAAAG,UAAA,KAAAH,CAAA,CAAAI,YAAA,cAAAJ,CAAA,GAAAA,CAAA,CAAAK,QAAA,KAAAtB,MAAA,CAAAC,cAAA,CAAAI,CAAA,CAAAkB,cAAA,CAAAN,CAAA,CAAAO,GAAA,EAAAP,CAAA,WAAAQ,aAAApB,CAAA,CAAAS,CAAA,CAAAG,CAAA,SAAAH,CAAA,EAAAE,iBAAA,CAAAX,CAAA,CAAAO,SAAA,CAAAE,CAAA,EAAAG,CAAA,EAAAD,iBAAA,CAAAX,CAAA,CAAAY,CAAA,EAAAjB,MAAA,CAAAC,cAAA,CAAAI,CAAA,cAAAiB,QAAA,MAAAjB,CAAA,UAAAkB,eAAAlB,CAAA,MAAAS,CAAA,CAAAY,YAAA,CAAArB,CAAA,4BAAAG,OAAA,CAAAM,CAAA,EAAAA,CAAA,CAAAA,CAAA,aAAAY,aAAArB,CAAA,CAAAS,CAAA,gBAAAN,OAAA,CAAAH,CAAA,UAAAA,CAAA,QAAAA,CAAA,KAAAY,CAAA,CAAAZ,CAAA,CAAAI,MAAA,CAAAkB,WAAA,KAAAV,CAAA,eAAAC,CAAA,CAAAD,CAAA,CAAAW,IAAA,CAAAvB,CAAA,CAAAS,CAAA,2BAAAN,OAAA,CAAAU,CAAA,SAAAA,CAAA,WAAAH,SAAA,mEAAAD,CAAA,CAAAe,MAAA,CAAAC,MAAA,EAAAzB,CAAA,KAMzB,CAAAD,MAAM,kCAAAC,EAAA,EAAAQ,eAAA,MAAAR,CAAA,SAAAoB,YAAA,CAAApB,CAAA,QAAAmB,GAAA,8BAAArB,KAAA,CACjB,SAAA4B,2BAAA1B,CAAA,CAIiD,IAH/C,CAAA2B,CAAW,CAAA3B,CAAA,CAAX2B,WAAW,CACXC,CAAU,CAAA5B,CAAA,CAAV4B,UAAU,CACVC,CAAW,CAAA7B,CAAA,CAAX6B,WAAW,CAEPC,CAAiB,CAAG,EAAE,CAQ1B,MANI,CAAAD,CAAW,CAACf,MAAM,EACpBe,CAAW,CAACE,OAAO,CAAC,SAACC,CAAa,CAAK,CACrCF,CAAiB,EAAWE,CAAa,CAAClC,KAAK,GACjD,CAAC,CAAC,CAGG,IAAI,CAACmC,aAAa,CAACN,CAAW,CAAGC,CAAU,CAAGE,CAAiB,CACxE,CAAC,GAAAX,GAAA,+BAAArB,KAAA,CAED,SAAAoC,4BAAAlC,CAAA,CAIkD,IAHhD,CAAA2B,CAAW,CAAA3B,CAAA,CAAX2B,WAAW,CACXC,CAAU,CAAA5B,CAAA,CAAV4B,UAAU,CACVC,CAAW,CAAA7B,CAAA,CAAX6B,WAAW,CAEPM,CAAM,CAAG,EAAE,CAMf,MAJI,CAAAN,CAAW,GACbM,CAAM,EAAWN,CAAW,GAAC,EAGxB,IAAI,CAACI,aAAa,CAACN,CAAW,CAAGC,CAAU,CAAGO,CAAM,CAC7D,CAEA;AACA;AACA;AACA;AACA;AAAA,GAAAhB,GAAA,iBAAArB,KAAA,CACA,SAAAmC,cAAqBG,CAAY,CAAU,CACzC,GAAM,CAAAC,CAAU,CAAG,GAAAC,YAAM,EAACF,CAAI,CAAC,CAACG,QAAQ,EAAE,CAE1C,MAAO,CAAAC,QAAQ,CAACH,CAAU,CAAE,EAAE,CAAC,CAAGI,IAAI,CAACC,GAAG,CAAC,CAAC,CAAE,GAAG,CACnD,CAAC,IAAA1C,CAAA,IAAAH,OAAA,CAAAE,MAAA,CAAAA,MAAA"}
1
+ {"version":3,"file":"hasher.js","names":["_sha","_interopRequireDefault","require","Object","defineProperty","exports","value","Hasher","a","__esModule","default","_typeof","Symbol","iterator","constructor","prototype","_classCallCheck","b","TypeError","_defineProperties","c","d","length","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","call","String","Number","getHashDouble","visitorCode","id","respoolTime","suffix","calculateHash","seed","hashDigest","sha256","toString","parseInt","Math","pow"],"sources":["../../src/hasher/hasher.ts"],"sourcesContent":["import sha256 from 'crypto-js/sha256';\nimport { GetHashDoubleParamsType } from './types';\n\nexport class Hasher {\n static getHashDouble({\n visitorCode,\n id,\n respoolTime,\n }: GetHashDoubleParamsType): number {\n let suffix = '';\n\n if (respoolTime) {\n suffix += String(respoolTime);\n }\n\n return this.calculateHash(visitorCode + id + suffix);\n }\n\n // --- Note ---\n // `hashDouble` is a seeded pseudo-random number between 0 and 1\n // used for deciding what variation to assign\n // `calculateHash` algorithm is consistent between every SDK\n // and will always provide same pseudo-random value for the same input parameters\n static calculateHash(seed: string): number {\n const hashDigest = sha256(seed).toString();\n\n return parseInt(hashDigest, 16) / Math.pow(2, 256);\n }\n}\n"],"mappings":"aAAA,IAAAA,IAAA,CAAAC,sBAAA,CAAAC,OAAA,sBAAsCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,MAAA,iBAAAN,uBAAAO,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,EAAAE,OAAA,CAAAF,CAAA,WAAAG,QAAAH,CAAA,mCAAAG,OAAA,oBAAAC,MAAA,mBAAAA,MAAA,CAAAC,QAAA,UAAAL,CAAA,gBAAAA,CAAA,WAAAA,CAAA,SAAAA,CAAA,qBAAAI,MAAA,EAAAJ,CAAA,CAAAM,WAAA,GAAAF,MAAA,EAAAJ,CAAA,GAAAI,MAAA,CAAAG,SAAA,iBAAAP,CAAA,EAAAG,OAAA,CAAAH,CAAA,WAAAQ,gBAAAR,CAAA,CAAAS,CAAA,OAAAT,CAAA,YAAAS,CAAA,YAAAC,SAAA,+CAAAC,kBAAAX,CAAA,CAAAS,CAAA,UAAAG,CAAA,CAAAC,CAAA,GAAAA,CAAA,CAAAJ,CAAA,CAAAK,MAAA,CAAAD,CAAA,GAAAD,CAAA,CAAAH,CAAA,CAAAI,CAAA,EAAAD,CAAA,CAAAG,UAAA,CAAAH,CAAA,CAAAG,UAAA,KAAAH,CAAA,CAAAI,YAAA,cAAAJ,CAAA,GAAAA,CAAA,CAAAK,QAAA,KAAAtB,MAAA,CAAAC,cAAA,CAAAI,CAAA,CAAAkB,cAAA,CAAAN,CAAA,CAAAO,GAAA,EAAAP,CAAA,WAAAQ,aAAApB,CAAA,CAAAS,CAAA,CAAAG,CAAA,SAAAH,CAAA,EAAAE,iBAAA,CAAAX,CAAA,CAAAO,SAAA,CAAAE,CAAA,EAAAG,CAAA,EAAAD,iBAAA,CAAAX,CAAA,CAAAY,CAAA,EAAAjB,MAAA,CAAAC,cAAA,CAAAI,CAAA,cAAAiB,QAAA,MAAAjB,CAAA,UAAAkB,eAAAlB,CAAA,MAAAS,CAAA,CAAAY,YAAA,CAAArB,CAAA,4BAAAG,OAAA,CAAAM,CAAA,EAAAA,CAAA,CAAAA,CAAA,aAAAY,aAAArB,CAAA,CAAAS,CAAA,gBAAAN,OAAA,CAAAH,CAAA,UAAAA,CAAA,QAAAA,CAAA,KAAAY,CAAA,CAAAZ,CAAA,CAAAI,MAAA,CAAAkB,WAAA,KAAAV,CAAA,eAAAC,CAAA,CAAAD,CAAA,CAAAW,IAAA,CAAAvB,CAAA,CAAAS,CAAA,2BAAAN,OAAA,CAAAU,CAAA,SAAAA,CAAA,WAAAH,SAAA,mEAAAD,CAAA,CAAAe,MAAA,CAAAC,MAAA,EAAAzB,CAAA,KAGzB,CAAAD,MAAM,qBAAAC,EAAA,EAAAQ,eAAA,MAAAR,CAAA,SAAAoB,YAAA,CAAApB,CAAA,QAAAmB,GAAA,iBAAArB,KAAA,CACjB,SAAA4B,cAAA1B,CAAA,CAIoC,IAHlC,CAAA2B,CAAW,CAAA3B,CAAA,CAAX2B,WAAW,CACXC,CAAE,CAAA5B,CAAA,CAAF4B,EAAE,CACFC,CAAW,CAAA7B,CAAA,CAAX6B,WAAW,CAEPC,CAAM,CAAG,EAAE,CAMf,MAJI,CAAAD,CAAW,GACbC,CAAM,EAAWD,CAAW,GAAC,EAGxB,IAAI,CAACE,aAAa,CAACJ,CAAW,CAAGC,CAAE,CAAGE,CAAM,CACrD,CAAC,GAAAX,GAAA,iBAAArB,KAAA,CAOD,SAAAiC,cAAqBC,CAAY,CAAU,CACzC,GAAM,CAAAC,CAAU,CAAG,GAAAC,YAAM,EAACF,CAAI,CAAC,CAACG,QAAQ,EAAE,CAE1C,MAAO,CAAAC,QAAQ,CAACH,CAAU,CAAE,EAAE,CAAC,CAAGI,IAAI,CAACC,GAAG,CAAC,CAAC,CAAE,GAAG,CACnD,CAAC,IAAAtC,CAAA,IAAAH,OAAA,CAAAE,MAAA,CAAAA,MAAA"}
@@ -1,12 +1,5 @@
1
- import { RespoolTimeType } from '../campaignConfiguration/types';
2
- type ObtainHashDoubleParamsType = {
3
- visitorCode: string;
4
- campaignId: string;
5
- };
6
- export type ObtainExperimentHashDoubleParamsType = ObtainHashDoubleParamsType & {
7
- respoolTime: RespoolTimeType[];
8
- };
9
- export type ObtainFeatureFlagHashDoubleParamsType = ObtainHashDoubleParamsType & {
1
+ export type GetHashDoubleParamsType = {
10
2
  respoolTime: number | null;
3
+ visitorCode: string;
4
+ id: string;
11
5
  };
12
- export {};
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/hasher/types.ts"],"sourcesContent":["import { RespoolTimeType } from 'src/campaignConfiguration/types';\n\ntype ObtainHashDoubleParamsType = {\n visitorCode: string;\n campaignId: string;\n};\n\nexport type ObtainExperimentHashDoubleParamsType =\n ObtainHashDoubleParamsType & {\n respoolTime: RespoolTimeType[];\n };\n\nexport type ObtainFeatureFlagHashDoubleParamsType =\n ObtainHashDoubleParamsType & {\n respoolTime: number | null;\n };\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/hasher/types.ts"],"sourcesContent":["export type GetHashDoubleParamsType = {\n respoolTime: number | null;\n visitorCode: string;\n id: string;\n};\n"],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -2,11 +2,13 @@ export { Ok, Result, Err } from 'ts-res';
2
2
  export { KameleoonClient as KameleoonCore, IKameleoonClient as IKameleoonCore, } from './kameleoonClient';
3
3
  export { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';
4
4
  export { KameleoonException, KameleoonError } from './kameleoonError';
5
- export { ExperimentVariationsType, KameleoonStorageKey, StorageDataType, IExternalStorage, IExternalStorageConstructor, } from './storage';
6
- export { Cookie, VISITOR_CODE_LENGTH, SdkLanguageType } from './constants';
7
- export { CLEANUP_TARGETING_DATA_INTERVAL } from './campaignConfiguration';
8
- export { JSONType } from './campaignConfiguration';
9
- export { Environment, VariableType, ExperimentType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, ExternalPackageInfoType, TrackConversionParamsType, FeatureVariableResultType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, ServerGetVisitorCodeParametersType, ClientGetVisitorCodeParametersType, MobileGetVisitorCodeParametersType, Milliseconds, } from './types';
10
- export { CustomData, Conversion, Device, Browser, UserAgent, DeviceType, BrowserType, PageView, KameleoonData, KameleoonDataType, PageViewParametersType, ConversionParametersType, } from './kameleoonData';
5
+ export { VisitorDataFiltersType } from './utilities';
6
+ export { FeatureFlagVariationsType, KameleoonStorageKey, StorageDataType, IExternalStorage, IExternalStorageConstructor, } from './storage';
7
+ export { CookieManager } from './cookieManager';
8
+ export { CookieParameter, VISITOR_CODE_LENGTH, SdkLanguageType, } from './constants';
9
+ export { JSONType, ConfigurationDataType } from './clientConfiguration';
10
+ export { Environment, VariableType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, ExternalPackageInfoType, TrackConversionParamsType, FeatureVariableResultType, RemoteVisitorDataParamsType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, ServerGetVisitorCodeParametersType, ClientGetVisitorCodeParametersType, ServerSetLegalConsentParametersType, ClientSetLegalConsentParametersType, ServerSetCookieParametersType, ClientSetCookieParametersType, Milliseconds, } from './types';
11
+ export { DEFAULT_CLEANUP_INTERVAL } from './kameleoonData';
12
+ export { ApplicationVersion, CustomData, Conversion, Device, Cookie, Browser, UserAgent, DeviceType, CookieType, GeolocationData, GeolocationInfoType, OperatingSystemType, OperatingSystem, BrowserType, PageView, KameleoonData, KameleoonDataType, PageViewParametersType, ConversionParametersType, ApplicationVersionDataType, } from './kameleoonData';
11
13
  export { RealTimeEventType, IExternalEventSource, EventSourceOpenParametersType, IExternalEventSourceConstructor, } from './eventSource';
12
- export { Header, HttpMethod, TrackParametersType, IExternalRequestDispatcher, GetClientConfigurationResultType, } from './requester';
14
+ export { Header, HttpMethod, TrackParametersType, IExternalRequestDispatcher, } from './requester';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _kameleoonData.Browser}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function get(){return _kameleoonData.BrowserType}}),Object.defineProperty(exports,"CLEANUP_TARGETING_DATA_INTERVAL",{enumerable:!0,get:function get(){return _campaignConfiguration.CLEANUP_TARGETING_DATA_INTERVAL}}),Object.defineProperty(exports,"ClientGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.ClientGetVisitorCodeParametersType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function get(){return _kameleoonData.Conversion}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function get(){return _kameleoonData.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function get(){return _constants.Cookie}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function get(){return _kameleoonData.CustomData}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function get(){return _kameleoonData.Device}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function get(){return _kameleoonData.DeviceType}}),Object.defineProperty(exports,"Environment",{enumerable:!0,get:function get(){return _types.Environment}}),Object.defineProperty(exports,"Err",{enumerable:!0,get:function get(){return _tsRes.Err}}),Object.defineProperty(exports,"EventSourceOpenParametersType",{enumerable:!0,get:function get(){return _eventSource.EventSourceOpenParametersType}}),Object.defineProperty(exports,"ExperimentType",{enumerable:!0,get:function get(){return _types.ExperimentType}}),Object.defineProperty(exports,"ExperimentVariationsType",{enumerable:!0,get:function get(){return _storage.ExperimentVariationsType}}),Object.defineProperty(exports,"ExternalPackageInfoType",{enumerable:!0,get:function get(){return _types.ExternalPackageInfoType}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function get(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureVariableResultType",{enumerable:!0,get:function get(){return _types.FeatureVariableResultType}}),Object.defineProperty(exports,"GetClientConfigurationResultType",{enumerable:!0,get:function get(){return _requester.GetClientConfigurationResultType}}),Object.defineProperty(exports,"GetFeatureFlagVariableParamsType",{enumerable:!0,get:function get(){return _types.GetFeatureFlagVariableParamsType}}),Object.defineProperty(exports,"GetVisitorWarehouseAudienceParamsType",{enumerable:!0,get:function get(){return _types.GetVisitorWarehouseAudienceParamsType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function get(){return _requester.Header}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function get(){return _requester.HttpMethod}}),Object.defineProperty(exports,"IExternalEventSource",{enumerable:!0,get:function get(){return _eventSource.IExternalEventSource}}),Object.defineProperty(exports,"IExternalEventSourceConstructor",{enumerable:!0,get:function get(){return _eventSource.IExternalEventSourceConstructor}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function get(){return _requester.IExternalRequestDispatcher}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function get(){return _storage.IExternalStorage}}),Object.defineProperty(exports,"IExternalStorageConstructor",{enumerable:!0,get:function get(){return _storage.IExternalStorageConstructor}}),Object.defineProperty(exports,"IKameleoonCore",{enumerable:!0,get:function get(){return _kameleoonClient.IKameleoonClient}}),Object.defineProperty(exports,"InternalSDKConfigurationType",{enumerable:!0,get:function get(){return _types.InternalSDKConfigurationType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function get(){return _campaignConfiguration.JSONType}}),Object.defineProperty(exports,"KameleoonCore",{enumerable:!0,get:function get(){return _kameleoonClient.KameleoonClient}}),Object.defineProperty(exports,"KameleoonCoreUtils",{enumerable:!0,get:function get(){return _kameleoonUtils.KameleoonUtils}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function get(){return _kameleoonData.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function get(){return _kameleoonData.KameleoonDataType}}),Object.defineProperty(exports,"KameleoonError",{enumerable:!0,get:function get(){return _kameleoonError.KameleoonError}}),Object.defineProperty(exports,"KameleoonException",{enumerable:!0,get:function get(){return _kameleoonError.KameleoonException}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function get(){return _storage.KameleoonStorageKey}}),Object.defineProperty(exports,"Milliseconds",{enumerable:!0,get:function get(){return _types.Milliseconds}}),Object.defineProperty(exports,"MobileGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.MobileGetVisitorCodeParametersType}}),Object.defineProperty(exports,"Ok",{enumerable:!0,get:function get(){return _tsRes.Ok}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function get(){return _kameleoonData.PageView}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function get(){return _kameleoonData.PageViewParametersType}}),Object.defineProperty(exports,"RealTimeEventType",{enumerable:!0,get:function get(){return _eventSource.RealTimeEventType}}),Object.defineProperty(exports,"Result",{enumerable:!0,get:function get(){return _tsRes.Result}}),Object.defineProperty(exports,"SDKConfigurationType",{enumerable:!0,get:function get(){return _types.SDKConfigurationType}}),Object.defineProperty(exports,"SDKCoreParameters",{enumerable:!0,get:function get(){return _types.SDKCoreParameters}}),Object.defineProperty(exports,"SdkLanguageType",{enumerable:!0,get:function get(){return _constants.SdkLanguageType}}),Object.defineProperty(exports,"ServerGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.ServerGetVisitorCodeParametersType}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function get(){return _storage.StorageDataType}}),Object.defineProperty(exports,"TrackConversionParamsType",{enumerable:!0,get:function get(){return _types.TrackConversionParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function get(){return _requester.TrackParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function get(){return _kameleoonData.UserAgent}}),Object.defineProperty(exports,"VISITOR_CODE_LENGTH",{enumerable:!0,get:function get(){return _constants.VISITOR_CODE_LENGTH}}),Object.defineProperty(exports,"VariableType",{enumerable:!0,get:function get(){return _types.VariableType}});var _tsRes=require("ts-res"),_kameleoonClient=require("./kameleoonClient"),_kameleoonUtils=require("./kameleoonUtils"),_kameleoonError=require("./kameleoonError"),_storage=require("./storage"),_constants=require("./constants"),_campaignConfiguration=require("./campaignConfiguration"),_types=require("./types"),_kameleoonData=require("./kameleoonData"),_eventSource=require("./eventSource"),_requester=require("./requester");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function get(){return _kameleoonData.ApplicationVersion}}),Object.defineProperty(exports,"ApplicationVersionDataType",{enumerable:!0,get:function get(){return _kameleoonData.ApplicationVersionDataType}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _kameleoonData.Browser}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function get(){return _kameleoonData.BrowserType}}),Object.defineProperty(exports,"ClientGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.ClientGetVisitorCodeParametersType}}),Object.defineProperty(exports,"ClientSetCookieParametersType",{enumerable:!0,get:function get(){return _types.ClientSetCookieParametersType}}),Object.defineProperty(exports,"ClientSetLegalConsentParametersType",{enumerable:!0,get:function get(){return _types.ClientSetLegalConsentParametersType}}),Object.defineProperty(exports,"ConfigurationDataType",{enumerable:!0,get:function get(){return _clientConfiguration.ConfigurationDataType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function get(){return _kameleoonData.Conversion}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function get(){return _kameleoonData.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function get(){return _kameleoonData.Cookie}}),Object.defineProperty(exports,"CookieManager",{enumerable:!0,get:function get(){return _cookieManager.CookieManager}}),Object.defineProperty(exports,"CookieParameter",{enumerable:!0,get:function get(){return _constants.CookieParameter}}),Object.defineProperty(exports,"CookieType",{enumerable:!0,get:function get(){return _kameleoonData.CookieType}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function get(){return _kameleoonData.CustomData}}),Object.defineProperty(exports,"DEFAULT_CLEANUP_INTERVAL",{enumerable:!0,get:function get(){return _kameleoonData.DEFAULT_CLEANUP_INTERVAL}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function get(){return _kameleoonData.Device}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function get(){return _kameleoonData.DeviceType}}),Object.defineProperty(exports,"Environment",{enumerable:!0,get:function get(){return _types.Environment}}),Object.defineProperty(exports,"Err",{enumerable:!0,get:function get(){return _tsRes.Err}}),Object.defineProperty(exports,"EventSourceOpenParametersType",{enumerable:!0,get:function get(){return _eventSource.EventSourceOpenParametersType}}),Object.defineProperty(exports,"ExternalPackageInfoType",{enumerable:!0,get:function get(){return _types.ExternalPackageInfoType}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function get(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureFlagVariationsType",{enumerable:!0,get:function get(){return _storage.FeatureFlagVariationsType}}),Object.defineProperty(exports,"FeatureVariableResultType",{enumerable:!0,get:function get(){return _types.FeatureVariableResultType}}),Object.defineProperty(exports,"GeolocationData",{enumerable:!0,get:function get(){return _kameleoonData.GeolocationData}}),Object.defineProperty(exports,"GeolocationInfoType",{enumerable:!0,get:function get(){return _kameleoonData.GeolocationInfoType}}),Object.defineProperty(exports,"GetFeatureFlagVariableParamsType",{enumerable:!0,get:function get(){return _types.GetFeatureFlagVariableParamsType}}),Object.defineProperty(exports,"GetVisitorWarehouseAudienceParamsType",{enumerable:!0,get:function get(){return _types.GetVisitorWarehouseAudienceParamsType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function get(){return _requester.Header}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function get(){return _requester.HttpMethod}}),Object.defineProperty(exports,"IExternalEventSource",{enumerable:!0,get:function get(){return _eventSource.IExternalEventSource}}),Object.defineProperty(exports,"IExternalEventSourceConstructor",{enumerable:!0,get:function get(){return _eventSource.IExternalEventSourceConstructor}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function get(){return _requester.IExternalRequestDispatcher}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function get(){return _storage.IExternalStorage}}),Object.defineProperty(exports,"IExternalStorageConstructor",{enumerable:!0,get:function get(){return _storage.IExternalStorageConstructor}}),Object.defineProperty(exports,"IKameleoonCore",{enumerable:!0,get:function get(){return _kameleoonClient.IKameleoonClient}}),Object.defineProperty(exports,"InternalSDKConfigurationType",{enumerable:!0,get:function get(){return _types.InternalSDKConfigurationType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function get(){return _clientConfiguration.JSONType}}),Object.defineProperty(exports,"KameleoonCore",{enumerable:!0,get:function get(){return _kameleoonClient.KameleoonClient}}),Object.defineProperty(exports,"KameleoonCoreUtils",{enumerable:!0,get:function get(){return _kameleoonUtils.KameleoonUtils}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function get(){return _kameleoonData.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function get(){return _kameleoonData.KameleoonDataType}}),Object.defineProperty(exports,"KameleoonError",{enumerable:!0,get:function get(){return _kameleoonError.KameleoonError}}),Object.defineProperty(exports,"KameleoonException",{enumerable:!0,get:function get(){return _kameleoonError.KameleoonException}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function get(){return _storage.KameleoonStorageKey}}),Object.defineProperty(exports,"Milliseconds",{enumerable:!0,get:function get(){return _types.Milliseconds}}),Object.defineProperty(exports,"Ok",{enumerable:!0,get:function get(){return _tsRes.Ok}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function get(){return _kameleoonData.OperatingSystem}}),Object.defineProperty(exports,"OperatingSystemType",{enumerable:!0,get:function get(){return _kameleoonData.OperatingSystemType}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function get(){return _kameleoonData.PageView}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function get(){return _kameleoonData.PageViewParametersType}}),Object.defineProperty(exports,"RealTimeEventType",{enumerable:!0,get:function get(){return _eventSource.RealTimeEventType}}),Object.defineProperty(exports,"RemoteVisitorDataParamsType",{enumerable:!0,get:function get(){return _types.RemoteVisitorDataParamsType}}),Object.defineProperty(exports,"Result",{enumerable:!0,get:function get(){return _tsRes.Result}}),Object.defineProperty(exports,"SDKConfigurationType",{enumerable:!0,get:function get(){return _types.SDKConfigurationType}}),Object.defineProperty(exports,"SDKCoreParameters",{enumerable:!0,get:function get(){return _types.SDKCoreParameters}}),Object.defineProperty(exports,"SdkLanguageType",{enumerable:!0,get:function get(){return _constants.SdkLanguageType}}),Object.defineProperty(exports,"ServerGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.ServerGetVisitorCodeParametersType}}),Object.defineProperty(exports,"ServerSetCookieParametersType",{enumerable:!0,get:function get(){return _types.ServerSetCookieParametersType}}),Object.defineProperty(exports,"ServerSetLegalConsentParametersType",{enumerable:!0,get:function get(){return _types.ServerSetLegalConsentParametersType}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function get(){return _storage.StorageDataType}}),Object.defineProperty(exports,"TrackConversionParamsType",{enumerable:!0,get:function get(){return _types.TrackConversionParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function get(){return _requester.TrackParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function get(){return _kameleoonData.UserAgent}}),Object.defineProperty(exports,"VISITOR_CODE_LENGTH",{enumerable:!0,get:function get(){return _constants.VISITOR_CODE_LENGTH}}),Object.defineProperty(exports,"VariableType",{enumerable:!0,get:function get(){return _types.VariableType}}),Object.defineProperty(exports,"VisitorDataFiltersType",{enumerable:!0,get:function get(){return _utilities.VisitorDataFiltersType}});var _tsRes=require("ts-res"),_kameleoonClient=require("./kameleoonClient"),_kameleoonUtils=require("./kameleoonUtils"),_kameleoonError=require("./kameleoonError"),_utilities=require("./utilities"),_storage=require("./storage"),_cookieManager=require("./cookieManager"),_constants=require("./constants"),_clientConfiguration=require("./clientConfiguration"),_types=require("./types"),_kameleoonData=require("./kameleoonData"),_eventSource=require("./eventSource"),_requester=require("./requester");
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { Ok, Result, Err } from 'ts-res';\nexport {\n KameleoonClient as KameleoonCore,\n IKameleoonClient as IKameleoonCore,\n} from './kameleoonClient';\nexport { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';\nexport { KameleoonException, KameleoonError } from './kameleoonError';\nexport {\n ExperimentVariationsType,\n KameleoonStorageKey,\n StorageDataType,\n IExternalStorage,\n IExternalStorageConstructor,\n} from './storage';\nexport { Cookie, VISITOR_CODE_LENGTH, SdkLanguageType } from './constants';\nexport { CLEANUP_TARGETING_DATA_INTERVAL } from './campaignConfiguration';\nexport { JSONType } from './campaignConfiguration';\nexport {\n Environment,\n VariableType,\n ExperimentType,\n FeatureFlagType,\n SDKCoreParameters,\n SDKConfigurationType,\n ExternalPackageInfoType,\n TrackConversionParamsType,\n FeatureVariableResultType,\n InternalSDKConfigurationType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n ServerGetVisitorCodeParametersType,\n ClientGetVisitorCodeParametersType,\n MobileGetVisitorCodeParametersType,\n Milliseconds,\n} from './types';\nexport {\n CustomData,\n Conversion,\n Device,\n Browser,\n UserAgent,\n DeviceType,\n BrowserType,\n PageView,\n KameleoonData,\n KameleoonDataType,\n PageViewParametersType,\n ConversionParametersType,\n} from './kameleoonData';\nexport {\n RealTimeEventType,\n IExternalEventSource,\n EventSourceOpenParametersType,\n IExternalEventSourceConstructor,\n} from './eventSource';\nexport {\n Header,\n HttpMethod,\n TrackParametersType,\n IExternalRequestDispatcher,\n GetClientConfigurationResultType,\n} from './requester';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { Ok, Result, Err } from 'ts-res';\nexport {\n KameleoonClient as KameleoonCore,\n IKameleoonClient as IKameleoonCore,\n} from './kameleoonClient';\nexport { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';\nexport { KameleoonException, KameleoonError } from './kameleoonError';\nexport { VisitorDataFiltersType } from './utilities';\nexport {\n FeatureFlagVariationsType,\n KameleoonStorageKey,\n StorageDataType,\n IExternalStorage,\n IExternalStorageConstructor,\n} from './storage';\nexport { CookieManager } from './cookieManager';\nexport {\n CookieParameter,\n VISITOR_CODE_LENGTH,\n SdkLanguageType,\n} from './constants';\nexport { JSONType, ConfigurationDataType } from './clientConfiguration';\nexport {\n Environment,\n VariableType,\n FeatureFlagType,\n SDKCoreParameters,\n SDKConfigurationType,\n ExternalPackageInfoType,\n TrackConversionParamsType,\n FeatureVariableResultType,\n RemoteVisitorDataParamsType,\n InternalSDKConfigurationType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n ServerGetVisitorCodeParametersType,\n ClientGetVisitorCodeParametersType,\n ServerSetLegalConsentParametersType,\n ClientSetLegalConsentParametersType,\n ServerSetCookieParametersType,\n ClientSetCookieParametersType,\n Milliseconds,\n} from './types';\nexport { DEFAULT_CLEANUP_INTERVAL } from './kameleoonData';\nexport {\n ApplicationVersion,\n CustomData,\n Conversion,\n Device,\n Cookie,\n Browser,\n UserAgent,\n DeviceType,\n CookieType,\n GeolocationData,\n GeolocationInfoType,\n OperatingSystemType,\n OperatingSystem,\n BrowserType,\n PageView,\n KameleoonData,\n KameleoonDataType,\n PageViewParametersType,\n ConversionParametersType,\n ApplicationVersionDataType,\n} from './kameleoonData';\nexport {\n RealTimeEventType,\n IExternalEventSource,\n EventSourceOpenParametersType,\n IExternalEventSourceConstructor,\n} from './eventSource';\nexport {\n Header,\n HttpMethod,\n TrackParametersType,\n IExternalRequestDispatcher,\n} from './requester';\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
- import { JSONType } from './campaignConfiguration';
1
+ import { JSONType } from './clientConfiguration';
2
2
  import { CustomData, KameleoonDataType } from './kameleoonData';
3
- import { TrackConversionParamsType, ExperimentType, FeatureFlagType, GetFeatureFlagVariableParamsType, FeatureVariableResultType, SDKCoreParameters, GetVisitorWarehouseAudienceParamsType } from './types';
3
+ import { TrackConversionParamsType, FeatureFlagType, GetFeatureFlagVariableParamsType, FeatureVariableResultType, SDKCoreParameters, RemoteVisitorDataParamsType, GetVisitorWarehouseAudienceParamsType, ServerGetVisitorCodeParametersType, ClientGetVisitorCodeParametersType, ServerSetLegalConsentParametersType, ClientSetLegalConsentParametersType } from './types';
4
4
  /**
5
5
  * @interface an interface of KameleoonClient instance
6
6
  */
@@ -27,38 +27,22 @@ export interface IKameleoonClient {
27
27
  * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
28
28
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
29
29
  * - `KameleoonException.StorageWrite` Couldn't update storage data
30
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
30
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
31
31
  */
32
32
  addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;
33
33
  /**
34
- * @method getRemoteVisitorData - an asynchronous method for retrieving custom data for the latest visit of `visitorCode` from Kameleoon Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.
35
- * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
36
- * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`
34
+ * @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.
35
+ * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters
37
36
  * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data
38
37
  * @throws `KameleoonError` with one of the following `type` s:
39
38
  *
40
39
  * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
41
40
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
42
41
  * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server
42
+ * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25
43
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
43
44
  */
44
- getRemoteVisitorData: (visitorCode: string, shouldAddData?: boolean) => Promise<KameleoonDataType[]>;
45
- /**
46
- * @method triggerExperiment - triggers experiment by assigning the variation to the user with `visitorCode`, if the variation is already assigned just returns it's id. Note: returned id `0` indicates default variation. At the same time sends tracking request.
47
- * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
48
- * @param {number} experimentId - id of experiment running for the current visitor
49
- * @returns {number} associated variationId which is successfully searched/assigned
50
- * @throws `KameleoonError` with one of the following `type` s:
51
- *
52
- * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
53
- * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
54
- * - `KameleoonException.ExperimentConfigurationNotFound` No configuration found for provided `experimentId`
55
- * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
56
- * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
57
- * - `KameleoonException.StorageRead` Couldn't find associated experiment by provided `experimentId` and `visitorCode` inside the storage
58
- * - `KameleoonException.NotTargeted` Current visitor is not targeted
59
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
60
- */
61
- triggerExperiment: (visitorCode: string, experimentId: number) => number;
45
+ getRemoteVisitorData: ({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;
62
46
  /**
63
47
  * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter
64
48
  * @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking
@@ -74,56 +58,22 @@ export interface IKameleoonClient {
74
58
  * @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,
75
59
  * sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,
76
60
  * then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input
77
- * the method first attemps to send all previously failed tracking requests which were stored locally during the offline mode.
61
+ * the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.
78
62
  * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length
79
63
  * @returns {void}
80
64
  * @throws `KameleoonError` with one of the following `type` s:
81
65
  *
82
66
  * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
83
67
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
84
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
68
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
85
69
  */
86
70
  flush: (visitorCode: string) => void;
87
- /**
88
- * @deprecated Use flush method instead.
89
- */
90
- flushData: (visitorCode: string) => void;
91
- /**
92
- * @method getExperiments - returns a list of experiments stored in the client configuration
93
- * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields
94
- * @throws `KameleoonError` with one of the following `type` s:
95
- *
96
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
97
- */
98
- getExperiments: () => ExperimentType[];
99
- /**
100
- * @method getVisitorExperiments - returns a list of experiments that the visitor with `visitorCode` is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated if the experiment will be triggered).
101
- * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
102
- * @param {boolean | undefined} isAllocated - boolean value indicating that only experiments *allocated* for visitor will be returned. Default value is `true`
103
- * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields
104
- * @throws `KameleoonError` with one of the following `type` s:
105
- *
106
- * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
107
- * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
108
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
109
- */
110
- getVisitorExperiments: (visitorCode: string, isAllocated?: boolean) => ExperimentType[];
111
- /**
112
- * @method getExperimentVariationData - returns variation data in JSON format for the variation with `variationId`
113
- * @param {number} variationId - id of variation
114
- * @returns {JSONType} variation data in JSON format
115
- * @throws `KameleoonError` with one of the following `type` s:
116
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
117
- * - `KameleoonException.JSONParse` - Couldn't pass JSON value
118
- * - `KameleoonException.VariationNotFound` - No variation found for provided `variationId`
119
- */
120
- getExperimentVariationData: (variationId: number) => JSONType | null;
121
71
  /**
122
72
  * @method getFeatureFlags - returns a list of feature flags stored in the client configuration
123
73
  * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields
124
74
  * @throws `KameleoonError` with one of the following `type` s:
125
75
  *
126
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
76
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
127
77
  */
128
78
  getFeatureFlags: () => FeatureFlagType[];
129
79
  /**
@@ -135,6 +85,7 @@ export interface IKameleoonClient {
135
85
  * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
136
86
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
137
87
  * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
88
+ * - `KameleoonException.StorageRead` - Couldn't read storage data
138
89
  * - `KameleoonException.NotTargeted` - Current visitor is not targeted
139
90
  */
140
91
  getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];
@@ -147,8 +98,8 @@ export interface IKameleoonClient {
147
98
  *
148
99
  * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
149
100
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
150
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
151
- * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`
101
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
102
+ * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
152
103
  * - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.
153
104
  * - `KameleoonException.NotTargeted` - Current visitor is not targeted
154
105
  */
@@ -162,27 +113,46 @@ export interface IKameleoonClient {
162
113
  *
163
114
  * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
164
115
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
165
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
166
- * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`
116
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
117
+ * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
118
+ * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment
167
119
  * - `KameleoonException.NotTargeted` - Current visitor is not targeted
168
120
  */
169
121
  getFeatureFlagVariationKey: (visitorCode: string, featureKey: string) => string;
170
122
  /**
171
123
  * @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
172
124
  * @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.
173
- * @returns {FeatureVariableResultType} a variable object containing `type` and `value` fields, `type` can be checked against `FeatureVariableType` enum, if the `type` is `FeatureVariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
125
+ * @returns {FeatureVariableResultType} a variable object containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.
174
126
  * @throws `KameleoonError` with one of the following `type` s:
175
127
  *
176
128
  * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
177
129
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
178
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
179
- * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`
130
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
131
+ * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
180
132
  * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`
133
+ * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment
181
134
  * - `KameleoonException.NotTargeted` - Current visitor is not targeted
182
- * - `KameleoonException.JSONParse` - Couldn't pass JSON value
183
- * - `KameleoonException.NumberParse` - Couldn't pass Number value
135
+ * - `KameleoonException.JSONParse` - Couldn't parse JSON value
136
+ * - `KameleoonException.NumberParse` - Couldn't parse Number value
184
137
  */
185
138
  getFeatureFlagVariable: ({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType) => FeatureVariableResultType;
139
+ /**
140
+ * @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
141
+ * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters
142
+ * @param {string} featureKey - a unique key for feature flag
143
+ * @returns {FeatureVariableResultType[]} a list of variable objects containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.
144
+ * @throws `KameleoonError` with one of the following `type` s:
145
+ *
146
+ * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
147
+ * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
148
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
149
+ * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
150
+ * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`
151
+ * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment
152
+ * - `KameleoonException.JSONParse` - Couldn't parse JSON value
153
+ * - `KameleoonException.NumberParse` - Couldn't parse Number value
154
+ */
155
+ getFeatureFlagVariables: (visitorCode: string, featureKey: string) => FeatureVariableResultType[];
186
156
  /**
187
157
  * @method getRemoteData - returns a data which is stored for specified siteCode on a remote Kameleoon server.
188
158
  * @param {string} key - unique key that the data you try to get is associated with.
@@ -216,13 +186,35 @@ export interface IKameleoonClient {
216
186
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
217
187
  */
218
188
  getEngineTrackingCode: (visitorCode: string) => string;
189
+ /**
190
+ * @method getVisitorCode - obtains visitor code from cookie or storage, if the visitor code doesn't yet exist generates a random visitor code (or uses a provided default)
191
+ * @param { ServerGetVisitorCodeParametersType | ClientGetVisitorCodeParametersType } params - an object of type `ServerGetVisitorCodeParametersType` or `ClientGetVisitorCodeParametersType`
192
+ * @returns {string} result visitor code
193
+ * @throws `KameleoonError` with one of the following `type` s:
194
+ *
195
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
196
+ * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
197
+ * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
198
+ */
199
+ getVisitorCode: (params: ServerGetVisitorCodeParametersType | ClientGetVisitorCodeParametersType) => string;
200
+ /**
201
+ * @method setLegalConsent - sets or updates the legal consent status for a visitor identified by their unique visitor code, affecting values in the response cookies based on the consent status
202
+ * @param {ServerSetLegalConsentParametersType | ClientSetLegalConsentParametersType} params - an object of type `ServerSetLegalConsentParametersType` or `ClientSetLegalConsentParametersType`
203
+ * @returns {void}
204
+ * @throws `KameleoonError` with one of the following `type` s:
205
+ *
206
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
207
+ * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
208
+ * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
209
+ */
210
+ setLegalConsent: (params: ServerSetLegalConsentParametersType | ClientSetLegalConsentParametersType) => void;
219
211
  /**
220
212
  * @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.
221
213
  * @param {() => void} callback - callback function with no parameters that will be called upon configuration update
222
214
  * @returns {void}
223
215
  * @throws `KameleoonError` with one of the following `type` s:
224
216
  *
225
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
217
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
226
218
  */
227
219
  onConfigurationUpdate: (callback: () => void) => void;
228
220
  }
@@ -232,36 +224,39 @@ export interface IKameleoonClient {
232
224
  * for communicating with Kameleoon JavaScript SDK Core, when new instance is created
233
225
  */
234
226
  export declare class KameleoonClient implements IKameleoonClient {
235
- private variationConfiguration?;
236
- private campaignConfiguration;
237
- private variationDataStorage;
227
+ private variationConfiguration;
228
+ private clientConfiguration;
229
+ private dataManager;
238
230
  private offlineTrackingStorage;
231
+ private consentDataStorage;
239
232
  private trackingCache;
240
233
  private requester;
241
234
  private externalPackageInfo;
242
235
  private isOfflineModeOn?;
236
+ private initialized;
237
+ private environment?;
238
+ private cookieManager;
243
239
  /**
244
240
  * @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core
245
241
  */
246
242
  constructor({ siteCode, configuration, internalConfiguration, }: SDKCoreParameters);
247
243
  initialize(useCache?: boolean): Promise<boolean>;
248
244
  addData(visitorCode: string, ...data: KameleoonDataType[]): void;
249
- getRemoteVisitorData(visitorCode: string, shouldAddData?: boolean): Promise<KameleoonDataType[]>;
250
- triggerExperiment(visitorCode: string, experimentId: number): number;
245
+ getRemoteVisitorData({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]>;
251
246
  trackConversion({ visitorCode, goalId, revenue, }: TrackConversionParamsType): void;
252
247
  flush(visitorCode?: string): void;
253
- flushData(visitorCode?: string): void;
254
- getExperiments(): ExperimentType[];
255
- getVisitorExperiments(visitorCode: string, isActive?: boolean): ExperimentType[];
256
- getExperimentVariationData(variationId: number): JSONType;
257
248
  getFeatureFlags(): FeatureFlagType[];
258
249
  getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[];
259
250
  getFeatureFlagVariationKey(visitorCode: string, featureKey: string): string;
260
251
  getFeatureFlagVariable({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType): FeatureVariableResultType;
252
+ getFeatureFlagVariables(visitorCode: string, featureKey: string): FeatureVariableResultType[];
261
253
  isFeatureFlagActive(visitorCode: string, featureKey: string): boolean;
262
254
  getRemoteData(key: string): Promise<JSONType>;
263
255
  getVisitorWarehouseAudience({ visitorCode, customDataIndex, warehouseKey, }: GetVisitorWarehouseAudienceParamsType): Promise<CustomData | null>;
264
256
  onConfigurationUpdate(callback: () => void): void;
265
257
  getEngineTrackingCode(visitorCode: string): string;
258
+ getVisitorCode(params: ServerGetVisitorCodeParametersType | ClientGetVisitorCodeParametersType): string;
259
+ setLegalConsent(params: ServerSetLegalConsentParametersType | ClientSetLegalConsentParametersType): void;
260
+ private _isConsentProvided;
266
261
  private _getFeatureFlagVariation;
267
262
  }
@@ -1,19 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _tsRes=require("ts-res"),_cacheManager=require("./cacheManager"),_campaignConfiguration=require("./campaignConfiguration"),_clientSettings=require("./clientSettings"),_constants=require("./constants"),_kameleoonData=require("./kameleoonData"),_kameleoonError=require("./kameleoonError"),_requester=require("./requester"),_storage=require("./storage"),_utilities=require("./utilities"),_variationConfiguration=require("./variationConfiguration");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
2
- * @class
3
- * KameleoonClient - a class for creating kameleoon client instance
4
- * for communicating with Kameleoon JavaScript SDK Core, when new instance is created
5
- */var KameleoonClient=/*#__PURE__*/function(){/**
6
- * @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core
7
- */function a(b){var c=b.siteCode,d=b.configuration,e=b.internalConfiguration;_classCallCheck(this,a),_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"campaignConfiguration",void 0),_defineProperty(this,"variationDataStorage",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"trackingCache",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"externalPackageInfo",void 0),_defineProperty(this,"isOfflineModeOn",void 0);var f=new _clientSettings.ClientSettings(c,d),g=f.settings,h=e.externalStorage,i=e.externalEventSource,j=e.externalPackageInfo,k=e.externalRequestDispatcher,l=e.externalClientConfiguration,m=new _requester.Requester({siteCode:c,environment:g.environment,packageInfo:j,requestDispatcher:k}),n=new _cacheManager.CacheManager(_constants.CACHE_CLEANUP_TIMEOUT),o=h.initialize(_storage.KameleoonStorageKey.ClientData),p=h.initialize(_storage.KameleoonStorageKey.VariationData),q=h.initialize(_storage.KameleoonStorageKey.OfflineTracking),r=new _campaignConfiguration.CampaignConfiguration({settings:g,storage:o,requester:m,externalClientConfiguration:l,targetingCleanupInterval:null===d||void 0===d?void 0:d.targetingDataCleanupInterval,offlineTrackingStorage:q,externalEventSource:i});this.requester=m,this.trackingCache=n,this.campaignConfiguration=r,this.variationDataStorage=p,this.externalPackageInfo=j,this.offlineTrackingStorage=q}return _createClass(a,[{key:"initialize",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d;return _regeneratorRuntime().wrap(function e(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.campaignConfiguration.initialize(a);case 2:return c=b.sent,c.throw(),d=new _variationConfiguration.VariationConfiguration(this.campaignConfiguration.experiments,this.variationDataStorage),this.variationConfiguration=d,this.isOfflineModeOn=a,b.abrupt("return",c.ok);case 8:case"end":return b.stop();}},b,this)}));return a}()},{key:"addData",value:function addData(a){var b;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];(b=this.campaignConfiguration).addTargetingData.apply(b,[a].concat(d)).throw()}},{key:"getRemoteVisitorData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j=arguments;return _regeneratorRuntime().wrap(function k(b){for(;1;)switch(b.prev=b.next){case 0:return c=!(1<j.length&&void 0!==j[1])||j[1],b.next=3,this.requester.getVisitorData(a);case 3:d=b.sent,e=d.throw(),f=_utilities.Utilities.parseVisitorData(e),g=_createForOfIteratorHelper(f);try{for(g.s();!(h=g.n()).done;)i=h.value,(c||this.campaignConfiguration.isPersistentCustomData(i))&&this.addData(a,i)}catch(a){g.e(a)}finally{g.f()}return b.abrupt("return",f);case 9:case"end":return b.stop();}},b,this)}));return a}()},{key:"triggerExperiment",value:function triggerExperiment(a,b){var c=this;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.campaignConfiguration||!this.variationConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var d=this.campaignConfiguration.experiments.find(function(a){return a.id===b+""});if(!d)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.ExperimentConfigurationNotFound,b,a);var e=this.campaignConfiguration.storedTargetingData[a],f=_constants.UNALLOCATED_VARIATION_ID,g=_utilities.Utilities.checkTargeting({visitorCode:a,experimentId:b,targetingData:e,segment:d.segment,campaignConfiguration:this.campaignConfiguration,variationConfiguration:this.variationConfiguration,packageInfo:this.externalPackageInfo}).throw();if(f=this.variationConfiguration.getAssociatedVariationId(a,b).else(function(d){if(d.type===_kameleoonError.KameleoonException.NotAllocated)return _utilities.Utilities.trackExperiment({requester:c.requester,campaignConfiguration:c.campaignConfiguration,isUnallocated:!0,variationId:f,visitorCode:a,experimentId:b,isOfflineModeOn:c.isOfflineModeOn,offlineTrackingStorage:c.offlineTrackingStorage}),_constants.UNALLOCATED_VARIATION_ID;throw d}),_utilities.Utilities.trackExperiment({requester:this.requester,campaignConfiguration:this.campaignConfiguration,isUnallocated:!1,variationId:f,visitorCode:a,experimentId:b,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage}),!g)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NotTargeted,a);return _utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:b,variationId:f}),f}},{key:"trackConversion",value:function trackConversion(a){var b=a.visitorCode,c=a.goalId,d=a.revenue;this.addData(b,new _kameleoonData.Conversion({goalId:c,revenue:d})),this.flush(b)}},{key:"flush",value:function flush(a){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);if("string"==typeof a&&_utilities.Utilities.validateVisitorCode(a).throw(),a)return void _utilities.Utilities.trackData({visitorCode:a,campaignConfiguration:this.campaignConfiguration,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage});// --- Note ---
8
- // `Utilities.trackData` executes `Utilities.sendOfflineTracking` asynchronously at first, but
9
- // we need to execute `Utilities.sendOfflineTracking` even if calling `Utilities.trackData` is skipped
10
- // due to lack of unsent data
11
- if(!this.campaignConfiguration.unsentDataVisitors.length)return void _utilities.Utilities.sendOfflineTracking({requester:this.requester,storage:this.offlineTrackingStorage});var b,c=_createForOfIteratorHelper(this.campaignConfiguration.unsentDataVisitors);try{for(c.s();!(b=c.n()).done;){var d=b.value;_utilities.Utilities.trackData({visitorCode:d,campaignConfiguration:this.campaignConfiguration,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage})}}catch(a){c.e(a)}finally{c.f()}}},{key:"flushData",value:function flushData(a){this.flush(a)}},{key:"getExperiments",value:function getExperiments(){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.campaignConfiguration.experiments.map(function(a){var b=a.id,c=a.name;return{id:+b,name:c}})}},{key:"getVisitorExperiments",value:function getVisitorExperiments(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];if(!this.variationConfiguration||!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(a).throw();var c,d=this.campaignConfiguration.experiments,e=[],f=this.campaignConfiguration.storedTargetingData[a],g=_createForOfIteratorHelper(d);try{for(g.s();!(c=g.n()).done;){var h=c.value,i=h.id,j=h.name,k=h.segment,l=_utilities.Utilities.checkTargeting({targetingData:f,visitorCode:a,segment:k,variationConfiguration:this.variationConfiguration,campaignConfiguration:this.campaignConfiguration,experimentId:+i,packageInfo:this.externalPackageInfo}).throw();if(l){// -- If `isActive=false` then return every experiment
12
- if(!b){e.push({id:+i,name:j});continue}// -- Else first check if there are saved variations for the experiment
13
- // if there is at least one than it's active
14
- var m=this.variationConfiguration.getAssignedVariations(a);if(m.ok){var n=m.data[h.id];if(n){e.push({id:+i,name:j});continue}}// -- Second check if the experiment will have an allocated variation upon triggering
15
- // if yes than it's active
16
- var o=this.variationConfiguration.getExperimentVariation(a,h);o.ok&&e.push({id:+i,name:j})}}}catch(a){g.e(a)}finally{g.f()}return e}},{key:"getExperimentVariationData",value:function getExperimentVariationData(a){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b,c=this.campaignConfiguration.experiments,d=_createForOfIteratorHelper(c);try{for(d.s();!(b=d.n()).done;){var e=b.value,f=e.variations.find(function(b){return b.id===a+""});if(f)try{return JSON.parse(f.customJson)}catch(a){throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a)}}}catch(a){d.e(a)}finally{d.f()}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VariationNotFound)}},{key:"getFeatureFlags",value:function getFeatureFlags(){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.campaignConfiguration.featureFlags.map(function(a){var b=a.id,c=a.featureKey;return{id:b,key:c}})}},{key:"getVisitorFeatureFlags",value:function getVisitorFeatureFlags(a){if(!this.variationConfiguration||!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b,c=this.campaignConfiguration.featureFlags,d=[],e=this.campaignConfiguration.storedTargetingData[a],f=_createForOfIteratorHelper(c);try{for(f.s();!(b=f.n()).done;){var g=b.value,h=this.variationConfiguration.getFeatureFlagVariation({visitorCode:a,targetingData:e,featureFlag:g,campaignConfiguration:this.campaignConfiguration,packageInfo:this.externalPackageInfo}).throw();if(h.variationKey!==_constants.OFF_VARIATION_KEY){var i=h.featureFlagId,j=h.featureKey;d.push({id:i,key:j})}}}catch(a){f.e(a)}finally{f.f()}return d}},{key:"getFeatureFlagVariationKey",value:function getFeatureFlagVariationKey(a,b){_utilities.Utilities.validateVisitorCode(a).throw();var c=this._getFeatureFlagVariation(a,b).throw(),d=c.variationKey;return d}},{key:"getFeatureFlagVariable",value:function getFeatureFlagVariable(a){var b,c=a.visitorCode,d=a.featureKey,e=a.variableKey;_utilities.Utilities.validateVisitorCode(c).throw();var f=this._getFeatureFlagVariation(c,d).throw(),g=f.variationKey,h=this.campaignConfiguration.featureFlags,i=h.find(function(a){return a.featureKey===d});// --- Note ---
17
- // `_getFeatureFlagVariation` already checks `campaignConfiguration` initialization
18
- if(!i)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,d,c);var j=null===(b=i.variations.find(function(a){return a.key===g}))||void 0===b?void 0:b.variables.find(function(a){return a.key===e});if(!j)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariableNotFound,e,c);var k=_utilities.Utilities.parseFeatureVariable(j).throw();return k}},{key:"isFeatureFlagActive",value:function isFeatureFlagActive(a,b){var c=this.getFeatureFlagVariationKey(a,b);return c!==_constants.OFF_VARIATION_KEY}},{key:"getRemoteData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.requester.getRemoteData(a);case 2:return c=b.sent,b.abrupt("return",c.throw());case 4:case"end":return b.stop();}},b,this)}));return a}()},{key:"getVisitorWarehouseAudience",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g;return _regeneratorRuntime().wrap(function h(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.customDataIndex,e=a.warehouseKey,_utilities.Utilities.validateVisitorCode(c).throw(),b.next=4,this.getRemoteData(e||c);case 4:if(f=b.sent,f){b.next=7;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.RemoteData);case 7:if(f[_constants.WAREHOUSE_AUDIENCE_KEY]&&0!==Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY]).length){b.next=9;break}return b.abrupt("return",null);case 9:return g=_construct(_kameleoonData.CustomData,[d].concat(_toConsumableArray(Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY])))),this.campaignConfiguration.addTargetingData(c,g),b.abrupt("return",g);case 12:case"end":return b.stop();}},b,this)}));return a}()},{key:"onConfigurationUpdate",value:function onConfigurationUpdate(a){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);this.campaignConfiguration.onConfigurationUpdate(a)}},{key:"getEngineTrackingCode",value:function getEngineTrackingCode(a){return _utilities.Utilities.validateVisitorCode(a).throw(),_utilities.Utilities.getTrackingCode(this.trackingCache,a)}},{key:"_getFeatureFlagVariation",value:function _getFeatureFlagVariation(a,b){if(!this.variationConfiguration||!this.campaignConfiguration)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));var c=this.campaignConfiguration.featureFlags,d=c.find(function(a){return a.featureKey===b});if(!d)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b,a));var e=this.campaignConfiguration.storedTargetingData[a],f=this.variationConfiguration.getFeatureFlagVariation({visitorCode:a,featureFlag:d,targetingData:e,withAssignment:!0,campaignConfiguration:this.campaignConfiguration,packageInfo:this.externalPackageInfo}).throw(),g=f.experimentId,h=f.variationId;return"number"==typeof h&&"number"==typeof g&&_utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:g,variationId:h}),_utilities.Utilities.trackRule({visitorCode:a,requester:this.requester,featureFlagVariation:f,campaignConfiguration:this.campaignConfiguration,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage}),(0,_tsRes.Ok)(f)}}]),a}();exports.KameleoonClient=KameleoonClient;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _tsRes=require("ts-res"),_cacheManager=require("./cacheManager"),_clientConfiguration=require("./clientConfiguration"),_clientSettings=require("./clientSettings"),_constants=require("./constants"),_kameleoonData=require("./kameleoonData"),_kameleoonError=require("./kameleoonError"),_requester=require("./requester"),_storage=require("./storage"),_types=require("./types"),_utilities=require("./utilities"),_variationConfiguration=require("./variationConfiguration");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var KameleoonClient=function(){function a(b){var c=b.siteCode,d=b.configuration,e=b.internalConfiguration;_classCallCheck(this,a),_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"clientConfiguration",void 0),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"consentDataStorage",void 0),_defineProperty(this,"trackingCache",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"externalPackageInfo",void 0),_defineProperty(this,"isOfflineModeOn",void 0),_defineProperty(this,"initialized",!1),_defineProperty(this,"environment",void 0),_defineProperty(this,"cookieManager",void 0);var f=new _clientSettings.ClientSettings(c,d),g=f.settings;this.environment=g.environment;var h=e.externalStorage,i=e.externalEventSource,j=e.externalPackageInfo,k=e.externalCookieManager,l=e.externalRequestDispatcher,m=e.externalClientConfiguration,n=new _requester.Requester({siteCode:c,environment:g.environment,packageInfo:j,requestDispatcher:l}),o=new _cacheManager.CacheManager(_constants.CACHE_CLEANUP_TIMEOUT),p=h.initialize(_storage.KameleoonStorageKey.ClientData),q=h.initialize(_storage.KameleoonStorageKey.TargetingData),r=h.initialize(_storage.KameleoonStorageKey.VariationData),s=h.initialize(_storage.KameleoonStorageKey.OfflineTracking),t=h.initialize(_storage.KameleoonStorageKey.ConsentData),u=new _kameleoonData.DataManager({storage:q,targetingCleanupInterval:null===d||void 0===d?void 0:d.targetingDataCleanupInterval}),v=new _clientConfiguration.ClientConfiguration({settings:g,storage:p,dataManager:u,requester:n,externalClientConfiguration:m,offlineTrackingStorage:s,externalEventSource:i,externalCookieManager:k}),w=new _variationConfiguration.VariationConfiguration(r);this.variationConfiguration=w,this.requester=n,this.trackingCache=o,this.dataManager=u,this.clientConfiguration=v,this.externalPackageInfo=j,this.offlineTrackingStorage=s,this.consentDataStorage=t,this.cookieManager=k}return _createClass(a,[{key:"initialize",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.clientConfiguration.initialize(a);case 2:return c=b.sent,c.throw(),this.isOfflineModeOn=a,this.initialized=!0,b.abrupt("return",c.ok);case 7:case"end":return b.stop();}},b,this)}));return a}()},{key:"addData",value:function addData(a){var b;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];(b=this.dataManager).addData.apply(b,[a].concat(d)).throw()}},{key:"getRemoteVisitorData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(b){for(;1;)switch(b.prev=b.next){case 0:if(c=a.visitorCode,d=a.shouldAddData,e=void 0===d||d,f=a.filters,g=void 0===f?_constants.DEFAULT_VISITOR_DATA_FILTERS:f,this.initialized){b.next=3;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);case 3:if(_utilities.Utilities.validateVisitorCode(c).throw(),h=g.previousVisitAmount,!("number"==typeof h&&(1>h||25<h))){b.next=7;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitAmount);case 7:return b.next=9,this.requester.getVisitorData(c,g);case 9:i=b.sent,j=i.throw(),k=_utilities.Utilities.parseVisitorData({data:j,filters:g,visitorCode:c,variationConfiguration:this.variationConfiguration}),l=_createForOfIteratorHelper(k);try{for(l.s();!(m=l.n()).done;)n=m.value,(e||this.dataManager.isPersistentCustomData(n))&&this.addData(c,n)}catch(a){l.e(a)}finally{l.f()}return b.abrupt("return",k);case 15:case"end":return b.stop();}},b,this)}));return a}()},{key:"trackConversion",value:function trackConversion(a){var b=a.visitorCode,c=a.goalId,d=a.revenue;this.addData(b,new _kameleoonData.Conversion({goalId:c,revenue:d})),this.flush(b)}},{key:"flush",value:function flush(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);if("string"==typeof a&&_utilities.Utilities.validateVisitorCode(a).throw(),a)return void _utilities.Utilities.trackData({visitorCode:a,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(a),offlineTrackingStorage:this.offlineTrackingStorage});if(!this.dataManager.unsentDataVisitors.length)return void _utilities.Utilities.sendOfflineTracking({requester:this.requester,storage:this.offlineTrackingStorage});var b,c=_createForOfIteratorHelper(this.dataManager.unsentDataVisitors);try{for(c.s();!(b=c.n()).done;){var d=b.value;_utilities.Utilities.trackData({visitorCode:d,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(d),offlineTrackingStorage:this.offlineTrackingStorage})}}catch(a){c.e(a)}finally{c.f()}}},{key:"getFeatureFlags",value:function getFeatureFlags(){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.clientConfiguration.featureFlags.map(function(a){var b=a.id,c=a.featureKey;return{id:b,key:c}})}},{key:"getVisitorFeatureFlags",value:function getVisitorFeatureFlags(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b,c=this.clientConfiguration.featureFlags,d=[],e=this.dataManager.storedTargetingData[a],f=_createForOfIteratorHelper(c);try{for(f.s();!(b=f.n()).done;){var g=b.value,h=this.variationConfiguration.getVariation({visitorCode:a,targetingData:e,featureFlag:g,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw();if(h.variationKey!==_constants.OFF_VARIATION_KEY&&g.environmentEnabled){var i=h.featureFlagId,j=h.featureKey;d.push({id:i,key:j})}}}catch(a){f.e(a)}finally{f.f()}return d}},{key:"getFeatureFlagVariationKey",value:function getFeatureFlagVariationKey(a,b){_utilities.Utilities.validateVisitorCode(a).throw();var c=this._getFeatureFlagVariation(a,b).throw(),d=c.variationKey;return d}},{key:"getFeatureFlagVariable",value:function getFeatureFlagVariable(a){var b,c=a.visitorCode,d=a.featureKey,e=a.variableKey;_utilities.Utilities.validateVisitorCode(c).throw();var f=this._getFeatureFlagVariation(c,d).throw(),g=f.variationKey,h=this.clientConfiguration.featureFlags,i=h.find(function(a){return a.featureKey===d});if(!i)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,d);var j=null===(b=i.variations.find(function(a){return a.key===g}))||void 0===b?void 0:b.variables.find(function(a){return a.key===e});if(!j)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariableNotFound,e,c);var k=_utilities.Utilities.parseFeatureVariable(j).throw();return k}},{key:"getFeatureFlagVariables",value:function getFeatureFlagVariables(a,b){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(a).throw();var c=this._getFeatureFlagVariation(a,b).throw(),d=c.variationKey,e=this.clientConfiguration.featureFlags,f=e.find(function(a){return a.featureKey===b});if(!f)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b);var g=f.variations.find(function(a){return a.key===d});if(!g)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariationNotFound,d,a);var h,i=[],j=_createForOfIteratorHelper(g.variables);try{for(j.s();!(h=j.n()).done;){var k=h.value,l=_utilities.Utilities.parseFeatureVariable(k).throw();i.push(l)}}catch(a){j.e(a)}finally{j.f()}return i}},{key:"isFeatureFlagActive",value:function isFeatureFlagActive(a,b){try{var c=this.getFeatureFlagVariationKey(a,b);return c!==_constants.OFF_VARIATION_KEY}catch(a){if(a instanceof _kameleoonError.KameleoonError&&a.type===_kameleoonError.KameleoonException.FeatureFlagEnvironmentDisabled)return!1;throw a}}},{key:"getRemoteData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.requester.getRemoteData(a);case 2:return c=b.sent,b.abrupt("return",c.throw());case 4:case"end":return b.stop();}},b,this)}));return a}()},{key:"getVisitorWarehouseAudience",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g;return _regeneratorRuntime().wrap(function h(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.customDataIndex,e=a.warehouseKey,_utilities.Utilities.validateVisitorCode(c).throw(),b.next=4,this.getRemoteData(e||c);case 4:if(f=b.sent,f){b.next=7;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.RemoteData);case 7:if(f[_constants.WAREHOUSE_AUDIENCE_KEY]&&0!==Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY]).length){b.next=9;break}return b.abrupt("return",null);case 9:return g=_construct(_kameleoonData.CustomData,[d].concat(_toConsumableArray(Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY])))),this.dataManager.addData(c,g),b.abrupt("return",g);case 12:case"end":return b.stop();}},b,this)}));return a}()},{key:"onConfigurationUpdate",value:function onConfigurationUpdate(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);this.clientConfiguration.onConfigurationUpdate(a)}},{key:"getEngineTrackingCode",value:function getEngineTrackingCode(a){return _utilities.Utilities.validateVisitorCode(a).throw(),_utilities.Utilities.getTrackingCode(this.trackingCache,a)}},{key:"getVisitorCode",value:function getVisitorCode(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.cookieManager.getVisitorCode(a)}},{key:"setLegalConsent",value:function setLegalConsent(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b=a.visitorCode,c=a.consent;_utilities.Utilities.validateVisitorCode(b).throw(),this.consentDataStorage.update(_defineProperty({},b,c)),c?_utilities.Utilities.isServerEnvironment(a)?this.cookieManager.setCookie({visitorCode:a.visitorCode,response:a.response}):this.cookieManager.setCookie({visitorCode:a.visitorCode}):this.cookieManager.getConsentRequired()&&(_utilities.Utilities.isServerEnvironment(a)?this.cookieManager.setCookie({visitorCode:"",response:a.response}):this.cookieManager.setCookie({visitorCode:""}))}},{key:"_isConsentProvided",value:function _isConsentProvided(a){var b=this.clientConfiguration.isConsentRequired,c=this.consentDataStorage.read();return!b||c.ok&&c.data[a]}},{key:"_getFeatureFlagVariation",value:function _getFeatureFlagVariation(a,b){if(!this.initialized)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));var c=this.clientConfiguration.featureFlags,d=c.find(function(a){return a.featureKey===b});if(!d)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b));if(!d.environmentEnabled)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagEnvironmentDisabled,d.featureKey,this.environment||_types.Environment.Production));var e=this.dataManager.storedTargetingData[a],f=this.variationConfiguration.getVariation({visitorCode:a,featureFlag:d,targetingData:e,withAssignment:!0,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw(),g=f.experimentId,h=f.variationId;return"number"==typeof h&&"number"==typeof g&&_utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:g,variationId:h}),_utilities.Utilities.trackFeatureExperiment({visitorCode:a,requester:this.requester,featureFlagVariation:f,dataManager:this.dataManager,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(a),offlineTrackingStorage:this.offlineTrackingStorage}),(0,_tsRes.Ok)(f)}}]),a}();exports.KameleoonClient=KameleoonClient;
19
2
  //# sourceMappingURL=kameleoonClient.js.map