create-heresay 0.2.33 → 0.2.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-heresay",
3
- "version": "0.2.33",
3
+ "version": "0.2.34",
4
4
  "description": "Set up your own Heresay: in-app feedback that every report gets a hearing. Creates a Firebase project in your Google account and deploys the dashboard, API and SDK to it.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/release/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.33
1
+ 0.2.34
@@ -1,3 +1,3 @@
1
1
  /** The Heresay release. Bumped by the release script; the CLI and /v1/health report it. */
2
- export const VERSION = '0.2.33';
2
+ export const VERSION = '0.2.34';
3
3
  //# sourceMappingURL=version.js.map
@@ -127,14 +127,15 @@
127
127
 
128
128
  /** One message at a time, bottom of the screen, with an optional action. Read out by screen readers. */
129
129
  var toastBox = null, toastTimer = null;
130
- function toast(text, action) {
130
+ /** `failed`: something didn't work, so no tick. */
131
+ function toast(text, action, failed) {
131
132
  if (!toastBox) {
132
133
  toastBox = el('div', { class: 'toast', role: 'status', 'aria-live': 'polite' });
133
134
  document.body.appendChild(toastBox);
134
135
  }
135
136
  clearTimeout(toastTimer);
136
137
  toastBox.textContent = '';
137
- toastBox.appendChild(el('span', { class: 'toast-tick', 'aria-hidden': 'true' }));
138
+ if (!failed) toastBox.appendChild(el('span', { class: 'toast-tick', 'aria-hidden': 'true' }));
138
139
  toastBox.appendChild(el('span', { text: text }));
139
140
  if (action) toastBox.appendChild(el('button', { type: 'button', text: action.label, onclick: function () { hideToast(); action.run(); } }));
140
141
  toastBox.classList.add('on');
@@ -1479,7 +1480,7 @@
1479
1480
  loaded = true; drawProducts(); render(background === true);
1480
1481
  }).catch(function (x) {
1481
1482
  if (!shell.isConnected) return;
1482
- if (loaded) { toast('Could not refresh reports. ' + x.message); return; }
1483
+ if (loaded) { toast('Could not refresh reports. ' + x.message, null, true); return; }
1483
1484
  list.textContent = ''; detail.textContent = '';
1484
1485
  list.appendChild(el('div', { class: 'inbox-empty' }, [el('h2', { text: 'Could not load reports' }), el('p', { class: 'err', role: 'alert', text: x.message }), el('button', { class: 'btn', text: 'Retry', onclick: load })]));
1485
1486
  });
@@ -1701,7 +1702,7 @@
1701
1702
  el('span', { class: 'mute', text: ' · ' + TYPE_LABEL[d.type] + (showPlatform ? ' · ' + platformOf(dp.platform).label : '') + ' · ' + new Date(d.created_at).toLocaleDateString() }),
1702
1703
  d.status === 'open' ? el('button', { class: 'link', type: 'button', text: 'Unmerge', onclick: function () {
1703
1704
  api('POST', '/projects/' + d.project_id + '/reports/' + d.id + '/unmerge').then(function () { toast('Unmerged.'); ctx.reload(); })
1704
- .catch(function (x) { toast(x.message); });
1705
+ .catch(function (x) { toast(x.message, null, true); });
1705
1706
  } }) : null,
1706
1707
  ]);
1707
1708
  })),
@@ -1763,7 +1764,7 @@
1763
1764
  var save = el('button', { class: 'btn primary', type: 'button', text: 'Save', onclick: function () {
1764
1765
  api('POST', '/projects/' + r.project_id + '/reports/' + r.id + '/fix-ref', { version: v.value.trim() })
1765
1766
  .then(function (b) { f = b.report.fix_ref || f; draw(); toast('They’ll see “Fixed in ' + f.version + '”.'); })
1766
- .catch(function (x) { toast(x.message); });
1767
+ .catch(function (x) { toast(x.message, null, true); });
1767
1768
  } });
1768
1769
  submitOnCmdEnter(v, save);
1769
1770
  line.appendChild(v); line.appendChild(save);
