ninchat-embed 2.4.1 → 2.5.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.
package/README.md CHANGED
@@ -1224,20 +1224,47 @@ Change a route on Ninchat in iframe.
1224
1224
  Ninchat.route(Route)
1225
1225
  ```
1226
1226
 
1227
- ## Enums
1227
+ ## Events
1228
1228
 
1229
- #### [Ninchat.Event](#events)
1229
+ #### Common Events for both embed 'app' and 'queue' versions
1230
+
1231
+ | Event | Event name | Parameters | Description |
1232
+ | ----------- | ---------- | ---------- | ----------- |
1233
+ | Route | route | `route`: {`name`, `params`, `audience_id?`, `metadata?`} | Emitted whenever user's route in Ninchat is changed |
1234
+ | Error | error | `error_type`: string, plus error-specific fields | Emitted when an error occurs |
1235
+ | ActivityCount | activity_count | `activity`: number, `highlights`: number | Typical use case for `ActivityCount` is to display activity as a number in host sites favicon. `activity` property contains the total activity including `highlights`. `highlights` are activity which has importance based on users settings or their role. Eg. highlight can be a name mention or a visitor requesting an audience. |
1236
+ | AudienceEnded | audience_eneded | `audience_id`: string | Emitted when an audience session ends |
1237
+ | AudienceClosed | audience_closed | `audience_id`: string | Emitted when the chat is closed |
1238
+ | SessionCreated | session_created | `user_queues?`: {[queue_id]: {`delivery_time`, `queue_time`, `realm_id`, `queue_attrs`}}, `user_channels?`: {[channel_id]: {`channel_attrs`, `channel_status?`, `realm_id?`}} | Emitted when a user session is created with queue and channel information |
1239
+ | QueueUpdated | queue_updated | `queue_id`: string, `queue_attrs`: {`name`, `length`, `group_id`, `is_group`}, `queue_time?`: number, `realm_id?`: string | Emitted when queue information is updated |
1240
+ | ChannelUpdated | channel_updated | `channel_id`: string, `channel_attrs`: {`audience_id`, `queue_id`, `name`, `closed`}, `channel_status?`: string, `realm_id?`: string | Emitted when channel information is updated |
1241
+ | ContainerInitialized | container_initialized | - | Emitted when the embed container is initialized |
1242
+
1243
+ #### Events for 'app' version
1244
+
1245
+ | Event | Event name | Parameters | Description |
1246
+ | ----------- | ---------- | ---------- | ----------- |
1247
+ | AudienceAccepted | audience_accepted | `audience_id`: string, `metadata?`: Record<string, unknown>[] | Emitted when a new chat session is started |
1248
+ | AcceptAudienceError | accept_audience_error | `queue_id`: string, `audience_id?`: string, `reason?`: string | event to parent frame if related event dispatch has been rejected |
1249
+ | AcceptServiceRequestError | accept_service_request_error | `queue_id`: string, `reason?`: string | event to parent frame if related event assign transcript dispatch has been rejected |
1250
+ | Notification | notification | `type`: NotificationType, `audio?`: boolean, `channel_name?`: string, `desktop?`: boolean, `message?`: string, `queue_name?`: string, `realm_name?`: string, `user_name?`: string | `Notification` event is emited whenever user would receive either a desktop or an audio notification based on users preferences. When Ninchat is embedded, instead of firing a desktop or audio notification, a `Notification` event is emited instead. |
1251
+
1252
+
1253
+ #### Events for 'queue' version
1254
+
1255
+ | Event | Event name | Parameters | Description |
1256
+ | ----------- | ---------- | ---------- | ----------- |
1257
+ | AudienceEnqueued | audience_enqueued | `audience_id`: string, `position`: number, `queue_id`: string | Emitted when user is placed in a queue with their position |
1258
+ | AudienceEnqueuedNext | audience_enqueued_next | `audience_id`: string, `queue_id`: string | Emitted when user is next in the queue |
1259
+ | AudienceStarted | audience_started | `audience_id`: string, `channel_id`: string | Emitted when an audience/chat session starts |
1260
+ | AudienceResumed | audience_resumed | `channel_id`: string | Emitted when an audience/chat session is resumed, for example after browser refresh |
1261
+ | AudienceRegistered | audience_registered | `queue_id`: string | Emitted when user registers to a queue |
1262
+ | AudienceTransferred | audience_transferred | `audience_id`: string, `audience_transferred`: string, `channel_id`: string | Emitted when an audience is transferred to another queue |
1263
+ | MessageReceived | message_received | `channel_id`: string | Emitted when a message is received in a channel |
1264
+ | MessageSent | message_sent | `channel_id`: string | Emitted when a message is sent in a channel |
1265
+ | State | state | `state`: 'minimized' \| 'open' \| 'full' | Emitted when embed display state changes |
1266
+ | Close | close | - | Emitted when the embed is closed |
1230
1267
 
1231
- | Enum value |
1232
- | ----------------------------------------------------------- |
1233
- | [`ActivityCount`](#ninchateventactivitycount) |
1234
- | [`AudienceAccepted`](#ninchateventaudienceaccepted) |
1235
- | [`AudienceClosed`](#ninchateventaudienceclosed) |
1236
- | [`AudienceEnded`](#ninchateventaudienceended) |
1237
- | [`ContainerInitialized`](#ninchateventcontainerinitialized) |
1238
- | [`Error`](#ninchateventerror) |
1239
- | [`Notification`](#ninchateventnotification) |
1240
- | [`Route`](#ninchateventroute) |
1241
1268
 
1242
1269
  #### Ninchat.ErrorType
1243
1270
 
@@ -1274,125 +1301,18 @@ the `route.name` property is one of the following:
1274
1301
  | Enum value |
1275
1302
  | ------------------- |
1276
1303
  | `Channel` |
1277
- | `Else` |
1304
+ | `Queue` |
1278
1305
  | `Transcript` |
1306
+ | `Realm` |
1307
+ | `Else` |
1308
+ | ------------------- |
1309
+ | `EmbedChannel` -> embed queue only |
1310
+ | `EmbedQueue` -> embed queue only |
1279
1311
 
1280
- ## Events
1281
-
1282
- Currently, the following events are supported:
1283
-
1284
- #### Ninchat.Event.ActivityCount
1285
-
1286
- ```typescript
1287
- {
1288
- event: Ninchat.Event.ActivityCount
1289
- activity: number
1290
- highlights: number
1291
- }
1292
- ```
1293
-
1294
- Typical use case for `ActivityCount` is to display activity as a number in host sites favicon.
1295
- `activity` property contains the total activity including `highlights`.
1296
-
1297
- `highlights` are activity which has importance based on users settings or their role.
1298
- Eg. highlight can be a name mention or a visitor requesting an audience.
1299
-
1300
- #### Ninchat.Event.AudienceAccepted
1301
-
1302
- ```typescript
1303
- {
1304
- audience_id: string
1305
- event: Ninchat.Event.AudienceAccepted
1306
- metadata?: []
1307
- }
1308
- ```
1309
-
1310
- `AudienceAccepted` event is emitted when a new chat session is started by interaction in current user interface.
1311
-
1312
- `metadata` array follows specifications described at [`AudienceRoute`](#audienceroute),
1313
-
1314
- #### Ninchat.Event.AudienceClosed
1315
-
1316
- ```typescript
1317
- {
1318
- audience_id: string
1319
- event: Ninchat.Event.AudienceClosed
1320
- }
1321
- ```
1322
-
1323
- `AudienceClosed` event is emitted when the chat is closed.
1324
-
1325
- #### Ninchat.Event.AudienceEnded
1326
-
1327
- ```typescript
1328
- {
1329
- audience_id: string
1330
- event: Ninchat.Event.AudienceEnded
1331
- }
1332
- ```
1333
-
1334
- `AudienceEnded` event is emitted when the chat session is ended.
1335
-
1336
- #### Ninchat.Event.ContainerInitialized
1337
-
1338
- ```typescript
1339
- {
1340
- event: Ninchat.Event.ContainerInitialized
1341
- }
1342
- ```
1343
-
1344
- #### Ninchat.Event.Error
1345
-
1346
- ```typescript
1347
- {
1348
- error_type: string
1349
- event: Ninchat.Event.Error
1350
- }
1351
- ```
1352
-
1353
- #### Ninchat.Event.Notification
1354
-
1355
- ```typescript
1356
- {
1357
- audio?: boolean
1358
- channel_name?: string
1359
- desktop?: boolean
1360
- event: Ninchat.Event.Notification
1361
- queue_name?: string
1362
- realm_name?: string
1363
- type: Ninchat.NotificationType
1364
- user_name?: string
1365
- }
1366
- ```
1367
-
1368
- `Notification` event is emited whenever user would receive either a desktop or an audio notification
1369
- based on users preferences. When Ninchat is embedded, instead of firing a desktop or audio notification,
1370
- a `Notification` event is emited instead.
1371
-
1372
- #### Ninchat.Event.Route
1373
-
1374
- ```typescript
1375
- {
1376
- event: Ninchat.Event.Route
1377
- route: AudienceRoute | ChannelRoute | ElseRoute | TranscriptRoute
1378
- }
1379
- ```
1380
-
1381
- `Route` event is emited whenever users route in Ninchat is changed. Host site can distinquish between different routes based on
1382
- the passed properties. `metadata` in `AudienceRoute` and `TranscriptRoute` contains pre-whitelisted subset of audience customers metadata.
1383
1312
 
1384
- ##### AudienceRoute
1313
+ ## Examples
1385
1314
 
1386
- ```typescript
1387
- {
1388
- audience_id: string
1389
- name: Ninchat.RouteName.Channel
1390
- metadata?: []
1391
- params: {
1392
- channel_id: string
1393
- }
1394
- }
1395
- ```
1315
+ ### Metadata
1396
1316
 
1397
1317
  `metadata` array contains secure metadata which is exposed to the parent on purpose. Array is used here, since in conversation can be multiple users with metadata.
1398
1318
 
@@ -1430,42 +1350,6 @@ Example: secure metadata containing following `shared` field..
1430
1350
  }
1431
1351
  ```
