@sphoro/bugcatch-web-sdk 0.16.0 → 0.18.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 (52) hide show
  1. package/README.md +92 -5
  2. package/dist/bugcatch-call.es.js +586 -0
  3. package/dist/bugcatch-call.es.js.map +1 -0
  4. package/dist/bugcatch-call.umd.js +2 -0
  5. package/dist/bugcatch-call.umd.js.map +1 -0
  6. package/dist/bugcatch-core.es.js +3214 -0
  7. package/dist/bugcatch-core.es.js.map +1 -0
  8. package/dist/bugcatch-panel.es.js +2402 -0
  9. package/dist/bugcatch-panel.es.js.map +1 -0
  10. package/dist/bugcatch-panel.umd.js +1240 -0
  11. package/dist/bugcatch-panel.umd.js.map +1 -0
  12. package/dist/bugcatch.es.js +2 -5522
  13. package/dist/bugcatch.es.js.map +1 -1
  14. package/dist/bugcatch.standalone.umd.js +1536 -0
  15. package/dist/bugcatch.standalone.umd.js.map +1 -0
  16. package/dist/bugcatch.umd.js +89 -1183
  17. package/dist/bugcatch.umd.js.map +1 -1
  18. package/package.json +6 -6
  19. package/src/agent-issues.js +30 -0
  20. package/src/announcements.js +147 -0
  21. package/src/busy.js +18 -0
  22. package/src/call.js +7 -0
  23. package/src/capture.js +9 -0
  24. package/src/chunks.js +56 -0
  25. package/src/gesture.js +33 -0
  26. package/src/icons.js +18 -0
  27. package/src/identity.js +14 -9
  28. package/src/incoming-call.js +8 -30
  29. package/src/index.d.ts +50 -0
  30. package/src/index.js +170 -37
  31. package/src/lazy.js +23 -0
  32. package/src/notice.js +68 -0
  33. package/src/panel/call.js +242 -0
  34. package/src/panel/compose.js +416 -0
  35. package/src/panel/composer.js +235 -0
  36. package/src/panel/icons.js +34 -0
  37. package/src/panel/index.js +251 -0
  38. package/src/panel/known.js +130 -0
  39. package/src/panel/messages.js +176 -0
  40. package/src/panel/notices.js +34 -0
  41. package/src/panel/picks.js +61 -0
  42. package/src/panel/refs.js +321 -0
  43. package/src/panel/render.js +124 -0
  44. package/src/panel/signin.js +228 -0
  45. package/src/panel/styles.js +960 -0
  46. package/src/panel/thread.js +384 -0
  47. package/src/session.js +8 -3
  48. package/src/umd/call.js +6 -0
  49. package/src/umd/lazy.js +98 -0
  50. package/src/umd/panel.js +6 -0
  51. package/src/updates.js +20 -7
  52. package/src/widget.js +243 -3164
