replace diagnostics script with curl, simplify flow
Remove send-diagnostics.ts entirely. Claude writes the JSON, shows it to the user, and sends via curl. Opt-out is permanent: Claude replaces diagnostics.md contents and removes the section from SKILL.md. No dependencies, no state files, no .nanoclaw/ directory. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,36 +2,58 @@
|
||||
|
||||
After the update is complete, offer to send anonymous diagnostics.
|
||||
|
||||
## 1. Check opt-out
|
||||
## 1. Write the event
|
||||
|
||||
```bash
|
||||
npx tsx scripts/send-diagnostics.ts --event update_complete --success --data '{}' --dry-run
|
||||
Write a JSON file to `/tmp/nanoclaw-diagnostics.json` with the update outcome. Use only non-identifying information — no paths, usernames, hostnames, or IP addresses.
|
||||
|
||||
```json
|
||||
{
|
||||
"event": "update_complete",
|
||||
"success": true,
|
||||
"properties": {
|
||||
"nanoclaw_version": "1.2.21",
|
||||
"os_platform": "darwin",
|
||||
"arch": "arm64",
|
||||
"node_major_version": 22,
|
||||
"version_age_days": 45,
|
||||
"update_method": "merge",
|
||||
"conflict_count": 0,
|
||||
"breaking_changes_found": false,
|
||||
"error_count": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If no output, the user opted out permanently — stop here.
|
||||
Fill in the values based on what happened during the session.
|
||||
|
||||
## 2. Prepare event
|
||||
## 2. Show and ask
|
||||
|
||||
Run `--dry-run` to get the final payload:
|
||||
|
||||
```bash
|
||||
npx tsx scripts/send-diagnostics.ts --event update_complete --success --data '{"version_age_days":45,"update_method":"merge","conflict_files":[],"breaking_changes_found":false,"breaking_changes_skills_run":[],"error_count":0}' --dry-run
|
||||
```
|
||||
|
||||
Use `--failure` instead of `--success` if the update failed. Fill in the values based on what actually happened during the session.
|
||||
|
||||
## 3. Ask the user
|
||||
Show the contents of the file to the user and ask:
|
||||
|
||||
> "Would you like to send anonymous diagnostics to help improve NanoClaw? Here's exactly what would be sent:"
|
||||
>
|
||||
> (show JSON payload)
|
||||
> (show JSON)
|
||||
>
|
||||
> **Yes** / **No** / **Never ask again**
|
||||
|
||||
Use AskUserQuestion.
|
||||
|
||||
## 4. Handle response
|
||||
## 3. Handle response
|
||||
|
||||
- **Yes**: Run the command again without `--dry-run`. Confirm: "Diagnostics sent."
|
||||
- **No**: Do nothing.
|
||||
- **Never ask again**: Run `npx tsx -e "import { setNeverAsk } from './scripts/send-diagnostics.ts'; setNeverAsk();"` — confirm: "Got it — you won't be asked again."
|
||||
**Yes**: Send it:
|
||||
```bash
|
||||
curl -s -X POST https://us.i.posthog.com/capture/ \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{\"api_key\":\"phc_fx1Hhx9ucz8GuaJC8LVZWO8u03yXZZJJ6ObS4yplnaP\",\"event\":\"$(jq -r .event /tmp/nanoclaw-diagnostics.json)\",\"distinct_id\":\"$(uuidgen)\",\"properties\":$(jq .properties /tmp/nanoclaw-diagnostics.json)}"
|
||||
rm /tmp/nanoclaw-diagnostics.json
|
||||
```
|
||||
Confirm: "Diagnostics sent."
|
||||
|
||||
**No**: `rm /tmp/nanoclaw-diagnostics.json` — do nothing else.
|
||||
|
||||
**Never ask again**: Replace the contents of this file (`diagnostics.md`) with:
|
||||
```
|
||||
# Diagnostics — opted out
|
||||
```
|
||||
Then remove the "Diagnostics (Optional)" section from the end of `SKILL.md` in this skill directory. Delete `/tmp/nanoclaw-diagnostics.json`.
|
||||
Confirm: "Got it — you won't be asked again."
|
||||
|
||||
Reference in New Issue
Block a user