@kameleoon/react-sdk 8.5.2 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/CHANGELOG.md +479 -0
  2. package/CHANGELOG_INTERNAL.md +3 -0
  3. package/README.md +26 -133
  4. package/dist/KameleoonContext.d.ts +3 -3
  5. package/dist/KameleoonContext.js +1 -1
  6. package/dist/KameleoonContext.js.map +1 -1
  7. package/dist/KameleoonProvider.d.ts +6 -6
  8. package/dist/KameleoonProvider.js +1 -1
  9. package/dist/KameleoonProvider.js.map +1 -1
  10. package/dist/createClient.d.ts +6 -0
  11. package/dist/createClient.js +2 -0
  12. package/dist/createClient.js.map +1 -0
  13. package/dist/index.d.ts +11 -24
  14. package/dist/index.js +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/interfaces/useData.d.ts +80 -0
  17. package/dist/interfaces/useData.js +2 -0
  18. package/dist/interfaces/useData.js.map +1 -0
  19. package/dist/interfaces/useFeatureFlag.d.ts +101 -0
  20. package/dist/interfaces/useFeatureFlag.js +2 -0
  21. package/dist/interfaces/useFeatureFlag.js.map +1 -0
  22. package/dist/interfaces/useInitialize.d.ts +23 -0
  23. package/dist/interfaces/useInitialize.js +2 -0
  24. package/dist/interfaces/useInitialize.js.map +1 -0
  25. package/dist/{useSetLegalConsent.d.ts → interfaces/useVisitorCode.d.ts} +12 -7
  26. package/dist/interfaces/useVisitorCode.js +2 -0
  27. package/dist/interfaces/useVisitorCode.js.map +1 -0
  28. package/dist/useData.d.ts +13 -0
  29. package/dist/useData.js +2 -0
  30. package/dist/useData.js.map +1 -0
  31. package/dist/useFeatureFlag.d.ts +15 -0
  32. package/dist/useFeatureFlag.js +2 -0
  33. package/dist/useFeatureFlag.js.map +1 -0
  34. package/dist/useInitialize.d.ts +6 -17
  35. package/dist/useInitialize.js +1 -1
  36. package/dist/useInitialize.js.map +1 -1
  37. package/dist/useKameleoon.d.ts +4 -4
  38. package/dist/useKameleoon.js +1 -1
  39. package/dist/useKameleoon.js.map +1 -1
  40. package/dist/useVisitorCode.d.ts +9 -0
  41. package/dist/useVisitorCode.js +2 -0
  42. package/dist/useVisitorCode.js.map +1 -0
  43. package/package.json +11 -15
  44. package/dist/eventSource/browserEventSource.d.ts +0 -4
  45. package/dist/eventSource/browserEventSource.js +0 -2
  46. package/dist/eventSource/browserEventSource.js.map +0 -1
  47. package/dist/eventSource/index.d.ts +0 -2
  48. package/dist/eventSource/index.js +0 -2
  49. package/dist/eventSource/index.js.map +0 -1
  50. package/dist/eventSource/nativeEventSource.d.ts +0 -4
  51. package/dist/eventSource/nativeEventSource.js +0 -2
  52. package/dist/eventSource/nativeEventSource.js.map +0 -1
  53. package/dist/kameleoonClient.d.ts +0 -7
  54. package/dist/kameleoonClient.js +0 -2
  55. package/dist/kameleoonClient.js.map +0 -1
  56. package/dist/kameleoonUtils/browserUtils.d.ts +0 -13
  57. package/dist/kameleoonUtils/browserUtils.js +0 -2
  58. package/dist/kameleoonUtils/browserUtils.js.map +0 -1
  59. package/dist/kameleoonUtils/nativeUtils.d.ts +0 -12
  60. package/dist/kameleoonUtils/nativeUtils.js +0 -2
  61. package/dist/kameleoonUtils/nativeUtils.js.map +0 -1
  62. package/dist/requester.d.ts +0 -9
  63. package/dist/requester.js +0 -2
  64. package/dist/requester.js.map +0 -1
  65. package/dist/storage/index.d.ts +0 -2
  66. package/dist/storage/index.js +0 -2
  67. package/dist/storage/index.js.map +0 -1
  68. package/dist/storage/localStorage.d.ts +0 -4
  69. package/dist/storage/localStorage.js +0 -2
  70. package/dist/storage/localStorage.js.map +0 -1
  71. package/dist/storage/nativeStorage.d.ts +0 -14
  72. package/dist/storage/nativeStorage.js +0 -2
  73. package/dist/storage/nativeStorage.js.map +0 -1
  74. package/dist/types.d.ts +0 -21
  75. package/dist/types.js +0 -2
  76. package/dist/types.js.map +0 -1
  77. package/dist/useAddData.d.ts +0 -22
  78. package/dist/useAddData.js +0 -2
  79. package/dist/useAddData.js.map +0 -1
  80. package/dist/useBrowserVisitorCode.d.ts +0 -17
  81. package/dist/useBrowserVisitorCode.js +0 -2
  82. package/dist/useBrowserVisitorCode.js.map +0 -1
  83. package/dist/useConfigurationUpdate.d.ts +0 -17
  84. package/dist/useConfigurationUpdate.js +0 -2
  85. package/dist/useConfigurationUpdate.js.map +0 -1
  86. package/dist/useEngineTrackingCode.d.ts +0 -5
  87. package/dist/useEngineTrackingCode.js +0 -2
  88. package/dist/useEngineTrackingCode.js.map +0 -1
  89. package/dist/useFeatureFlagActive.d.ts +0 -24
  90. package/dist/useFeatureFlagActive.js +0 -2
  91. package/dist/useFeatureFlagActive.js.map +0 -1
  92. package/dist/useFeatureFlagVariationKey.d.ts +0 -23
  93. package/dist/useFeatureFlagVariationKey.js +0 -2
  94. package/dist/useFeatureFlagVariationKey.js.map +0 -1
  95. package/dist/useFeatureFlags.d.ts +0 -18
  96. package/dist/useFeatureFlags.js +0 -2
  97. package/dist/useFeatureFlags.js.map +0 -1
  98. package/dist/useFeatureVariable.d.ts +0 -26
  99. package/dist/useFeatureVariable.js +0 -2
  100. package/dist/useFeatureVariable.js.map +0 -1
  101. package/dist/useFeatureVariables.d.ts +0 -25
  102. package/dist/useFeatureVariables.js +0 -2
  103. package/dist/useFeatureVariables.js.map +0 -1
  104. package/dist/useFlush.d.ts +0 -22
  105. package/dist/useFlush.js +0 -2
  106. package/dist/useFlush.js.map +0 -1
  107. package/dist/useNativeVisitorCode.d.ts +0 -16
  108. package/dist/useNativeVisitorCode.js +0 -2
  109. package/dist/useNativeVisitorCode.js.map +0 -1
  110. package/dist/useReactNativeVisitorCode.d.ts +0 -19
  111. package/dist/useReactNativeVisitorCode.js +0 -2
  112. package/dist/useReactNativeVisitorCode.js.map +0 -1
  113. package/dist/useReactVisitorCode.d.ts +0 -19
  114. package/dist/useReactVisitorCode.js +0 -2
  115. package/dist/useReactVisitorCode.js.map +0 -1
  116. package/dist/useRemoteData.d.ts +0 -19
  117. package/dist/useRemoteData.js +0 -2
  118. package/dist/useRemoteData.js.map +0 -1
  119. package/dist/useRemoteVisitorData.d.ts +0 -23
  120. package/dist/useRemoteVisitorData.js +0 -2
  121. package/dist/useRemoteVisitorData.js.map +0 -1
  122. package/dist/useSetLegalConsent.js +0 -2
  123. package/dist/useSetLegalConsent.js.map +0 -1
  124. package/dist/useTrackConversion.d.ts +0 -20
  125. package/dist/useTrackConversion.js +0 -2
  126. package/dist/useTrackConversion.js.map +0 -1
  127. package/dist/useVisitorFeatureFlags.d.ts +0 -22
  128. package/dist/useVisitorFeatureFlags.js +0 -2
  129. package/dist/useVisitorFeatureFlags.js.map +0 -1
  130. package/dist/useVisitorWarehouseAudience.d.ts +0 -24
  131. package/dist/useVisitorWarehouseAudience.js +0 -2
  132. package/dist/useVisitorWarehouseAudience.js.map +0 -1
  133. package/dist/visitorCodeManager/index.d.ts +0 -2
  134. package/dist/visitorCodeManager/index.js +0 -2
  135. package/dist/visitorCodeManager/index.js.map +0 -1
  136. package/dist/visitorCodeManager/reactNativeVisitorCodeManager.d.ts +0 -8
  137. package/dist/visitorCodeManager/reactNativeVisitorCodeManager.js +0 -2
  138. package/dist/visitorCodeManager/reactNativeVisitorCodeManager.js.map +0 -1
  139. package/dist/visitorCodeManager/reactVisitorCodeManager.d.ts +0 -8
  140. package/dist/visitorCodeManager/reactVisitorCodeManager.js +0 -2
  141. package/dist/visitorCodeManager/reactVisitorCodeManager.js.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,479 @@
