@kameleoon/react-sdk 8.5.2 → 9.0.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 (141) hide show
  1. package/CHANGELOG.md +472 -0
  2. package/CHANGELOG_INTERNAL.md +3 -0
  3. package/README.md +26 -133
  4. package/dist/KameleoonContext.d.ts +2 -2
  5. package/dist/KameleoonContext.js +1 -1
  6. package/dist/KameleoonContext.js.map +1 -1
  7. package/dist/KameleoonProvider.d.ts +5 -5
  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 +8 -14
  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,472 @@
1
+ # Change Log
2
+
3
+ ## 9.0.0 (2024-02-16)
4
+
5
+ ### Breaking Changes
6
+
7
+ - `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
8
+ - `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
9
+ - Previously deprecated `getBrowserVisitorCode` method and according hook were removed
10
+ - Most hooks were merged and methods were grouped by hooks:
11
+ - `useAddData`/`useTrackConversion`/`useFlush`/`useRemoteData`/`useRemoteVisitorData`/`useWarehouseAudience` -> `useData` ,containing all methods from the listed hooks
12
+ - `useFeatureFlagActive`/`useFeatureFlags`/`useFeatureVariable`/`useFeatureVariables`/`useFeatureFlagVariationKey`/`useVisitorFeatureFlags`/`useEngineTrackingCode` -> `useFeatureFlag`, containing all methods from the listed hooks
13
+ - `useConfigurationUpdate` -> `useInitialize`, containing `onConfigurationUpdate` and `initialize` methods
14
+ - `useSetLegalConsent` -> `useVisitorCode`, containing `getVisitorCode` and `setLegalConsent` methods
15
+ - 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)
16
+ - React SDK no more has React Native related packages in it's dependencies
17
+
18
+ ### Features
19
+
20
+ - Added [External Dependencies](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#external-dependencies) capabilities
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+ - @kameleoon/javascript-sdk@3.0.0
26
+
27
+ ## 8.5.2 (2024-02-07)
28
+
29
+ ### Bug fixes
30
+
31
+ - Tracking wasn't sent if consent is required
32
+
33
+ ## 8.5.1 (2024-01-29)
34
+
35
+ ### Bug fixes
36
+
37
+ - Context binding in [useSetLegalConsent](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk/#usesetlegalconsent) hook
38
+
39
+ ## 8.5.0 (2024-01-18)
40
+
41
+ ### Bug fixes
42
+
43
+ - SDK threw an error reading storage when migrating from older SDK versions
44
+ - React Native visitor code couldn't be read from storage in certain React Native versions
45
+ - React SDK request headers caused CORS errors
46
+
47
+ ### Features
48
+
49
+ - 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
50
+
51
+ ## 8.4.1 (2023-12-15)
52
+
53
+ ### Bug fixes
54
+
55
+ - Fix nonce for `Conversion` data
56
+
57
+ ## 8.4.0 (2023-12-12)
58
+
59
+ ### Features
60
+
61
+ - 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`
62
+ - 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.
63
+
64
+ ### Bug fixes
65
+
66
+ - Custom Data mapping identifier wasn't tracked correctly
67
+
68
+ ## 8.3.0 (2023-12-11)
69
+
70
+ ### Features
71
+
72
+ - [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
73
+
74
+ ### Bug fixes
75
+
76
+ - Targeting data cleanup caused `TypeError`
77
+
78
+ ## 8.2.1 (2023-12-04)
79
+
80
+ ### Bug fixes
81
+
82
+ - Client cookie is now set properly
83
+
84
+ ## 8.2.0 (2023-11-30)
85
+
86
+ ### Features
87
+
88
+ - [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)
89
+
90
+ ## 8.1.0 (2023-11-24)
91
+
92
+ ### Features
93
+
94
+ - 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).
95
+
96
+ ## 8.0.0 (2023-11-16)
97
+
98
+ ### Breaking change
99
+
100
+ - SDK stopped the support of the following methods were:
101
+ - `useExperiments`
102
+ - `useVisitorExperiments`
103
+ - `useTriggerExperiment`
104
+ - Previously deprecated `useFlushData` hook was removed
105
+ - [`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)
106
+ - [`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
107
+
108
+ ### Features
109
+
110
+ - 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)
111
+ - [`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
112
+ - [`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
113
+ - [`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
114
+ - [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)
115
+ - [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)
116
+ - `Browser Cookie`
117
+ - `Application Version`
118
+ - `Operating System`
119
+ - `IP Geolocation`
120
+ - `Segment`
121
+ - `Target Feature Flag`
122
+ - `Previous Page`
123
+ - `Number of Page Views`
124
+ - `Time since First Visit`
125
+ - `Time since Last Visit`
126
+ - `Number of Visits Today`
127
+ - `Total Number of Visits`
128
+ - `New or Returning Visitor`
129
+ - New Kameleoon Data types were introduced:
130
+ - [`ApplicationVersion`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#applicationversion)
131
+ - [`Cookie`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#cookie)
132
+ - [`OperatingSystem`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#operatingsystem)
133
+ - [`GeolocationData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#geolocationdata)
134
+
135
+ ### Bug fixes
136
+
137
+ - `SDKParameters` type is now correctly exported from SDK
138
+ - 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
139
+ - [`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)
140
+
141
+ ## 7.6.1 (2023-10-20)
142
+
143
+ ### Bug fixes
144
+
145
+ - Fix previous version deploy issue
146
+
147
+ ## 7.6.0 (2023-10-20)
148
+
149
+ ### Features
150
+
151
+ - Added new hook [`useVisitorWarehouseAudience`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usevisitorwarehousedata)
152
+
153
+ ## 7.5.4 (2023-10-11)
154
+
155
+ ### Bug fixes
156
+
157
+ - Storage data parse overhead optimization
158
+
159
+ ## 7.5.3 (2023-09-05)
160
+
161
+ ### Bug fixes
162
+
163
+ - `UserAgent` was not exported from SDK
164
+
165
+ ## 7.5.2 (2023-08-31)
166
+
167
+ ### Bug fixes
168
+
169
+ - `Custom Data Condition` now handles index `0` properly
170
+
171
+ ## 7.5.1 (2023-08-25)
172
+
173
+ ### Bug fixes
174
+
175
+ - Multiple `Real Time Update` connections are no longer created
176
+ - `Custom Data Condition` now handles all exceptions properly
177
+
178
+ ## 7.5.0 (2023-08-11)
179
+
180
+ ### Bug fixes
181
+
182
+ - Empty Custom Data is now sending activity tracking event
183
+
184
+ ### Features
185
+
186
+ - 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
187
+
188
+ ## 7.4.1 (2023-07-26)
189
+
190
+ ### Bug fixes
191
+
192
+ - 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.
193
+ - Timestamps for offline requests are set correctly.
194
+
195
+ ## 7.4.0 (2023-07-21)
196
+
197
+ ### Features
198
+
199
+ - `useFlushData` has been deprecated in favor of [`useFlush`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useflush).
200
+ - 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.
201
+
202
+ ## 7.3.2 (2023-07-17)
203
+
204
+ ### Bug fixes
205
+
206
+ - Typescript `.d.ts` files have proper relative path resolution.
207
+ - Unused tracking parameters are no longer sent.
208
+ - Real-time update events now get the latest configuration.
209
+ - Added exports for following types:
210
+ - [`ExperimentType`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useexperiments)
211
+ - [`FeatureFlagType`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usefeatureflags)
212
+ - [`FeatureVariableResultType`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#usefeaturevariable)
213
+ - [`KameleoonDataType`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useremotevisitordata)
214
+
215
+ ### Features
216
+
217
+ - 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.
218
+ - 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.
219
+
220
+ ## 7.3.1 (2023-06-30)
221
+
222
+ ### Bug fixes
223
+
224
+ - Tracking data duplication
225
+
226
+ ## 7.3.0 (2023-06-28)
227
+
228
+ ### Bug fixes
229
+
230
+ - 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)
231
+ - Visitor code is now validated correctly in every method that uses it.
232
+ - Result bundle is now compatible with systems not using `ESM` and `CommonJS`. It's minimized and uses code splitting for `crypto-js` `sha256` function.
233
+ - Parameter `revenue` for [`Conversion`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#conversion) is now optional.
234
+ - 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`.
235
+
236
+ ### Features
237
+
238
+ - 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).
239
+ - [`Browser`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#browser) now has new optional parameter `version`.
240
+ - [`flushData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#flush-tracking-data) `visitorCode` parameter is now optional.
241
+ - Custom data that is marked as `local only` on Kameleoon Platform is now only used for targeting (not flushed with tracking requests).
242
+
243
+ ## 7.2.4 (2023-06-01)
244
+
245
+ ### Bug fixes
246
+
247
+ - Empty visitor code is no more allowed
248
+ - Incorrect tracking body upon triggering an experiment
249
+
250
+ ## 7.2.3 (2023-05-24)
251
+
252
+ ### Bug fixes
253
+
254
+ - Fixed issue for sending unique `Nonce` parameter on tracking requests
255
+
256
+ ## 7.2.2 (2023-05-21)
257
+
258
+ ### Bug fixes
259
+
260
+ - [`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
261
+
262
+ ## 7.2.1 (2023-05-20)
263
+
264
+ ### Bug fixes
265
+
266
+ - [`useRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#obtain-custom-data-from-kameleoon-data-api) data parse error
267
+
268
+ ## 7.2.0 (2023-05-19)
269
+
270
+ ### Features
271
+
272
+ - New hook [`useRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#obtain-custom-data-from-kameleoon-data-api)
273
+ - New offline mode for [`useInitialize`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#initialize-kameleoon-client) method
274
+
275
+ ## 7.1.2 (2023-04-24)
276
+
277
+ ### Bug fixes
278
+
279
+ - Tracking feature flag rule with variation `off` wasn't displayed on result page
280
+
281
+ ## 7.1.1 (2023-04-22)
282
+
283
+ ### Bug fixes
284
+
285
+ - core dependency fix
286
+
287
+ ## 7.1.0 (2023-04-21)
288
+
289
+ ### Features
290
+
291
+ - New hook [`useEngineTrackingCode`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#sending-exposure-events-to-external-tools)
292
+
293
+ ## 7.0.0 (2023-04-14)
294
+
295
+ ### Breaking change
296
+
297
+ - 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)
298
+
299
+ ### Features
300
+
301
+ - Added hook [`useExperimentVariationData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#useexperimentvariationdata)
302
+ - 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
303
+ - [`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)
304
+
305
+ ### Bug fixes
306
+
307
+ - `variationId` is undefined when using feature flag related methods
308
+
309
+ ## 6.1.3 (2023-04-05)
310
+
311
+ ### Bug fixes
312
+
313
+ - export missing hooks
314
+
315
+ ## 6.1.2 (2023-04-05)
316
+
317
+ ### Bug fixes
318
+
319
+ - react sdk tests
320
+
321
+ ## 6.1.1 (2023-03-24)
322
+
323
+ ### Bug fixes
324
+
325
+ - change broken dependency
326
+
327
+ ## 6.1.0 (2023-03-22)
328
+
329
+ ### Features
330
+
331
+ - License changed from `GPL3.0` to `ISC`
332
+
333
+ ## 6.0.0 (2023-03-21)
334
+
335
+ ### Features
336
+
337
+ - Feature Flag v2 support
338
+ - Improved stability
339
+
340
+ ### Breaking change
341
+
342
+ - All `HOCs`,`Feature` render props, `compose` were removed
343
+ - All data types hooks were removed: `useDevice`, `useConversion`, `useCustomData`, `usePageView`, `useBrowser`
344
+ - Renamed hooks:
345
+ - `useFlush` -> `useFlushData`
346
+ - `useActivateFeature` -> `useFeatureActive`
347
+ - `useVisitorCode` -> `useBrowserVisitorCode`
348
+ - `useAsyncVisitorCode` -> `useNativeVisitorCode`
349
+ - `useRetrieveDataFromRemoteSource` -> `useRemoteData`
350
+ - Removed hooks:
351
+ - `useVariationAssociatedData`
352
+ - `useRunWhenReady`
353
+ - `useFeature`
354
+ - Added hooks:
355
+ - `useInitialize`
356
+ - `useConfigurationUpdate`
357
+ - `useFeatureFlags`
358
+ - `useVisitorFeatureFlags`
359
+ - `useExperiments`
360
+ - `useVisitorExperiments`
361
+ - `useFeatureFlagVariationKey`
362
+
363
+ ## 5.0.0 (2023-02-03)
364
+
365
+ ### Bug fixes
366
+
367
+ - remove xhr
368
+
369
+ ### Breaking change
370
+
371
+ - visitor code is now mandatory for hasFeature and useFeature
372
+
373
+ ## 4.1.1 (2022-11-01)
374
+
375
+ ### Bug fixes
376
+
377
+ - update tests
378
+
379
+ ## 4.1.0 (2022-10-13)
380
+
381
+ ### Features
382
+
383
+ - react native async storage
384
+
385
+ ## 4.0.3 (2022-09-05)
386
+
387
+ ### Bug fixes
388
+
389
+ - rerender error
390
+
391
+ ## 4.0.2 (2022-09-02)
392
+
393
+ ### Bug fixes
394
+
395
+ - max depth error
396
+
397
+ ## 4.0.1 (2022-08-23)
398
+
399
+ ### Bug fixes
400
+
401
+ - useDevice hook description
402
+
403
+ ## 4.0.0 (2022-08-18)
404
+
405
+ ### Features
406
+
407
+ - swap feature arguments
408
+ - add device custom data
409
+
410
+ ## 3.0.0 (2022-07-01)
411
+
412
+ ### Features
413
+
414
+ - error handling
415
+
416
+ ### Breaking change
417
+
418
+ - `useFeature` hook and `withFeature` high-order component can no longer be used the same way
419
+
420
+ ## 2.1.0 (2022-04-18)
421
+
422
+ ### Features
423
+
424
+ - retrieve data from remote source
425
+
426
+ ## 2.0.0 (2022-02-24)
427
+
428
+ ### Features
429
+
430
+ - add multi environment support
431
+
432
+ ### Breaking change
433
+
434
+ - variableKeys became an object and no longer can be used as an array or a string
435
+
436
+ ## 1.2.2 (2022-02-06)
437
+
438
+ ### Bug fixes
439
+
440
+ - bundle source and internal changelog
441
+
442
+ ## 1.2.1 (2022-02-06)
443
+
444
+ ### Bug fixes
445
+
446
+ - decrease bundle size
447
+
448
+ ## 1.2.0 (2022-01-27)
449
+
450
+ ### Bug Fixes
451
+
452
+ - linting issues
453
+
454
+ ## 1.1.0 (2022-01-26)
455
+
456
+ ### Bug Fixes
457
+
458
+ - package json
459
+
460
+ ## 1.0.0 (2022-01-20)
461
+
462
+ ### Bug Fixes
463
+
464
+ - linting and addData
465
+
466
+ ### Features
467
+
468
+ - add HOCs
469
+ - add render props
470
+ - test react sdk methods
471
+ - complete the documentation
472
+ - 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
- ```
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { KameleoonContextType } from './types';
3
- export declare const KameleoonContext: import("react").Context<KameleoonContextType | null>;
2
+ import { KameleoonClient } from '@kameleoon/javascript-sdk';
3
+ export declare const KameleoonContext: import("react").Context<KameleoonClient | null>;