create-heresay 0.2.0 → 0.2.2
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 +42 -13
- package/release/functions/lib/core/handler.js +91 -0
- package/release/functions/lib/core/store.js +9 -0
- package/release/functions/lib/core/version.js +1 -1
- package/release/functions/lib/providers/firebase/firestore-store.js +4 -0
- package/release/public/dashboard.css +34 -0
- package/release/public/dashboard.js +230 -80
- package/release/public/guides/index.json +2 -1
- package/release/public/guides/install-apple.md +3 -2
- package/release/public/guides/install-web.md +3 -2
- package/release/public/guides/start.md +3 -1
- package/release/public/guides/uninstall.md +41 -0
- package/release/public/sdk.js +19 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-heresay",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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.2
|
|
@@ -52,8 +52,9 @@ export async function tokens(p, me, req, deps, body) {
|
|
|
52
52
|
return json(200, { tokens: all.map(publicToken) });
|
|
53
53
|
}
|
|
54
54
|
if (p.length === 1 && req.method === 'POST') {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
// No repo: the token is for a prompt, and binds to the repo that first connects with it.
|
|
56
|
+
const repo = body.repo === undefined || body.repo === null || body.repo === '' ? null : normaliseRepo(body.repo);
|
|
57
|
+
if (repo === null && body.repo)
|
|
57
58
|
return json(400, { error: 'name the repo, for example github.com/acme/web' });
|
|
58
59
|
const ids = Array.isArray(body.app_ids) ? body.app_ids.filter((x) => typeof x === 'string') : [];
|
|
59
60
|
for (const id of ids)
|
|
@@ -82,7 +83,7 @@ export async function tokens(p, me, req, deps, body) {
|
|
|
82
83
|
}
|
|
83
84
|
/** The repos connected to an app: where a brief for it can be routed. */
|
|
84
85
|
export async function reposFor(project_id, deps) {
|
|
85
|
-
const ts = (await deps.store.listAgentTokens()).filter((t) => !t.revoked_at && t.app_ids.includes(project_id));
|
|
86
|
+
const ts = (await deps.store.listAgentTokens()).filter((t) => !t.revoked_at && t.repo && t.app_ids.includes(project_id));
|
|
86
87
|
ts.sort((a, b) => a.created_at.localeCompare(b.created_at));
|
|
87
88
|
return [...new Set(ts.map((t) => t.repo))];
|
|
88
89
|
}
|
|
@@ -109,11 +110,27 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
109
110
|
if (!token.last_used_at || now - Date.parse(token.last_used_at) > 3600_000) {
|
|
110
111
|
await deps.store.updateAgentToken(token.id, { last_used_at: at });
|
|
111
112
|
}
|
|
112
|
-
const me = `agent:${token.repo}`;
|
|
113
113
|
const apps = (await Promise.all(token.app_ids.map((id) => deps.store.getProject(id)))).filter((x) => !!x);
|
|
114
114
|
if (p[0] === 'me' && req.method === 'GET') {
|
|
115
115
|
return json(200, { repo: token.repo, version: deps.version, apps: apps.map(appView) });
|
|
116
116
|
}
|
|
117
|
+
if (p[0] === 'bind' && req.method === 'POST') {
|
|
118
|
+
const repo = normaliseRepo(body.repo);
|
|
119
|
+
if (!repo)
|
|
120
|
+
return json(400, { error: 'name the repo, for example github.com/acme/web' });
|
|
121
|
+
if (token.repo && token.repo !== repo)
|
|
122
|
+
return json(409, { error: `this token belongs to ${token.repo}`, repo: token.repo });
|
|
123
|
+
if (!token.repo) {
|
|
124
|
+
await deps.store.updateAgentToken(token.id, { repo });
|
|
125
|
+
deps.log('api.agent_token_bound', { repo, by: token.created_by });
|
|
126
|
+
}
|
|
127
|
+
return json(200, { repo, version: deps.version, apps: apps.map(appView) });
|
|
128
|
+
}
|
|
129
|
+
// Everything else needs to know which repo it is working in.
|
|
130
|
+
if (!token.repo)
|
|
131
|
+
return json(409, { error: 'this token isn\'t connected to a repo yet. Run npx heresay connect with it in the repo first.' });
|
|
132
|
+
const repoName = token.repo;
|
|
133
|
+
const me = `agent:${repoName}`;
|
|
117
134
|
if (p[0] === 'apps') {
|
|
118
135
|
if (p.length === 1 && req.method === 'GET')
|
|
119
136
|
return json(200, { apps: apps.map(appView) });
|
|
@@ -127,12 +144,22 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
127
144
|
const project = res.body.project;
|
|
128
145
|
// An app created from a repo belongs to that repo's token from then on.
|
|
129
146
|
await deps.store.updateAgentToken(token.id, { app_ids: [...token.app_ids, project.id] });
|
|
130
|
-
deps.log('api.agent_app_created', { repo:
|
|
147
|
+
deps.log('api.agent_app_created', { repo: repoName, project_id: project.id });
|
|
131
148
|
return json(201, { app: appView(project) });
|
|
132
149
|
}
|
|
133
150
|
const app = apps.find((a) => a.id === p[1]);
|
|
134
151
|
if (!app)
|
|
135
152
|
return json(404, { error: 'this repo is not connected to that app' });
|
|
153
|
+
if (p[2] === 'verify' && req.method === 'POST') {
|
|
154
|
+
// What `heresay check` found in this repo: the file holding the app's key.
|
|
155
|
+
const file = str(body.file, 300);
|
|
156
|
+
if (!file)
|
|
157
|
+
return json(400, { error: 'say which file has the key' });
|
|
158
|
+
const code_found = { at, repo: repoName, file };
|
|
159
|
+
await deps.store.updateProject(app.id, { code_found });
|
|
160
|
+
deps.log('api.install_verified', { project_id: app.id, repo: repoName });
|
|
161
|
+
return json(200, { code_found });
|
|
162
|
+
}
|
|
136
163
|
if (p[2] === 'check' && req.method === 'GET') {
|
|
137
164
|
// Counts and screens only. Report text is untrusted, and an install check doesn't need it.
|
|
138
165
|
const rs = await deps.store.listReports(app.id);
|
|
@@ -141,6 +168,8 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
141
168
|
reports: rs.length,
|
|
142
169
|
first: first ? { route: first.context.route, app_version: first.context.app_version, created_at: first.created_at } : null,
|
|
143
170
|
framework: app.framework, framework_detected: !!app.framework_detected,
|
|
171
|
+
sdk_seen: app.sdk_seen ?? null, code_found: app.code_found ?? null,
|
|
172
|
+
installed: !!(app.sdk_seen || app.code_found),
|
|
144
173
|
});
|
|
145
174
|
}
|
|
146
175
|
return json(404, { error: 'not found' });
|
|
@@ -157,9 +186,9 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
157
186
|
out.push(summary(t, app, now));
|
|
158
187
|
}
|
|
159
188
|
}
|
|
160
|
-
out.sort((a, b) => Number(!!a.claimed_by && a.claimed_by !==
|
|
189
|
+
out.sort((a, b) => Number(!!a.claimed_by && a.claimed_by !== repoName) - Number(!!b.claimed_by && b.claimed_by !== repoName)
|
|
161
190
|
|| a.accepted_at.localeCompare(b.accepted_at));
|
|
162
|
-
return json(200, { repo:
|
|
191
|
+
return json(200, { repo: repoName, briefs: out });
|
|
163
192
|
}
|
|
164
193
|
// One brief. Found by id within this token's apps only.
|
|
165
194
|
let found = null;
|
|
@@ -186,7 +215,7 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
186
215
|
return json(404, { error: 'not found' });
|
|
187
216
|
if (done)
|
|
188
217
|
return json(409, { error: `this brief is already ${report?.status}`, status: report?.status });
|
|
189
|
-
const takenByOther = (t) => claimLive(t, now) && t.claim.repo !==
|
|
218
|
+
const takenByOther = (t) => claimLive(t, now) && t.claim.repo !== repoName;
|
|
190
219
|
const addNote = (t, text, kind) => ({ ...t, notes: [...(t.notes ?? []), { by: me, at, text, kind }] });
|
|
191
220
|
if (p[2] === 'claim') {
|
|
192
221
|
let refused = '';
|
|
@@ -195,11 +224,11 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
195
224
|
refused = cur.claim.repo;
|
|
196
225
|
return cur;
|
|
197
226
|
}
|
|
198
|
-
return { ...cur, claim: { repo:
|
|
227
|
+
return { ...cur, claim: { repo: repoName, at } };
|
|
199
228
|
});
|
|
200
229
|
if (refused)
|
|
201
230
|
return json(409, { error: `already in progress in ${refused}`, claimed_by: refused });
|
|
202
|
-
deps.log('api.brief_claimed', { repo:
|
|
231
|
+
deps.log('api.brief_claimed', { repo: repoName, report_id: t.id });
|
|
203
232
|
return json(200, { brief: summary(t, app, now) });
|
|
204
233
|
}
|
|
205
234
|
if (p[2] === 'notes') {
|
|
@@ -209,7 +238,7 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
209
238
|
const t = await deps.store.updateTask(app.id, found.task.id, (cur) => {
|
|
210
239
|
const next = addNote(cur, text, 'note');
|
|
211
240
|
// Working on it keeps the claim fresh.
|
|
212
|
-
return cur.claim?.repo ===
|
|
241
|
+
return cur.claim?.repo === repoName ? { ...next, claim: { repo: repoName, at } } : next;
|
|
213
242
|
});
|
|
214
243
|
return json(200, { brief: summary(t, app, now) });
|
|
215
244
|
}
|
|
@@ -222,7 +251,7 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
222
251
|
if (!to || !repos.includes(to)) {
|
|
223
252
|
return json(400, { error: `hand off to a repo connected to ${app.name}: ${repos.join(', ') || 'none yet'}`, repos });
|
|
224
253
|
}
|
|
225
|
-
if (to ===
|
|
254
|
+
if (to === repoName)
|
|
226
255
|
return json(400, { error: 'that is this repo' });
|
|
227
256
|
let refused = '';
|
|
228
257
|
const t = await deps.store.updateTask(app.id, found.task.id, (cur) => {
|
|
@@ -234,7 +263,7 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
234
263
|
});
|
|
235
264
|
if (refused)
|
|
236
265
|
return json(409, { error: `in progress in ${refused}`, claimed_by: refused });
|
|
237
|
-
deps.log('api.brief_handed_off', { from:
|
|
266
|
+
deps.log('api.brief_handed_off', { from: repoName, to, report_id: t.id });
|
|
238
267
|
return json(200, { brief: summary(t, app, now) });
|
|
239
268
|
}
|
|
240
269
|
if (p[2] === 'fixed') {
|
|
@@ -6,6 +6,26 @@ import { LIMITS, PLATFORMS, REPORT_ORDER, REPORT_TYPES, isFramework, isPlatform,
|
|
|
6
6
|
* defence: the device id is chosen by the client and can be rotated, the IP limit catches that,
|
|
7
7
|
* and the key limit caps what any one project can be flooded with whatever else gets through.
|
|
8
8
|
*/
|
|
9
|
+
/** Reading your own reports: generous, but not unlimited. Per network. */
|
|
10
|
+
export const MINE_LIMIT = { limit: 240, windowMs: 3600_000 };
|
|
11
|
+
/** How often "seen running" is written, at most, per app. */
|
|
12
|
+
const SEEN_EVERY_MS = 10 * 60_000;
|
|
13
|
+
/**
|
|
14
|
+
* Every SDK call proves the SDK is loaded in the app. Remember when and where, so the dashboard
|
|
15
|
+
* can say "installed" without anyone sending a test report. Not from this Heresay's own pages.
|
|
16
|
+
*/
|
|
17
|
+
async function markSeen(project, req, body, deps) {
|
|
18
|
+
const now = deps.now();
|
|
19
|
+
if (project.sdk_seen && now - Date.parse(project.sdk_seen.at) < SEEN_EVERY_MS)
|
|
20
|
+
return;
|
|
21
|
+
const origin = req.headers['origin'] ? normaliseOrigin(req.headers['origin']) : null;
|
|
22
|
+
if (origin && (deps.selfOrigins ?? []).includes(origin))
|
|
23
|
+
return;
|
|
24
|
+
const sdk = typeof body.sdk === 'string' && ['web', 'ios', 'macos'].includes(body.sdk) ? body.sdk : (origin ? 'web' : null);
|
|
25
|
+
await deps.store.updateProject(project.id, {
|
|
26
|
+
sdk_seen: { at: new Date(now).toISOString(), where: origin ?? (sdk === 'ios' ? 'the iOS app' : sdk === 'macos' ? 'the Mac app' : 'the app'), sdk },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
9
29
|
export const RATE_LIMITS = [
|
|
10
30
|
{ scope: 'device', limit: 5, windowMs: 10 * 60_000 },
|
|
11
31
|
{ scope: 'device', limit: 20, windowMs: 24 * 3600_000 },
|
|
@@ -119,6 +139,10 @@ async function route(req, deps) {
|
|
|
119
139
|
return json(404, { error: 'no such app' });
|
|
120
140
|
if (p.length === 2 && req.method === 'GET')
|
|
121
141
|
return json(200, { project });
|
|
142
|
+
if (p.length === 2 && req.method === 'PATCH')
|
|
143
|
+
return updateProject(project, member, req, deps);
|
|
144
|
+
if (p.length === 2 && req.method === 'DELETE')
|
|
145
|
+
return deleteProject(project, member, req, deps);
|
|
122
146
|
if (p[2] === 'reports' && p.length === 3 && req.method === 'GET') {
|
|
123
147
|
// Alongside each accepted report: where its fix is going, and whether an agent has it.
|
|
124
148
|
const now = deps.now();
|
|
@@ -265,6 +289,7 @@ async function submit(req, deps) {
|
|
|
265
289
|
fix_note: null, created_at: at, updated_at: at, triaged_by: null,
|
|
266
290
|
};
|
|
267
291
|
await deps.store.createReport(report);
|
|
292
|
+
await markSeen(project, req, body, deps);
|
|
268
293
|
// Nobody said what the app is built with, and the SDK could tell: remember it. Not from
|
|
269
294
|
// this Heresay's own test page, which isn't the app.
|
|
270
295
|
const fromSelf = (deps.selfOrigins ?? []).includes(normaliseOrigin(req.headers['origin'] ?? ''));
|
|
@@ -287,6 +312,12 @@ async function mine(req, deps) {
|
|
|
287
312
|
// The device id is random and long, so knowing it is what proves these are yours.
|
|
288
313
|
if (!validDeviceId(body.device_id))
|
|
289
314
|
return json(400, { error: 'bad device_id' }, headers);
|
|
315
|
+
const now = deps.now();
|
|
316
|
+
const start = Math.floor(now / MINE_LIMIT.windowMs) * MINE_LIMIT.windowMs;
|
|
317
|
+
if (!(await deps.store.hit(`mine:${sha(req.ip)}:${start}`, MINE_LIMIT.limit, start + MINE_LIMIT.windowMs))) {
|
|
318
|
+
return json(429, { error: 'too many requests, try again later' }, { ...headers, 'retry-after': String(Math.ceil((start + MINE_LIMIT.windowMs - now) / 1000)) });
|
|
319
|
+
}
|
|
320
|
+
await markSeen(project, req, body, deps);
|
|
290
321
|
const rs = await deps.store.listReportsForDevice(project.id, body.device_id);
|
|
291
322
|
rs.sort((a, b) => b.created_at.localeCompare(a.created_at));
|
|
292
323
|
return json(200, { reports: rs.map(toReporterView) }, headers);
|
|
@@ -348,6 +379,66 @@ async function createProject(me, req, deps) {
|
|
|
348
379
|
deps.log('api.project_created', { project_id: project.id, by: me.email, platform });
|
|
349
380
|
return json(201, { project });
|
|
350
381
|
}
|
|
382
|
+
/** Going back in the add-app wizard edits the app rather than making another. The key stays. */
|
|
383
|
+
async function updateProject(project, me, req, deps) {
|
|
384
|
+
const body = parseBody(req.body);
|
|
385
|
+
const patch = {};
|
|
386
|
+
if (body.name !== undefined) {
|
|
387
|
+
const name = str(body.name, 80);
|
|
388
|
+
if (!name)
|
|
389
|
+
return json(400, { error: 'an app needs a name' });
|
|
390
|
+
patch.name = name;
|
|
391
|
+
}
|
|
392
|
+
if (body.platform !== undefined) {
|
|
393
|
+
if (!isPlatform(body.platform))
|
|
394
|
+
return json(400, { error: `platform must be one of ${PLATFORMS.join(', ')}` });
|
|
395
|
+
patch.platform = body.platform;
|
|
396
|
+
}
|
|
397
|
+
if (body.framework !== undefined) {
|
|
398
|
+
const f = str(body.framework, 40);
|
|
399
|
+
patch.framework = f ? f.toLowerCase() : null;
|
|
400
|
+
patch.framework_detected = false;
|
|
401
|
+
}
|
|
402
|
+
if (body.allowed_origins !== undefined) {
|
|
403
|
+
const origins = [];
|
|
404
|
+
for (const o of Array.isArray(body.allowed_origins) ? body.allowed_origins : []) {
|
|
405
|
+
if (typeof o !== 'string' || !o.trim())
|
|
406
|
+
continue;
|
|
407
|
+
let u;
|
|
408
|
+
try {
|
|
409
|
+
u = new URL(o.trim());
|
|
410
|
+
}
|
|
411
|
+
catch {
|
|
412
|
+
return json(400, { error: `not a URL: ${o}` });
|
|
413
|
+
}
|
|
414
|
+
origins.push(normaliseOrigin(u.origin));
|
|
415
|
+
}
|
|
416
|
+
patch.allowed_origins = [...new Set(origins)];
|
|
417
|
+
}
|
|
418
|
+
await deps.store.updateProject(project.id, patch);
|
|
419
|
+
deps.log('api.project_updated', { project_id: project.id, by: me.email, fields: Object.keys(patch) });
|
|
420
|
+
return json(200, { project: { ...project, ...patch } });
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Gone for good: the app, its reports and briefs. Its key stops working at once. Connected
|
|
424
|
+
* repos keep their tokens (they may serve other apps) but lose this app.
|
|
425
|
+
*/
|
|
426
|
+
async function deleteProject(project, me, req, deps) {
|
|
427
|
+
if (me.role !== 'owner')
|
|
428
|
+
return json(403, { error: 'only an owner can delete an app' });
|
|
429
|
+
const body = parseBody(req.body);
|
|
430
|
+
// Typed, not clicked: this can't be undone.
|
|
431
|
+
if (body.confirm !== project.name)
|
|
432
|
+
return json(400, { error: 'type the app\'s name to confirm' });
|
|
433
|
+
await deps.store.deleteProject(project.id);
|
|
434
|
+
for (const t of await deps.store.listAgentTokens()) {
|
|
435
|
+
if (t.app_ids.includes(project.id)) {
|
|
436
|
+
await deps.store.updateAgentToken(t.id, { app_ids: t.app_ids.filter((id) => id !== project.id) });
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
deps.log('api.project_deleted', { project_id: project.id, by: me.email });
|
|
440
|
+
return json(200, { ok: true });
|
|
441
|
+
}
|
|
351
442
|
function transitionRes(t) {
|
|
352
443
|
if (t.ok)
|
|
353
444
|
return json(200, { report: t.report });
|
|
@@ -23,6 +23,15 @@ export class MemoryStore {
|
|
|
23
23
|
if (p)
|
|
24
24
|
this.projects.set(id, { ...p, ...patch, id });
|
|
25
25
|
}
|
|
26
|
+
async deleteProject(id) {
|
|
27
|
+
this.projects.delete(id);
|
|
28
|
+
for (const [k, r] of this.reports)
|
|
29
|
+
if (r.project_id === id)
|
|
30
|
+
this.reports.delete(k);
|
|
31
|
+
for (const [k, t] of this.tasks)
|
|
32
|
+
if (t.project_id === id)
|
|
33
|
+
this.tasks.delete(k);
|
|
34
|
+
}
|
|
26
35
|
async createReport(r) { this.reports.set(r.id, { ...r }); }
|
|
27
36
|
async getReport(project_id, id) {
|
|
28
37
|
const r = this.reports.get(id);
|
|
@@ -47,6 +47,10 @@ export class FirestoreStore {
|
|
|
47
47
|
const { id: _ignored, ...rest } = patch;
|
|
48
48
|
await this.projects().doc(id).update(rest);
|
|
49
49
|
}
|
|
50
|
+
/** recursiveDelete, because deleting a document leaves its subcollections behind. */
|
|
51
|
+
async deleteProject(id) {
|
|
52
|
+
await this.db.recursiveDelete(this.projects().doc(id));
|
|
53
|
+
}
|
|
50
54
|
async createReport(r) { await this.reports(r.project_id).doc(r.id).create(r); }
|
|
51
55
|
async getReport(project_id, id) {
|
|
52
56
|
const s = await this.reports(project_id).doc(id).get();
|
|
@@ -164,3 +164,37 @@ a.platform:hover { border-color:var(--acc); box-shadow:0 0 0 3px var(--mist); }
|
|
|
164
164
|
.check { display:flex; align-items:center; gap:6px; }
|
|
165
165
|
.token-out h2 { margin-bottom:6px; }
|
|
166
166
|
.actions select { padding:7px 10px; }
|
|
167
|
+
|
|
168
|
+
/* wizard: back links, live feed */
|
|
169
|
+
.steps a { display:flex; align-items:center; gap:8px; color:inherit; text-decoration:none; border-radius:6px; }
|
|
170
|
+
.steps a:hover { color:var(--deep); }
|
|
171
|
+
.steps a:hover span { border-color:var(--acc); }
|
|
172
|
+
.platform.current { border-color:var(--acc); box-shadow:0 0 0 3px var(--mist); }
|
|
173
|
+
.feed { list-style:none; margin:12px 0 0; padding:0; }
|
|
174
|
+
.feed:empty { display:none; }
|
|
175
|
+
.feed li { display:grid; grid-template-columns:auto 1fr; gap:2px 12px; padding:10px 0; border-top:1px solid var(--line); }
|
|
176
|
+
.feed li .mute { grid-column:2; }
|
|
177
|
+
.feed-text { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
|
178
|
+
.feed li.fresh { animation:arrive 1.2s ease-out; }
|
|
179
|
+
@keyframes arrive { from { background:var(--mist); } to { background:transparent; } }
|
|
180
|
+
@media (prefers-reduced-motion: reduce) { .feed li.fresh { animation:none; } }
|
|
181
|
+
.row.split { align-items:center; }
|
|
182
|
+
.row.split .hint { margin:0; }
|
|
183
|
+
.btn:disabled { opacity:.45; cursor:not-allowed; }
|
|
184
|
+
.count.todo { color:var(--confusing); font-weight:600; }
|
|
185
|
+
|
|
186
|
+
/* verify, delete */
|
|
187
|
+
.checks-list { list-style:none; margin:14px 0 0; padding:0; }
|
|
188
|
+
.checks-list li { display:flex; gap:12px; align-items:flex-start; padding:10px 0; }
|
|
189
|
+
.checks-list li + li { border-top:1px solid var(--line); }
|
|
190
|
+
.checks-list li > div { display:flex; flex-direction:column; }
|
|
191
|
+
.checks-list .mark { width:22px; height:22px; flex:none; border-radius:50%; border:2px solid var(--line); margin-top:1px; }
|
|
192
|
+
.checks-list li.skip .mark { border-style:dashed; }
|
|
193
|
+
.checks-list li:not(.ok):not(.skip) .mark { border-color:var(--acc); border-right-color:transparent; animation:spin 1s linear infinite; }
|
|
194
|
+
.checks-list li.ok .mark { border-color:var(--acc); background:var(--acc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L19 7'/%3E%3C/svg%3E") center/14px no-repeat; }
|
|
195
|
+
@keyframes spin { to { transform:rotate(360deg); } }
|
|
196
|
+
@media (prefers-reduced-motion: reduce) { .checks-list .mark { animation:none !important; } }
|
|
197
|
+
.btn.danger { background:var(--broken); border-color:var(--broken); color:#fff; }
|
|
198
|
+
.btn.danger:disabled { opacity:.4; }
|
|
199
|
+
.row.tight { margin-top:0; }
|
|
200
|
+
.form label input[name=confirm] { margin-top:6px; }
|
|
@@ -158,10 +158,11 @@
|
|
|
158
158
|
view.textContent = '';
|
|
159
159
|
if (parts[0] === 'team') return teamView(view);
|
|
160
160
|
if (parts[0] === 'connect') return connectView(view, query);
|
|
161
|
-
if (parts[0] === 'new') return newAppView(view, parts[1]);
|
|
161
|
+
if (parts[0] === 'new') return newAppView(view, parts[1], query);
|
|
162
162
|
if (parts[0] === 'apps' && parts[1]) {
|
|
163
163
|
return withProject(parts[1], function (p) {
|
|
164
164
|
if (parts[2] === 'setup') setupView(view, p);
|
|
165
|
+
else if (parts[2] === 'delete') deleteView(view, p);
|
|
165
166
|
else reportsView(view, p);
|
|
166
167
|
});
|
|
167
168
|
}
|
|
@@ -212,14 +213,17 @@
|
|
|
212
213
|
var grid = el('div', { class: 'apps' });
|
|
213
214
|
projects.forEach(function (p) {
|
|
214
215
|
var count = el('span', { class: 'count', text: ' ' });
|
|
215
|
-
|
|
216
|
+
var card = el('a', { class: 'app-card', href: '#/apps/' + p.id }, [
|
|
216
217
|
icon(platformOf(p.platform)),
|
|
217
218
|
el('div', {}, [el('b', { text: p.name }), el('span', { class: 'mute', text: platformOf(p.platform).label + (p.framework ? ' · ' + frameworkLabel(p.framework) : '') })]),
|
|
218
219
|
count,
|
|
219
|
-
])
|
|
220
|
+
]);
|
|
221
|
+
grid.appendChild(card);
|
|
220
222
|
api('GET', '/projects/' + p.id + '/reports').then(function (r) {
|
|
221
223
|
var open = r.reports.filter(function (x) { return x.status === 'open'; }).length;
|
|
222
|
-
|
|
224
|
+
// No report yet means setup isn't proven: send them back to finish it.
|
|
225
|
+
if (!r.reports.length && !p.sdk_seen && !p.code_found) { card.href = '#/apps/' + p.id + '/setup'; count.textContent = 'Setup not finished'; count.className = 'count todo'; return; }
|
|
226
|
+
count.textContent = !r.reports.length ? 'No reports yet' : open ? open + ' open' : 'All answered';
|
|
223
227
|
if (open) count.className = 'count on';
|
|
224
228
|
});
|
|
225
229
|
});
|
|
@@ -236,21 +240,39 @@
|
|
|
236
240
|
];
|
|
237
241
|
function frameworkLabel(id) { var f = FRAMEWORKS.filter(function (x) { return x[0] === id; })[0]; return f ? f[1] : id; }
|
|
238
242
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
+
/**
|
|
244
|
+
* The four steps. Earlier ones are links, so you can go back and change things; later ones
|
|
245
|
+
* aren't, because each step needs the one before it. `tested` marks the last step done.
|
|
246
|
+
*/
|
|
247
|
+
function stepper(active, p, tested) {
|
|
248
|
+
var q = p ? '?app=' + p.id : '';
|
|
249
|
+
var links = ['#/new' + q, p ? '#/new/' + p.platform + q : null, p ? '#/apps/' + p.id + '/setup' : null, null];
|
|
250
|
+
var names = ['Platform', 'Details', 'Install', 'Test'];
|
|
251
|
+
return el('ol', { class: 'steps' }, names.map(function (s, i) {
|
|
252
|
+
var n = i + 1;
|
|
253
|
+
var cls = n < active || (tested && n <= 4) ? 'done' : n === active ? 'now' : '';
|
|
254
|
+
var inner = [el('span', { text: tested && n <= 4 ? '✓' : String(n) }), s];
|
|
255
|
+
var back = n < active && links[i];
|
|
256
|
+
return el('li', { class: cls }, back ? [el('a', { href: links[i], 'aria-label': 'Back to ' + s }, inner)] : inner);
|
|
243
257
|
}));
|
|
244
258
|
}
|
|
245
259
|
|
|
246
|
-
|
|
260
|
+
/** Adding an app, or with ?app=<id>, going back to change one that already exists. */
|
|
261
|
+
function newAppView(view, platform, query) {
|
|
262
|
+
var editId = query && query.get('app');
|
|
263
|
+
if (editId) return withProject(editId, function (p) { drawNewApp(view, platform, p); });
|
|
264
|
+
drawNewApp(view, platform, null);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function drawNewApp(view, platform, editing) {
|
|
268
|
+
var q = editing ? '?app=' + editing.id : '';
|
|
247
269
|
if (!platform) {
|
|
248
|
-
view.appendChild(stepper(1));
|
|
270
|
+
view.appendChild(stepper(1, editing));
|
|
249
271
|
view.appendChild(el('h1', { text: 'What are you adding Heresay to?' }));
|
|
250
272
|
var grid = el('div', { class: 'platforms' });
|
|
251
273
|
PLATFORMS.forEach(function (p) {
|
|
252
274
|
grid.appendChild(el(p.ready ? 'a' : 'div', {
|
|
253
|
-
class: 'platform' + (p.ready ? '' : ' soon'), href: p.ready ? '#/new/' + p.id : null,
|
|
275
|
+
class: 'platform' + (p.ready ? '' : ' soon') + (editing && editing.platform === p.id ? ' current' : ''), href: p.ready ? '#/new/' + p.id + q : null,
|
|
254
276
|
'aria-disabled': p.ready ? null : 'true',
|
|
255
277
|
}, [icon(p), el('b', { text: p.label }), el('span', { class: 'mute', text: p.note }), p.ready ? null : el('span', { class: 'tag', text: 'Soon' })]));
|
|
256
278
|
});
|
|
@@ -259,11 +281,11 @@
|
|
|
259
281
|
return;
|
|
260
282
|
}
|
|
261
283
|
|
|
262
|
-
view.appendChild(stepper(2));
|
|
284
|
+
view.appendChild(stepper(2, editing));
|
|
263
285
|
var native = !!platformOf(platform).apple;
|
|
264
286
|
view.appendChild(el('h1', { text: 'About your ' + platformOf(platform).label + ' app' }));
|
|
265
287
|
var err = el('p', { class: 'err', role: 'alert' });
|
|
266
|
-
var fw = 'unknown';
|
|
288
|
+
var fw = editing && editing.framework && !editing.framework_detected ? editing.framework : 'unknown';
|
|
267
289
|
var chips = el('div', { class: 'chips', role: 'radiogroup', 'aria-label': 'Framework' });
|
|
268
290
|
FRAMEWORKS.forEach(function (f) {
|
|
269
291
|
chips.appendChild(el('button', {
|
|
@@ -277,7 +299,7 @@
|
|
|
277
299
|
var form = el('form', { class: 'form' }, native ? [
|
|
278
300
|
el('label', {}, ['Name', el('input', { name: 'name', required: true, maxlength: '80', placeholder: 'Acme for ' + platformOf(platform).label, autocomplete: 'off' })]),
|
|
279
301
|
el('p', { class: 'hint', text: 'Native apps have no web address to lock the key to, so any copy of your app can send reports. The per-device, per-network and per-app rate limits still apply.' }),
|
|
280
|
-
el('div', { class: 'row' }, [el('a', { class: 'btn ghost', href: '#/new', text: 'Back' }), el('button', { class: 'btn primary', text: 'Create app' })]),
|
|
302
|
+
el('div', { class: 'row' }, [el('a', { class: 'btn ghost', href: '#/new' + q, text: 'Back' }), el('button', { class: 'btn primary', text: editing ? 'Save and continue' : 'Create app' })]),
|
|
281
303
|
err,
|
|
282
304
|
] : [
|
|
283
305
|
el('label', {}, ['Name', el('input', { name: 'name', required: true, maxlength: '80', placeholder: 'Acme web', autocomplete: 'off' })]),
|
|
@@ -285,18 +307,27 @@
|
|
|
285
307
|
el('p', { class: 'hint', text: 'Only changes the install steps we show. Not sure? Leave it: your coding agent can work it out, and the general steps work everywhere.' })]),
|
|
286
308
|
el('label', {}, ['Where it runs', el('textarea', { name: 'origins', rows: '3', placeholder: 'https://app.example.com\nhttp://localhost:3000' })]),
|
|
287
309
|
el('p', { class: 'hint', text: 'One address per line: your live site and anywhere you test it. Only these sites can send reports with this app’s key. Leave it empty to allow any site while you try things out.' }),
|
|
288
|
-
el('div', { class: 'row' }, [el('a', { class: 'btn ghost', href: '#/new', text: 'Back' }), el('button', { class: 'btn primary', text: 'Create app' })]),
|
|
310
|
+
el('div', { class: 'row' }, [el('a', { class: 'btn ghost', href: '#/new' + q, text: 'Back' }), el('button', { class: 'btn primary', text: editing ? 'Save and continue' : 'Create app' })]),
|
|
289
311
|
err,
|
|
290
312
|
]);
|
|
291
313
|
form.onsubmit = function (e) {
|
|
292
314
|
e.preventDefault();
|
|
293
315
|
err.textContent = '';
|
|
294
316
|
var origins = native ? [] : form.origins.value.split(/[\s,]+/).map(function (s) { return s.trim(); }).filter(Boolean);
|
|
295
|
-
|
|
296
|
-
|
|
317
|
+
var body = { name: form.name.value, platform: platform, framework: native ? 'swiftui' : (fw === 'unknown' ? null : fw), allowed_origins: origins };
|
|
318
|
+
// Editing keeps the key, so a line already pasted into the app keeps working.
|
|
319
|
+
(editing ? api('PATCH', '/projects/' + editing.id, body) : api('POST', '/projects', body))
|
|
320
|
+
.then(function (b) {
|
|
321
|
+
projects = projects.filter(function (x) { return x.id !== b.project.id; }).concat([b.project]);
|
|
322
|
+
location.hash = '#/apps/' + b.project.id + '/setup';
|
|
323
|
+
})
|
|
297
324
|
.catch(function (x) { err.textContent = x.message; });
|
|
298
325
|
};
|
|
299
326
|
view.appendChild(form);
|
|
327
|
+
if (editing) {
|
|
328
|
+
form.name.value = editing.name;
|
|
329
|
+
if (!native) form.origins.value = editing.allowed_origins.join('\n');
|
|
330
|
+
}
|
|
300
331
|
form.name.focus();
|
|
301
332
|
}
|
|
302
333
|
|
|
@@ -374,55 +405,67 @@
|
|
|
374
405
|
];
|
|
375
406
|
}
|
|
376
407
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
'Add Heresay, an in-app feedback button, to this ' + platformOf(p.platform).label + ' app.',
|
|
381
|
-
'',
|
|
382
|
-
'1. Add the Swift package ' + SWIFT_PACKAGE + ' (product "Heresay") to the app target.',
|
|
383
|
-
'2. In the App struct\'s init, call Heresay.configure(key: "' + p.key + '", url: URL(string: "' + location.origin + '")!).',
|
|
384
|
-
p.platform === 'macos'
|
|
385
|
-
? '3. Add .heresay() to the root view of the main WindowGroup, and .commands { HeresayCommands() } to that WindowGroup.'
|
|
386
|
-
: '3. Add .heresayReportButton() to the root view of the main WindowGroup.',
|
|
387
|
-
'4. If the app has signed-in users, call Heresay.identify(id:label:) after sign-in and Heresay.identify() after sign-out.',
|
|
388
|
-
'5. Where it is easy, call Heresay.setScreen("<screen name>") when the main screens appear.',
|
|
389
|
-
'',
|
|
390
|
-
'Change nothing else. Reference: ' + location.origin + '/guides/install-apple.md',
|
|
391
|
-
].join('\n');
|
|
392
|
-
}
|
|
408
|
+
/** One prompt that connects the repo, installs Heresay and waits for the test report. */
|
|
409
|
+
function onePrompt(p, token) {
|
|
410
|
+
var apple = platformOf(p.platform).apple;
|
|
393
411
|
return [
|
|
394
|
-
'
|
|
412
|
+
'Set up Heresay, in-app feedback, in this repo. Do these steps in order.',
|
|
413
|
+
'',
|
|
414
|
+
'1. Connect this repo to Heresay. This adds .mcp.json, a Heresay skill and an AGENTS.md section, and saves the token in ~/.heresay, outside the repo. Do not copy the token into any file.',
|
|
415
|
+
'',
|
|
416
|
+
' npx -y heresay@0 connect --url ' + location.origin + ' --token ' + token + ' --yes',
|
|
395
417
|
'',
|
|
396
|
-
'
|
|
418
|
+
'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.'),
|
|
397
419
|
'',
|
|
398
|
-
' ' +
|
|
420
|
+
' npx -y heresay@0 install ' + p.id,
|
|
399
421
|
'',
|
|
400
|
-
'
|
|
401
|
-
'3. If the app has a version number (for example package.json "version"), add data-version="<version>" to the tag.',
|
|
402
|
-
'4. If screens change without the URL changing, call window.Heresay?.setScreen("<screen name>") on each change.',
|
|
422
|
+
'3. Verify the install. This finds the app\'s key in the code and tells the Heresay dashboard, which is waiting for it:',
|
|
403
423
|
'',
|
|
404
|
-
'
|
|
424
|
+
' npx -y heresay@0 check ' + p.id,
|
|
425
|
+
'',
|
|
426
|
+
' You are done when it prints "installed": true. If it doesn\'t, fix what it says and run it again.',
|
|
427
|
+
'',
|
|
428
|
+
'Change nothing else in the app.',
|
|
405
429
|
].join('\n');
|
|
406
430
|
}
|
|
407
431
|
|
|
408
432
|
function setupView(view, p) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
433
|
+
var apple = platformOf(p.platform).apple;
|
|
434
|
+
var steps = stepper(3, p, false);
|
|
435
|
+
view.appendChild(steps);
|
|
436
|
+
view.appendChild(el('div', { class: 'head' }, [el('h1', { text: 'Put Heresay in ' + p.name })]));
|
|
437
|
+
|
|
438
|
+
// The agent route: one prompt by default, with the same thing as two steps for people who
|
|
439
|
+
// would rather run the command themselves.
|
|
440
|
+
var promptBox = el('div');
|
|
441
|
+
var getPrompt = el('button', { class: 'btn primary', type: 'button', text: 'Get the prompt' });
|
|
442
|
+
getPrompt.onclick = function () {
|
|
443
|
+
getPrompt.disabled = true;
|
|
444
|
+
getPrompt.textContent = 'Making a token…';
|
|
445
|
+
// No repo yet: the token binds to whichever repo the agent runs it in.
|
|
446
|
+
api('POST', '/agent-tokens', { app_ids: [p.id] }).then(function (b) {
|
|
447
|
+
getPrompt.remove();
|
|
448
|
+
promptBox.appendChild(codeBlock(onePrompt(p, b.token)));
|
|
449
|
+
promptBox.appendChild(el('p', { class: 'hint', html: 'It carries a token for this app that works only in the first repo that uses it. You can revoke it under <a href="#/connect">Connected repos</a>.' }));
|
|
450
|
+
}).catch(function (x) {
|
|
451
|
+
getPrompt.disabled = false;
|
|
452
|
+
getPrompt.textContent = 'Get the prompt';
|
|
453
|
+
promptBox.appendChild(el('p', { class: 'err', text: x.message }));
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
promptBox.appendChild(getPrompt);
|
|
414
457
|
|
|
415
|
-
|
|
416
|
-
var agentFirst = !platformOf(p.platform).apple && (!p.framework || p.framework === 'other');
|
|
458
|
+
var agentFirst = !apple && (!p.framework || p.framework === 'other');
|
|
417
459
|
var panes = { hand: el('div', { hidden: agentFirst }, byHand(p)), agent: el('div', { hidden: !agentFirst }, [
|
|
418
|
-
el('
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
el('
|
|
422
|
-
el('
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
460
|
+
el('p', { text: 'Paste one prompt into your coding agent (Claude Code, Cursor, Codex, …), opened in your app’s repo. It connects the repo, installs Heresay, and verifies it.' }),
|
|
461
|
+
promptBox,
|
|
462
|
+
el('details', { class: 'where' }, [el('summary', { text: 'Or do it in two steps' }),
|
|
463
|
+
el('ol', { class: 'agent-steps' }, [
|
|
464
|
+
el('li', {}, [el('b', { text: 'In your app’s repo, run:' }), codeBlock('npx heresay connect --url ' + location.origin),
|
|
465
|
+
el('p', { class: 'hint', text: 'It opens this dashboard to make a token for the repo, and adds the Heresay skill and MCP server for your agent. The token stays on your computer, not in the repo.' })]),
|
|
466
|
+
el('li', {}, [el('b', { text: 'Then tell your agent:' }), codeBlock('Add Heresay to this app'),
|
|
467
|
+
el('p', { class: 'hint', text: 'It installs Heresay in the right place and verifies it. Later, “Fix the next Heresay report” works the same way.' })]),
|
|
468
|
+
])]),
|
|
426
469
|
]) };
|
|
427
470
|
var tabs = el('div', { class: 'seg', role: 'tablist' });
|
|
428
471
|
(agentFirst ? [['agent', 'Ask your coding agent'], ['hand', 'Add it yourself']] : [['hand', 'Add it yourself'], ['agent', 'Ask your coding agent']]).forEach(function (t, i) {
|
|
@@ -436,40 +479,75 @@
|
|
|
436
479
|
});
|
|
437
480
|
view.appendChild(el('section', { class: 'card' }, [
|
|
438
481
|
tabs, panes.hand, panes.agent,
|
|
439
|
-
|
|
482
|
+
apple
|
|
440
483
|
? el('p', { class: 'hint', text: 'Your key is meant to be public: it can only send reports, never read them. It is fine in your source code.' })
|
|
441
484
|
: el('p', { class: 'hint', html: 'Your key is meant to be public: it only lets the sites you listed send reports. Optional extras (who is signed in, your app version, your brand colour) are in the <a href="/docs.html#options" target="_blank">docs</a>.' }),
|
|
442
485
|
]));
|
|
443
486
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
487
|
+
// Step 4 lives on this page and needs nobody to do anything: it completes when Heresay is
|
|
488
|
+
// found in the code (the agent's `heresay check`) or seen running in the app (any SDK call).
|
|
489
|
+
// Nothing moves on until then, because that is the proof the install works.
|
|
490
|
+
var rowCode = checkRow('In your code', 'Waiting for your agent to confirm it, or for your app to load it.');
|
|
491
|
+
var rowRun = checkRow('Running in your app', apple ? 'Waiting for your app to start with Heresay in it.' : 'Waiting for a page with Heresay on it to load, anywhere: your live site or localhost.');
|
|
492
|
+
var status = el('div', { class: 'wait', role: 'status', text: 'Checking automatically…' });
|
|
493
|
+
var feed = el('ul', { class: 'feed', 'aria-live': 'polite' });
|
|
494
|
+
var cont = el('button', { class: 'btn primary', type: 'button', disabled: true, text: 'Continue to reports' });
|
|
495
|
+
cont.onclick = function () { location.hash = '#/apps/' + p.id; };
|
|
496
|
+
var lockNote = el('span', { class: 'hint', text: 'Unlocks as soon as the install is verified.' });
|
|
447
497
|
view.appendChild(el('section', { class: 'card test' }, [
|
|
448
|
-
el('div', { class: 'test-head' }, [el('span', { class: 'stepnum', text: '4' }), el('h2', { text: '
|
|
449
|
-
el('p', { class: 'mute', text:
|
|
450
|
-
|
|
451
|
-
: 'Open your app, tap Report in the corner and send anything. Or use our test page. It shows up here within a few seconds.' }),
|
|
498
|
+
el('div', { class: 'test-head' }, [el('span', { class: 'stepnum', text: '4' }), el('h2', { text: 'Verify' })]),
|
|
499
|
+
el('p', { class: 'mute', text: 'Heresay checks this by itself. No test report needed.' }),
|
|
500
|
+
el('ul', { class: 'checks-list' }, [rowCode.li, rowRun.li]),
|
|
452
501
|
status,
|
|
453
|
-
|
|
502
|
+
feed,
|
|
503
|
+
el('div', { class: 'row split' }, [el('span', { class: 'spacer' }), lockNote, cont]),
|
|
454
504
|
]));
|
|
455
505
|
|
|
456
|
-
|
|
506
|
+
function checkRow(title, waiting) {
|
|
507
|
+
var mark = el('span', { class: 'mark', 'aria-hidden': 'true' });
|
|
508
|
+
var detail = el('span', { class: 'mute small', text: waiting });
|
|
509
|
+
var li = el('li', {}, [mark, el('div', {}, [el('b', { text: title }), detail])]);
|
|
510
|
+
return {
|
|
511
|
+
li: li,
|
|
512
|
+
set: function (text) { li.className = 'ok'; detail.textContent = text; },
|
|
513
|
+
// The other check proved it already; this one stops waiting and says it is optional.
|
|
514
|
+
settle: function (text) { if (li.className !== 'ok') { li.className = 'skip'; detail.textContent = text; } },
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
var known = {}, first = true;
|
|
519
|
+
function ago(iso) {
|
|
520
|
+
var s = Math.max(0, Math.round((Date.now() - Date.parse(iso)) / 1000));
|
|
521
|
+
return s < 60 ? 'just now' : s < 3600 ? Math.round(s / 60) + ' min ago' : new Date(iso).toLocaleString();
|
|
522
|
+
}
|
|
457
523
|
function check() {
|
|
458
|
-
api('GET', '/projects/' + p.id + '/reports').then(function (
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if (
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
524
|
+
Promise.all([api('GET', '/projects/' + p.id), api('GET', '/projects/' + p.id + '/reports')]).then(function (x) {
|
|
525
|
+
var app = x[0].project, rs = x[1].reports.slice().sort(function (a, c) { return a.created_at < c.created_at ? 1 : -1; });
|
|
526
|
+
if (app.code_found) rowCode.set('Found in ' + app.code_found.file + ' (' + app.code_found.repo + '), ' + ago(app.code_found.at));
|
|
527
|
+
if (app.sdk_seen) rowRun.set('Seen on ' + app.sdk_seen.where + ', ' + ago(app.sdk_seen.at));
|
|
528
|
+
var ok = !!(app.code_found || app.sdk_seen || rs.length);
|
|
529
|
+
if (ok && cont.disabled) {
|
|
530
|
+
cont.disabled = false;
|
|
531
|
+
lockNote.remove();
|
|
532
|
+
status.className = 'wait ok';
|
|
533
|
+
status.textContent = 'Installed. Reports will arrive here and on the reports page.';
|
|
534
|
+
steps.replaceWith(steps = stepper(3, p, true));
|
|
535
|
+
}
|
|
536
|
+
if (ok) {
|
|
537
|
+
rowCode.settle('Optional. Your coding agent confirms it with npx heresay check.');
|
|
538
|
+
rowRun.settle('Optional. Shows here the first time your app loads Heresay.');
|
|
465
539
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
540
|
+
// Any reports that do come in show up live, so nobody has to leave the page to see one.
|
|
541
|
+
feed.textContent = '';
|
|
542
|
+
rs.slice(0, 5).forEach(function (r) {
|
|
543
|
+
feed.appendChild(el('li', { class: !first && !known[r.id] ? 'fresh' : '' }, [
|
|
544
|
+
el('span', { class: 'pill ' + r.type, text: TYPE_LABEL[r.type] }),
|
|
545
|
+
el('span', { class: 'feed-text', text: r.text }),
|
|
546
|
+
el('span', { class: 'mute small', text: [r.context.route, r.context.platform, new Date(r.created_at).toLocaleTimeString()].filter(Boolean).join(' · ') }),
|
|
547
|
+
]));
|
|
548
|
+
known[r.id] = true;
|
|
549
|
+
});
|
|
550
|
+
first = false;
|
|
473
551
|
}).catch(function () {});
|
|
474
552
|
}
|
|
475
553
|
check();
|
|
@@ -490,7 +568,10 @@
|
|
|
490
568
|
view.appendChild(el('div', { class: 'head' }, [
|
|
491
569
|
el('div', { class: 'title' }, [icon(platformOf(p.platform)), el('div', {}, [el('h1', { text: p.name }),
|
|
492
570
|
p.framework ? el('span', { class: 'mute small', text: frameworkLabel(p.framework) + (p.framework_detected ? ' (detected)' : '') }) : null])]),
|
|
493
|
-
el('
|
|
571
|
+
el('div', { class: 'row tight' }, [
|
|
572
|
+
el('a', { class: 'btn', href: '#/apps/' + p.id + '/setup', text: 'Install' }),
|
|
573
|
+
el('a', { class: 'btn ghost', href: '#/apps/' + p.id + '/delete', text: 'Delete…' }),
|
|
574
|
+
]),
|
|
494
575
|
]));
|
|
495
576
|
view.appendChild(repoLine);
|
|
496
577
|
view.appendChild(filters);
|
|
@@ -625,6 +706,75 @@
|
|
|
625
706
|
]);
|
|
626
707
|
}
|
|
627
708
|
|
|
709
|
+
// ---- delete an app ---------------------------------------------------------------------
|
|
710
|
+
|
|
711
|
+
/** The prompt that takes Heresay back out of a repo: the code, then the agent files. */
|
|
712
|
+
function removePrompt(p) {
|
|
713
|
+
var apple = platformOf(p.platform).apple;
|
|
714
|
+
return [
|
|
715
|
+
'Remove Heresay, an in-app feedback SDK, from this repo. Do these steps in order.',
|
|
716
|
+
'',
|
|
717
|
+
'1. Read the removal steps and follow them:',
|
|
718
|
+
'',
|
|
719
|
+
' npx -y heresay@0 guide uninstall',
|
|
720
|
+
'',
|
|
721
|
+
'2. Remove it from the app\'s code. Search for the key ' + p.key + ' and for "' + (apple ? 'Heresay' : 'sdk/v1.js') + '". ' + (apple
|
|
722
|
+
? 'Remove the Heresay Swift package dependency, `import Heresay`, the Heresay.configure(…) call, .heresayReportButton() / .heresay(), HeresayCommands, and any Heresay.identify / setScreen / present calls.'
|
|
723
|
+
: 'Remove the Heresay script tag (or its next/script, nuxt.config or layout entry) and any window.Heresay calls such as identify or setScreen.'),
|
|
724
|
+
'',
|
|
725
|
+
'3. Remove the agent files Heresay added (.mcp.json entry, skill, AGENTS.md section, saved token):',
|
|
726
|
+
'',
|
|
727
|
+
' npx -y heresay@0 disconnect --yes',
|
|
728
|
+
'',
|
|
729
|
+
'Change nothing else. Build and run the tests to make sure nothing else broke.',
|
|
730
|
+
].join('\n');
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
function deleteView(view, p) {
|
|
734
|
+
var owner = me.role === 'owner';
|
|
735
|
+
view.appendChild(el('div', { class: 'head' }, [
|
|
736
|
+
el('div', { class: 'title' }, [icon(platformOf(p.platform)), el('h1', { text: 'Delete ' + p.name })]),
|
|
737
|
+
el('a', { class: 'btn ghost', href: '#/apps/' + p.id, text: 'Cancel' }),
|
|
738
|
+
]));
|
|
739
|
+
|
|
740
|
+
view.appendChild(el('section', { class: 'card' }, [
|
|
741
|
+
el('h2', { text: '1. Take Heresay out of your code' }),
|
|
742
|
+
el('p', { class: 'mute', text: 'Do this first, so nothing in your app still points at Heresay. Paste this into your coding agent, in the app’s repo:' }),
|
|
743
|
+
codeBlock(removePrompt(p)),
|
|
744
|
+
el('details', { class: 'where' }, [el('summary', { text: 'Or remove it by hand' }), el('ol', { class: 'agent-steps' }, (platformOf(p.platform).apple ? [
|
|
745
|
+
'In Xcode, remove the Heresay package from the target (Project › Package Dependencies).',
|
|
746
|
+
'Delete import Heresay, the Heresay.configure(…) line, .heresayReportButton() or .heresay(), and HeresayCommands.',
|
|
747
|
+
'Delete any Heresay.identify, setScreen, present or send calls.',
|
|
748
|
+
] : [
|
|
749
|
+
'Delete the Heresay script tag (search your code for ' + p.key + ' or sdk/v1.js). In Next.js it is a <Script> in the layout; in Nuxt an entry in nuxt.config.',
|
|
750
|
+
'Delete any window.Heresay calls (identify, setScreen, open).',
|
|
751
|
+
'If you set a Content Security Policy for Heresay, take its address out of script-src and connect-src.',
|
|
752
|
+
]).concat(['In the repo, run npx heresay disconnect. It removes the .mcp.json entry, the Heresay skill, the AGENTS.md section and the saved token.']).map(function (t) { return el('li', { text: t }); }))]),
|
|
753
|
+
]));
|
|
754
|
+
|
|
755
|
+
var err = el('p', { class: 'err', role: 'alert' });
|
|
756
|
+
var confirm = el('input', { name: 'confirm', autocomplete: 'off', placeholder: p.name, 'aria-label': 'Type the app’s name to confirm' });
|
|
757
|
+
var go = el('button', { class: 'btn danger', type: 'submit', disabled: true, text: 'Delete ' + p.name });
|
|
758
|
+
confirm.oninput = function () { go.disabled = confirm.value !== p.name; };
|
|
759
|
+
var form = el('form', { class: 'form' }, [
|
|
760
|
+
el('p', { text: 'This deletes the app and every report sent from it, for everyone on the team. People who sent reports can no longer see them, and the key stops working: any copy of the app still carrying it hides its Report button. Connected repos keep their tokens for their other apps.' }),
|
|
761
|
+
el('label', {}, ['Type ', el('b', { text: p.name }), ' to confirm', confirm]),
|
|
762
|
+
el('div', { class: 'row' }, [go]),
|
|
763
|
+
err,
|
|
764
|
+
]);
|
|
765
|
+
form.onsubmit = function (e) {
|
|
766
|
+
e.preventDefault();
|
|
767
|
+
err.textContent = '';
|
|
768
|
+
go.disabled = true;
|
|
769
|
+
api('DELETE', '/projects/' + p.id, { confirm: confirm.value }).then(function () {
|
|
770
|
+
projects = projects.filter(function (x) { return x.id !== p.id; });
|
|
771
|
+
location.hash = '#/';
|
|
772
|
+
}).catch(function (x) { err.textContent = x.message; go.disabled = false; });
|
|
773
|
+
};
|
|
774
|
+
view.appendChild(el('section', { class: 'card' }, owner ? [el('h2', { text: '2. Delete the app from Heresay' }), form]
|
|
775
|
+
: [el('h2', { text: '2. Delete the app from Heresay' }), el('p', { class: 'mute', text: 'Only an owner can delete an app. Ask one of the owners on the Team page.' })]));
|
|
776
|
+
}
|
|
777
|
+
|
|
628
778
|
// ---- connect a repo for coding agents ----------------------------------------------------
|
|
629
779
|
|
|
630
780
|
function connectView(view, query) {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"install-web": "Add the Heresay web SDK to an app, for any framework, and prove it works",
|
|
6
6
|
"install-apple": "Add the Heresay Swift package to an iOS or macOS app",
|
|
7
7
|
"fix-brief": "Fix an accepted report: find, claim, fix, hand off, mark fixed",
|
|
8
|
-
"write-note": "Write the note the reporter reads when a report is fixed"
|
|
8
|
+
"write-note": "Write the note the reporter reads when a report is fixed",
|
|
9
|
+
"uninstall": "Remove Heresay from an app, and disconnect the repo"
|
|
9
10
|
}
|
|
10
11
|
}
|
|
@@ -52,5 +52,6 @@ Change nothing else in the app.
|
|
|
52
52
|
|
|
53
53
|
## 5. Prove it
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
Call `check_install`: it finds the key in this repo's code by itself (`found_in_code`). Build and
|
|
56
|
+
run on a simulator or device and `seen_running` shows the SDK loaded. To test the whole path,
|
|
57
|
+
open the Report sheet and send a test; `reports` goes up. The key is public by design; it is fine in source control.
|
|
@@ -39,8 +39,9 @@ Change nothing else in the app.
|
|
|
39
39
|
|
|
40
40
|
## 4. Prove it
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
Call `check_install`. It finds the key in this repo's code by itself (`found_in_code`). Then run
|
|
43
|
+
the app and open it in a browser: `seen_running` shows the SDK loaded there. To test the whole
|
|
44
|
+
path, tap **Report** in the bottom corner and send a test; `reports` goes up. If the button doesn't
|
|
44
45
|
appear: the tag isn't on that page, or a CSP blocked it (check the browser console). If sending
|
|
45
46
|
fails with "this site is not allowed": that origin isn't in the app's sites.
|
|
46
47
|
|
|
@@ -19,9 +19,11 @@ sees the outcome in the app, including the note you write when you mark it fixed
|
|
|
19
19
|
|
|
20
20
|
- Adding Heresay to an app: `install-web` for web apps, `install-apple` for iOS and macOS.
|
|
21
21
|
- Fixing reports: `fix-brief`, then `write-note`.
|
|
22
|
+
- Removing Heresay from an app: `uninstall`.
|
|
22
23
|
|
|
23
24
|
## Tools
|
|
24
25
|
|
|
25
|
-
`list_apps`, `create_app`, `install_guide`, `check_install` for installing.
|
|
26
|
+
`list_apps`, `create_app`, `install_guide`, `check_install` for installing. `check_install`
|
|
27
|
+
verifies by itself: it finds the key in this repo's code and says if the SDK has been seen running.
|
|
26
28
|
`list_briefs`, `get_brief`, `claim_brief`, `add_note`, `handoff`, `mark_fixed` for fixing.
|
|
27
29
|
Without MCP, the same actions exist as `npx heresay <command>`; run `npx heresay help`.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Remove Heresay from an app
|
|
2
|
+
|
|
3
|
+
Goal: the app no longer loads Heresay, and this repo is no longer connected to it. Do the steps
|
|
4
|
+
in order: the code first, then disconnect (disconnecting removes the tools you use to read this).
|
|
5
|
+
|
|
6
|
+
## 1. Find every place it is
|
|
7
|
+
|
|
8
|
+
Search the repo for the app's key (it starts with `pk_`; `list_apps` shows it) and for
|
|
9
|
+
`heresay`, `Heresay` and `sdk/v1.js`. Skip `node_modules` and build output.
|
|
10
|
+
|
|
11
|
+
## 2. Web apps
|
|
12
|
+
|
|
13
|
+
- Remove the script tag, wherever it is: a `<script src=".../sdk/v1.js" data-key="pk_...">` in
|
|
14
|
+
an HTML file or layout, a `next/script` `<Script>` in `app/layout.tsx` or `pages/_app.tsx`,
|
|
15
|
+
an entry in `nuxt.config.ts` `app.head.script`, or the equivalent for the framework.
|
|
16
|
+
- Remove the calls: `window.Heresay?.identify(...)` and `window.Heresay?.setScreen(...)`.
|
|
17
|
+
- If a Content Security Policy allowed the Heresay origin only for Heresay, remove it there too.
|
|
18
|
+
|
|
19
|
+
## 3. iOS and macOS apps
|
|
20
|
+
|
|
21
|
+
- Remove the Swift package dependency (`heresay-swift`, product `Heresay`): in Xcode, the
|
|
22
|
+
project's Package Dependencies; or `Package.swift`; or the XcodeGen / Tuist config.
|
|
23
|
+
- Remove `import Heresay`, `Heresay.configure(...)`, `.heresayReportButton()`, `.heresay()`,
|
|
24
|
+
`.commands { HeresayCommands() }`, and any `Heresay.identify`, `Heresay.setScreen` or
|
|
25
|
+
`Heresay.present()` calls.
|
|
26
|
+
|
|
27
|
+
Build the app to be sure nothing still refers to it. Change nothing else.
|
|
28
|
+
|
|
29
|
+
## 4. Disconnect the repo
|
|
30
|
+
|
|
31
|
+
npx heresay disconnect
|
|
32
|
+
|
|
33
|
+
It removes the `heresay` entry from `.mcp.json` (and `.cursor/mcp.json`), the skill in
|
|
34
|
+
`.claude/skills/heresay/`, the Heresay section of `AGENTS.md`, and this repo's token from
|
|
35
|
+
`~/.heresay`. Anything else in those files stays. Commit the result.
|
|
36
|
+
|
|
37
|
+
## 5. The app and its reports
|
|
38
|
+
|
|
39
|
+
Removing the code does not delete anything in Heresay. The app, its reports and briefs stay
|
|
40
|
+
until an owner deletes the app in the dashboard. Once it is deleted, its key stops working: any
|
|
41
|
+
copy of the app still out there hides the Report button instead of failing.
|
package/release/public/sdk.js
CHANGED
|
@@ -135,8 +135,22 @@
|
|
|
135
135
|
|
|
136
136
|
// ---- network ---------------------------------------------------------------------------
|
|
137
137
|
|
|
138
|
+
// A 404 means the key is unknown: the app was deleted from the dashboard, or the key is
|
|
139
|
+
// wrong. Nothing will ever work, so take the widget off the page once rather than keep
|
|
140
|
+
// offering a button that fails.
|
|
141
|
+
var dead = false;
|
|
142
|
+
function unknownKey() {
|
|
143
|
+
if (dead) return;
|
|
144
|
+
dead = true;
|
|
145
|
+
close();
|
|
146
|
+
host.remove();
|
|
147
|
+
console.warn('[heresay] this key isn\'t known to ' + new URL(API).origin +
|
|
148
|
+
'; the app may have been deleted. Remove the Heresay script tag.');
|
|
149
|
+
}
|
|
150
|
+
|
|
138
151
|
function body(res) {
|
|
139
152
|
return res.json().catch(function () { return {}; }).then(function (b) {
|
|
153
|
+
if (res.status === 404) unknownKey();
|
|
140
154
|
if (!res.ok) throw new Error(b.error || ('HTTP ' + res.status));
|
|
141
155
|
return b;
|
|
142
156
|
});
|
|
@@ -147,7 +161,7 @@
|
|
|
147
161
|
return fetch(API + '/reports', {
|
|
148
162
|
method: 'POST',
|
|
149
163
|
headers: { 'content-type': 'text/plain;charset=UTF-8' },
|
|
150
|
-
body: JSON.stringify({ key: KEY, device_id: deviceId(), type: type, text: text, context: context() }),
|
|
164
|
+
body: JSON.stringify({ key: KEY, device_id: deviceId(), sdk: 'web', type: type, text: text, context: context() }),
|
|
151
165
|
}).then(body);
|
|
152
166
|
}
|
|
153
167
|
|
|
@@ -155,7 +169,8 @@
|
|
|
155
169
|
return fetch(API + '/reports/mine', {
|
|
156
170
|
method: 'POST',
|
|
157
171
|
headers: { 'content-type': 'text/plain;charset=UTF-8' },
|
|
158
|
-
|
|
172
|
+
// sdk tells the dashboard the widget is live in this app (install check).
|
|
173
|
+
body: JSON.stringify({ key: KEY, device_id: deviceId(), sdk: 'web' }),
|
|
159
174
|
}).then(body).then(function (b) {
|
|
160
175
|
state.reports = b.reports || [];
|
|
161
176
|
renderBadge();
|
|
@@ -267,7 +282,7 @@
|
|
|
267
282
|
renderBadge();
|
|
268
283
|
|
|
269
284
|
function open(which) {
|
|
270
|
-
if (scrim) return;
|
|
285
|
+
if (scrim || dead) return;
|
|
271
286
|
lastFocus = document.activeElement;
|
|
272
287
|
view = which || (unseen() ? 'mine' : 'new');
|
|
273
288
|
scrim = el('div', { class: 'scrim', onclick: function (e) { if (e.target === scrim) close(); } });
|
|
@@ -386,6 +401,7 @@
|
|
|
386
401
|
}
|
|
387
402
|
|
|
388
403
|
function mount() {
|
|
404
|
+
if (dead) return;
|
|
389
405
|
if (!host.isConnected) document.body.appendChild(host);
|
|
390
406
|
refresh();
|
|
391
407
|
}
|