@@ -2332,7 +2333,10 @@
2332
2333
  function link(href, label) {
2333
2334
  var ok = /^(https?:\/\/|mailto:)/i.test(href);
2334
2335
  if (!ok) return document.createTextNode(label === href ? href : label + ' (' + href + ')');
2335
- return inline(el('a', { href: href, target: '_blank', rel: 'noopener noreferrer nofollow' }), label);
2336
+ var a = el('a', { href: href, target: '_blank', rel: 'noopener noreferrer nofollow' });
2337
+ // A bare address is its own label: as text, or inline() finds it again and never stops.
2338
+ if (label === href) { a.textContent = href; return a; }
2339
+ return inline(a, label);
2336
2340
  }
2337
2341
 
2338
2342
  // ---- chat apps -------------------------------------------------------------------------
@@ -102,7 +102,7 @@
102
102
  <tr><td><code>data-preferences</code></td><td><code>show</code> · <code>hide</code></td></tr>
103
103
  <tr><td><code>data-trail</code></td><td>on · <code>off</code> · the parts to keep, like <code>pages errors requests</code>. What happened before a report: pages, clicks, failed requests, errors. The reporter sees it and can take it off. Never what anyone typed.</td></tr>
104
104
  <tr><td><code>data-heresay-private</code></td><td>on any element of your app: clicks on it are recorded without its text</td></tr>
105
- <tr><td><code>data-nudge</code></td><td>off · <code>on</code> · the signals to watch, like <code>clicks errors</code>. When something failed (a button pressed again and again with nothing happening, an error right after a click, requests failing), a small note by the button asks “Something not working?”. When someone seems unsure (<code>stalled</code>: typing that stopped; <code>circles</code>: the same few pages over and over; <code>refused</code>: a field refused 3 times), it asks “Stuck on something?” and opens as Confusing. Watched on the device, never sent. Once per tab; quiet for 7 days after “Not now”.</td></tr></table>
105
+ <tr><td><code>data-nudge</code></td><td>off · <code>on</code> · the signals to watch, like <code>clicks errors</code>. When something failed (a button pressed again and again with nothing happening, an error right after a click, requests failing), a small note by the button asks “Something not working?”. When someone seems unsure (<code>stalled</code>: typing that stopped; <code>circles</code>: the same few pages over and over; <code>refused</code>: a field refused 3 times), it asks “Stuck on something?” and opens as Confusing. Watched on the device, never sent. Once per tab.</td></tr></table>
106
106
  <p>Always there, whatever you choose: the Heresay mark on the button, the <b>Your reports</b> tab (people read why a report was declined), and <b>Powered by Heresay</b> in the panel and the introduction, so people can tell your app uses an outside tool. The widget lives in a shadow root, so your CSS can't restyle it.</p>
107
107
 
108
108
  <h2 id="api">JavaScript API</h2>
@@ -76,8 +76,8 @@ anyone typed. On by default; change it only when asked.
76
76
 
77
77
  When someone seems stuck, a small note by the button (or in its corner on macOS) asks "Something
78
78
  not working?" and opens the sheet as Broken, with the trail. Watched on the device, never sent. At
79
- most once per launch, and not for 7 days after "Not now". Off by default: it appears on the app's
80
- own screen, so add it only when asked.
79
+ most once per launch. Off by default: it appears on the app's own screen, so add it only when
80
+ asked.
81
81
 
82
82
  | Option | Values |
83
83
  | --- | --- |
@@ -92,9 +92,8 @@ app updated from 1.3 to 1.4". On by default; change it only when asked.
92
92
  **Offering help**
93
93
 
94
94
  When someone seems stuck, a small note by the button asks "Something not working?" and opens the
95
- form as Broken, with the trail. Watched on the device, never sent. At most once per tab, and not
96
- for 7 days after "Not now". Off by default: it appears on the app's own page, so add it only when
97
- asked.
95
+ form as Broken, with the trail. Watched on the device, never sent. At most once per tab. Off by default:
96
+ it appears on the app's own page, so add it only when asked.
98
97
 
99
98
  | Attribute | Values |
100
99
  | --- | --- |
@@ -487,7 +487,9 @@
487
487
  var TRAIL_MAX = 50, TRAIL_AGE = 5 * 60000;
488
488
  // Pages visited and when someone last typed, for data-nudge ("offering help"). Here because the
489
489
  // page watcher below records the first page before that part of the script runs.
