Skip to content

Commit f554eb2

Browse files
authored
fix: telemetry hardening — nil guard, bounded queue, logger-to-Sentry wiring, source maps (#2477)
* docs: add telemetry hardening design spec (#41-#45) Design for five telemetry issues: CaptureError nil guard, bounded deferredMessages, FormData Blob validation, logger-to-Sentry wiring, and CI source map uploads. Grouped into three independent PRs. * docs: add telemetry hardening implementation plan 9-task plan across 3 PRs: backend telemetry hardening (nil guard, bounded deferred queue), frontend telemetry wiring (Blob validation, logger-to-Sentry injection), and CI source map uploads. * fix: add nil guard to CaptureError to prevent panic * fix: cap deferred message queue at 100 to prevent unbounded growth * fix: drain deferred message queue when Sentry is disabled * fix: remove incorrect t.Parallel from global-state-mutating test TestCaptureError_NilError calls EnableTestMode/DisableTestMode which mutate package-level atomics. Tests mutating global state must not use t.Parallel per project testing guidelines. * fix: count Blob size in FormData validation * feat: add captureError function to frontend Sentry module * feat: wire logger.error() to Sentry via dependency injection * fix: align frontend Sentry release format with backend * feat: enable hidden source map generation for Sentry * ci: add source map upload to Sentry in release and nightly builds * fix: clear stale Sentry logger hook on re-init and failed init Clear setSentryCaptureError(null) before Sentry init and in the .catch handler to prevent stale forwarding after opt-out or failure. Add clarifying comment on args.length > 2 threshold in error() method. --------- Co-authored-by: tphakala <tphakala@users.noreply.github.com>
1 parent fdd23fd commit f554eb2

File tree

13 files changed

+1456
-28
lines changed

13 files changed

+1456
-28
lines changed

.github/workflows/nightly-build.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,32 @@ jobs:
8181
PUPPETEER_SKIP_DOWNLOAD: true
8282
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
8383

84+
- name: Upload source maps to Sentry
85+
if: matrix.goos == 'linux' && matrix.goarch == 'amd64'
86+
env:
87+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
88+
SENTRY_ORG: tphakala
89+
SENTRY_PROJECT: birdnet-go
90+
run: |
91+
npx @sentry/cli sourcemaps upload \
92+
--release "birdnet-go@${{ env.BUILD_VERSION }}" \
93+
--url-prefix '~/ui/assets/' \
94+
frontend/dist/
95+
8496
- name: Create Release Artifacts
8597
run: |
8698
# Create artifacts directory
8799
mkdir -p artifacts
88-
100+
89101
# Set binary name based on OS
90102
BINARY_NAME=birdnet-go
91103
if [ "${{ matrix.goos }}" = "windows" ]; then
92104
BINARY_NAME=birdnet-go.exe
93105
fi
94-
106+
95107
# Copy binary
96108
cp bin/$BINARY_NAME artifacts/
97-
109+
98110
# Copy required library files based on OS and architecture
99111
if [ "${{ matrix.goos }}" = "linux" ]; then
100112
if [ "${{ matrix.goarch }}" = "amd64" ]; then
@@ -107,7 +119,7 @@ jobs:
107119
elif [ "${{ matrix.goos }}" = "darwin" ]; then
108120
cp /opt/homebrew/lib/libtensorflowlite_c.dylib artifacts/
109121
fi
110-
122+
111123
# Create tarball
112124
cd artifacts
113125
tar czf ../birdnet-go-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz *

.github/workflows/release-build.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ jobs:
6666
CGO_ENABLED: 1
6767
BUILD_VERSION: ${{ github.ref_name }}
6868

69+
- name: Setup Node.js for Sentry CLI
70+
if: matrix.goos == 'linux' && matrix.goarch == 'amd64'
71+
uses: actions/setup-node@v6
72+
with:
73+
node-version: '24'
74+
75+
- name: Upload source maps to Sentry
76+
if: matrix.goos == 'linux' && matrix.goarch == 'amd64'
77+
env:
78+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
79+
SENTRY_ORG: tphakala
80+
SENTRY_PROJECT: birdnet-go
81+
run: |
82+
npx @sentry/cli sourcemaps upload \
83+
--release "birdnet-go@${{ github.ref_name }}" \
84+
--url-prefix '~/ui/assets/' \
85+
frontend/dist/
86+
6987
- name: Create Release Artifacts
7088
run: |
7189
# Create artifacts directory

0 commit comments

Comments
 (0)