1432
1352
 
1433
- ##### ChannelRoute
1434
-
1435
- ```typescript
1436
- {
1437
- name: Ninchat.RouteName.Channel
1438
- params: {
1439
- channel_id: string
1440
- }
1441
- }
1442
- ```
1443
-
1444
- ##### ElseRoute
1445
-
1446
- ```typescript
1447
- {
1448
- name: Ninchat.RouteName.Else
1449
- }
1450
- ```
1451
-
1452
- ##### TranscriptRoute
1453
-
1454
- ```typescript
1455
- {
1456
- audience_id: string
1457
- name: Ninchat.RouteName.Transcript
1458
- metadata?: []
1459
- params: {
1460
- audience_id: string
1461
- }
1462
- }
1463
- ```
1464
-
1465
- `metadata` array follows specifications described at [`AudienceRoute`](#audienceroute),
1466
-
1467
- ## Examples
1468
-
1469
1353
  ### SSO
1470
1354
 
1471
1355
  SSO using email address:
@@ -1547,6 +1431,10 @@ Ninchat.route(route)
1547
1431
 
1548
1432
  ## Release history
1549
1433
 
1434
+ ### v2.5.0
1435
+
1436
+ - add AcceptAudienceError and AcceptServiceRequestError events
1437
+
1550
1438
  ### v2.4.1
1551
1439
 
1552
1440
  - force library code into single file