490
- var visits = [], typedAt = 0;
490
+ // Also when they last clicked or pressed a key, and when the page last changed, to tell what
491
+ // they sent from what the app sent by itself.
492
+ var visits = [], typedAt = 0, actedAt = 0, pageAt = 0;
491
493
  // data-nudge, read here because the request watchers below serve both. See "offering help".
492
494
  var NUDGE_SIGNALS = ['clicks', 'errors', 'requests', 'stalled', 'circles', 'refused'];
493
495
  var NUDGE = (function () {
@@ -617,6 +619,7 @@
617
619
  var w = location.pathname + location.hash;
618
620
  if (w === lastWhere) return;
619
621
  lastWhere = w;
622
+ pageAt = Date.now();
620
623
  visited(w);
621
624
  if (first === true) { note('page', titled(w)); return; }
622
625
  // Single-page apps set the title just after the address: the entry goes in now, in order,
@@ -720,10 +723,10 @@
720
723
  var url = typeof input === 'string' ? input : input && (input.url || String(input));
721
724
  if (url && !ours(url)) {
722
725
  var method = String(init && init.method || input && input.method || 'GET').toUpperCase();
723
- var t0 = Date.now();
726
+ var t0 = Date.now(), mine = byHand();
724
727
  p.then(function (res) {
725
728
  if (!res.ok && res.type !== 'opaque') { note('request', method + ' ' + shortUrl(url) + ' → ' + res.status + took(t0)); requestFailed(res.status); }
726
- else { slow(method, url, res.status, t0); if (method !== 'GET' && method !== 'HEAD') sentSomething(); }
729
+ else { slow(method, url, res.status, t0); if (mine && method !== 'GET' && method !== 'HEAD') sentSomething(); }
727
730
  }, function (err) {
728
731
  if (err && err.name === 'AbortError') return;
729
732
  note('request', method + ' ' + shortUrl(url) + ' → failed (' + (navigator.onLine === false ? 'offline' : 'network error') + ')' + took(t0));
@@ -744,12 +747,12 @@
744
747
  var x = this, r = x.__heresay;
745
748
  try {
746
749
  if (r && !ours(r.u)) {
747
- var aborted = false, t0 = Date.now();
750
+ var aborted = false, t0 = Date.now(), mine = byHand();
748
751
  x.addEventListener('abort', function () { aborted = true; });
749
752
  x.addEventListener('loadend', function () {
750
753
  if (x.status >= 400) { note('request', r.m + ' ' + shortUrl(r.u) + ' → ' + x.status + took(t0)); requestFailed(x.status); }
751
754
  else if (x.status === 0 && !aborted) { note('request', r.m + ' ' + shortUrl(r.u) + ' → failed (network error)' + took(t0)); requestFailed(0); }
752
- else if (x.status) { slow(r.m, r.u, x.status, t0); if (r.m !== 'GET' && r.m !== 'HEAD') sentSomething(); }
755
+ else if (x.status) { slow(r.m, r.u, x.status, t0); if (mine && r.m !== 'GET' && r.m !== 'HEAD') sentSomething(); }
753
756
  });
754
757
  }
755
758
  } catch (e) { /* ignore */ }
@@ -854,7 +857,7 @@
854
857
  * refused the same field refused 3 times in 2 minutes (the browser's check, or the app
855
858
  * setting aria-invalid)
856
859
  *
857
- * At most once per tab, and not for 7 days after "Not now".
860
+ * At most once per tab. "Not now" only closes it.
858
861
  */
859
862
  var DEAD_WAIT = 1500, DEAD_SPAN = 10000, DEAD_COUNT = 3;
860
863
  var lastPress = 0;
@@ -930,11 +933,19 @@
930
933
  }
931
934
  function trouble(why) { if (NUDGE[why]) offerHelp(/^(stalled|circles|refused)$/.test(why) ? 'stuck' : 'broken'); }
932
935
 
933
- // Unsure, not blocked. Anything sent (a form, a request that changes something) means they
936
+ // Unsure, not blocked. Anything they sent (a form, a request that changes something) means they
934
937
  // got there, so it starts these over.
935
938
  var sentAt = 0;
936
939
  function sentSomething() { sentAt = Date.now(); visits = []; typedAt = 0; }
937
940
  document.addEventListener('submit', function (e) { if (!host.contains(e.target)) sentSomething(); }, true);
941
+ // A request is theirs if it started within 2 s of a click or key press, with no page change in
942
+ // between. Apps send requests by themselves too: polling, analytics, and loading the new page's
943
+ // data after a page change (Firestore, for one, POSTs to listen). Those must not start "circles"
944
+ // over, or it would never be reached.
945
+ function acted(e) { if (!host.contains(e.target)) actedAt = Date.now(); }
946
+ document.addEventListener('pointerdown', acted, true);
947
+ document.addEventListener('keydown', acted, true);
948
+ function byHand() { return Date.now() - actedAt < 2000 && pageAt <= actedAt; }
938
949
 
939
950
  // Going in circles: a few pages, over and over, inside a minute.
940
951
  function visited(where) {
@@ -1598,8 +1609,8 @@
1598
1609
 
1599
1610
  // Someone seems stuck (data-nudge), or the app says so (nudge()). A note by the button, which
1600
1611
  // takes no focus and goes by itself after 15 s unless it is being read. "Tell the team" opens
1601
- // the form as Broken, with the trail. At most once per tab; "Not now" quiets it for 7 days.
1602
- var NUDGE_NO = 'fbsdk.nudge.no.' + KEY, NUDGE_TAB = 'fbsdk.nudged.' + KEY, NUDGE_REST = 7 * 864e5;
1612
+ // the form as Broken, with the trail. At most once per tab; "Not now" only closes it.
1613
+ var NUDGE_TAB = 'fbsdk.nudged.' + KEY;
1603
1614
  var nudgeEl = null;
1604
1615
  /** True if this tab was already offered help; otherwise marks it. */
1605
1616
  function offeredInTab() {
@@ -1617,28 +1628,26 @@
1617
1628
  function offerHelp(kind) {
1618
1629
  var stuck = kind === 'stuck';
1619
1630
  if (dead || scrim || bubble || nudgeEl || !host.isConnected || hiddenHere() || document.visibilityState === 'hidden') return false;
1620
- if (Date.now() - (+load(NUDGE_NO) || 0) < NUDGE_REST) return false;
1621
1631
  if (offeredInTab()) return false;
1622
1632
  var timer = null;
1623
- var done = function (no) {
1633
+ var done = function () {
1624
1634
  clearTimeout(timer);
1625
- if (no) save(NUDGE_NO, String(Date.now()));
1626
1635
  if (nudgeEl) { nudgeEl.remove(); nudgeEl = null; }
1627
1636
  };
1628
- var later = function () { clearTimeout(timer); timer = setTimeout(function () { done(false); }, 15000); };
1637
+ var later = function () { clearTimeout(timer); timer = setTimeout(done, 15000); };
1629
1638
  var stay = function () { clearTimeout(timer); };
1630
1639
  nudgeEl = el('div', {
1631
1640
  class: 'intro nudge ' + PLACE + ' st-' + STYLE + (fabShowing() ? '' : ' free'),
1632
1641
  role: 'status', 'aria-label': S.nudgeAria,
1633
1642
  onpointerenter: stay, onpointerleave: later, onfocusin: stay, onfocusout: later,
1634
- onkeydown: function (e) { if (e.key === 'Escape') done(true); },
1643
+ onkeydown: function (e) { if (e.key === 'Escape') done(); },
1635
1644
  }, [
1636
1645
  el('b', { text: stuck ? S.nudgeStuckTitle : S.nudgeTitle }),
1637
1646
  el('p', { text: stuck ? S.nudgeStuckBody : S.nudgeBody }),
1638
1647
  el('div', { class: 'row' }, [
1639
- el('button', { class: 'link', type: 'button', text: S.nudgeNo, onclick: function () { done(true); } }),
1648
+ el('button', { class: 'link', type: 'button', text: S.nudgeNo, onclick: function () { done(); } }),
1640
1649
  el('button', { class: 'send', type: 'button', text: S.nudgeYes, onclick: function () {
1641
- done(false);
1650
+ done();
1642
1651
  var as = stuck ? 'confusing' : 'broken';
1643
1652
  if (!state.type && OFFERED.some(function (t) { return t.id === as; })) state.type = as;
1644
1653
  open('new');