obi-sdk 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -222,6 +222,47 @@ const sdk = new ObiSDK({
222
222
  })
223
223
  ```
224
224
 
225
+ ## Always Load the Latest SDK Version
226
+
227
+ The SDK includes a simple function to always load the latest version from the CDN, which can be useful for applications that need to ensure users always have the newest features. The dynamic loader follows the same version detection mechanism as the inline script, querying the npm registry to get the latest version.
228
+
229
+ ```tsx
230
+ import { initObi } from "obi-sdk"
231
+
232
+ // In a React component:
233
+ useEffect(() => {
234
+ const setupObi = async () => {
235
+ try {
236
+ // This will:
237
+ // 1. Check npm registry for the latest version
238
+ // 2. Load that specific version from unpkg.com
239
+ // 3. Initialize the widget with your config
240
+ await initObi({
241
+ apiKey: "YOUR_API_KEY",
242
+ position: "bottom-right",
243
+ user: {
244
+ id: "user-123",
245
+ email: "user@example.com",
246
+ },
247
+ })
248
+ console.log("Obi Assistant initialized with latest SDK")
249
+ } catch (error) {
250
+ console.error("Failed to initialize Obi Assistant:", error)
251
+ }
252
+ }
253
+
254
+ // Initialize Obi
255
+ setupObi()
256
+ }, [])
257
+ ```
258
+
259
+ This approach ensures your application always uses the newest SDK version without requiring updates to your codebase. The loader will:
260
+
261
+ 1. Query the npm registry to find the latest published version
262
+ 2. Load that specific version from unpkg.com
263
+ 3. Fall back to the "latest" tag if the specific version fails to load
264
+ 4. Initialize the Obi widget with your configuration
265
+
225
266
  ## Building the SDK
226
267
 
227
268
  To build the SDK locally: