create-heresay 0.2.9 → 0.2.11
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 +26 -3
- package/release/VERSION +1 -1
- package/release/functions/lib/core/version.js +1 -1
- package/release/public/dashboard.css +80 -0
- package/release/public/dashboard.js +423 -0
- package/release/public/demo.html +5 -1
- package/release/public/docs.html +32 -6
- package/release/public/guides/changes.json +18 -0
- package/release/public/guides/customize-apple.md +74 -0
- package/release/public/guides/customize-web.md +95 -0
- package/release/public/guides/index.json +3 -1
- package/release/public/guides/install-apple.md +4 -2
- package/release/public/guides/install-web.md +6 -2
- package/release/public/guides/start.md +3 -0
- package/release/public/llms.txt +2 -0
- package/release/public/sdk.js +429 -97
|
@@ -199,12 +199,14 @@
|
|
|
199
199
|
});
|
|
200
200
|
var view = $('view');
|
|
201
201
|
view.textContent = '';
|
|
202
|
+
view.classList.remove('wide');
|
|
202
203
|
if (parts[0] === 'team') return teamView(view);
|
|
203
204
|
if (parts[0] === 'connect') return connectView(view, query);
|
|
204
205
|
if (parts[0] === 'new') return newAppView(view, parts[1], query);
|
|
205
206
|
if (parts[0] === 'apps' && parts[1]) {
|
|
206
207
|
return withProject(parts[1], function (p) {
|
|
207
208
|
if (parts[2] === 'setup') setupView(view, p);
|
|
209
|
+
else if (parts[2] === 'design' && (p.platform === 'web' || platformOf(p.platform).apple)) designView(view, p);
|
|
208
210
|
else if (parts[2] === 'delete') deleteView(view, p);
|
|
209
211
|
else reportsView(view, p);
|
|
210
212
|
});
|
|
@@ -235,6 +237,8 @@
|
|
|
235
237
|
{ id: 'flutter', label: 'Flutter', note: 'Dart, any platform',
|
|
236
238
|
icon: '<path d="M14 3 5 12l3 3L20 3zM14 12l-5 5 5 5h6l-5-5 5-5z"/>' },
|
|
237
239
|
];
|
|
240
|
+
/** Platforms with an SDK whose look can be designed. */
|
|
241
|
+
var designable = function (p) { return p.platform === 'web' || !!platformOf(p.platform).apple; };
|
|
238
242
|
var platformOf = function (id) { return PLATFORMS.filter(function (x) { return x.id === id; })[0] || PLATFORMS[0]; };
|
|
239
243
|
/** Apps that are platforms of one product share its id: the first app's. */
|
|
240
244
|
var productOf = function (p) { return p.product_id || p.id; };
|
|
@@ -432,6 +436,422 @@
|
|
|
432
436
|
form.name.focus();
|
|
433
437
|
}
|
|
434
438
|
|
|
439
|
+
// ---- design ----------------------------------------------------------------------------
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* What a developer can change about the web widget, and the value we recommend first. Only
|
|
443
|
+
* what differs from the recommendation goes in the tag. The full list: public/guides/customize-web.md.
|
|
444
|
+
*/
|
|
445
|
+
var DESIGN = [
|
|
446
|
+
{ group: 'The button', items: [
|
|
447
|
+
{ a: 'position', label: 'Where it sits', c: [['', 'Bottom right'], ['left', 'Bottom left'], ['top-right', 'Top right'], ['top-left', 'Top left'], ['center', 'Bottom centre']] },
|
|
448
|
+
{ a: 'offset', label: 'Distance from the edge', c: [['', '20px'], ['40', '40px'], ['96', '96px, above a chat bubble']], text: 'or x,y like 24,96', pattern: /^\d{1,3}(\s*,\s*\d{1,3})?$/ },
|
|
449
|
+
{ a: 'button', label: 'When it shows', c: [['', 'Always'], ['none', 'Never: my app has its own menu item'], ['desktop', 'Not on phones'], ['scroll', 'After the first scroll']] },
|
|
450
|
+
{ a: 'label', label: 'Text', c: [['', 'Report'], ['Feedback', 'Feedback'], ['Help us improve', 'Help us improve'], ['Found a bug?', 'Found a bug?']], text: 'or your own words', max: 40 },
|
|
451
|
+
{ a: 'style', label: 'Style', c: [['', 'Pill with text'], ['icon', 'Icon only'], ['tab', 'Tab on the side']] },
|
|
452
|
+
{ a: 'size', label: 'Size', c: [['', 'Regular'], ['small', 'Small'], ['large', 'Large']] },
|
|
453
|
+
{ a: 'fill', label: 'Button colour', c: [['', 'White, or dark in dark mode'], ['accent', 'Filled with your colour']] },
|
|
454
|
+
{ a: 'shadow', label: 'Shadow', c: [['', 'Soft'], ['none', 'None'], ['strong', 'Strong']] },
|
|
455
|
+
{ a: 'hide-on', label: 'Hide it on these pages', c: [], text: '/checkout, /login', max: 300, hint: 'That path and everything under it.' },
|
|
456
|
+
]},
|
|
457
|
+
{ group: 'Look', items: [
|
|
458
|
+
{ a: 'accent', label: 'Your colour', color: true, c: [['', 'Heresay peacock', '#0f766e'], ['#7c3aed', 'Purple', '#7c3aed'], ['#2563eb', 'Blue', '#2563eb'], ['#e11d48', 'Rose', '#e11d48'], ['#15171c', 'Ink', '#15171c']] },
|
|
459
|
+
{ a: 'mark', label: 'Logo colour', c: [['', 'Follows your colour'], ['heresay', 'Heresay teal']] },
|
|
460
|
+
{ a: 'theme', label: 'Light or dark', c: [['', 'Follow the device'], ['light', 'Always light'], ['dark', 'Always dark']] },
|
|
461
|
+
{ a: 'font', label: 'Font', c: [['', 'System font'], ['inherit', 'My page’s font']] },
|
|
462
|
+
]},
|
|
463
|
+
{ group: 'Words', items: [
|
|
464
|
+
{ a: 'lang', label: 'Language', c: [['', 'My page’s language'], ['auto', 'The browser’s'], ['en', 'English'], ['fr', 'Français'], ['ta', 'தமிழ்'], ['hi', 'हिन्दी']], hint: 'English, French, Tamil and Hindi today; any other language shows English.' },
|
|
465
|
+
{ a: 'placeholder', label: 'Question in the text box', c: [['', 'What happened, or what would you change?']], text: 'or your own words', max: 120 },
|
|
466
|
+
{ a: 'types', label: 'Report types', c: [['', 'All four'], ['broken,confusing,improvement', 'No “Idea”'], ['broken,confusing', 'Only Broken and Confusing']], hint: 'Their names can’t change: the type sets the priority.' },
|
|
467
|
+
{ a: 'thanks', label: 'Thank-you line after sending', c: [['', 'None']], text: 'e.g. Thanks! We read every one.', max: 160 },
|
|
468
|
+
]},
|
|
469
|
+
{ group: 'The panel', items: [
|
|
470
|
+
{ a: 'panel', label: 'Where it opens', c: [['', 'Next to the button'], ['sheet', 'Side sheet'], ['center', 'Middle of the screen']] },
|
|
471
|
+
{ a: 'width', label: 'Width', c: [['', 'Regular'], ['narrow', 'Narrow'], ['wide', 'Wide']] },
|
|
472
|
+
{ a: 'backdrop', label: 'Behind it', c: [['', 'Dim the page'], ['clear', 'Leave the page clear'], ['blur', 'Blur']] },
|
|
473
|
+
{ a: 'preferences', label: 'Preferences tab', c: [['', 'Show'], ['hide', 'Hide']], hint: 'Hide it if your app calls identify() and asks nothing else.' },
|
|
474
|
+
{ a: 'intro', label: 'Introduce the button', c: [['', 'When my app calls introduce()'], ['auto', '3 seconds after the first visit']] },
|
|
475
|
+
]},
|
|
476
|
+
];
|
|
477
|
+
var DESIGN_ITEMS = [].concat.apply([], DESIGN.map(function (g) { return g.items; }));
|
|
478
|
+
|
|
479
|
+
function esc(s) { return String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); }
|
|
480
|
+
|
|
481
|
+
/** The data- attributes a design adds to the tag, in the order the list shows them. */
|
|
482
|
+
function designAttrs(cfg) {
|
|
483
|
+
return DESIGN_ITEMS.filter(function (it) { return cfg[it.a]; }).map(function (it) { return ['data-' + it.a, cfg[it.a]]; });
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function designTag(p, cfg) {
|
|
487
|
+
var a = designAttrs(cfg);
|
|
488
|
+
if (!a.length) return tag(p);
|
|
489
|
+
return '<script src="' + SDK_URL + '"\n data-key="' + p.key + '"' +
|
|
490
|
+
a.map(function (x) { return '\n ' + x[0] + '="' + esc(x[1]) + '"'; }).join('') + '\n defer></scr' + 'ipt>';
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** A made-up page in the app's name, with the real widget on it in preview mode. */
|
|
494
|
+
function previewDoc(p, cfg, show, dark) {
|
|
495
|
+
var own = cfg.button === 'none';
|
|
496
|
+
var attrs = designAttrs(cfg).map(function (x) { return ' ' + x[0] + '="' + esc(x[1]) + '"'; }).join('');
|
|
497
|
+
var then = {
|
|
498
|
+
panel: 'H.open();',
|
|
499
|
+
intro: 'if(!H.introduce())document.getElementById("note").hidden=false;',
|
|
500
|
+
sent: 'H.open({type:"broken",text:"The export button does nothing."});' +
|
|
501
|
+
'document.querySelector("[data-feedback-sdk]").shadowRoot.querySelector(".send").click();',
|
|
502
|
+
}[show] || '';
|
|
503
|
+
return '<!doctype html><html lang="en"><head><meta charset="utf-8"><style>' +
|
|
504
|
+
'body{margin:0;min-height:1400px;font:15px/1.6 Georgia,serif;background:' + (dark ? '#111317;color:#e6e8eb' : '#fff;color:#1d2127') + '}' +
|
|
505
|
+
'header{display:flex;justify-content:space-between;align-items:center;padding:14px 22px;border-bottom:1px solid ' + (dark ? '#262a31' : '#e6e8eb') + ';font-weight:700;font-size:17px}' +
|
|
506
|
+
'nav{display:flex;gap:16px;font:14px system-ui;font-weight:400;opacity:.8}nav a{color:inherit;text-decoration:none}nav a.own{border:1px dashed currentColor;padding:1px 8px;border-radius:6px}' +
|
|
507
|
+
'main{padding:22px;max-width:620px}.bar{height:12px;border-radius:6px;margin:12px 0;background:' + (dark ? '#262a31' : '#eceef1') + '}' +
|
|
508
|
+
'#note{position:fixed;left:22px;bottom:22px;font:13px system-ui;opacity:.7}</style></head><body>' +
|
|
509
|
+
'<header>' + esc(productName(p)) + '<nav><a>Docs</a><a>Settings</a>' + (own ? '<a class="own" href="#" onclick="Heresay.open();return false">Feedback</a>' : '') + '</nav></header>' +
|
|
510
|
+
'<main><h2 style="margin:0 0 8px">Welcome back</h2><p>A paragraph in this page’s own font, so you can see whether the widget matches it.</p>' +
|
|
511
|
+
'<div class="bar" style="width:70%"></div><div class="bar" style="width:52%"></div><div class="bar" style="width:84%"></div></main>' +
|
|
512
|
+
'<p id="note" hidden>' + (own ? 'No button, so no introduction. People open it from “Feedback” in your menu.' : 'No introduction here: the button is hidden on this page.') + '</p>' +
|
|
513
|
+
'<script src="' + SDK_URL + '" data-key="' + p.key + '" data-preview' + attrs + '></scr' + 'ipt>' +
|
|
514
|
+
'<script>var H=window.Heresay;' + then + '</scr' + 'ipt></body></html>';
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/** The web kit: the real sdk.js in a sandboxed iframe, and a script tag. */
|
|
518
|
+
function webKit(p) {
|
|
519
|
+
return {
|
|
520
|
+
groups: DESIGN,
|
|
521
|
+
shows: [['button', 'Button'], ['panel', 'Panel'], ['intro', 'Introduction'], ['sent', 'After sending']],
|
|
522
|
+
darkLabel: 'Dark app',
|
|
523
|
+
changes: function (cfg) { return designAttrs(cfg).length; },
|
|
524
|
+
preview: function () {
|
|
525
|
+
var frame = el('iframe', { class: 'design-frame', title: 'Preview', sandbox: 'allow-scripts allow-popups allow-popups-to-escape-sandbox' });
|
|
526
|
+
return { el: frame, draw: function (cfg, show, dark) { frame.srcdoc = previewDoc(p, cfg, show, dark); } };
|
|
527
|
+
},
|
|
528
|
+
code: function (cfg) {
|
|
529
|
+
var out = [codeBlock(designTag(p, cfg))];
|
|
530
|
+
if (cfg.button === 'none') {
|
|
531
|
+
out.push(el('p', { class: 'hint', text: 'Then open it from your own menu item:' }));
|
|
532
|
+
out.push(codeBlock('window.Heresay?.open();'));
|
|
533
|
+
}
|
|
534
|
+
return out;
|
|
535
|
+
},
|
|
536
|
+
prompt: function (cfg) {
|
|
537
|
+
var a = designAttrs(cfg);
|
|
538
|
+
return 'Update the Heresay script tag in this app (the one with data-key="' + p.key + '") so it looks like this. ' +
|
|
539
|
+
'Keep it where it is and keep the framework\'s own way of writing it (for example next/script in Next.js). ' +
|
|
540
|
+
'Remove any other design attributes it has (data-position, data-offset, data-button, data-label, data-style, data-size, data-fill, data-shadow, data-hide-on, data-accent, data-mark, data-theme, data-font, data-lang, data-placeholder, data-types, data-thanks, data-panel, data-width, data-backdrop, data-preferences, data-intro); keep data-key, data-version and anything about the signed-in user.\n\n' +
|
|
541
|
+
designTag(p, cfg) + '\n' +
|
|
542
|
+
(cfg.button === 'none' ? '\nThere is no floating button now, so add a "Send feedback" item to the app\'s own help or account menu that calls window.Heresay?.open().\n' : '') +
|
|
543
|
+
(a.some(function (x) { return x[0] === 'data-intro'; }) ? '' : '\nIf the app doesn\'t call window.Heresay?.introduce() yet, call it once the main screen appears.\n') +
|
|
544
|
+
'\nFor what each option does, read the Heresay guide customize-web (heresay_guide, or npx -y heresay@latest guide customize-web).';
|
|
545
|
+
},
|
|
546
|
+
fixed: 'Always there, whatever you choose: the Heresay mark on the button, the “Your reports” tab (people read why a report was declined), and “Powered by Heresay”, so people can tell your app uses an outside tool.',
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function designView(view, p) {
|
|
551
|
+
var apple = platformOf(p.platform).apple;
|
|
552
|
+
var kit = apple ? appleKit(p) : webKit(p);
|
|
553
|
+
var KEY = 'heresay.design.' + p.id;
|
|
554
|
+
var cfg = {};
|
|
555
|
+
try { cfg = JSON.parse(localStorage.getItem(KEY) || '{}') || {}; } catch (e) { cfg = {}; }
|
|
556
|
+
var show = kit.shows[0][0], dark = false;
|
|
557
|
+
|
|
558
|
+
view.classList.add('wide');
|
|
559
|
+
view.appendChild(el('a', { class: 'back', href: '#/apps/' + p.id, text: '← ' + productName(p) }));
|
|
560
|
+
view.appendChild(el('div', { class: 'head' }, [el('div', {}, [
|
|
561
|
+
el('h1', { text: 'Design the Report button' }),
|
|
562
|
+
el('p', { class: 'mute', text: apple
|
|
563
|
+
? 'Every choice starts on what we recommend. Change what your app needs, then copy the Swift or the prompt for your coding agent. The preview is a close likeness of the ' + platformOf(p.platform).label + ' sheet, with your choices.'
|
|
564
|
+
: 'Every choice starts on what we recommend. Change what your app needs, then copy the tag or the prompt for your coding agent.' }),
|
|
565
|
+
])]));
|
|
566
|
+
|
|
567
|
+
var controls = el('div', { class: 'design-controls' });
|
|
568
|
+
var preview = kit.preview();
|
|
569
|
+
var codeBox = el('div');
|
|
570
|
+
var changed = el('span', { class: 'hint' });
|
|
571
|
+
|
|
572
|
+
function save() { try { localStorage.setItem(KEY, JSON.stringify(cfg)); } catch (e) { /* private mode */ } }
|
|
573
|
+
function redraw() {
|
|
574
|
+
save();
|
|
575
|
+
preview.draw(cfg, show, dark);
|
|
576
|
+
var n = kit.changes(cfg);
|
|
577
|
+
changed.textContent = n ? n + ' change' + (n === 1 ? '' : 's') + ' from the recommended setup' : 'The recommended setup';
|
|
578
|
+
codeBox.textContent = '';
|
|
579
|
+
kit.code(cfg).forEach(function (x) { codeBox.appendChild(x); });
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
kit.groups.forEach(function (g) {
|
|
583
|
+
controls.appendChild(el('h2', { class: 'design-group', text: g.group }));
|
|
584
|
+
g.items.forEach(function (it) {
|
|
585
|
+
var chips = el('div', { class: 'filters' });
|
|
586
|
+
var input = it.text ? el('input', { type: 'text', placeholder: it.text, maxlength: String(it.max || 20), 'aria-label': it.label }) : null;
|
|
587
|
+
var colour = it.color ? el('input', { type: 'color', 'aria-label': 'Any colour', value: cfg[it.a] || '#0f766e' }) : null;
|
|
588
|
+
function sync() {
|
|
589
|
+
var v = cfg[it.a] || '';
|
|
590
|
+
var known = it.c.some(function (c) { return c[0] === v; });
|
|
591
|
+
chips.querySelectorAll('button').forEach(function (b) { b.setAttribute('aria-pressed', String(b.dataset.v === v)); });
|
|
592
|
+
if (input && document.activeElement !== input) input.value = known ? '' : v;
|
|
593
|
+
}
|
|
594
|
+
it.c.forEach(function (c) {
|
|
595
|
+
chips.appendChild(el('button', { type: 'button', 'data-v': c[0], onclick: function () { cfg[it.a] = c[0]; sync(); redraw(); } },
|
|
596
|
+
[c[2] ? el('span', { class: 'swatch', style: 'background:' + c[2] }) : null, c[1] + (c[0] === '' && it.c.length > 1 ? ' ' : ''),
|
|
597
|
+
c[0] === '' && it.c.length > 1 ? el('span', { class: 'n', text: '· recommended' }) : null]));
|
|
598
|
+
});
|
|
599
|
+
if (colour) {
|
|
600
|
+
colour.oninput = function () { cfg[it.a] = colour.value; sync(); redraw(); };
|
|
601
|
+
chips.appendChild(el('label', { class: 'pick-colour' }, [colour, 'Any colour']));
|
|
602
|
+
}
|
|
603
|
+
if (input) {
|
|
604
|
+
input.oninput = function () {
|
|
605
|
+
var v = input.value.trim();
|
|
606
|
+
if (!v) cfg[it.a] = '';
|
|
607
|
+
else if (!it.pattern || it.pattern.test(v)) cfg[it.a] = it.list ? v.split(',').map(function (s) { return s.trim(); }).filter(Boolean).join(',') : v;
|
|
608
|
+
else return;
|
|
609
|
+
sync(); redraw();
|
|
610
|
+
};
|
|
611
|
+
chips.appendChild(input);
|
|
612
|
+
}
|
|
613
|
+
controls.appendChild(el('div', { class: 'design-item' }, [el('b', { text: it.label }), chips, it.hint ? el('p', { class: 'hint', text: it.hint }) : null]));
|
|
614
|
+
sync();
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
controls.appendChild(el('p', { class: 'hint design-fixed', text: kit.fixed }));
|
|
618
|
+
|
|
619
|
+
var showSeg = el('div', { class: 'seg', role: 'tablist', 'aria-label': 'Show' });
|
|
620
|
+
kit.shows.forEach(function (s) {
|
|
621
|
+
showSeg.appendChild(el('button', { type: 'button', role: 'tab', 'aria-selected': String(s[0] === show), text: s[1], onclick: function () {
|
|
622
|
+
show = s[0];
|
|
623
|
+
showSeg.querySelectorAll('button').forEach(function (b) { b.setAttribute('aria-selected', String(b === this)); }, this);
|
|
624
|
+
redraw();
|
|
625
|
+
} }));
|
|
626
|
+
});
|
|
627
|
+
var darkBox = el('input', { type: 'checkbox', onchange: function () { dark = darkBox.checked; redraw(); } });
|
|
628
|
+
|
|
629
|
+
view.appendChild(el('div', { class: 'design' }, [
|
|
630
|
+
controls,
|
|
631
|
+
el('div', { class: 'design-side' }, [
|
|
632
|
+
el('div', { class: 'row tight design-toolbar' }, [showSeg, el('label', { class: 'small mute' }, [darkBox, ' ' + kit.darkLabel])]),
|
|
633
|
+
preview.el,
|
|
634
|
+
el('div', { class: 'row tight' }, [changed, el('span', { class: 'spacer' }),
|
|
635
|
+
el('button', { class: 'btn ghost', type: 'button', text: 'Start over', onclick: function () { try { localStorage.removeItem(KEY); } catch (e) { /* private mode */ } view.textContent = ''; designView(view, p); } }),
|
|
636
|
+
copyButton(function () { return kit.prompt(cfg); }, 'Copy prompt for your agent')]),
|
|
637
|
+
codeBox,
|
|
638
|
+
]),
|
|
639
|
+
]));
|
|
640
|
+
redraw();
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// ---- design, iOS and macOS ------------------------------------------------------------
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* The same choices for the Swift package, as `HeresayStyle`. Keys are the Swift parameter
|
|
647
|
+
* names; the order is HeresayStyle.init's, which Swift requires.
|
|
648
|
+
*/
|
|
649
|
+
function appleDesign(mac) {
|
|
650
|
+
return [
|
|
651
|
+
{ group: 'The button', items: [
|
|
652
|
+
{ a: 'entry', label: mac ? 'How people open it' : 'The button', c: mac
|
|
653
|
+
? [['', 'Help › Report a Problem… (⌥⌘R)'], ['button', 'That, and a corner button'], ['none', 'My own button or menu item']]
|
|
654
|
+
: [['', 'A button in the corner'], ['none', 'No button: my own button or menu item']],
|
|
655
|
+
hint: mac ? 'Mac apps usually keep it in the Help menu, where people look for it.' : null },
|
|
656
|
+
{ a: 'position', label: 'Where the button sits', c: [['', 'Bottom right'], ['bottomLeading', 'Bottom left'], ['topTrailing', 'Top right'], ['topLeading', 'Top left'], ['bottom', 'Bottom centre']] },
|
|
657
|
+
{ a: 'offset', label: 'Distance from the edge', c: [['', '16 pt'], ['24', '24 pt'], ['80', '80 pt, above a tab bar']], text: 'or any number', pattern: /^\d{1,3}$/ },
|
|
658
|
+
{ a: 'label', label: 'Text', c: [['', 'Report'], ['Feedback', 'Feedback'], ['Help us improve', 'Help us improve'], ['Found a bug?', 'Found a bug?']], text: 'or your own words', max: 40 },
|
|
659
|
+
{ a: 'button', label: 'Style', c: [['', 'Pill with text'], ['icon', 'Icon only']] },
|
|
660
|
+
{ a: 'size', label: 'Size', c: [['', 'Regular'], ['small', 'Small'], ['large', 'Large']] },
|
|
661
|
+
{ a: 'fill', label: 'Button colour', c: [['', 'Filled with your colour'], ['neutral', 'System background']] },
|
|
662
|
+
{ a: 'shadow', label: 'Shadow', c: [['', 'Soft'], ['none', 'None'], ['strong', 'Strong']] },
|
|
663
|
+
{ a: 'hiddenOnScreens', label: 'Hide it on these screens', c: [], text: 'Checkout, Sign in', max: 200, list: true, hint: 'Screen names as your app sets them with Heresay.setScreen(…).' },
|
|
664
|
+
]},
|
|
665
|
+
{ group: 'Look', items: [
|
|
666
|
+
{ a: 'accent', label: 'Your colour', color: true, c: [['', 'Heresay peacock', '#0f766e'], ['#7c3aed', 'Purple', '#7c3aed'], ['#2563eb', 'Blue', '#2563eb'], ['#e11d48', 'Rose', '#e11d48'], ['#15171c', 'Ink', '#15171c']] },
|
|
667
|
+
{ a: 'markFollowsAccent', label: 'Logo colour', c: [['', 'Follows your colour'], ['false', 'Heresay teal']] },
|
|
668
|
+
{ a: 'theme', label: 'Light or dark', c: [['', 'Follow the app'], ['light', 'Always light'], ['dark', 'Always dark']] },
|
|
669
|
+
{ a: 'typeface', label: 'Typeface', c: [['', 'System'], ['rounded', 'Rounded'], ['serif', 'Serif']] },
|
|
670
|
+
]},
|
|
671
|
+
{ group: 'Words', items: [
|
|
672
|
+
{ a: 'language', label: 'Language', c: [['', 'My app’s language'], ['en', 'English'], ['fr', 'Français'], ['ta', 'தமிழ்'], ['hi', 'हिन्दी']], hint: 'English, French, Tamil and Hindi today; any other language shows English.' },
|
|
673
|
+
{ a: 'placeholder', label: 'Question in the text box', c: [['', 'What happened, or what would you change?']], text: 'or your own words', max: 120 },
|
|
674
|
+
{ a: 'types', label: 'Report types', c: [['', 'All four'], ['broken,confusing,improvement', 'No “Idea”'], ['broken,confusing', 'Only Broken and Confusing']], hint: 'Their names can’t change: the type sets the priority.' },
|
|
675
|
+
{ a: 'thanks', label: 'Thank-you line after sending', c: [['', 'None']], text: 'e.g. Thanks! We read every one.', max: 160 },
|
|
676
|
+
]},
|
|
677
|
+
{ group: 'The sheet', items: [
|
|
678
|
+
{ a: 'sheet', label: 'Size', c: mac ? [['', 'Regular'], ['compact', 'Narrow'], ['large', 'Wide']]
|
|
679
|
+
: [['', 'Full height'], ['compact', 'Half height, pull up for more'], ['large', 'Full screen']] },
|
|
680
|
+
{ a: 'showsPreferences', label: 'Preferences tab', c: [['', 'Show'], ['false', 'Hide']], hint: 'Hide it if your app calls identify() and asks nothing else.' },
|
|
681
|
+
]},
|
|
682
|
+
];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
var SWIFT_ORDER = ['position', 'offset', 'label', 'button', 'size', 'fill', 'shadow', 'hiddenOnScreens', 'markFollowsAccent',
|
|
686
|
+
'theme', 'typeface', 'language', 'placeholder', 'types', 'thanks', 'sheet', 'showsPreferences'];
|
|
687
|
+
|
|
688
|
+
function swiftString(s) { return '"' + String(s).replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"'; }
|
|
689
|
+
|
|
690
|
+
/** One HeresayStyle argument, in Swift. */
|
|
691
|
+
function swiftArg(k, v) {
|
|
692
|
+
if (k === 'offset') return k + ': ' + (+v);
|
|
693
|
+
if (k === 'label' || k === 'placeholder' || k === 'thanks' || k === 'language') return k + ': ' + swiftString(v);
|
|
694
|
+
if (k === 'hiddenOnScreens') return k + ': [' + v.split(',').map(swiftString).join(', ') + ']';
|
|
695
|
+
if (k === 'types') return k + ': [' + v.split(',').map(function (t) { return '.' + t; }).join(', ') + ']';
|
|
696
|
+
if (k === 'markFollowsAccent' || k === 'showsPreferences') return k + ': ' + v;
|
|
697
|
+
return k + ': .' + v;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function swiftColor(hex) {
|
|
701
|
+
var n = parseInt(hex.slice(1), 16);
|
|
702
|
+
var c = [n >> 16 & 255, n >> 8 & 255, n & 255].map(function (x) { return (x / 255).toFixed(3).replace(/0+$/, '').replace(/\.$/, '.0'); });
|
|
703
|
+
return 'Color(red: ' + c[0] + ', green: ' + c[1] + ', blue: ' + c[2] + ')';
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
function swiftConfigure(p, cfg) {
|
|
707
|
+
var args = SWIFT_ORDER.filter(function (k) { return cfg[k]; }).map(function (k) { return swiftArg(k, cfg[k]); });
|
|
708
|
+
var lines = ['key: "' + p.key + '"', 'url: URL(string: "' + location.origin + '")!'];
|
|
709
|
+
if (cfg.accent) lines.push('accent: ' + swiftColor(cfg.accent));
|
|
710
|
+
if (args.length) lines.push('style: HeresayStyle(\n ' + args.join(',\n ') + '\n )');
|
|
711
|
+
return 'Heresay.configure(\n ' + lines.join(',\n ') + '\n)';
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/** Where the sheet (and the button) attach: the root view, and on the Mac the menu. */
|
|
715
|
+
function swiftAttach(p, cfg) {
|
|
716
|
+
var mac = p.platform === 'macos';
|
|
717
|
+
var button = mac ? cfg.entry === 'button' : cfg.entry !== 'none';
|
|
718
|
+
var view = 'ContentView().' + (button ? 'heresayReportButton()' : 'heresay()');
|
|
719
|
+
if (mac && cfg.entry !== 'none') return 'WindowGroup {\n ' + view + '\n}\n.commands { HeresayCommands() } // Help › Report a Problem… (⌥⌘R)';
|
|
720
|
+
return 'WindowGroup {\n ' + view + '\n}' + (button ? '' : '\n\n// Then, from your own button or menu item:\nHeresay.present()');
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
function appleKit(p) {
|
|
724
|
+
var mac = p.platform === 'macos';
|
|
725
|
+
var groups = appleDesign(mac);
|
|
726
|
+
return {
|
|
727
|
+
groups: groups,
|
|
728
|
+
shows: [['button', mac ? 'Window' : 'Button'], ['panel', 'Sheet'], ['intro', 'Introduction'], ['sent', 'After sending']],
|
|
729
|
+
darkLabel: 'Dark mode',
|
|
730
|
+
changes: function (cfg) { return Object.keys(cfg).filter(function (k) { return cfg[k]; }).length; },
|
|
731
|
+
preview: function () {
|
|
732
|
+
var box = el('div', { class: 'design-frame apple-frame', role: 'img', 'aria-label': 'Preview' });
|
|
733
|
+
// The phone is drawn at its real size, then zoomed to fit the box.
|
|
734
|
+
var fit = function () {
|
|
735
|
+
var ph = box.querySelector('.am-phone');
|
|
736
|
+
if (ph) ph.style.zoom = String(Math.min(1, (box.clientHeight - 28) / 630));
|
|
737
|
+
};
|
|
738
|
+
window.addEventListener('resize', fit);
|
|
739
|
+
return { el: box, draw: function (cfg, show, dark) { box.innerHTML = appleMock(p, cfg, show, dark); fit(); } };
|
|
740
|
+
},
|
|
741
|
+
code: function (cfg) {
|
|
742
|
+
return [el('p', { class: 'hint', text: 'In your App’s init():' }), codeBlock(swiftConfigure(p, cfg)),
|
|
743
|
+
el('p', { class: 'hint', text: 'And on the root view:' }), codeBlock(swiftAttach(p, cfg))];
|
|
744
|
+
},
|
|
745
|
+
prompt: function (cfg) {
|
|
746
|
+
return 'Update how Heresay is set up in this ' + (mac ? 'macOS' : 'iOS') + ' app (the Heresay.configure call with key "' + p.key + '") so it matches this. ' +
|
|
747
|
+
'Keep the key, the URL and anything else it passes (version, session). Replace any existing accent: and style: arguments with these. ' +
|
|
748
|
+
'Heresay 0.2.11 or later is needed for style:; update the Swift package if it is older.\n\n' +
|
|
749
|
+
swiftConfigure(p, cfg) + '\n\nThe root view and scene:\n\n' + swiftAttach(p, cfg) + '\n' +
|
|
750
|
+
(cfg.hiddenOnScreens ? '\nThe button hides on screens named with Heresay.setScreen(…). Make sure those screens call it with exactly these names: ' + cfg.hiddenOnScreens + '.\n' : '') +
|
|
751
|
+
'\nIf the app doesn\'t call Heresay.introduce() yet, call it once the main screen appears.' +
|
|
752
|
+
'\nFor what each option does, read the Heresay guide customize-apple (heresay_guide, or npx -y heresay@latest guide customize-apple).';
|
|
753
|
+
},
|
|
754
|
+
fixed: 'Always there, whatever you choose: the Heresay mark, the “Your reports” tab (people read why a report was declined), and “Powered by Heresay” in the sheet and the introduction, so people can tell your app uses an outside tool.',
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/** The words the preview shows, from Words.swift. Only a likeness needs these few. */
|
|
759
|
+
var APPLE_WORDS = {
|
|
760
|
+
en: { report: 'Report', send: 'Send', sendFeedback: 'Send feedback', straight: 'Straight to the {app} team', tabs: ['Report', 'Your reports', 'Preferences'],
|
|
761
|
+
what: 'What is it?', happened: 'What happened?', ph: 'What happened, or what would you change?', attached: 'Sent with this screen and the app version.',
|
|
762
|
+
types: [['Broken', 'Something doesn’t work'], ['Confusing', 'I couldn’t tell how'], ['Could be better', 'It works, and could be better'], ['Idea', 'Something that isn’t there yet']],
|
|
763
|
+
powered: 'Powered by Heresay', introTitle: 'Something not right? Tell the team.',
|
|
764
|
+
introBody: '{reach} to tell the team what’s broken, confusing or could be better. A person reads every report, and you’ll see what happens to yours.',
|
|
765
|
+
reachTap: 'Tap {label} in the corner any time', reachClick: 'Click {label} any time', reachMenu: 'Choose Help › Report a Problem… (⌥⌘R) any time', reachUse: 'Use {label} any time',
|
|
766
|
+
tryIt: 'Try it', gotIt: 'Got it', cancel: 'Cancel', sentTitle: 'Sent. Thank you.', sentBody: 'A person on the team reads every report. You’ll see what happens to it under Your reports.',
|
|
767
|
+
another: 'Send another', see: 'See your reports', menu: 'Report a Problem…' },
|
|
768
|
+
fr: { report: 'Signaler', send: 'Envoyer', sendFeedback: 'Envoyer un retour', straight: 'Directement à l’équipe {app}', tabs: ['Signaler', 'Vos signalements', 'Préférences'],
|
|
769
|
+
what: 'De quoi s’agit-il ?', happened: 'Que s’est-il passé ?', ph: 'Que s’est-il passé, ou que changeriez-vous ?', attached: 'Envoyé avec cet écran et la version de l’app.',
|
|
770
|
+
types: [['Cassé', 'Quelque chose ne marche pas'], ['Déroutant', 'Je ne voyais pas comment faire'], ['Pourrait être mieux', 'Ça marche, mais ça pourrait être mieux'], ['Idée', 'Quelque chose qui n’existe pas encore']],
|
|
771
|
+
powered: 'Propulsé par Heresay', introTitle: 'Un souci ? Dites-le à l’équipe.',
|
|
772
|
+
introBody: '{reach} pour dire à l’équipe ce qui ne marche pas, ce qui est déroutant ou ce qui pourrait être mieux. Une personne lit chaque signalement, et vous verrez ce qu’il devient.',
|
|
773
|
+
reachTap: 'Touchez {label} dans le coin à tout moment', reachClick: 'Cliquez sur {label} à tout moment', reachMenu: 'Choisissez Aide › Signaler un problème… (⌥⌘R) à tout moment', reachUse: 'Utilisez {label} à tout moment',
|
|
774
|
+
tryIt: 'Essayer', gotIt: 'Compris', cancel: 'Annuler', sentTitle: 'Envoyé. Merci.', sentBody: 'Une personne de l’équipe lit chaque signalement. Vous verrez ce qu’il devient dans Vos signalements.',
|
|
775
|
+
another: 'En envoyer un autre', see: 'Voir vos signalements', menu: 'Signaler un problème…' },
|
|
776
|
+
ta: { report: 'தெரிவி', send: 'அனுப்பு', sendFeedback: 'கருத்து அனுப்பு', straight: 'நேராக {app} குழுவுக்கு', tabs: ['தெரிவி', 'உங்கள் புகார்கள்', 'விருப்பங்கள்'],
|
|
777
|
+
what: 'இது என்ன வகை?', happened: 'என்ன நடந்தது?', ph: 'என்ன நடந்தது, அல்லது எதை மாற்ற விரும்புகிறீர்கள்?', attached: 'இந்தத் திரை மற்றும் ஆப் பதிப்புடன் அனுப்பப்படும்.',
|
|
778
|
+
types: [['வேலை செய்யவில்லை', 'ஏதோ ஒன்று சரியாக இயங்கவில்லை'], ['குழப்பமாக உள்ளது', 'எப்படிச் செய்வது என்று புரியவில்லை'], ['இன்னும் சிறப்பாக்கலாம்', 'வேலை செய்கிறது, ஆனால் மேம்படுத்தலாம்'], ['யோசனை', 'இன்னும் இல்லாத ஒன்று']],
|
|
779
|
+
powered: 'Heresay மூலம் இயங்குகிறது', introTitle: 'ஏதாவது சரியில்லையா? குழுவிடம் சொல்லுங்கள்.',
|
|
780
|
+
introBody: 'எது வேலை செய்யவில்லை, எது குழப்பமாக உள்ளது, எதை மேம்படுத்தலாம் என்று குழுவிடம் சொல்ல, {reach}. ஒவ்வொரு புகாரையும் ஒருவர் படிக்கிறார்; உங்களுடையதற்கு என்ன ஆனது என்பதைப் பார்க்கலாம்.',
|
|
781
|
+
reachTap: 'எப்போது வேண்டுமானாலும் மூலையில் உள்ள {label} ஐத் தட்டுங்கள்', reachClick: 'எப்போது வேண்டுமானாலும் {label} ஐக் கிளிக் செய்யுங்கள்', reachMenu: 'எப்போது வேண்டுமானாலும் Help › சிக்கலைத் தெரிவி… (⌥⌘R) என்பதைத் தேர்ந்தெடுங்கள்', reachUse: 'எப்போது வேண்டுமானாலும் {label} ஐப் பயன்படுத்துங்கள்',
|
|
782
|
+
tryIt: 'முயன்று பாருங்கள்', gotIt: 'சரி', cancel: 'ரத்துசெய்', sentTitle: 'அனுப்பப்பட்டது. நன்றி.', sentBody: 'குழுவில் ஒருவர் ஒவ்வொரு புகாரையும் படிக்கிறார். அதற்கு என்ன ஆனது என்பதை “உங்கள் புகார்கள்” பகுதியில் பார்க்கலாம்.',
|
|
783
|
+
another: 'இன்னொன்று அனுப்பு', see: 'உங்கள் புகார்களைப் பார்', menu: 'சிக்கலைத் தெரிவி…' },
|
|
784
|
+
hi: { report: 'रिपोर्ट करें', send: 'भेजें', sendFeedback: 'फ़ीडबैक भेजें', straight: 'सीधे {app} टीम को', tabs: ['रिपोर्ट', 'आपकी रिपोर्ट', 'प्राथमिकताएँ'],
|
|
785
|
+
what: 'यह क्या है?', happened: 'क्या हुआ?', ph: 'क्या हुआ, या आप क्या बदलना चाहेंगे?', attached: 'इस स्क्रीन और ऐप के वर्शन के साथ भेजा जाता है।',
|
|
786
|
+
types: [['टूटा हुआ', 'कुछ काम नहीं कर रहा'], ['उलझन भरा', 'समझ नहीं आया कि कैसे करें'], ['बेहतर हो सकता है', 'काम करता है, पर बेहतर हो सकता है'], ['सुझाव', 'कुछ ऐसा जो अभी नहीं है']],
|
|
787
|
+
powered: 'Heresay द्वारा संचालित', introTitle: 'कुछ ठीक नहीं लग रहा? टीम को बताइए।',
|
|
788
|
+
introBody: 'टीम को यह बताने के लिए कि क्या टूटा है, क्या उलझन भरा है या क्या बेहतर हो सकता है, {reach}। हर रिपोर्ट कोई इंसान पढ़ता है, और आपकी रिपोर्ट का क्या हुआ, यह आप देखेंगे।',
|
|
789
|
+
reachTap: 'कभी भी कोने में {label} पर टैप करें', reachClick: 'कभी भी {label} पर क्लिक करें', reachMenu: 'कभी भी Help › समस्या की रिपोर्ट करें… (⌥⌘R) चुनें', reachUse: 'कभी भी {label} का इस्तेमाल करें',
|
|
790
|
+
tryIt: 'आज़माएँ', gotIt: 'ठीक है', cancel: 'रद्द करें', sentTitle: 'भेज दिया गया। धन्यवाद।', sentBody: 'टीम का कोई व्यक्ति हर रिपोर्ट पढ़ता है। इसका क्या हुआ, यह आप “आपकी रिपोर्ट” में देखेंगे।',
|
|
791
|
+
another: 'एक और भेजें', see: 'अपनी रिपोर्ट देखें', menu: 'समस्या की रिपोर्ट करें…' },
|
|
792
|
+
};
|
|
793
|
+
var TYPE_IDS = ['broken', 'confusing', 'improvement', 'idea'];
|
|
794
|
+
var TYPE_ICON = { broken: '⚠︎', confusing: '?', improvement: '✦', idea: '💡' };
|
|
795
|
+
|
|
796
|
+
/** A likeness of the Swift package's button, sheet, alert and sent view, as HTML. */
|
|
797
|
+
function appleMock(p, cfg, show, darkMode) {
|
|
798
|
+
var mac = p.platform === 'macos';
|
|
799
|
+
var w = APPLE_WORDS[cfg.language] || APPLE_WORDS.en;
|
|
800
|
+
var fmt = function (s, o) { return s.replace(/\{(\w+)\}/g, function (_, k) { return o[k]; }); };
|
|
801
|
+
var acc = cfg.accent || '#0f766e';
|
|
802
|
+
var dark = cfg.theme === 'dark' || (cfg.theme !== 'light' && darkMode);
|
|
803
|
+
var markC = cfg.markFollowsAccent === 'false' || !cfg.accent ? (dark ? '#2dd4bf' : '#0b5e57') : acc;
|
|
804
|
+
var mark = function (c, s) { return '<span class="am-mark" style="width:' + s + 'px;height:' + s + 'px;background:' + c + '"></span>'; };
|
|
805
|
+
var label = cfg.label || w.report;
|
|
806
|
+
var hasButton = mac ? cfg.entry === 'button' : cfg.entry !== 'none';
|
|
807
|
+
var face = { rounded: 'ui-rounded,"SF Pro Rounded",system-ui', serif: 'ui-serif,Georgia,serif' }[cfg.typeface] || '-apple-system,system-ui,sans-serif';
|
|
808
|
+
var off = +(cfg.offset || 16);
|
|
809
|
+
var pos = cfg.position || 'bottomTrailing';
|
|
810
|
+
var place = (/top/.test(pos) ? 'top:' + (off + (mac ? 34 : 54)) + 'px;' : 'bottom:' + (off + (mac ? 0 : 20)) + 'px;') +
|
|
811
|
+
(pos === 'bottom' ? 'left:50%;transform:translateX(-50%);' : /Leading/.test(pos) ? 'left:' + off + 'px;' : 'right:' + off + 'px;');
|
|
812
|
+
var sz = { small: [11, 10, 6, 13], large: [16, 18, 12, 21] }[cfg.size] || [13, 14, 9, 17];
|
|
813
|
+
var neutral = cfg.fill === 'neutral';
|
|
814
|
+
var icon = cfg.button === 'icon';
|
|
815
|
+
var btnDark = dark || darkMode;
|
|
816
|
+
var shadow = { none: 'none', strong: '0 6px 16px rgba(0,0,0,.35)' }[cfg.shadow] || '0 3px 8px rgba(0,0,0,.18)';
|
|
817
|
+
var button = hasButton && show !== 'panel' && show !== 'sent'
|
|
818
|
+
? '<div class="am-btn" style="' + place + 'font-size:' + sz[0] + 'px;padding:' + (icon ? (sz[2] + 1) + 'px' : sz[2] + 'px ' + sz[1] + 'px') + ';border-radius:999px;box-shadow:' + shadow + ';' +
|
|
819
|
+
(neutral ? 'background:' + (btnDark ? 'rgba(40,42,48,.92)' : 'rgba(255,255,255,.92)') + ';color:' + (btnDark ? '#f2f2f7' : '#111') + ';border:1px solid rgba(127,127,127,.25)' : 'background:' + acc + ';color:#fff') + '">' +
|
|
820
|
+
mark(neutral ? markC : '#fff', sz[3]) + (icon ? '' : '<b>' + esc(label) + '</b>') + '</div>' : '';
|
|
821
|
+
|
|
822
|
+
var types = (cfg.types || TYPE_IDS.join(',')).split(',');
|
|
823
|
+
var typeCards = types.map(function (t) {
|
|
824
|
+
var tw = w.types[TYPE_IDS.indexOf(t)];
|
|
825
|
+
return '<div class="am-type"><span class="am-ti" style="color:' + acc + ';background:' + acc + '1f">' + TYPE_ICON[t] + '</span><span><b>' + esc(tw[0]) + '</b><i>' + esc(tw[1]) + '</i></span></div>';
|
|
826
|
+
}).join('');
|
|
827
|
+
var tabs = [w.tabs[0], w.tabs[1]].concat(cfg.showsPreferences === 'false' ? [] : [w.tabs[2]]);
|
|
828
|
+
var powered = '<div class="am-powered">' + mark(markC, 11) + esc(w.powered) + '</div>';
|
|
829
|
+
var head = '<div class="am-head">' + mark(markC, 28) + '<div><b>' + esc(w.sendFeedback) + '</b><span>' + esc(fmt(w.straight, { app: productName(p) })) + '</span></div>' + (mac ? '' : '<em>✕</em>') + '</div>' +
|
|
830
|
+
'<div class="am-seg">' + tabs.map(function (t, i) { return '<span' + (i === 0 ? ' class="on"' : '') + '>' + esc(t) + '</span>'; }).join('') + '</div>';
|
|
831
|
+
var form = '<div class="am-body"><p class="am-lab">' + esc(w.what) + '</p><div class="am-types' + (mac ? ' grid' : '') + '">' + typeCards + '</div>' +
|
|
832
|
+
'<p class="am-lab">' + esc(w.happened) + '</p><div class="am-text">' + esc(cfg.placeholder || w.ph) + '</div></div>' + powered +
|
|
833
|
+
'<div class="am-foot"><span>' + esc(w.attached) + '</span>' + (mac ? '<u>' + esc(w.cancel) + '</u>' : '') + '<strong style="background:' + acc + '">' + esc(w.send) + '</strong></div>';
|
|
834
|
+
var sent = '<div class="am-body am-sent">' + mark(markC, 56) + '<b>' + esc(w.sentTitle) + '</b>' + (cfg.thanks ? '<p>' + esc(cfg.thanks) + '</p>' : '') +
|
|
835
|
+
'<p class="mute">' + esc(w.sentBody) + '</p><div><u>' + esc(w.another) + '</u><strong style="background:' + acc + '">' + esc(w.see) + '</strong></div></div>' + powered;
|
|
836
|
+
var sheetSize = cfg.sheet || '';
|
|
837
|
+
var sheet = show === 'panel' || show === 'sent'
|
|
838
|
+
? '<div class="am-dim"></div><div class="am-sheet ' + (mac ? 'mac ' : '') + (sheetSize || 'regular') + '">' + head + (show === 'sent' ? sent : form) + '</div>' : '';
|
|
839
|
+
var reach = mac ? (cfg.entry !== 'none' ? w.reachMenu : fmt(hasButton ? w.reachClick : w.reachUse, { label: cfg.label ? '“' + cfg.label + '”' : w.report }))
|
|
840
|
+
: fmt(hasButton ? w.reachTap : w.reachUse, { label: cfg.label ? '“' + cfg.label + '”' : w.report });
|
|
841
|
+
var alert = show === 'intro'
|
|
842
|
+
? '<div class="am-dim"></div><div class="am-alert"><b>' + esc(w.introTitle) + '</b><p>' + esc(fmt(w.introBody, { reach: reach })) + '</p><p>' + esc(w.powered) + '</p>' +
|
|
843
|
+
'<div><span>' + esc(w.gotIt) + '</span><span>' + esc(w.tryIt) + '</span></div></div>' : '';
|
|
844
|
+
var menu = mac && cfg.entry !== 'none' && show === 'button'
|
|
845
|
+
? '<div class="am-menu"><span>' + esc(w.menu) + '</span><kbd>⌥⌘R</kbd></div>' : '';
|
|
846
|
+
var rows = ['Groceries', 'Trip to Ooty', 'Quarterly plan', 'Book list'].map(function (r) { return '<li>' + r + '</li>'; }).join('');
|
|
847
|
+
var app = mac
|
|
848
|
+
? '<div class="am-menubar"><b></b><b>' + esc(productName(p)) + '</b><span>File</span><span>Edit</span><span' + (menu ? ' class="on"' : '') + '>Help</span></div>' + menu +
|
|
849
|
+
'<div class="am-window"><div class="am-titlebar"><i></i><i></i><i></i><span>' + esc(productName(p)) + '</span></div><div class="am-content"><h3>Notes</h3><ul>' + rows + '</ul></div>' + button + sheet + alert + '</div>'
|
|
850
|
+
: '<div class="am-phone"><div class="am-status"><span>9:41</span><i></i></div><div class="am-content"><h3>Notes</h3><ul>' + rows + '</ul></div>' + button + sheet + alert + '</div>';
|
|
851
|
+
return '<div class="am ' + (mac ? 'am-mac' : 'am-ios') + (darkMode ? ' app-dark' : '') + (dark ? ' dark' : '') + '" style="--acc:' + acc + ';font-family:' + face + '">' + app + '</div>';
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
|
|
435
855
|
// ---- install and test ------------------------------------------------------------------
|
|
436
856
|
|
|
437
857
|
function tag(p) { return '<script src="' + SDK_URL + '" data-key="' + p.key + '" defer></scr' + 'ipt>'; }
|
|
@@ -773,6 +1193,7 @@
|
|
|
773
1193
|
: (p.framework ? frameworkLabel(p.framework) + (p.framework_detected ? ' (detected)' : '') : platformOf(p.platform).label) })])]));
|
|
774
1194
|
head.appendChild(el('div', { class: 'row tight' }, [
|
|
775
1195
|
el('a', { class: 'btn ghost', href: '#/new?product=' + productOf(p), text: '+ Add a platform' }),
|
|
1196
|
+
many || !designable(p) ? null : el('a', { class: 'btn ghost', href: '#/apps/' + p.id + '/design', text: 'Design' }),
|
|
776
1197
|
many ? null : el('a', { class: 'btn', href: '#/apps/' + p.id + '/setup', text: 'Install' }),
|
|
777
1198
|
many ? null : el('a', { class: 'btn ghost', href: '#/apps/' + p.id + '/delete', text: 'Delete…' }),
|
|
778
1199
|
]));
|
|
@@ -790,6 +1211,8 @@
|
|
|
790
1211
|
el('a', { href: '#/connect?app=' + x.id, text: 'Connect a repo' }),
|
|
791
1212
|
many ? document.createTextNode(' · ') : null,
|
|
792
1213
|
many ? el('a', { href: '#/apps/' + x.id + '/setup', text: 'Install' }) : null,
|
|
1214
|
+
many && designable(x) ? document.createTextNode(' · ') : null,
|
|
1215
|
+
many && designable(x) ? el('a', { href: '#/apps/' + x.id + '/design', text: 'Design' }) : null,
|
|
793
1216
|
many ? document.createTextNode(' · ') : null,
|
|
794
1217
|
many ? el('a', { href: '#/apps/' + x.id + '/delete', text: 'Delete…' }) : null,
|
|
795
1218
|
]));
|
package/release/public/demo.html
CHANGED
|
@@ -23,7 +23,11 @@
|
|
|
23
23
|
s.src = '/sdk/v1.js';
|
|
24
24
|
s.dataset.key = q.get('key') || '';
|
|
25
25
|
s.dataset.version = '0.0.1-demo';
|
|
26
|
-
|
|
26
|
+
// The design options, so a look can be tried here before it goes in the app's code.
|
|
27
|
+
['accent', 'position', 'offset', 'button', 'label', 'style', 'size', 'fill', 'shadow', 'mark', 'theme',
|
|
28
|
+
'font', 'lang', 'placeholder', 'types', 'thanks', 'panel', 'width', 'backdrop', 'preferences', 'intro']
|
|
29
|
+
.forEach(function (k) { if (q.get(k) != null) s.setAttribute('data-' + k, q.get(k)); });
|
|
30
|
+
if (q.has('preview')) s.setAttribute('data-preview', '');
|
|
27
31
|
document.body.appendChild(s);
|
|
28
32
|
</script>
|
|
29
33
|
</body>
|
package/release/public/docs.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<div class="docs">
|
|
21
21
|
<aside class="toc">
|
|
22
22
|
<b>START</b><a href="#self-host">Set up Heresay</a><a href="#quick-start">Add it to an app</a><a href="#what-users-see">What your users see</a><a href="#dashboard">The dashboard</a>
|
|
23
|
-
<b>REFERENCE</b><a href="#options">Script tag options</a><a href="#api">JavaScript API</a><a href="#statuses">Report types and statuses</a><a href="#agents">Coding agents</a>
|
|
23
|
+
<b>REFERENCE</b><a href="#options">Script tag options</a><a href="#design">Look and placement</a><a href="#api">JavaScript API</a><a href="#statuses">Report types and statuses</a><a href="#agents">Coding agents</a>
|
|
24
24
|
<b>MORE</b><a href="#security">Security and limits</a><a href="#privacy">Privacy</a><a href="#csp">Content Security Policy</a><a href="#apple">iOS and macOS</a><a href="#rest">Other platforms</a><a href="#trouble">Troubleshooting</a>
|
|
25
25
|
</aside>
|
|
26
26
|
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
<tr><td><code>data-user-id</code></td><td><code>u_1842</code></td><td>Who the user is, in your system.</td></tr>
|
|
69
69
|
<tr><td><code>data-user-label</code></td><td><code>Asha K.</code></td><td>A name to show in your dashboard.</td></tr>
|
|
70
70
|
<tr><td><code>data-user-email</code></td><td><code>asha@example.com</code></td><td>Their email, so you can reply. Or use <code>identify</code> below.</td></tr>
|
|
71
|
-
<tr><td><code>data-accent</code></td><td><code>#6d28d9</code></td><td>Your brand colour for the Send button and
|
|
72
|
-
<tr><td><code>data-position</code></td><td><code>left</code></td><td>Put the button in the bottom-left corner instead of the right
|
|
71
|
+
<tr><td><code>data-accent</code></td><td><code>#6d28d9</code></td><td>Your brand colour for the Send button, selected states and the logo. Hex only. Text on it switches to white or black automatically.</td></tr>
|
|
72
|
+
<tr><td><code>data-position</code></td><td><code>left</code></td><td>Put the button in the bottom-left corner instead of the right. More in <a href="#design">Look and placement</a>.</td></tr>
|
|
73
73
|
<tr><td><code>data-api</code></td><td><code>https://…/v1</code></td><td>Rarely needed. Where your Heresay API lives, if it is not at the same address as <code>sdk.js</code>.</td></tr></table>
|
|
74
74
|
<pre><code><span class="k"><script</span> src="ORIGIN/sdk/v1.js"
|
|
75
75
|
data-key="pk_your_key"
|
|
@@ -77,14 +77,40 @@
|
|
|
77
77
|
data-accent="#6d28d9"
|
|
78
78
|
defer<span class="k">></script></span></code></pre>
|
|
79
79
|
|
|
80
|
+
<h2 id="design">Look and placement</h2>
|
|
81
|
+
<p>The defaults are what we recommend: change only what your app needs. The easiest way is the dashboard: open an app and choose <b>Design</b> to try each option on the real widget and copy the tag. The first value is the default.</p>
|
|
82
|
+
<table><tr><th>Attribute</th><th>Values</th></tr>
|
|
83
|
+
<tr><td><code>data-position</code></td><td><code>right</code> · <code>left</code> · <code>top-right</code> · <code>top-left</code> · <code>center</code></td></tr>
|
|
84
|
+
<tr><td><code>data-offset</code></td><td><code>20</code> px from the edges, or <code>x,y</code> like <code>24,96</code> to clear a chat bubble</td></tr>
|
|
85
|
+
<tr><td><code>data-button</code></td><td><code>always</code> · <code>none</code> (open it from your own menu with <code>Heresay.open()</code>) · <code>desktop</code> (not on phones) · <code>scroll</code> (after the first scroll)</td></tr>
|
|
86
|
+
<tr><td><code>data-label</code></td><td><code>Report</code>, or your own words up to 40 characters</td></tr>
|
|
87
|
+
<tr><td><code>data-style</code></td><td><code>pill</code> · <code>icon</code> · <code>tab</code> (on the side edge)</td></tr>
|
|
88
|
+
<tr><td><code>data-size</code></td><td><code>regular</code> · <code>small</code> · <code>large</code></td></tr>
|
|
89
|
+
<tr><td><code>data-fill</code></td><td><code>neutral</code> · <code>accent</code> (filled with your colour)</td></tr>
|
|
90
|
+
<tr><td><code>data-shadow</code></td><td><code>soft</code> · <code>none</code> · <code>strong</code></td></tr>
|
|
91
|
+
<tr><td><code>data-hide-on</code></td><td>paths where the button stays hidden, like <code>/checkout,/login</code></td></tr>
|
|
92
|
+
<tr><td><code>data-mark</code></td><td><code>accent</code> (the logo follows your colour) · <code>heresay</code> (keep the Heresay teal)</td></tr>
|
|
93
|
+
<tr><td><code>data-theme</code></td><td><code>auto</code> (follows the device) · <code>light</code> · <code>dark</code></td></tr>
|
|
94
|
+
<tr><td><code>data-font</code></td><td><code>system</code> · <code>inherit</code> (your page's font)</td></tr>
|
|
95
|
+
<tr><td><code>data-lang</code></td><td>your page's <code><html lang></code> · <code>auto</code> (the browser's) · <code>en</code> · <code>fr</code> · <code>ta</code> (Tamil) · <code>hi</code> (Hindi)</td></tr>
|
|
96
|
+
<tr><td><code>data-placeholder</code></td><td>the question in the text box</td></tr>
|
|
97
|
+
<tr><td><code>data-types</code></td><td>all four, or some of <code>broken,confusing,improvement,idea</code>. Their names don't change: the type sets the priority.</td></tr>
|
|
98
|
+
<tr><td><code>data-thanks</code></td><td>a line shown after sending</td></tr>
|
|
99
|
+
<tr><td><code>data-panel</code></td><td><code>corner</code> · <code>sheet</code> (full height on that side) · <code>center</code></td></tr>
|
|
100
|
+
<tr><td><code>data-width</code></td><td><code>regular</code> · <code>narrow</code> · <code>wide</code></td></tr>
|
|
101
|
+
<tr><td><code>data-backdrop</code></td><td><code>dim</code> · <code>clear</code> · <code>blur</code></td></tr>
|
|
102
|
+
<tr><td><code>data-preferences</code></td><td><code>show</code> · <code>hide</code></td></tr></table>
|
|
103
|
+
<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>
|
|
104
|
+
|
|
80
105
|
<h2 id="api">JavaScript API</h2>
|
|
81
106
|
<p>The script creates <code>window.Heresay</code> (also available as <code>window.Feedback</code>). Call these any time after it loads.</p>
|
|
82
107
|
<table><tr><th>Call</th><th>What it does</th></tr>
|
|
83
108
|
<tr><td><code>Heresay.identify({ id, label, email })</code></td><td>Tell Heresay who is signed in. Call it after login; pass nothing to clear it. Then nobody is asked their name to send a report, and with <code>email</code> you can reply to them. Apps with many users and logins need nothing more: it follows whoever is signed in on that device.</td></tr>
|
|
84
109
|
<tr><td><code>Heresay.setVersion("1.4.0")</code></td><td>Set or change the app version.</td></tr>
|
|
85
110
|
<tr><td><code>Heresay.setScreen("Checkout")</code></td><td>Name the current screen, for apps whose URL doesn't change between screens.</td></tr>
|
|
86
|
-
<tr><td><code>Heresay.open()</code></td><td>Open the report form from your own button or menu item.</td></tr>
|
|
87
|
-
<tr><td><code>Heresay.
|
|
111
|
+
<tr><td><code>Heresay.open({ type, text })</code></td><td>Open the report form from your own button or menu item. <code>type</code> and <code>text</code> are optional and fill it in, for example from an error screen; the person still reviews and sends it.</td></tr>
|
|
112
|
+
<tr><td><code>Heresay.on("sent", fn)</code></td><td>Calls <code>fn({ id, type })</code> after each report is sent, to thank people or count it in your analytics. Returns a function that stops it.</td></tr>
|
|
113
|
+
<tr><td><code>Heresay.introduce({ title, body })</code></td><td>Once per device, a small bubble over the button says what it's for, so people know it exists. Call it when your main screen is up (after sign-in or onboarding), or add <code>data-intro="auto"</code> to the tag. Later calls do nothing. <code>title</code> and <code>body</code> are optional, to use your own words.</td></tr>
|
|
88
114
|
<tr><td><code>Heresay.openPreferences()</code></td><td>Open the Preferences tab: a note about their setup, sent with every report. People who aren't signed in can also add a name and an email for replies. It's all optional and saved on their device. Where the button sits is yours to choose, with <code>data-position</code>.</td></tr>
|
|
89
115
|
<tr><td><code>Heresay.close()</code></td><td>Close the panel.</td></tr></table>
|
|
90
116
|
<p>Each report also carries the page it came from: its title, its address without the query string, and the window size.</p>
|
|
@@ -157,7 +183,7 @@ connect-src ORIGIN;</code></pre>
|
|
|
157
183
|
WindowGroup { ContentView().heresayReportButton() } <span class="k">// iOS: a Report button in the corner</span>
|
|
158
184
|
}
|
|
159
185
|
}</code></pre>
|
|
160
|
-
<p>On macOS, use <code>ContentView().heresay()</code> and add <code>.commands { HeresayCommands() }</code> for <b>Help › Report a Problem…</b> (⌥⌘R). The same calls as the web SDK exist: <code>Heresay.identify(id:label:email:)</code>, <code>Heresay.presentPreferences()</code>, <code>Heresay.introduce()</code> (once per install, an alert saying where to find it; call it when the main screen appears), <code>Heresay.setScreen(_:)</code>, <code>Heresay.present()</code>, and <code>Heresay.send(_:text:)</code> for your own UI. The app version comes from the bundle. Native apps have no web origin to lock the key to; the rate limits still apply.</p>
|
|
186
|
+
<p>On macOS, use <code>ContentView().heresay()</code> and add <code>.commands { HeresayCommands() }</code> for <b>Help › Report a Problem…</b> (⌥⌘R). The same calls as the web SDK exist: <code>Heresay.identify(id:label:email:)</code>, <code>Heresay.presentPreferences()</code>, <code>Heresay.introduce()</code> (once per install, an alert saying where to find it; call it when the main screen appears), <code>Heresay.setScreen(_:)</code>, <code>Heresay.present(type:text:)</code>, <code>Heresay.onSent</code>, and <code>Heresay.send(_:text:)</code> for your own UI. How it looks is one <code>HeresayStyle</code> passed to <code>configure(…, style:)</code>, with the same choices as the web (corner, offset, text, pill or icon, size, fill, shadow, screens to hide it on, theme, typeface, English, French, Tamil or Hindi, report types, a thank-you line, sheet size, the Preferences tab). The defaults are recommended; the dashboard's <b>Design</b> page shows each choice and gives the Swift. The app version comes from the bundle. Native apps have no web origin to lock the key to; the rate limits still apply.</p>
|
|
161
187
|
|
|
162
188
|
<h2 id="rest">Other platforms</h2>
|
|
163
189
|
<p>Android, React Native and Flutter SDKs are on the way. Until then, any app can talk to the same API. Both calls take a JSON body.</p>
|