@journyio/messaging-sdk 1.0.0 → 1.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.
- package/README.md +30 -0
- package/dist/index.d.ts +1 -1
- package/dist/journy-messages.esm.js +238 -98
- package/dist/journy-messages.js +238 -98
- package/dist/journy-messages.min.js +3 -3
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,8 +52,14 @@ npm install @journyio/messaging-sdk
|
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
```javascript
|
|
55
|
+
import React from 'react';
|
|
56
|
+
import ReactDOM from 'react-dom';
|
|
55
57
|
import { JournyMessaging } from '@journyio/messaging-sdk';
|
|
56
58
|
|
|
59
|
+
// Make React available globally for the SDK's internal rendering
|
|
60
|
+
window.React = React;
|
|
61
|
+
window.ReactDOM = ReactDOM;
|
|
62
|
+
|
|
57
63
|
const messaging = new JournyMessaging({
|
|
58
64
|
writeKey: 'your-write-key',
|
|
59
65
|
userId: 'user-123',
|
|
@@ -73,6 +79,8 @@ const messaging = new JournyMessages({
|
|
|
73
79
|
});
|
|
74
80
|
```
|
|
75
81
|
|
|
82
|
+
> **Note**: The SDK renders its widget using `window.React` and `window.ReactDOM`. In a bundled React app these are not on `window` by default — you must assign them before creating a `JournyMessaging` instance. When using script tags, the UMD builds set these globals automatically.
|
|
83
|
+
|
|
76
84
|
## Configuration
|
|
77
85
|
|
|
78
86
|
### Basic Configuration
|
|
@@ -85,6 +93,9 @@ const messaging = new JournyMessaging({
|
|
|
85
93
|
entityType: 'user', // Required: 'user' or 'account'
|
|
86
94
|
apiEndpoint: 'https://jtm.journy.io', // Optional: API base URL
|
|
87
95
|
pollingInterval: 30000, // Optional: Polling interval in ms (default: 30000)
|
|
96
|
+
displayMode: 'widget', // Optional: 'widget' (floating) or 'list' (inline)
|
|
97
|
+
isCollapsed: false, // Optional: Start collapsed or expanded
|
|
98
|
+
renderTarget: 'self', // Optional: 'self', 'parent', or 'top'
|
|
88
99
|
});
|
|
89
100
|
```
|
|
90
101
|
|
|
@@ -98,6 +109,10 @@ const messaging = new JournyMessaging({
|
|
|
98
109
|
| `entityType` | `'user' \| 'account'` | Yes | - | Type of entity to fetch messages for |
|
|
99
110
|
| `apiEndpoint` | `string` | No | `'https://jtm.journy.io'` | API base URL |
|
|
100
111
|
| `pollingInterval` | `number` | No | `30000` | Interval in milliseconds to poll for new messages |
|
|
112
|
+
| `displayMode` | `'widget' \| 'list'` | No | `'widget'` | Display as floating widget or inline list |
|
|
113
|
+
| `isCollapsed` | `boolean` | No | `false` | Whether the widget starts collapsed |
|
|
114
|
+
| `styles` | `'default' \| 'none' \| { url: string } \| { css: string }` | No | `'default'` | Style injection mode |
|
|
115
|
+
| `renderTarget` | `'self' \| 'parent' \| 'top'` | No | `'self'` | Which document to render the widget in (useful for iframes) |
|
|
101
116
|
|
|
102
117
|
## API Reference
|
|
103
118
|
|
|
@@ -226,6 +241,21 @@ When using default styles, you can still customize by overriding these CSS class
|
|
|
226
241
|
- `.journy-message-warning` - Warning messages (orange border)
|
|
227
242
|
- `.journy-message-error` - Error messages (red border)
|
|
228
243
|
|
|
244
|
+
## Rendering Inside an Iframe
|
|
245
|
+
|
|
246
|
+
If the SDK is loaded inside an iframe and you want the widget to appear on the parent page:
|
|
247
|
+
|
|
248
|
+
```javascript
|
|
249
|
+
const messaging = new JournyMessages({
|
|
250
|
+
writeKey: 'your-write-key',
|
|
251
|
+
entityType: 'user',
|
|
252
|
+
userId: 'user-123',
|
|
253
|
+
renderTarget: 'parent', // or 'top' for the top-level window
|
|
254
|
+
});
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The parent page must be same-origin. If cross-origin, the SDK falls back to rendering inside the iframe.
|
|
258
|
+
|
|
229
259
|
## Security
|
|
230
260
|
|
|
231
261
|
### XSS Prevention
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JournyMessaging } from './core/JournyMessaging';
|
|
2
2
|
export { JournyMessaging };
|
|
3
3
|
export type { JournyMessagingConfig } from './core/JournyMessaging';
|
|
4
|
-
export type { Message, AppDisplayMode, StylesConfig } from './types';
|
|
4
|
+
export type { Message, AppDisplayMode, StylesConfig, RenderTarget } from './types';
|
|
5
5
|
export default JournyMessaging;
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|