package/README.md CHANGED
@@ -55,7 +55,7 @@ BugCatch.init({
55
55
  ```html
56
56
  <!-- Pin the version. Without one the CDN serves whatever is latest, so a
57
57
  future release changes behaviour on a site nobody redeployed. -->
58
- <script src="https://unpkg.com/@sphoro/bugcatch-web-sdk@0.16.0/dist/bugcatch.umd.js"></script>
58
+ <script src="https://unpkg.com/@sphoro/bugcatch-web-sdk@0.18.0/dist/bugcatch.umd.js"></script>
59
59
  <script>
60
60
  BugCatch.init({ apiBase: '…', apiKey: 'bc_live_…', projectId: '…' });
61
61
  </script>
@@ -65,6 +65,21 @@ A floating **Report a bug** button appears, and whatever the page was doing is
65
65
  attached to each report. Types ship with the package (`src/index.d.ts`), so
66
66
  editors autocomplete every option and method below.
67
67
 
68
+ The script is the launcher and the capture, and nothing more. The report panel
69
+ and the call code are separate files in `dist/` — `bugcatch-panel.umd.js` and
70
+ `bugcatch-call.umd.js` — fetched from the folder the script was loaded from the
71
+ first time they are needed: the panel once the page has settled (or when the
72
+ button is pressed, if that comes first), the call code when a call is offered.
73
+ From a bundler, the same two parts are `import()`ed and your bundler splits them.
74
+
75
+ - **Content-Security-Policy:** allow the host in `script-src`, not the one file.
76
+ A `nonce` on the script tag is carried over to the parts it loads.
77
+ - **Hosting it yourself:** copy every `dist/bugcatch*.umd.js` into one folder
78
+ and load `bugcatch.umd.js` from it. If the script cannot know its own address
79
+ — pasted inline, or concatenated into one of your files — point it at the
80
+ folder with `init({ chunkBase: '/vendor/bugcatch/' })`, or serve
81
+ `dist/bugcatch.standalone.umd.js`, which is all of it in one file.
82
+
68
83
  Call `init()` once, as early as you can — console and network capture start at
69
84
  `init()`, so anything before it is not recorded. `identify()` and `setContext()`
70
85
  may be called before or after it.
@@ -287,6 +302,26 @@ seconds while its thread is open, and `BugCatch.myReport(bugId)` does it for you
287
302
  own view (it also returns `report.assistant`). Each change fires
288
303
  `onAssistantPhase` / `'assistant'` once.
289
304
 
305
+ ### Questions it answers and closes by itself
306
+
307
+ When the project has the Sphoro Agent answering questions, the widget opens
308
+ with one-tap questions: *Where is my application?*, *When is my next EMI due?*,
309
+ *Is my KYC complete?*, *My application was rejected — please review it again*,
310
+ and others. It only shows the ones your connected data source can answer. The
311
+ assistant looks the customer up, answers from their own record, and asks
312
+ *"Did this answer your question?"*. **Yes** resolves the report, **No** hands it
313
+ to your team, and no reply in two days closes it (any later reply reopens it).
314
+ A rejected-application request is explained and passed to your team, who move
315
+ the customer in your system and mark it done.
316
+
317
+ Building your own form (`widget: false`)? Offer the same list:
318
+
319
+ ```js
320
+ const issues = await BugCatch.agentIssues();
321
+ // [{ key: 'emi', title: 'When is my next EMI due?', hint: 'The date and the amount' }, …]
322
+ await BugCatch.report({ title: issues[0].title, issue: issues[0].key });
323
+ ```
324
+
290
325
  **Passing IDs is the biggest thing you can do for it.** Without them, the first
291
326
  thing the assistant usually has to do is ask the customer which account or loan
292
327
  they mean — the `needs_info` step — and wait for an answer.
@@ -344,13 +379,16 @@ On top of that:
344
379
  | `attachments` | `true` | Offer screenshot, recording and file attach. |
345
380
  | `maxAttachments` / `maxAttachmentBytes` / `maxRecordingMs` | `5` / `25 MB` / `120000` | Attachment limits. |
346
381
  | `drafts` | `true` | Recover an unfinished report on this device for seven days. |
382
+ | `agentIssues` | `true` | Show the one-tap questions the assistant answers by itself. Draws nothing until the project turns the agent on. |
347
383
  | `knownIssues` | `true` | Show what this project already knows is broken, with "me too". Draws nothing until the project turns it on. |
384
+ | `announcements` | `true` | Show what your team publishes under Settings → Project → Widget announcements, in the panel and beside the button. Draws nothing until one is published. `false` to show them your own way with `announcements()`. |
348
385
  | `beforeSend` | — | Mutate the payload, or return `false` to cancel. |
349
386
  | `updates` | `true` | Tell the reporter live when a report they filed moves. |
350
387
  | `updateToast` | `true` | Show the built-in notification; `false` to render your own from `'update'` / `'unread'`. |
351
388
  | `onUpdate` | — | Called on every update. |
352
389
  | `voice` | `true` | Offer calls where the workspace has calling configured. `false` switches calls off in both directions. |
353
390
  | `onCallState` / `onIncomingCall` | — | See [Talking a report through](#talking-a-report-through). |
391
+ | `chunkBase` | the script's own folder | Script tag only: where the panel and call code are fetched from. Set it when the bundle is inlined or its `dist/` files are served elsewhere. |
354
392
 
355
393
  An option the SDK does not know is reported in the console with a suggestion
356
394
  (`unknown option "projectID" — did you mean "projectId"?`).
@@ -366,7 +404,7 @@ BugCatch.setContext(null); // clear
366
404
  BugCatch.getContext();
367
405
 
368
406
  BugCatch.open(); BugCatch.close(); BugCatch.isOpen();
369
- await BugCatch.report({ title, description, priority, context, references, metadata, attachments });
407
+ await BugCatch.report({ title, description, priority, context, references, metadata, attachments, issue });
370
408
  await BugCatch.uploadAttachment(blob, mime, onProgress);
371
409
 
372
410
  const off = BugCatch.on('report' | 'assistant' | 'error' | 'update' | 'unread' | 'call'
@@ -382,8 +420,10 @@ BugCatch.hasReports(); BugCatch.forgetReports();
382
420
  await BugCatch.loginState(); BugCatch.signedInAs();
383
421
  await BugCatch.signIn(email); await BugCatch.confirmSignIn(email, code); await BugCatch.signOut();
384
422
  await BugCatch.referenceFields(); // the identifier question this project asks
423
+ await BugCatch.agentIssues(); // one-tap questions the assistant answers and closes
385
424
 
386
425
  await BugCatch.knownIssues(); await BugCatch.matchKnownIssues(q, { signal }); await BugCatch.meToo(bugId);
426
+ await BugCatch.announcements(); BugCatch.dismissAnnouncement(a); // what your team is telling visitors
387
427
 
388
428
  await BugCatch.canCallNow(); await BugCatch.startCall(bugId?); BugCatch.endCall();
389
429
 
@@ -411,6 +451,7 @@ Turn on `debug: true` first: the console then shows what `init()` received, ever
411
451
  | `identify()` "did nothing" | It was called with a non-object (ignored with a warning), or an identifier was an object/array/too long. See the console. |
412
452
  | Reports are not attributed / no resolution email / no live updates / no Call button | `identify()` has no `email`. |
413
453
  | The panel will not open with `open()` | `widget: false` — there is no built-in panel; use `report()`. |
454
+ | *The report form didn't load* above the launcher | `bugcatch-panel.umd.js` could not be fetched from beside `bugcatch.umd.js` — the console names the address. Serve `dist/` together, allow it in `script-src`, or set `chunkBase`. |
414
455
  | Nothing is captured from before a certain point | Capture starts at `init()`. Call it as early as possible. |
415
456
 
416
457
  ## Reference
@@ -793,6 +834,41 @@ this on, which is the default — draw nothing rather than an empty heading. Wha
793
834
  comes back is a title, a state and a count, and never a severity, an assignee or
794
835
  a description: the question it answers is "is this the thing I came here about".
795
836
 
837
+ ### Telling visitors something
838
+
839
+ Your team can put a notice in the widget from the dashboard, and change it or
840
+ take it down there, without redeploying your site: **Settings → Project → Widget
841
+ announcements**. "UPI payments are delayed today — we're on it, no need to
842
+ report it" is the reason it exists: said where people come to report, before
843
+ they type it out.
844
+
845
+ Each one picks where it appears:
846
+
847
+ - **In the widget**: at the top of the report panel, when somebody opens it.
848
+ - **Next to the button, too**: also as a small card beside the launcher on
849
+ every page, for people who came to do something else. Always closable.
850
+
851
+ A tone (info, success, warning, critical) picks the colour and the icon; info
852
+ wears your `accent`. A link is optional — a path like `/status` is a page on
853
+ your site, a full `https://` address opens a tab. Each runs between two days,
854
+ inclusive, on the visitor's own calendar, and the last day is required.
855
+ Closing one is remembered in that browser until somebody presses **Show it
856
+ again**; editing the wording does not reopen it.
857
+
858
+ A browser asks at most every five minutes, so a change reaches visitors within
859
+ that, and a project with nothing published costs one small request per browser
860
+ per five minutes.
861
+
862
+ ```js
863
+ // widget: false, or announcements: false — draw them your own way
864
+ const notices = await BugCatch.announcements();
865
+ // [{ id, title, body, tone, ctaLabel, ctaHref, placement, dismissible, ... }]
866
+ BugCatch.dismissAnnouncement(notices[0]);
867
+ ```
868
+
869
+ `announcements()` is already narrowed to the visitor's day and to what this
870
+ browser has not closed, and resolves to an empty list on every failure.
871
+
796
872
  ### Talking a report through
797
873
 
798
874
  Where the workspace has sphoro.voice configured, a reporter can talk to the team
@@ -939,8 +1015,8 @@ call, and if both are open, the first to answer gets it.
939
1015
  deployment without sphoro.voice and any workspace that has not switched calling
940
1016
  on, which is most of them. `canCallNow` additionally needs `identify()` to have
941
1017
  supplied an email: a call with nobody to attribute has no way to tell the
942
- reporter what happened next. Set `voice: false` to opt out entirely; the code is
943
- still in the bundle, but nothing runs.
1018
+ reporter what happened next. Set `voice: false` to opt out entirely; the call
1019
+ code is then never fetched, and nothing runs.
944
1020
 
945
1021
  ### Notes
946
1022
 
@@ -958,5 +1034,16 @@ still in the bundle, but nothing runs.
958
1034
 
959
1035
  ```bash
960
1036
  npm install
961
- npm run build # dist/bugcatch.es.js + dist/bugcatch.umd.js
1037
+ npm run build # every file below, into dist/ (scripts/build.mjs; the builds are in vite.config.js)
1038
+ npm run dev # the same, rebuilt on change
962
1039
  ```
1040
+
1041
+ | File | For |
1042
+ |---|---|
1043
+ | `bugcatch.es.js` (+ `bugcatch-core.es.js`, `bugcatch-panel.es.js`, `bugcatch-call.es.js`) | Bundlers. The panel and call code are `import()`ed, so they split off. |
1044
+ | `bugcatch.umd.js` | A `<script>` tag; `window.BugCatch`. Fetches the two below from beside itself. |
1045
+ | `bugcatch-panel.umd.js`, `bugcatch-call.umd.js` | Those parts, as scripts that register themselves with it. |
1046
+ | `bugcatch.standalone.umd.js` | All of it in one file, for a page that cannot load a second one. |
1047
+
1048
+ The build fails if the main script ends up containing either part, or if a part
1049
+ carries its own copy of something whose state belongs to the main script.