Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ devenv.local.nix

node_modules/
appcast/dist/
appcast/logs/
appcast/report/
29 changes: 29 additions & 0 deletions BuildScripts/appcast-report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

set -eu

project_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
logs_dir="$project_dir/appcast/logs"
report_dir="$project_dir/appcast/report"
account_id=$(aws sts get-caller-identity --query Account --output text)
log_source="s3://tmpdisk-appcast-logs-prod/AWSLogs/$account_id/CloudFront/tmpdisk/"

mkdir -p "$logs_dir" "$report_dir"
aws s3 sync "$log_source" "$logs_dir" --exclude "*" --include "*.gz"

log_paths=$(find "$logs_dir" -type f -name "*.gz" -print)
if [ -z "$log_paths" ]; then
echo "no appcast logs found at $log_source" >&2
exit 1
fi

# CloudFront-generated object names contain no whitespace, so splitting the
# newline-delimited find output produces one argument per log file.
# shellcheck disable=SC2086
"$project_dir/node_modules/.bin/twinkle" report \
"$project_dir/appcast/current.json" \
$log_paths \
--html "$report_dir/index.html" \
> "$report_dir/report.json"

cat "$report_dir/report.json"
10 changes: 10 additions & 0 deletions appcast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ AWS_PROFILE=cg-prod npm run appcast:publish
```

Publishing validates both manifests before any upload. Published objects are versioned in S3; CloudFront caches them for five minutes.

## Offline metrics

Download the retained CloudFront logs and generate local JSON and HTML reports:

```sh
AWS_PROFILE=cg-prod npm run appcast:report
```

Outputs are written to the gitignored `appcast/report/` directory. Raw logs remain local in `appcast/logs/`. The report counts update checks and estimates version adoption; it does not measure installations or completed downloads.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"private": true,
"scripts": {
"appcast:render": "sh BuildScripts/appcast.sh render all",
"appcast:publish": "sh BuildScripts/appcast.sh publish"
"appcast:publish": "sh BuildScripts/appcast.sh publish",
"appcast:report": "sh BuildScripts/appcast-report.sh"
},
"devDependencies": {
"twinkle-appcast": "https://github.com/cosmicglue-io/twinkle/archive/8fdf6eb74ca51ba9d5d587d3c94e1032b68c79eb.tar.gz"
"twinkle-appcast": "https://github.com/cosmicglue-io/twinkle/archive/e45e3be7f9bf684ee123c9b790e9850feef14ae0.tar.gz"
}
}
Loading