obi-sdk 0.1.8 → 0.1.10
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 +6 -72
- package/dist/{index-d9a81606.js → index-719ec57d.js} +792 -889
- package/dist/modular/chunks/{obi-widget-0d63936f.js → obi-widget-ff350828.js} +4 -4
- package/dist/modular/chunks/{obi-widget-0d63936f.js.map → obi-widget-ff350828.js.map} +1 -1
- package/dist/modular/chunks/{session-88fd0dca.js → session-c3b70ffb.js} +2 -2
- package/dist/modular/chunks/{session-88fd0dca.js.map → session-c3b70ffb.js.map} +1 -1
- package/dist/modular/core.js +5 -5
- package/dist/modular/index.js +220 -130
- package/dist/modular/index.js.map +1 -1
- package/dist/modular/ui.js +11 -11
- package/dist/obi-loader.js +5 -83
- package/dist/obi-sdk.es.js +5 -6
- package/dist/obi-sdk.standalone.iife.js +15 -15
- package/dist/obi-sdk.standalone.iife.js.map +1 -1
- package/dist/obi-sdk.umd.js +41 -41
- package/dist/{session-c2549ff3.js → session-730ff76c.js} +1 -1
- package/package.json +1 -2
- package/dist/modular/chunks/assistant-5a47c1b4.js +0 -234
- package/dist/modular/chunks/assistant-5a47c1b4.js.map +0 -1
- package/dist/obi-loader.iife.js +0 -2
- package/dist/obi-loader.iife.js.map +0 -1
- package/dist/obi-loader.js.map +0 -1
- package/dist/obi-loader.umd.cjs +0 -2
- package/dist/obi-loader.umd.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -14,12 +14,11 @@ A JavaScript SDK with dynamic content capabilities for integrating Obi into your
|
|
|
14
14
|
|
|
15
15
|
The loader accepts the following configuration options:
|
|
16
16
|
|
|
17
|
-
| Option | Type
|
|
18
|
-
| ---------- |
|
|
19
|
-
| `position` | string
|
|
20
|
-
| `apiKey` | string
|
|
21
|
-
| `
|
|
22
|
-
| `user` | object | - | User information with `id` (required), `email` (optional) and `metadata` (optional) |
|
|
17
|
+
| Option | Type | Default | Description |
|
|
18
|
+
| ---------- | ------ | ---------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| `position` | string | `'bottom-right'` | Position of the widget on the page. Options: `'bottom-right'`, `'bottom-left'`, `'top-right'`, `'top-left'` |
|
|
20
|
+
| `apiKey` | string | - | Your Obi API key (required for production) |
|
|
21
|
+
| `user` | object | - | User information with `id` (required), `email` (optional) and `metadata` (optional) |
|
|
23
22
|
|
|
24
23
|
## Installation Options
|
|
25
24
|
|
|
@@ -52,7 +51,7 @@ The simplest way to add Obi to your website is by using the inline loader script
|
|
|
52
51
|
<body>
|
|
53
52
|
<!-- Your website content -->
|
|
54
53
|
<script>
|
|
55
|
-
(()=>{var s=window,
|
|
54
|
+
(()=>{var s=window,r=document,d={position:"bottom-right"};function t(){var t,e,o,a=s.obiWidgetConfig||{};for(t in d)t in a||(a[t]=d[t]);if("function"==typeof s.ObiSDK||"object"==typeof s.ObiSDK)l(a);else if(s.__obiSDKLoading)e=function(){l(a)},o=s.setInterval(function(){"function"!=typeof s.ObiSDK&&"object"!=typeof s.ObiSDK||(s.clearInterval(o),e())},100);else{var i=function(t){var e,o,i,n;t=t,e=function(){s.__obiSDKLoading=!1,l(a)},s.__obiSDKLoading=!0,(o=r.createElement("script")).type="text/javascript",o.async=!0,o.src=(i="https://unpkg.com/obi-sdk")+"@"+(n=t||"latest")+"/dist/obi-sdk.standalone.iife.js",o.onload=e,o.onerror=function(){"latest"!==n?(console.warn("Failed to load specific version, falling back to latest"),o.src=i+"@latest/dist/obi-sdk.standalone.iife.js",o.onload=e):(s.__obiSDKLoading=!1,console.error("Failed to load Obi SDK"))},r.head.appendChild(o)};try{var n=new XMLHttpRequest;n.open("GET","https://registry.npmjs.org/obi-sdk/latest"),n.onload=function(){if(200===n.status)try{var t=JSON.parse(n.responseText);i(t.version)}catch(t){i(null)}else i(null)},n.onerror=function(){i(null)},n.send()}catch(t){i(null)}}}function l(t){var e;r.querySelector("obi-widget")?console.log("Obi Widget already exists on the page"):customElements.get("obi-widget")?(e=r.createElement("obi-widget"),t.apiKey&&e.setAttribute("api-key",t.apiKey),t.position&&e.setAttribute("position",t.position),t.user&&e.setAttribute("user",JSON.stringify(t.user)),r.body.appendChild(e),console.log("Obi Widget added to page")):console.warn("Obi Widget component not registered - SDK may not have loaded properly")}s.__obiSDKLoading=s.__obiSDKLoading||!1,"complete"===r.readyState?t():s.attachEvent?s.attachEvent("onload",t):s.addEventListener("load",t,!1)})();
|
|
56
55
|
</script>
|
|
57
56
|
</body>
|
|
58
57
|
</html>
|
|
@@ -76,48 +75,6 @@ You can also include the loader directly from our CDN:
|
|
|
76
75
|
<script src="https://unpkg.com/obi-sdk@latest/dist/obi-loader.iife.js"></script>
|
|
77
76
|
```
|
|
78
77
|
|
|
79
|
-
### Installation for npm Projects
|
|
80
|
-
|
|
81
|
-
You can also install the SDK via npm:
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
npm install obi-sdk
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Always Load the Latest SDK Version
|
|
88
|
-
|
|
89
|
-
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:
|
|
90
|
-
|
|
91
|
-
```tsx
|
|
92
|
-
import { initObi } from "obi-sdk"
|
|
93
|
-
|
|
94
|
-
// In a React component:
|
|
95
|
-
useEffect(() => {
|
|
96
|
-
const setupObi = async () => {
|
|
97
|
-
try {
|
|
98
|
-
// This will:
|
|
99
|
-
// 1. Check npm registry for the latest version
|
|
100
|
-
// 2. Load that specific version from unpkg.com
|
|
101
|
-
// 3. Initialize the widget with your config
|
|
102
|
-
await initObi({
|
|
103
|
-
apiKey: "YOUR_API_KEY",
|
|
104
|
-
position: "bottom-right",
|
|
105
|
-
user: {
|
|
106
|
-
id: "user-123",
|
|
107
|
-
email: "user@example.com",
|
|
108
|
-
},
|
|
109
|
-
})
|
|
110
|
-
console.log("Obi Assistant initialized with latest SDK")
|
|
111
|
-
} catch (error) {
|
|
112
|
-
console.error("Failed to initialize Obi Assistant:", error)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Initialize Obi
|
|
117
|
-
setupObi()
|
|
118
|
-
}, [])
|
|
119
|
-
```
|
|
120
|
-
|
|
121
78
|
## Widget Positioning
|
|
122
79
|
|
|
123
80
|
The widget can be positioned in one of four corners of the page:
|
|
@@ -129,29 +86,6 @@ window.obiWidgetConfig = {
|
|
|
129
86
|
}
|
|
130
87
|
```
|
|
131
88
|
|
|
132
|
-
### Theming
|
|
133
|
-
|
|
134
|
-
The widget supports light and dark themes:
|
|
135
|
-
|
|
136
|
-
```js
|
|
137
|
-
window.obiWidgetConfig = {
|
|
138
|
-
theme: "light", // Options: "light", "dark"
|
|
139
|
-
apiKey: "YOUR_API_KEY",
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### SDK Version Control
|
|
144
|
-
|
|
145
|
-
You can specify which version of the SDK to load:
|
|
146
|
-
|
|
147
|
-
```js
|
|
148
|
-
window.obiWidgetConfig = {
|
|
149
|
-
sdkVersion: "latest", // Use "latest" or a specific version number
|
|
150
|
-
noCacheSDK: false, // Set to true to bypass cache
|
|
151
|
-
apiKey: "YOUR_API_KEY",
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
89
|
## License
|
|
156
90
|
|
|
157
91
|
SEE LICENSE IN LICENSE.txt
|