1
+ # Change Log
2
+
3
+ ## 9.0.1 (2024-02-21)
4
+
5
+ ### Patch Changes
6
+
7
+ - `<KameleoonProvider />` React dependency is now properly used
8
+ - Convert dependency on [JavaScript SDK](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/) from peer to concrete
9
+
10
+ ## 9.0.0 (2024-02-16)
11
+
12
+ ### Breaking Changes
13
+
14
+ - `getReactVisitorCode` method and according hook were removed, instead use [`getVisitorCode`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#getvisitorcode) method
15
+ - `getReactNativeVisitorCode` method and according hook were removed, instead use [`getVisitorCode`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#getvisitorcode) method
16
+ - Previously deprecated `getBrowserVisitorCode` method and according hook were removed
17
+ - Most hooks were merged and methods were grouped by hooks:
18
+ - `useAddData`/`useTrackConversion`/`useFlush`/`useRemoteData`/`useRemoteVisitorData`/`useWarehouseAudience` -> `useData` ,containing all methods from the listed hooks
19
+ - `useFeatureFlagActive`/`useFeatureFlags`/`useFeatureVariable`/`useFeatureVariables`/`useFeatureFlagVariationKey`/`useVisitorFeatureFlags`/`useEngineTrackingCode` -> `useFeatureFlag`, containing all methods from the listed hooks
20
+ - `useConfigurationUpdate` -> `useInitialize`, containing `onConfigurationUpdate` and `initialize` methods
21
+ - `useSetLegalConsent` -> `useVisitorCode`, containing `getVisitorCode` and `setLegalConsent` methods
22
+ - React SDK for React Native now requires [providing external dependencies](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#react-native-considerations)
23
+ - React SDK no more has React Native related packages in it's dependencies
24
+
25
+ ### Features
26
+
27
+ - Added [External Dependencies](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#external-dependencies) capabilities
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies
32
+ - @kameleoon/javascript-sdk@3.0.0
33
+
34
+ ## 8.5.2 (2024-02-07)
35
+
36
+ ### Bug fixes
37
+
38
+ - Tracking wasn't sent if consent is required
39
+
40
+ ## 8.5.1 (2024-01-29)
41
+
42
+ ### Bug fixes
43
+
44
+ - Context binding in [useSetLegalConsent](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk/#usesetlegalconsent) hook
45
+
46
+ ## 8.5.0 (2024-01-18)
47
+
48
+ ### Bug fixes
49
+
50
+ - SDK threw an error reading storage when migrating from older SDK versions
51
+ - React Native visitor code couldn't be read from storage in certain React Native versions
52
+ - React SDK request headers caused CORS errors
53
+
54
+ ### Features
55
+
56
+ - Added new SDK `configuration` parameter [`requestTimeout`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#1-initializing-the-kameleoon-client), which defines maximum time in _milliseconds_ after which any SDK network request will fail
57
+
58
+ ## 8.4.1 (2023-12-15)
59
+
60
+ ### Bug fixes
61
+
62
+ - Fix nonce for `Conversion` data
63
+
64
+ ## 8.4.0 (2023-12-12)
65
+
66
+ ### Features
67
+
68
+ - Updated the `getFeatureFlagVariable` function of [useFeatureVariable](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usefeaturevariable) hook to return an object of type `FeatureFlagVariableType`
69
+ - Enhanced the `getFeatureFlagVariables`function of [useFeatureVariables](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usefeaturevariables) hook to include the `key` field in its return value.
70
+
71
+ ### Bug fixes
72
+
73
+ - Custom Data mapping identifier wasn't tracked correctly
74
+
75
+ ## 8.3.0 (2023-12-11)
76
+
77
+ ### Features
78
+
79
+ - [flush](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useflush) and [trackConversion](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usetrackconversion) methods now have a new optional parameter `isUniqueIdentifier` used for extra [Kameleoon Cross-device Experimentation](https://developers.kameleoon.com/core-concepts/cross-device-experimentation) capabilities
80
+
81
+ ### Bug fixes
82
+
83
+ - Targeting data cleanup caused `TypeError`
84
+
85
+ ## 8.2.1 (2023-12-04)
86
+
87
+ ### Bug fixes
88
+
89
+ - Client cookie is now set properly
90
+
91
+ ## 8.2.0 (2023-11-30)
92
+
93
+ ### Features
94
+
95
+ - [CustomData session merging](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#using-custom-data-for-session-merging) abilities for [Kameleoon Cross-device Experimentation](https://developers.kameleoon.com/core-concepts/cross-device-experimentation)
96
+
97
+ ## 8.1.0 (2023-11-24)
98
+
99
+ ### Features
100
+
101
+ - Added `useSetLegalConsent` hook to determine the types data Kameleoon includes in tracking requests. This helps you adhere to legal and regulatory requirements while responsibly managing visitor data. You can find more information in the [Consent management policy](https://help.kameleoon.com/consent-management-policy).
102
+
103
+ ## 8.0.0 (2023-11-16)
104
+
105
+ ### Breaking change
106
+
107
+ - SDK stopped the support of the following methods were:
108
+ - `useExperiments`
109
+ - `useVisitorExperiments`
110
+ - `useTriggerExperiment`
111
+ - Previously deprecated `useFlushData` hook was removed
112
+ - [`createClient`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#createclient) method parameters are now an object with type [`SDKParameters`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#parameters)
113
+ - [`useRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useremotevisitordata) hook callback parameters was changed to an object with type [`RemoteVisitorDataParamsType`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#parameters-12) that has a new `filters` field
114
+
115
+ ### Features
116
+
117
+ - New hook with a method for retrieving multiple feature flag variables - [`useFeatureFlagVariables`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usefeatureflagvariables)
118
+ - [`useRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useremotevisitordata) callback is now capable of retrieving information from up to 25 visits along with some additional visit information configured by new `filters` field
119
+ - [`PageView`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#pageview) data items are now stored by unique URL with timestamps of visits - each visitor can have several `PageView` URLs stored
120
+ - [`Conversion`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#conversion) data items are now stored as a list of conversion for each visitor
121
+ - [Cross Device Synchronization](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#synchronizing-custom-data-across-devices) was improved - [`CustomData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#customdata) with `Visitor` scope is always re-sent with tracking calls allowing seamless synchronization using [`getRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#getremotevisitordata)
122
+ - [New targeting conditions](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#list-of-supported-targeting-conditions) are now available (some of them may require [`getRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#getremotevisitordata) pre-loaded data)
123
+ - `Browser Cookie`
124
+ - `Application Version`
125
+ - `Operating System`
126
+ - `IP Geolocation`
127
+ - `Segment`
128
+ - `Target Feature Flag`
129
+ - `Previous Page`
130
+ - `Number of Page Views`
131
+ - `Time since First Visit`
132
+ - `Time since Last Visit`
133
+ - `Number of Visits Today`
134
+ - `Total Number of Visits`
135
+ - `New or Returning Visitor`
136
+ - New Kameleoon Data types were introduced:
137
+ - [`ApplicationVersion`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#applicationversion)
138
+ - [`Cookie`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#cookie)
139
+ - [`OperatingSystem`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#operatingsystem)
140
+ - [`GeolocationData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#geolocationdata)
141
+
142
+ ### Bug fixes
143
+
144
+ - `SDKParameters` type is now correctly exported from SDK
145
+ - SDK Polling re-tries mechanism was optimized - SDK will now try to obtain configuration again during the next poll after 3 failed configuration loading attempts
146
+ - [`onConfigurationUpdate`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useconfigurationupdate) callback now fires on successful configuration update in storage (previously fired after network configuration retrieval)
147
+
148
+ ## 7.6.1 (2023-10-20)
149
+
150
+ ### Bug fixes
151
+
152
+ - Fix previous version deploy issue
153
+
154
+ ## 7.6.0 (2023-10-20)
155
+
156
+ ### Features
157
+
158
+ - Added new hook [`useVisitorWarehouseAudience`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usevisitorwarehousedata)
159
+
160
+ ## 7.5.4 (2023-10-11)
161
+
162
+ ### Bug fixes
163
+
164
+ - Storage data parse overhead optimization
165
+
166
+ ## 7.5.3 (2023-09-05)
167
+
168
+ ### Bug fixes
169
+
170
+ - `UserAgent` was not exported from SDK
171
+
172
+ ## 7.5.2 (2023-08-31)
173
+
174
+ ### Bug fixes
175
+
176
+ - `Custom Data Condition` now handles index `0` properly
177
+
178
+ ## 7.5.1 (2023-08-25)
179
+
180
+ ### Bug fixes
181
+
182
+ - Multiple `Real Time Update` connections are no longer created
183
+ - `Custom Data Condition` now handles all exceptions properly
184
+
185
+ ## 7.5.0 (2023-08-11)
186
+
187
+ ### Bug fixes
188
+
189
+ - Empty Custom Data is now sending activity tracking event
190
+
191
+ ### Features
192
+
193
+ - Added [Cross Device Custom Data Synchronization](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#cross-device-custom-data-synchronization) capabilities
194
+
195
+ ## 7.4.1 (2023-07-26)
196
+
197
+ ### Bug fixes
198
+
199
+ - The returned function of [`useFlush`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useflush) now sends offline tracking requests even if there's no new data to track.
200
+ - Timestamps for offline requests are set correctly.
201
+
202
+ ## 7.4.0 (2023-07-21)
203
+
204
+ ### Features
205
+
206
+ - `useFlushData` has been deprecated in favor of [`useFlush`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useflush).
207
+ - The function returned from [`useFlush`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useflush) sends failed tracking requests that were stored locally during the offline mode at first and then proceeds with the latest request.
208
+
209
+ ## 7.3.2 (2023-07-17)
210
+
211
+ ### Bug fixes
212
+
213
+ - Typescript `.d.ts` files have proper relative path resolution.
214
+ - Unused tracking parameters are no longer sent.
215
+ - Real-time update events now get the latest configuration.
216
+ - Added exports for following types:
217
+ - [`ExperimentType`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useexperiments)
218
+ - [`FeatureFlagType`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usefeatureflags)
219
+ - [`FeatureVariableResultType`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usefeaturevariable)
220
+ - [`KameleoonDataType`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useremotevisitordata)
221
+
222
+ ### Features
223
+
224
+ - When the client is initialized in offline mode, in case of network issues failed tracking requests made by returned functions of [`useFlushData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useflushdata), [`useTrackConversion`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usetrackconversion), [`useTriggerExperiment`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usetriggerexperiment), [`useFeatureFlagVariationKey`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usefeatureflagvariationkey) or [`useFeatureVariable`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usefeaturevariable) will be sent anew once the client is back online.
225
+ - Minor optimization for checking [targeting conditions](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#list-of-supported-targeting-conditions) of a segment.
226
+
227
+ ## 7.3.1 (2023-06-30)
228
+
229
+ ### Bug fixes
230
+
231
+ - Tracking data duplication
232
+
233
+ ## 7.3.0 (2023-06-28)
234
+
235
+ ### Bug fixes
236
+
237
+ - Improve error handling for [`getRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#obtain-custom-data-from-kameleoon-data-api)
238
+ - Visitor code is now validated correctly in every method that uses it.
239
+ - Result bundle is now compatible with systems not using `ESM` and `CommonJS`. It's minimized and uses code splitting for `crypto-js` `sha256` function.
240
+ - Parameter `revenue` for [`Conversion`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#conversion) is now optional.
241
+ - Each visitor can now only have one type of associated [`Kameleoon Data Type`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#data-types), except for [`CustomData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#customdata), that a visitor can have one per `customDataIndex`.
242
+
243
+ ### Features
244
+
245
+ - New conditions are now supported: `Device`, `Browser`, `SDKLanguage`, `Page Title`, `Page View`, `Visitor Code`, `Conversion`. See the [full list of supported conditions](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#list-of-supported-targeting-conditions).
246
+ - [`Browser`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#browser) now has new optional parameter `version`.
247
+ - [`flushData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#flush-tracking-data) `visitorCode` parameter is now optional.
248
+ - Custom data that is marked as `local only` on Kameleoon Platform is now only used for targeting (not flushed with tracking requests).
249
+
250
+ ## 7.2.4 (2023-06-01)
251
+
252
+ ### Bug fixes
253
+
254
+ - Empty visitor code is no more allowed
255
+ - Incorrect tracking body upon triggering an experiment
256
+
257
+ ## 7.2.3 (2023-05-24)
258
+
259
+ ### Bug fixes
260
+
261
+ - Fixed issue for sending unique `Nonce` parameter on tracking requests
262
+
263
+ ## 7.2.2 (2023-05-21)
264
+
265
+ ### Bug fixes
266
+
267
+ - [`useRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#obtain-custom-data-from-kameleoon-data-api) current visits not being up-to-date
268
+
269
+ ## 7.2.1 (2023-05-20)
270
+
271
+ ### Bug fixes
272
+
273
+ - [`useRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#obtain-custom-data-from-kameleoon-data-api) data parse error
274
+
275
+ ## 7.2.0 (2023-05-19)
276
+
277
+ ### Features
278
+
279
+ - New hook [`useRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#obtain-custom-data-from-kameleoon-data-api)
280
+ - New offline mode for [`useInitialize`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#initialize-kameleoon-client) method
281
+
282
+ ## 7.1.2 (2023-04-24)
283
+
284
+ ### Bug fixes
285
+
286
+ - Tracking feature flag rule with variation `off` wasn't displayed on result page
287
+
288
+ ## 7.1.1 (2023-04-22)
289
+
290
+ ### Bug fixes
291
+
292
+ - core dependency fix
293
+
294
+ ## 7.1.0 (2023-04-21)
295
+
296
+ ### Features
297
+
298
+ - New hook [`useEngineTrackingCode`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#sending-exposure-events-to-external-tools)
299
+
300
+ ## 7.0.0 (2023-04-14)
301
+
302
+ ### Breaking change
303
+
304
+ - Error handling has changed, hook do not return `error` object anymore. See [details](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#error-handling)
305
+
306
+ ### Features
307
+
308
+ - Added hook [`useExperimentVariationData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useexperimentvariationdata)
309
+ - Targeting data cleanup interval is now [`optional`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#1-initializing-the-kameleoon-client) and not set by default
310
+ - [`getFeatureFlagVariationKey`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#get-variation-key-for-a-certain-feature-flag), [`getFeatureFlagVariable`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#get-a-variable-of-a-certain-feature-flag), [`isFeatureFlagActive`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#check-if-the-feature-is-active-for-visitor) methods returned from according hooks do not check previously allocated variation, rather recalculate it each time. Same methods now send tracking request for any rule type (previously only for `Experementation` rule)
311
+
312
+ ### Bug fixes
313
+
314
+ - `variationId` is undefined when using feature flag related methods
315
+
316
+ ## 6.1.3 (2023-04-05)
317
+
318
+ ### Bug fixes
319
+
320
+ - export missing hooks
321
+
322
+ ## 6.1.2 (2023-04-05)
323
+
324
+ ### Bug fixes
325
+
326
+ - react sdk tests
327
+
328
+ ## 6.1.1 (2023-03-24)
329
+
330
+ ### Bug fixes
331
+
332
+ - change broken dependency
333
+
334
+ ## 6.1.0 (2023-03-22)
335
+
336
+ ### Features
337
+
338
+ - License changed from `GPL3.0` to `ISC`
339
+
340
+ ## 6.0.0 (2023-03-21)
341
+
342
+ ### Features
343
+
344
+ - Feature Flag v2 support
345
+ - Improved stability
346
+
347
+ ### Breaking change
348
+
349
+ - All `HOCs`,`Feature` render props, `compose` were removed
350
+ - All data types hooks were removed: `useDevice`, `useConversion`, `useCustomData`, `usePageView`, `useBrowser`
351
+ - Renamed hooks:
352
+ - `useFlush` -> `useFlushData`
353
+ - `useActivateFeature` -> `useFeatureActive`
354
+ - `useVisitorCode` -> `useBrowserVisitorCode`
355
+ - `useAsyncVisitorCode` -> `useNativeVisitorCode`
356
+ - `useRetrieveDataFromRemoteSource` -> `useRemoteData`
357
+ - Removed hooks:
358
+ - `useVariationAssociatedData`
359
+ - `useRunWhenReady`
360
+ - `useFeature`
361
+ - Added hooks:
362
+ - `useInitialize`
363
+ - `useConfigurationUpdate`
364
+ - `useFeatureFlags`
365
+ - `useVisitorFeatureFlags`
366
+ - `useExperiments`
367
+ - `useVisitorExperiments`
368
+ - `useFeatureFlagVariationKey`
369
+
370
+ ## 5.0.0 (2023-02-03)
371
+
372
+ ### Bug fixes
373
+
374
+ - remove xhr
375
+
376
+ ### Breaking change
377
+
378
+ - visitor code is now mandatory for hasFeature and useFeature
379
+
380
+ ## 4.1.1 (2022-11-01)
381
+
382
+ ### Bug fixes
383
+
384
+ - update tests
385
+
386
+ ## 4.1.0 (2022-10-13)
387
+
388
+ ### Features
389
+
390
+ - react native async storage
391
+
392
+ ## 4.0.3 (2022-09-05)
393
+
394
+ ### Bug fixes
395
+
396
+ - rerender error
397
+
398
+ ## 4.0.2 (2022-09-02)
399
+
400
+ ### Bug fixes
401
+
402
+ - max depth error
403
+
404
+ ## 4.0.1 (2022-08-23)
405
+
406
+ ### Bug fixes
407
+
408
+ - useDevice hook description
409
+
410
+ ## 4.0.0 (2022-08-18)
411
+
412
+ ### Features
413
+
414
+ - swap feature arguments
415
+ - add device custom data
416
+
417
+ ## 3.0.0 (2022-07-01)
418
+
419
+ ### Features
420
+
421
+ - error handling
422
+
423
+ ### Breaking change
424
+
425
+ - `useFeature` hook and `withFeature` high-order component can no longer be used the same way
426
+
427
+ ## 2.1.0 (2022-04-18)
428
+
429
+ ### Features
430
+
431
+ - retrieve data from remote source
432
+
433
+ ## 2.0.0 (2022-02-24)
434
+
435
+ ### Features
436
+
437
+ - add multi environment support
438
+
439
+ ### Breaking change
440
+
441
+ - variableKeys became an object and no longer can be used as an array or a string
442
+
443
+ ## 1.2.2 (2022-02-06)
444
+
445
+ ### Bug fixes
446
+
447
+ - bundle source and internal changelog
448
+
449
+ ## 1.2.1 (2022-02-06)
450
+
451
+ ### Bug fixes
452
+
453
+ - decrease bundle size
454
+
455
+ ## 1.2.0 (2022-01-27)
456
+
457
+ ### Bug Fixes
458
+
459
+ - linting issues
460
+
461
+ ## 1.1.0 (2022-01-26)
462
+
463
+ ### Bug Fixes
464
+
465
+ - package json
466
+
467
+ ## 1.0.0 (2022-01-20)
468
+
469
+ ### Bug Fixes
470
+
471
+ - linting and addData
472
+
473
+ ### Features
474
+
475
+ - add HOCs
476
+ - add render props
477
+ - test react sdk methods
478
+ - complete the documentation
479
+ - add createClient, provider and hooks
@@ -0,0 +1,3 @@
1
+ # Internal Change Log
2
+
3
+ All significant internal changes to this project will be documented in this file.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # Kameleoon React/React Native SDK
1
+ # Kameleoon React SDK
2
2
 
3
3
  ## Introduction
4
4
 
5
- Kameleoon React/React Native SDK is used to work with Kameleoon Feature Flags and Experiments.
6
- Integration of this SDK on web/mobile is easy, and its footprint is low.
5
+ Kameleoon React SDK is used to work with Kameleoon Feature Flags and Experiments using native JavaScript or specific React Native APIs.
6
+ The package provides a number of hooks and wrappers that can grant React oriented support for Kameleoon SDK when using it in React or React Native applications.
7
7
 
8
8
  This page describes the most basic configuration, for more in-depth review of all the hooks and configuration options follow [Official Kameleoon Documentation](https://developers.kameleoon.com/react-js-sdk.html)
9
9
 
@@ -11,22 +11,22 @@ This page describes the most basic configuration, for more in-depth review of al
11
11
 
12
12
  - [Installation](#installation)
13
13
  - [Configuration](#configuration)
14
- - [Using useReactVisitorCode and useReactNativeVisitorCode (Recommended)](#using-usereactvisitorcode-recommended)
15
- - [Legacy useBrowserVisitorCode and useNativeVisitorCode (Deprecated)](#legacy-usebrowservisitorcode-deprecated)
14
+ - [Usage Example](#usage-example)
16
15
 
17
16
  ## Installation
18
17
 
19
18
  - **npm** - `npm install @kameleoon/react-sdk`
20
19
  - **yarn** - `yarn add @kameleoon/react-sdk`
21
20
  - **pnpm** - `pnpm add @kameleoon/react-sdk`
21
+ - **bun** - `bun install @kameleoon/react-sdk`
22
22
 
23
23
  ## Configuration
24
24
 
25
25
  1. Obtain your site code from [Kameleoon Platform](https://app.kameleoon.com/)
26
- 2. Create client and pass it to `KameleoonProvider`
26
+ 2. Instantiate SDK client and pass it to `KameleoonProvider`
27
27
 
28
28
  ```tsx
29
- import { createClient, KameleoonProvider } from '@kameleoon/react-sdk';
29
+ import { KameleoonProvider, createClient } from '@kameleoon/react-sdk';
30
30
 
31
31
  const client = createClient({ siteCode: 'my_site_code' });
32
32
 
@@ -39,148 +39,41 @@ function MyComponentWrapper(): JSX.Element {
39
39
  }
40
40
  ```
41
41
 
42
- ## Using useReactVisitorCode (Recommended)
43
-
44
- 1. Asynchronously initialize client to fetch the configuration from remote server and handle possible errors
42
+ ## Usage Example
45
43
 
46
44
  ```tsx
47
45
  import { useEffect } from 'react';
48
46
  import {
49
- useInitialize,
50
- useAddData,
51
- useReactVisitorCode,
52
- useFeatureFlagActive,
47
+ useData,
53
48
  CustomData,
49
+ useInitialize,
50
+ useVisitorCode,
51
+ useFeatureFlag,
54
52
  } from '@kameleoon/react-sdk';
55
53
 
56
54
  function MyComponent(): JSX.Element {
57
55
  const { initialize } = useInitialize();
58
- const { addData } = useAddData();
59
- // -- Hook to generate new visitorCode. For React Native use `useReactNativeVisitorCode` hook
60
- const { getReactVisitorCode } = useReactVisitorCode();
61
- const { isFeatureFlagActive } = useFeatureFlagActive();
62
- const customDataIndex = 0;
63
-
64
- async function waitForInitialize(): Promise<void> {
65
- const isReady = await initialize();
66
-
67
- if (isReady) {
68
- const visitorCode = getReactVisitorCode();
69
-
70
- // -- Add targeting data
71
- addData(visitorCode, new CustomData(customDataIndex, 'my_data'));
72
-
73
- // -- Check if the feature is active for visitor
74
- const isMyFeatureActive = isFeatureFlagActive(
75
- visitorCode,
76
- 'my_feature_key',
77
- );
78
- }
79
- }
80
-
81
- useEffect(() => {
82
- waitForInitialize();
83
- }, []);
84
- }
85
- ```
86
-
87
- 2. `hooks` are ready to use. Note: They can be used only inside `KameleoonProvider`
88
-
89
- ```tsx
90
- import {
91
- useAddData,
92
- useReactVisitorCode,
93
- useFeatureFlagActive,
94
- CustomData,
95
- } from '@kameleoon/react-sdk';
96
-
97
- function MyComponent(): JSX.Element {
98
- const { addData } = useAddData();
99
- // -- Hook to generate new visitorCode. For React Native use `useReactNativeVisitorCode` hook
100
- const { getReactVisitorCode } = useReactVisitorCode();
101
- const { isFeatureFlagActive } = useFeatureFlagActive();
102
-
103
- const visitorCode = getReactVisitorCode();
104
- const customDataIndex = 0;
105
-
106
- // -- Add targeting data
107
- addData(visitorCode, new CustomData(customDataIndex, 'my_data'));
108
-
109
- // -- Check if the feature is active for visitor
110
- const isMyFeatureActive = isFeatureFlagActive(visitorCode, 'my_feature_key');
111
- }
112
- ```
56
+ const { addData } = useData();
57
+ const { isFeatureFlagActive } = useFeatureFlag();
58
+ const { getVisitorCode } = useVisitorCode();
113
59
 
114
- ## Legacy useBrowserVisitorCode (Deprecated)
60
+ async function init(): Promise<void> {
61
+ // -- Wait for the client initialization
62
+ await initialize();
115
63
 
116
- > **Note:** The `useBrowserVisitorCode` and `useNativeVisitorCode` hooks are deprecated and will be removed in a future release. Use [`useReactVisitorCode`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usereactvisitorcode) and [`useReactNativeVisitorCode`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usereactnativevisitorcode) instead.
64
+ // -- Generate a visitor code
65
+ const visitorCode = getVisitorCode();
117
66
 
118
- 1. Asynchronously initialize client to fetch the configuration from remote server and handle possible errors
67
+ // -- Add targeting data
68
+ const customDataIndex = 0;
69
+ addData(visitorCode, new CustomData(customDataIndex, 'my_data'));
119
70
 
120
- ```tsx
121
- import { useEffect } from 'react';
122
- import {
123
- useInitialize,
124
- useAddData,
125
- useBrowserVisitorCode,
126
- useFeatureFlagActive,
127
- CustomData,
128
- } from '@kameleoon/react-sdk';
129
-
130
- function MyComponent(): JSX.Element {
131
- const { initialize } = useInitialize();
132
- const { addData } = useAddData();
133
- // -- Hook to generate new visitorCode. For React Native use `useNativeVisitorCode` hook
134
- const { getBrowserVisitorCode } = useBrowserVisitorCode();
135
- const { isFeatureFlagActive } = useFeatureFlagActive();
136
-
137
- const visitorCode = getBrowserVisitorCode('www.example.com');
138
- const customDataIndex = 0;
139
-
140
- async function waitForInitialize(): Promise<void> {
141
- const isReady = await initialize();
142
-
143
- if (isReady) {
144
- // -- Add targeting data
145
- addData(visitorCode, new CustomData(customDataIndex, 'my_data'));
146
-
147
- // -- Check if the feature is active for visitor
148
- const isMyFeatureActive = isFeatureFlagActive(
149
- visitorCode,
150
- 'my_feature_key',
151
- );
152
- }
71
+ // -- Check if the feature is active for visitor
72
+ const isActive = isFeatureFlagActive(visitorCode, 'my_feature_key');
153
73
  }
154
74
 
155
75
  useEffect(() => {
156
- waitForInitialize();
76
+ init();
157
77
  }, []);
158
78
  }
159
79
  ```
160
-
161
- 2. `hooks` are ready to use. Note: They can be used only inside `KameleoonProvider`
162
-
163
- ```tsx
164
- import {
165
- useAddData,
166
- useBrowserVisitorCode,
167
- useFeatureFlagActive,
168
- CustomData,
169
- } from '@kameleoon/react-sdk';
170
-
171
- function MyComponent(): JSX.Element {
172
- const { addData } = useAddData();
173
- // -- Hook to generate new visitorCode. For React Native use `useNativeVisitorCode` hook
174
- const { getBrowserVisitorCode } = useBrowserVisitorCode();
175
- const { isFeatureFlagActive } = useFeatureFlagActive();
176
-
177
- const visitorCode = getBrowserVisitorCode('www.example.com');
178
- const customDataIndex = 0;
179
-
180
- // -- Add targeting data
181
- addData(visitorCode, new CustomData(customDataIndex, 'my_data'));
182
-
183
- // -- Check if the feature is active for visitor
184
- const isMyFeatureActive = isFeatureFlagActive(visitorCode, 'my_feature_key');
185
- }
186
- ```