create-heresay 0.2.6 → 0.2.7
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 +1 -1
- package/release/VERSION +1 -1
- package/release/functions/lib/core/agent.js +1 -0
- package/release/functions/lib/core/handler.js +10 -0
- package/release/functions/lib/core/version.js +1 -1
- package/release/public/dashboard.css +16 -0
- package/release/public/dashboard.js +175 -58
- package/release/public/docs.html +2 -1
- package/release/public/guides/install-apple.md +18 -2
- package/release/public/guides/install-web.md +17 -2
- package/release/public/guides/start.md +4 -0
- package/release/public/sdk.js +40 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-heresay",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
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.
|
|
1
|
+
0.2.7
|
|
@@ -283,6 +283,7 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
283
283
|
}
|
|
284
284
|
const appView = (p) => ({
|
|
285
285
|
id: p.id, name: p.name, platform: p.platform, framework: p.framework, sign_in: p.sign_in ?? null,
|
|
286
|
+
product_id: p.product_id ?? p.id,
|
|
286
287
|
framework_detected: !!p.framework_detected, key: p.key, allowed_origins: p.allowed_origins,
|
|
287
288
|
});
|
|
288
289
|
//# sourceMappingURL=agent.js.map
|
|
@@ -403,9 +403,19 @@ async function createProject(me, req, deps) {
|
|
|
403
403
|
}
|
|
404
404
|
if (body.sign_in != null && !isSignIn(body.sign_in))
|
|
405
405
|
return json(400, { error: 'sign_in must be yes, no or null' });
|
|
406
|
+
// Another platform of an existing product: it has to be one.
|
|
407
|
+
let product_id = null;
|
|
408
|
+
if (body.product_id != null) {
|
|
409
|
+
const want = str(body.product_id, 40);
|
|
410
|
+
const all = await deps.store.listProjects();
|
|
411
|
+
if (!want || !all.some((x) => (x.product_id ?? x.id) === want))
|
|
412
|
+
return json(400, { error: 'no such product to add a platform to' });
|
|
413
|
+
product_id = want;
|
|
414
|
+
}
|
|
406
415
|
const project = {
|
|
407
416
|
id: newId('p_', 9), name, platform, framework: framework ? framework.toLowerCase() : null,
|
|
408
417
|
sign_in: isSignIn(body.sign_in) ? body.sign_in : null,
|
|
418
|
+
product_id,
|
|
409
419
|
key: newId('pk_', 18), allowed_origins: [...new Set(origins)], created_by: me.email,
|
|
410
420
|
created_at: new Date(deps.now()).toISOString(),
|
|
411
421
|
};
|
|
@@ -65,6 +65,22 @@ input:focus, textarea:focus, select:focus { outline:2px solid var(--acc); outlin
|
|
|
65
65
|
.app-card .mute { font-size:13px; }
|
|
66
66
|
.app-card .count { grid-column:1 / -1; margin-top:10px; font-size:13px; color:var(--mute); }
|
|
67
67
|
.app-card .count.on { color:var(--deep); font-weight:700; }
|
|
68
|
+
.product-card { display:flex; flex-direction:column; border:1px solid var(--line); border-radius:16px; overflow:hidden; }
|
|
69
|
+
.product-card .app-card { border:0; border-radius:0; }
|
|
70
|
+
.product-card .app-card:hover { background:var(--soft); }
|
|
71
|
+
.product-card.single .app-card { padding-bottom:10px; }
|
|
72
|
+
.product-head { display:flex; justify-content:space-between; align-items:baseline; gap:10px; padding:16px 18px 6px; }
|
|
73
|
+
.product-head b { font-size:17px; }
|
|
74
|
+
.platform-line { padding:12px 18px; border-top:1px solid var(--line) !important; grid-template-columns:auto 1fr auto; }
|
|
75
|
+
.platform-line .count { grid-column:auto; margin:0; }
|
|
76
|
+
.add-platform { font-size:13px; font-weight:600; text-decoration:none; }
|
|
77
|
+
.product-card.single .add-platform { padding:0 18px 14px; }
|
|
78
|
+
.add-platform:hover { text-decoration:underline; }
|
|
79
|
+
.platform.added { color:var(--mute); background:var(--soft); border-color:transparent; }
|
|
80
|
+
.pill.platform-pill { color:var(--mute); border:1px solid var(--line); border-radius:999px; padding:0 8px; font-weight:600; }
|
|
81
|
+
.product-platforms .repos-line { margin:0 0 6px; }
|
|
82
|
+
.product-platforms { margin:-10px 0 18px; }
|
|
83
|
+
.platforms-filter { margin-bottom:8px; }
|
|
68
84
|
.picon { width:40px; height:40px; border-radius:12px; background:var(--mist); display:inline-flex; align-items:center; justify-content:center; flex:none; }
|
|
69
85
|
.picon svg { width:22px; height:22px; fill:none; stroke:var(--deep); stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
|
|
70
86
|
|
|
@@ -193,6 +193,14 @@
|
|
|
193
193
|
icon: '<path d="M14 3 5 12l3 3L20 3zM14 12l-5 5 5 5h6l-5-5 5-5z"/>' },
|
|
194
194
|
];
|
|
195
195
|
var platformOf = function (id) { return PLATFORMS.filter(function (x) { return x.id === id; })[0] || PLATFORMS[0]; };
|
|
196
|
+
/** Apps that are platforms of one product share its id: the first app's. */
|
|
197
|
+
var productOf = function (p) { return p.product_id || p.id; };
|
|
198
|
+
var siblings = function (p) {
|
|
199
|
+
var mine = projects.filter(function (x) { return productOf(x) === productOf(p); });
|
|
200
|
+
if (!mine.some(function (x) { return x.id === p.id; })) mine.push(p);
|
|
201
|
+
return mine.sort(function (a, b) { return a.created_at.localeCompare(b.created_at); });
|
|
202
|
+
};
|
|
203
|
+
var productName = function (p) { return siblings(p)[0].name; };
|
|
196
204
|
var icon = function (p) { return el('span', { class: 'picon', html: '<svg viewBox="0 0 24 24" aria-hidden="true">' + p.icon + '</svg>' }); };
|
|
197
205
|
|
|
198
206
|
function appsView(view) {
|
|
@@ -211,21 +219,34 @@
|
|
|
211
219
|
el('a', { class: 'btn primary', href: '#/new', text: 'Add an app' }),
|
|
212
220
|
]));
|
|
213
221
|
var grid = el('div', { class: 'apps' });
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
var
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
222
|
+
// One card per product; one line per platform in it, each with its own state.
|
|
223
|
+
var seen = {};
|
|
224
|
+
projects.forEach(function (first) {
|
|
225
|
+
if (seen[productOf(first)]) return;
|
|
226
|
+
seen[productOf(first)] = true;
|
|
227
|
+
var sibs = siblings(first);
|
|
228
|
+
var many = sibs.length > 1;
|
|
229
|
+
var rows = sibs.map(function (p) {
|
|
230
|
+
var count = el('span', { class: 'count', text: ' ' });
|
|
231
|
+
var line = el('a', { class: 'app-card' + (many ? ' platform-line' : ''), href: '#/apps/' + p.id }, [
|
|
232
|
+
icon(platformOf(p.platform)),
|
|
233
|
+
el('div', {}, [el('b', { text: many ? platformOf(p.platform).label : p.name }),
|
|
234
|
+
el('span', { class: 'mute', text: many ? (p.framework ? frameworkLabel(p.framework) : ' ') : platformOf(p.platform).label + (p.framework ? ' · ' + frameworkLabel(p.framework) : '') })]),
|
|
235
|
+
count,
|
|
236
|
+
]);
|
|
237
|
+
api('GET', '/projects/' + p.id + '/reports').then(function (r) {
|
|
238
|
+
var open = r.reports.filter(function (x) { return x.status === 'open'; }).length;
|
|
239
|
+
// No report yet means setup isn't proven: send them back to finish it.
|
|
240
|
+
if (!r.reports.length && !p.sdk_seen && !p.code_found) { line.href = '#/apps/' + p.id + '/setup'; count.textContent = 'Setup not finished'; count.className = 'count todo'; return; }
|
|
241
|
+
count.textContent = !r.reports.length ? 'No reports yet' : open ? open + ' open' : 'All answered';
|
|
242
|
+
if (open) count.className = 'count on';
|
|
243
|
+
});
|
|
244
|
+
return line;
|
|
228
245
|
});
|
|
246
|
+
var add = el('a', { class: 'add-platform', href: '#/new?product=' + productOf(first), text: '+ Add a platform' });
|
|
247
|
+
grid.appendChild(many
|
|
248
|
+
? el('div', { class: 'product-card' }, [el('div', { class: 'product-head' }, [el('b', { text: first.name }), add])].concat(rows))
|
|
249
|
+
: el('div', { class: 'product-card single' }, [rows[0], add]));
|
|
229
250
|
});
|
|
230
251
|
view.appendChild(grid);
|
|
231
252
|
});
|
|
@@ -238,14 +259,15 @@
|
|
|
238
259
|
['unknown', 'Not sure'], ['html', 'Plain HTML'], ['react', 'React'], ['next', 'Next.js'], ['vue', 'Vue'], ['nuxt', 'Nuxt'],
|
|
239
260
|
['svelte', 'SvelteKit'], ['angular', 'Angular'], ['other', 'Something else'],
|
|
240
261
|
];
|
|
241
|
-
|
|
262
|
+
var NATIVE_LABELS = { swiftui: 'SwiftUI', uikit: 'UIKit', appkit: 'AppKit' };
|
|
263
|
+
function frameworkLabel(id) { var f = FRAMEWORKS.filter(function (x) { return x[0] === id; })[0]; return f ? f[1] : NATIVE_LABELS[id] || id; }
|
|
242
264
|
|
|
243
265
|
/**
|
|
244
266
|
* The four steps. Earlier ones are links, so you can go back and change things; later ones
|
|
245
267
|
* aren't, because each step needs the one before it. `tested` marks the last step done.
|
|
246
268
|
*/
|
|
247
|
-
function stepper(active, p, tested) {
|
|
248
|
-
var q = p ? '?app=' + p.id : '';
|
|
269
|
+
function stepper(active, p, tested, query) {
|
|
270
|
+
var q = p ? '?app=' + p.id : (query || '');
|
|
249
271
|
var links = ['#/new' + q, p ? '#/new/' + p.platform + q : null, p ? '#/apps/' + p.id + '/setup' : null, null];
|
|
250
272
|
var names = ['Platform', 'Details', 'Install', 'Test'];
|
|
251
273
|
return el('ol', { class: 'steps' }, names.map(function (s, i) {
|
|
@@ -260,28 +282,43 @@
|
|
|
260
282
|
/** Adding an app, or with ?app=<id>, going back to change one that already exists. */
|
|
261
283
|
function newAppView(view, platform, query) {
|
|
262
284
|
var editId = query && query.get('app');
|
|
263
|
-
|
|
264
|
-
drawNewApp(view, platform, null);
|
|
285
|
+
var productId = query && query.get('product');
|
|
286
|
+
if (editId) return withProject(editId, function (p) { drawNewApp(view, platform, p, null); });
|
|
287
|
+
if (productId) {
|
|
288
|
+
return api('GET', '/projects').then(function (b) {
|
|
289
|
+
projects = b.projects;
|
|
290
|
+
var first = projects.filter(function (x) { return productOf(x) === productId; })[0];
|
|
291
|
+
if (!first) { location.hash = '#/'; return; }
|
|
292
|
+
drawNewApp(view, platform, null, first);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
drawNewApp(view, platform, null, null);
|
|
265
296
|
}
|
|
266
297
|
|
|
267
|
-
|
|
268
|
-
|
|
298
|
+
/** `sibling`: adding another platform to that app's product, not a new product. */
|
|
299
|
+
function drawNewApp(view, platform, editing, sibling) {
|
|
300
|
+
var q = editing ? '?app=' + editing.id : sibling ? '?product=' + productOf(sibling) : '';
|
|
301
|
+
var has = sibling ? siblings(sibling) : [];
|
|
269
302
|
if (!platform) {
|
|
270
|
-
view.appendChild(stepper(1, editing));
|
|
271
|
-
view.appendChild(el('h1', { text: 'What are you adding Heresay to?' }));
|
|
303
|
+
view.appendChild(stepper(1, editing, false, q));
|
|
304
|
+
view.appendChild(el('h1', { text: sibling ? 'Add a platform to ' + productName(sibling) : 'What are you adding Heresay to?' }));
|
|
305
|
+
if (sibling) view.appendChild(el('p', { class: 'mute', text: 'Its reports join the same inbox. Each platform gets its own key and install steps.' }));
|
|
272
306
|
var grid = el('div', { class: 'platforms' });
|
|
273
307
|
PLATFORMS.forEach(function (p) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
'
|
|
277
|
-
|
|
308
|
+
var there = has.filter(function (x) { return x.platform === p.id; })[0];
|
|
309
|
+
grid.appendChild(el(p.ready && !there ? 'a' : 'div', {
|
|
310
|
+
class: 'platform' + (p.ready ? '' : ' soon') + (there ? ' added' : '') + (editing && editing.platform === p.id ? ' current' : ''),
|
|
311
|
+
href: p.ready && !there ? '#/new/' + p.id + q : null,
|
|
312
|
+
'aria-disabled': p.ready && !there ? null : 'true',
|
|
313
|
+
}, [icon(p), el('b', { text: p.label }), el('span', { class: 'mute', text: p.note }),
|
|
314
|
+
there ? el('span', { class: 'tag', text: 'Added' }) : p.ready ? null : el('span', { class: 'tag', text: 'Soon' })]));
|
|
278
315
|
});
|
|
279
316
|
view.appendChild(grid);
|
|
280
317
|
view.appendChild(el('p', { class: 'mute small', text: 'Other platforms can already send reports through the API. See the docs, under Other platforms.' }));
|
|
281
318
|
return;
|
|
282
319
|
}
|
|
283
320
|
|
|
284
|
-
view.appendChild(stepper(2, editing));
|
|
321
|
+
view.appendChild(stepper(2, editing, false, q));
|
|
285
322
|
var native = !!platformOf(platform).apple;
|
|
286
323
|
view.appendChild(el('h1', { text: 'About your ' + platformOf(platform).label + ' app' }));
|
|
287
324
|
var err = el('p', { class: 'err', role: 'alert' });
|
|
@@ -297,7 +334,7 @@
|
|
|
297
334
|
}));
|
|
298
335
|
});
|
|
299
336
|
// Signed-in apps pass who it is to Heresay, so the person reporting is never asked their name.
|
|
300
|
-
var signIn = editing && editing.sign_in ? editing.sign_in : 'unknown';
|
|
337
|
+
var signIn = editing && editing.sign_in ? editing.sign_in : sibling && sibling.sign_in ? sibling.sign_in : 'unknown';
|
|
301
338
|
var signChips = el('div', { class: 'chips', role: 'radiogroup', 'aria-label': 'Do people sign in?' });
|
|
302
339
|
[['yes', 'Yes, they sign in'], ['no', 'No, anyone can use it'], ['unknown', 'Not sure']].forEach(function (c) {
|
|
303
340
|
signChips.appendChild(el('button', {
|
|
@@ -331,6 +368,7 @@
|
|
|
331
368
|
err.textContent = '';
|
|
332
369
|
var origins = native ? [] : form.origins.value.split(/[\s,]+/).map(function (s) { return s.trim(); }).filter(Boolean);
|
|
333
370
|
var body = { name: form.name.value, platform: platform, framework: native ? 'swiftui' : (fw === 'unknown' ? null : fw), allowed_origins: origins, sign_in: signIn === 'unknown' ? null : signIn };
|
|
371
|
+
if (sibling) body.product_id = productOf(sibling);
|
|
334
372
|
// Editing keeps the key, so a line already pasted into the app keeps working.
|
|
335
373
|
(editing ? api('PATCH', '/projects/' + editing.id, body) : api('POST', '/projects', body))
|
|
336
374
|
.then(function (b) {
|
|
@@ -343,6 +381,10 @@
|
|
|
343
381
|
if (editing) {
|
|
344
382
|
form.name.value = editing.name;
|
|
345
383
|
if (!native) form.origins.value = editing.allowed_origins.join('\n');
|
|
384
|
+
} else if (sibling) {
|
|
385
|
+
form.name.value = productName(sibling);
|
|
386
|
+
var web = has.filter(function (x) { return x.allowed_origins.length; })[0];
|
|
387
|
+
if (!native && web) form.origins.value = web.allowed_origins.join('\n');
|
|
346
388
|
}
|
|
347
389
|
form.name.focus();
|
|
348
390
|
}
|
|
@@ -411,8 +453,20 @@
|
|
|
411
453
|
el('p', { text: 'Then tell Heresay who is signed in, so nobody types their name to send a report:' }), codeBlock(code)])];
|
|
412
454
|
}
|
|
413
455
|
|
|
456
|
+
/** People who never noticed the button can't use it: a one-time introduction, shown by Heresay. */
|
|
457
|
+
function introStep(p) {
|
|
458
|
+
var apple = platformOf(p.platform).apple;
|
|
459
|
+
return apple ? [
|
|
460
|
+
el('p', { html: '<b>Last, tell people it’s there.</b> ' + (p.platform === 'macos' ? 'Under Help, nobody finds it by chance. ' : '') + 'Once the main screen appears, after sign-in and onboarding, show the one-time introduction. It says where to find Heresay and offers to open it:' }),
|
|
461
|
+
codeBlock('MainView()\n .onAppear { Heresay.introduce() } // once per install; later calls do nothing'),
|
|
462
|
+
] : [
|
|
463
|
+
el('p', { html: '<b>Last, tell people it’s there.</b> Add <code>data-intro="auto"</code> to the tag for a one-time bubble over the button. Apps with sign-in or onboarding: call this once the main screen appears instead:' }),
|
|
464
|
+
codeBlock('window.Heresay?.introduce(); // once per device; later calls do nothing'),
|
|
465
|
+
];
|
|
466
|
+
}
|
|
467
|
+
|
|
414
468
|
function byHand(p) {
|
|
415
|
-
return byHandSteps(p).concat(identifyStep(p));
|
|
469
|
+
return byHandSteps(p).concat(identifyStep(p), introStep(p));
|
|
416
470
|
}
|
|
417
471
|
|
|
418
472
|
function byHandSteps(p) {
|
|
@@ -458,7 +512,7 @@
|
|
|
458
512
|
'',
|
|
459
513
|
' npx -y heresay@latest connect --url ' + location.origin + ' --token ' + token + ' --yes',
|
|
460
514
|
'',
|
|
461
|
-
'2. Print the install steps for this app and follow them. They include the app\'s key and exactly where the code goes' + (apple ? ' (a Swift package and one line of setup)
|
|
515
|
+
'2. Print the install steps for this app and follow them. They include the app\'s key and exactly where the code goes' + (apple ? ' (a Swift package and one line of setup)' : ', for any framework') + '. Follow every required step, including telling the people who use the app that Heresay is there: call introduce() once the main screen appears, so it isn\'t hidden' + (apple ? ' under a menu' : ' in a corner') + '.',
|
|
462
516
|
'',
|
|
463
517
|
' npx -y heresay@latest install ' + p.id,
|
|
464
518
|
'',
|
|
@@ -466,7 +520,7 @@
|
|
|
466
520
|
'',
|
|
467
521
|
' npx -y heresay@latest check ' + p.id,
|
|
468
522
|
'',
|
|
469
|
-
' You are done when it prints "installed": true. If
|
|
523
|
+
' You are done when it prints "installed": true and an empty "todo" list. If not, do what it says and run it again.',
|
|
470
524
|
'',
|
|
471
525
|
'Change nothing else in the app.',
|
|
472
526
|
].join('\n');
|
|
@@ -614,6 +668,7 @@
|
|
|
614
668
|
rs.slice(0, 5).forEach(function (r) {
|
|
615
669
|
feed.appendChild(el('li', { class: !first && !known[r.id] ? 'fresh' : '' }, [
|
|
616
670
|
el('span', { class: 'pill ' + r.type, text: TYPE_LABEL[r.type] }),
|
|
671
|
+
showPlatform ? el('span', { class: 'pill platform-pill', text: platformOf(p.platform).label }) : null,
|
|
617
672
|
el('span', { class: 'feed-text', text: r.text }),
|
|
618
673
|
el('span', { class: 'mute small', text: [r.context.route, r.context.platform, new Date(r.created_at).toLocaleTimeString()].filter(Boolean).join(' · ') }),
|
|
619
674
|
]));
|
|
@@ -630,59 +685,120 @@
|
|
|
630
685
|
|
|
631
686
|
var filter = 'open';
|
|
632
687
|
|
|
688
|
+
/** Most urgent first, oldest first within a type, as the server sorts one app's reports. */
|
|
689
|
+
var TYPE_ORDER = { broken: 0, confusing: 1, improvement: 2, idea: 3 };
|
|
690
|
+
function triageSort(rs) {
|
|
691
|
+
return rs.slice().sort(function (a, b) {
|
|
692
|
+
return ((a.status === 'open' ? 0 : 1) - (b.status === 'open' ? 0 : 1))
|
|
693
|
+
|| (TYPE_ORDER[a.type] - TYPE_ORDER[b.type])
|
|
694
|
+
|| a.created_at.localeCompare(b.created_at);
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* One inbox for a product: every platform's reports together, each marked with where it came
|
|
700
|
+
* from. Install, delete and repos stay per platform, because keys and code differ.
|
|
701
|
+
*/
|
|
633
702
|
function reportsView(view, p) {
|
|
634
703
|
var reports = [];
|
|
704
|
+
var sibs = [p];
|
|
705
|
+
var where = 'all';
|
|
635
706
|
var filters = el('nav', { class: 'filters', 'aria-label': 'Filter' });
|
|
707
|
+
var platformBar = el('nav', { class: 'filters platforms-filter', 'aria-label': 'Platform' });
|
|
636
708
|
var list = el('div', { class: 'reports' });
|
|
637
709
|
var empty = el('p', { class: 'empty' });
|
|
638
|
-
var
|
|
639
|
-
var
|
|
710
|
+
var ctxs = {};
|
|
711
|
+
var head = el('div', { class: 'head' });
|
|
712
|
+
var platformsBox = el('div', { class: 'product-platforms' });
|
|
640
713
|
view.appendChild(el('a', { class: 'back', href: '#/', text: '← All apps' }));
|
|
641
|
-
view.appendChild(
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
el('div', { class: 'row tight' }, [
|
|
645
|
-
el('a', { class: 'btn', href: '#/apps/' + p.id + '/setup', text: 'Install' }),
|
|
646
|
-
el('a', { class: 'btn ghost', href: '#/apps/' + p.id + '/delete', text: 'Delete…' }),
|
|
647
|
-
]),
|
|
648
|
-
]));
|
|
649
|
-
view.appendChild(repoLine);
|
|
714
|
+
view.appendChild(head);
|
|
715
|
+
view.appendChild(platformsBox);
|
|
716
|
+
view.appendChild(platformBar);
|
|
650
717
|
view.appendChild(filters);
|
|
651
718
|
view.appendChild(list);
|
|
652
719
|
view.appendChild(empty);
|
|
653
720
|
|
|
721
|
+
function drawHead() {
|
|
722
|
+
head.textContent = '';
|
|
723
|
+
var many = sibs.length > 1;
|
|
724
|
+
head.appendChild(el('div', { class: 'title' }, [
|
|
725
|
+
many ? el('span', { class: 'picon', html: '<svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="3" width="8" height="8" rx="2"/><rect x="13" y="3" width="8" height="8" rx="2"/><rect x="3" y="13" width="8" height="8" rx="2"/><path d="M17 13v8M13 17h8"/></svg>' }) : icon(platformOf(p.platform)),
|
|
726
|
+
el('div', {}, [el('h1', { text: productName(p) }),
|
|
727
|
+
el('span', { class: 'mute small', text: many ? sibs.map(function (x) { return platformOf(x.platform).label; }).join(' · ')
|
|
728
|
+
: (p.framework ? frameworkLabel(p.framework) + (p.framework_detected ? ' (detected)' : '') : platformOf(p.platform).label) })])]));
|
|
729
|
+
head.appendChild(el('div', { class: 'row tight' }, [
|
|
730
|
+
el('a', { class: 'btn ghost', href: '#/new?product=' + productOf(p), text: '+ Add a platform' }),
|
|
731
|
+
many ? null : el('a', { class: 'btn', href: '#/apps/' + p.id + '/setup', text: 'Install' }),
|
|
732
|
+
many ? null : el('a', { class: 'btn ghost', href: '#/apps/' + p.id + '/delete', text: 'Delete…' }),
|
|
733
|
+
]));
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/** Per platform: where agents fix it, and its own Install and Delete. */
|
|
737
|
+
function drawPlatforms() {
|
|
738
|
+
platformsBox.textContent = '';
|
|
739
|
+
var many = sibs.length > 1;
|
|
740
|
+
sibs.forEach(function (x) {
|
|
741
|
+
var repos = (ctxs[x.id] || {}).repos || [];
|
|
742
|
+
platformsBox.appendChild(el('p', { class: 'repos-line' }, [
|
|
743
|
+
many ? el('b', { text: platformOf(x.platform).label + ': ' }) : null,
|
|
744
|
+
document.createTextNode(repos.length ? 'Agents fix these in ' + repos.join(', ') + ' · ' : 'No repo connected for agents yet · '),
|
|
745
|
+
el('a', { href: '#/connect?app=' + x.id, text: 'Connect a repo' }),
|
|
746
|
+
many ? document.createTextNode(' · ') : null,
|
|
747
|
+
many ? el('a', { href: '#/apps/' + x.id + '/setup', text: 'Install' }) : null,
|
|
748
|
+
many ? document.createTextNode(' · ') : null,
|
|
749
|
+
many ? el('a', { href: '#/apps/' + x.id + '/delete', text: 'Delete…' }) : null,
|
|
750
|
+
]));
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
|
|
654
754
|
function load() {
|
|
655
|
-
return
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
755
|
+
return api('GET', '/projects').then(function (b) {
|
|
756
|
+
projects = b.projects;
|
|
757
|
+
sibs = siblings(p);
|
|
758
|
+
drawHead();
|
|
759
|
+
return Promise.all(sibs.map(function (x) {
|
|
760
|
+
return Promise.all([api('GET', '/projects/' + x.id + '/reports'), api('GET', '/projects/' + x.id + '/repos')])
|
|
761
|
+
.then(function (r) { ctxs[x.id] = { briefs: r[0].briefs || {}, repos: r[1].repos, project: x, reports: r[0].reports }; });
|
|
762
|
+
}));
|
|
763
|
+
}).then(function () {
|
|
764
|
+
reports = triageSort([].concat.apply([], sibs.map(function (x) { return ctxs[x.id].reports; })));
|
|
765
|
+
drawPlatforms();
|
|
664
766
|
render();
|
|
665
767
|
});
|
|
666
768
|
}
|
|
667
769
|
|
|
668
770
|
function render() {
|
|
771
|
+
var many = sibs.length > 1;
|
|
772
|
+
platformBar.textContent = '';
|
|
773
|
+
platformBar.hidden = !many;
|
|
774
|
+
if (many) {
|
|
775
|
+
[{ id: 'all', label: 'All platforms' }].concat(sibs.map(function (x) { return { id: x.id, label: platformOf(x.platform).label }; })).forEach(function (f) {
|
|
776
|
+
var n = f.id === 'all' ? reports.length : reports.filter(function (r) { return r.project_id === f.id; }).length;
|
|
777
|
+
platformBar.appendChild(el('button', { 'aria-pressed': String(where === f.id), onclick: function () { where = f.id; render(); } },
|
|
778
|
+
[f.label + ' ', el('span', { class: 'n', text: String(n) })]));
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
var here = reports.filter(function (r) { return where === 'all' || r.project_id === where; });
|
|
669
782
|
filters.textContent = '';
|
|
670
783
|
['open', 'accepted', 'fixed', 'declined', 'all'].forEach(function (f) {
|
|
671
|
-
var n = f === 'all' ?
|
|
784
|
+
var n = f === 'all' ? here.length : here.filter(function (r) { return r.status === f; }).length;
|
|
672
785
|
filters.appendChild(el('button', {
|
|
673
786
|
'aria-pressed': String(filter === f),
|
|
674
787
|
onclick: function () { filter = f; render(); },
|
|
675
788
|
}, [(f === 'all' ? 'All' : STATUS_LABEL[f]) + ' ', el('span', { class: 'n', text: String(n) })]));
|
|
676
789
|
});
|
|
677
790
|
list.textContent = '';
|
|
678
|
-
var shown =
|
|
791
|
+
var shown = here.filter(function (r) { return filter === 'all' || r.status === filter; });
|
|
679
792
|
empty.hidden = shown.length > 0;
|
|
680
793
|
empty.textContent = '';
|
|
681
|
-
if (!
|
|
794
|
+
if (!here.length) {
|
|
682
795
|
empty.appendChild(document.createTextNode('No reports yet. '));
|
|
683
|
-
empty.appendChild(el('a', { href: '#/apps/' + p.id + '/setup', text: 'Check the install' }));
|
|
796
|
+
empty.appendChild(el('a', { href: '#/apps/' + (where === 'all' ? p.id : where) + '/setup', text: 'Check the install' }));
|
|
684
797
|
} else empty.textContent = filter === 'open' ? 'Nothing waiting. Every report has had its hearing.' : 'Nothing here.';
|
|
685
|
-
shown.forEach(function (r) {
|
|
798
|
+
shown.forEach(function (r) {
|
|
799
|
+
var c = ctxs[r.project_id];
|
|
800
|
+
list.appendChild(row(c.project, r, load, c, many));
|
|
801
|
+
});
|
|
686
802
|
}
|
|
687
803
|
|
|
688
804
|
load();
|
|
@@ -716,7 +832,7 @@
|
|
|
716
832
|
]);
|
|
717
833
|
}
|
|
718
834
|
|
|
719
|
-
function row(p, r, reload, ctx) {
|
|
835
|
+
function row(p, r, reload, ctx, showPlatform) {
|
|
720
836
|
var brief = ctx.briefs[r.id];
|
|
721
837
|
var err = el('span', { class: 'err' });
|
|
722
838
|
var actions = el('div', { class: 'actions' });
|
|
@@ -784,6 +900,7 @@
|
|
|
784
900
|
return el('article', { class: 'report' }, [
|
|
785
901
|
el('div', { class: 'meta' }, [
|
|
786
902
|
el('span', { class: 'pill ' + r.type, text: TYPE_LABEL[r.type] }),
|
|
903
|
+
showPlatform ? el('span', { class: 'pill platform-pill', text: platformOf(p.platform).label }) : null,
|
|
787
904
|
el('time', { datetime: r.created_at, text: new Date(r.created_at).toLocaleString() }),
|
|
788
905
|
el('span', { class: 'status s-' + r.status, text: STATUS_LABEL[r.status] }),
|
|
789
906
|
]),
|
package/release/public/docs.html
CHANGED
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
<tr><td><code>Heresay.setVersion("1.4.0")</code></td><td>Set or change the app version.</td></tr>
|
|
85
85
|
<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
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.introduce()</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.</td></tr>
|
|
87
88
|
<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>
|
|
88
89
|
<tr><td><code>Heresay.close()</code></td><td>Close the panel.</td></tr></table>
|
|
89
90
|
<p>Each report also carries the page it came from: its title, its address without the query string, and the window size.</p>
|
|
@@ -156,7 +157,7 @@ connect-src ORIGIN;</code></pre>
|
|
|
156
157
|
WindowGroup { ContentView().heresayReportButton() } <span class="k">// iOS: a Report button in the corner</span>
|
|
157
158
|
}
|
|
158
159
|
}</code></pre>
|
|
159
|
-
<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.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>
|
|
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>
|
|
160
161
|
|
|
161
162
|
<h2 id="rest">Other platforms</h2>
|
|
162
163
|
<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>
|
|
@@ -51,7 +51,23 @@ Heresay.identify() // after sign-out
|
|
|
51
51
|
|
|
52
52
|
Then nobody is asked their name to send a report, and the team can reply to them.
|
|
53
53
|
|
|
54
|
-
## 5.
|
|
54
|
+
## 5. Tell people it's there (required)
|
|
55
|
+
|
|
56
|
+
On macOS the report window lives under Help, and on iOS it's a small button; people who have never
|
|
57
|
+
seen it won't go looking. Call `Heresay.introduce()` once the person reaches the app's main
|
|
58
|
+
screen: after sign-in and after any onboarding, never over a login or first-run screen. It shows a
|
|
59
|
+
native alert, once per install, that says where to find it (Help › Report a Problem… (⌥⌘R) on
|
|
60
|
+
macOS, the Report button on iOS) and offers to open it. Later calls do nothing, so this is fine:
|
|
61
|
+
|
|
62
|
+
```swift
|
|
63
|
+
MainView()
|
|
64
|
+
.onAppear { Heresay.introduce() }
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
If the app already has a "What's new" or announcements screen, add a line there too. Don't
|
|
68
|
+
build a custom dialog for this; `introduce()` is the one.
|
|
69
|
+
|
|
70
|
+
## 6. Optional
|
|
55
71
|
|
|
56
72
|
- Screens: `Heresay.setScreen("Checkout")` in `.onAppear` of the main screens.
|
|
57
73
|
- The app version is read from the bundle (`CFBundleShortVersionString` and build).
|
|
@@ -59,7 +75,7 @@ Then nobody is asked their name to send a report, and the team can reply to them
|
|
|
59
75
|
|
|
60
76
|
Change nothing else in the app.
|
|
61
77
|
|
|
62
|
-
##
|
|
78
|
+
## 7. Prove it
|
|
63
79
|
|
|
64
80
|
Call `check_install`: it finds the key in this repo's code by itself (`found_in_code`). Build and
|
|
65
81
|
run on a simulator or device and `seen_running` shows the SDK loaded. To test the whole path,
|
|
@@ -42,7 +42,22 @@ Then the person is never asked their name to send a report, and the team can rep
|
|
|
42
42
|
follows whoever is signed in on that device, so apps with many users and many logins need
|
|
43
43
|
nothing else. Use the fields the app already has; leave out any it doesn't.
|
|
44
44
|
|
|
45
|
-
## 4.
|
|
45
|
+
## 4. Tell people it's there (required)
|
|
46
|
+
|
|
47
|
+
People who have never seen the Report button won't go looking for it. Heresay has a one-time
|
|
48
|
+
introduction: a small bubble over the button saying what it's for, shown once per device.
|
|
49
|
+
|
|
50
|
+
- Most apps: add `data-intro="auto"` to the tag. It appears a few seconds after the first page
|
|
51
|
+
load.
|
|
52
|
+
- Apps with sign-in, onboarding or a first-run tour: leave the attribute off and call
|
|
53
|
+
`window.Heresay?.introduce()` once the person reaches the main screen, so it never covers a
|
|
54
|
+
login form or competes with the tour. Calling it again later does nothing.
|
|
55
|
+
- If the app already has a "What's new" or announcements area, add a line there too, e.g.
|
|
56
|
+
"New: tell us what's broken or could be better with the Report button."
|
|
57
|
+
|
|
58
|
+
Don't build a custom dialog for this; `introduce()` is the one.
|
|
59
|
+
|
|
60
|
+
## 5. Optional, when the app has them
|
|
46
61
|
|
|
47
62
|
- A version: add `data-version="<version>"` to the tag (from package.json, a build env var, ...).
|
|
48
63
|
- Screens that change without the URL changing: `window.Heresay?.setScreen("<name>")` on each change.
|
|
@@ -50,7 +65,7 @@ nothing else. Use the fields the app already has; leave out any it doesn't.
|
|
|
50
65
|
|
|
51
66
|
Change nothing else in the app.
|
|
52
67
|
|
|
53
|
-
##
|
|
68
|
+
## 6. Prove it
|
|
54
69
|
|
|
55
70
|
Call `check_install`. It finds the key in this repo's code by itself (`found_in_code`). Then run
|
|
56
71
|
the app and open it in a browser: `seen_running` shows the SDK loaded there. To test the whole
|
|
@@ -14,6 +14,10 @@ sees the outcome in the app, including the note you write when you mark it fixed
|
|
|
14
14
|
3. **Claim before you start** (`claim_brief`), so another agent doesn't do the same work.
|
|
15
15
|
4. **The fix note is for the reporter**, not for developers. See `write-note`.
|
|
16
16
|
5. **Wrong repo?** `handoff` it to the repo where the fix belongs, with what you learned.
|
|
17
|
+
6. **An install tells people it exists.** Call `introduce()` once the main screen appears, so
|
|
18
|
+
the people using the app learn there's a way to report things. On macOS it lives under Help,
|
|
19
|
+
where nobody looks unprompted. `check_install` lists anything still owed in `todo`; the
|
|
20
|
+
install isn't done until that list is empty.
|
|
17
21
|
|
|
18
22
|
## Which topic next
|
|
19
23
|
|
package/release/public/sdk.js
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
* <script src="https://<sdk-host>/sdk.js" data-key="pk_..." defer></script>
|
|
5
5
|
*
|
|
6
6
|
* Optional attributes: data-version, data-user-id, data-user-label, data-position ("left"),
|
|
7
|
+
* data-intro ("auto": introduce the button a few seconds after the first page load),
|
|
7
8
|
* data-accent ("#0f766e"; a hex colour, to match the host app. Defaults to Heresay peacock).
|
|
8
9
|
* Optional calls, any time after the script runs:
|
|
9
10
|
* Feedback.identify({ id, label, email }) who is signed in; then nobody is asked their name
|
|
10
11
|
* Feedback.setVersion("1.4.0")
|
|
11
12
|
* Feedback.setScreen("Checkout") for apps whose URL does not change per screen
|
|
12
13
|
* Feedback.open()
|
|
14
|
+
* Feedback.introduce() once per device: a bubble saying the Report button is there
|
|
13
15
|
* Feedback.openPreferences() a note about their setup, and a name and email if not signed in
|
|
14
16
|
*
|
|
15
17
|
* No account, no cookies. The reporter is a random per-device id kept in localStorage, and
|
|
@@ -224,6 +226,17 @@
|
|
|
224
226
|
'padding:9px 14px;border-radius:999px;border:1px solid var(--fb-line);background:var(--fb-bg);color:var(--fb-fg);',
|
|
225
227
|
'box-shadow:0 4px 14px rgba(0,0,0,.18);cursor:pointer;font-weight:600}',
|
|
226
228
|
'.fab.left{right:auto;left:20px}',
|
|
229
|
+
'.intro{position:fixed;bottom:72px;right:20px;z-index:2147483000;width:min(300px,calc(100vw - 40px));padding:14px 16px;',
|
|
230
|
+
'background:var(--fb-bg);border:1px solid var(--fb-line);border-radius:14px;box-shadow:0 12px 32px rgba(0,0,0,.22);animation:fb-in .25s ease-out}',
|
|
231
|
+
'.intro.left{right:auto;left:20px}',
|
|
232
|
+
'.intro:after{content:"";position:absolute;bottom:-7px;right:36px;width:12px;height:12px;background:var(--fb-bg);',
|
|
233
|
+
'border-right:1px solid var(--fb-line);border-bottom:1px solid var(--fb-line);transform:rotate(45deg)}',
|
|
234
|
+
'.intro.left:after{right:auto;left:36px}',
|
|
235
|
+
'.intro b{display:block;margin-bottom:4px;font-weight:700}',
|
|
236
|
+
'.intro p{margin:0 0 12px;color:var(--fb-mute);font-size:13px}',
|
|
237
|
+
'.intro .row{margin-top:0;justify-content:flex-end}',
|
|
238
|
+
'@keyframes fb-in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}',
|
|
239
|
+
'@media (prefers-reduced-motion:reduce){.intro{animation:none}}',
|
|
227
240
|
'.mark{display:inline-flex;color:var(--fb-mark)}.mark svg{display:block}',
|
|
228
241
|
'.dot{width:8px;height:8px;border-radius:50%;background:var(--fb-acc)}',
|
|
229
242
|
'.scrim{position:fixed;inset:0;z-index:2147483001;background:rgba(0,0,0,.35);display:flex;align-items:flex-end;justify-content:flex-end;padding:16px}',
|
|
@@ -329,6 +342,7 @@
|
|
|
329
342
|
|
|
330
343
|
function open(which) {
|
|
331
344
|
if (scrim || dead) return;
|
|
345
|
+
if (bubble) { bubble.remove(); bubble = null; }
|
|
332
346
|
lastFocus = document.activeElement;
|
|
333
347
|
view = which || (unseen() ? 'mine' : 'new');
|
|
334
348
|
scrim = el('div', { class: 'scrim' + (LEFT ? ' left' : ''), onclick: function (e) { if (e.target === scrim) close(); } });
|
|
@@ -509,10 +523,34 @@
|
|
|
509
523
|
});
|
|
510
524
|
}
|
|
511
525
|
|
|
526
|
+
// ---- introduction ----------------------------------------------------------------------
|
|
527
|
+
|
|
528
|
+
// People can't use a button they never noticed. Once per device and app, a bubble says what it
|
|
529
|
+
// is for. The host app picks the moment (introduce()), or data-intro="auto" does it on load.
|
|
530
|
+
var INTRO_KEY = 'fbsdk.introduced.' + KEY;
|
|
531
|
+
var bubble = null;
|
|
532
|
+
function introduce() {
|
|
533
|
+
if (dead || bubble || scrim || load(INTRO_KEY)) return false;
|
|
534
|
+
save(INTRO_KEY, new Date().toISOString());
|
|
535
|
+
var done = function () { if (bubble) { bubble.remove(); bubble = null; } };
|
|
536
|
+
bubble = el('div', { class: 'intro' + (LEFT ? ' left' : ''), role: 'dialog', 'aria-label': 'About the Report button' }, [
|
|
537
|
+
el('b', { text: 'Something not right? Tell the team.' }),
|
|
538
|
+
el('p', { text: 'Use Report to say what is broken, confusing or could be better. A person reads every report, and you will see what happens to yours right here.' }),
|
|
539
|
+
el('div', { class: 'row' }, [
|
|
540
|
+
el('button', { class: 'link', type: 'button', text: 'Got it', onclick: done }),
|
|
541
|
+
el('button', { class: 'send', type: 'button', text: 'Try it', onclick: function () { done(); open('new'); } }),
|
|
542
|
+
]),
|
|
543
|
+
]);
|
|
544
|
+
bubble.addEventListener('keydown', function (e) { if (e.key === 'Escape') done(); });
|
|
545
|
+
root.appendChild(bubble);
|
|
546
|
+
return true;
|
|
547
|
+
}
|
|
548
|
+
|
|
512
549
|
function mount() {
|
|
513
550
|
if (dead) return;
|
|
514
551
|
if (!host.isConnected) document.body.appendChild(host);
|
|
515
552
|
refresh();
|
|
553
|
+
if (script.getAttribute('data-intro') === 'auto') setTimeout(introduce, 3000);
|
|
516
554
|
}
|
|
517
555
|
if (document.body) mount(); else document.addEventListener('DOMContentLoaded', mount);
|
|
518
556
|
|
|
@@ -529,6 +567,8 @@
|
|
|
529
567
|
setScreen: function (s) { state.screen = s != null ? String(s) : null; },
|
|
530
568
|
open: function () { open('new'); },
|
|
531
569
|
openPreferences: function () { open('prefs'); },
|
|
570
|
+
/** Show the one-time introduction now. False if it was already shown on this device. */
|
|
571
|
+
introduce: function () { return introduce(); },
|
|
532
572
|
close: close,
|
|
533
573
|
};
|
|
534
574
|
})();
|