Skip to content

New extended data for usage report#5465

Merged
netmindz merged 6 commits intowled:mainfrom
netmindz:usage-extended
Apr 11, 2026
Merged

New extended data for usage report#5465
netmindz merged 6 commits intowled:mainfrom
netmindz:usage-extended

Conversation

@netmindz
Copy link
Copy Markdown
Member

@netmindz netmindz commented Mar 30, 2026

Fixes #5444

Summary by CodeRabbit

  • New Features

    • Upgrade reports now include richer device telemetry: filesystem usage, LED bus count with readable bus type labels, matrix dimensions, peripherals, integrations, and usermod details.
    • Hardware/feature flags are reported as structured arrays to better reflect capabilities.
    • IR remote type is reported when configured, using mapped human-readable labels.
  • Bug Fixes

    • Improved handling when device configuration cannot be retrieved, avoiding misleading success states.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2c959ad6-2a01-41bb-8e92-cbc278bb25ac

📥 Commits

Reviewing files that changed from the base of the PR and between ab0cde1 and 7242e9d.

📒 Files selected for processing (1)
  • wled00/data/index.js

Walkthrough

reportUpgradeEvent now reuses the passed info, fetches /json/cfg, builds an expanded telemetry payload (fs, bus types/count, matrix dims, led/features, peripherals/integrations, usermods, ESP-NOW counts, conditional IR type via IR_TYPES), adds busTypeToString, and posts to the existing telemetry endpoint.

Changes

Cohort / File(s) Summary
Telemetry Data Expansion
wled00/data/index.js
reportUpgradeEvent now fetches /json/cfg (not /json/info), reuses the info argument, validates responses, assembles a larger upgradeData payload (fsUsed/fsTotal, busCount, busTypes via new busTypeToString, matrixWidth/matrixHeight, expanded ledFeatures, peripherals, integrations, usermods/usermodIds, ESP-NOW counts), conditionally maps IR via IR_TYPES to irRemoteType, and posts to the same telemetry endpoint. Added function busTypeToString(t); preserves existing toasts and updateVersionInfo(...) control flow.

Sequence Diagram(s)

sequenceDiagram
    participant Code as reportUpgradeEvent
    participant Device as Local Device API (/json/cfg)
    participant Server as usage.wled.me

    Code->>Device: GET /json/cfg
    Device-->>Code: cfg JSON
    Code->>Code: assemble upgradeData (info + cfg, map bus types & IR)
    Code->>Server: POST /api/usage/upgrade (upgradeData)
    Server-->>Code: 200 / error
    alt success
        Code->>Code: updateVersionInfo(...) + success toast
    else failure
        Code->>Code: show failure toast
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • DedeHai
  • softhack007
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: extending the usage report with additional configuration data fields.
Linked Issues check ✅ Passed The PR implements the requested telemetry extension with bus types, usermods, integrations, hardware fields, and feature flags matching issue #5444 requirements.
Out of Scope Changes check ✅ Passed All changes are directly aligned with extending telemetry reporting; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@netmindz netmindz added this to the 16.0.0 beta milestone Mar 30, 2026
@netmindz netmindz marked this pull request as ready for review April 1, 2026 01:25
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@wled00/data/index.js`:
- Around line 3416-3427: The IR_TYPES object in wled00/data/index.js is
misaligned with the ir.cpp remote type enum; update IR_TYPES so its keys match
ir.cpp: keep 0 as null, then set 1 -> "24-key", 2 -> "24-key-v2" (CW/WW/CT
control), 3 -> "40-key", 4 -> "44-key", 5 -> "21-key", 6 -> "6-key", 7 ->
"9-key", and 8 -> "json-remote" and remove the unused 9 entry so reported
telemetry matches the ir.cpp switch cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7aa42979-889a-4910-98a1-3f9b3eee10f4

📥 Commits

Reviewing files that changed from the base of the PR and between a5f28d0 and 3d2fac0.

📒 Files selected for processing (1)
  • wled00/data/index.js

Comment thread wled00/data/index.js
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
wled00/data/index.js (1)

3525-3528: ⚠️ Potential issue | 🟠 Major

Don't mark failed reports as handled.

This shared catch also covers the fresh /json/info and /json/cfg reads. Calling updateVersionInfo(...) here suppresses future prompts even when nothing reached the telemetry API, which also contradicts Line 3522. Only persist the new version after a successful POST or an explicit user opt-out.

Possible fix
 		.catch(e => {
 			console.log('Failed to report upgrade', e);
 			showToast('Report failed', true);
-			updateVersionInfo(info.ver, false, !!alwaysReport);
 		});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@wled00/data/index.js` around lines 3525 - 3528, The catch handler that logs
'Failed to report upgrade' currently calls updateVersionInfo(info.ver, false,
!!alwaysReport) which incorrectly marks the version as handled even when
telemetry POST or subsequent /json/info and /json/cfg reads failed; modify the
error path in the promise chain around the POST (the .catch(e => { ... }) that
contains showToast and console.log) to remove the updateVersionInfo(...) call so
it is only invoked after a successful POST response or when the user explicitly
opts out, or alternatively add a success flag and call
updateVersionInfo(info.ver, false, !!alwaysReport) only inside the successful
POST response handler (not in the shared catch) to avoid suppressing future
prompts; ensure references to updateVersionInfo, showToast and the failing
.catch are updated accordingly.
♻️ Duplicate comments (1)
wled00/data/index.js (1)

3416-3427: ⚠️ Potential issue | 🟠 Major

Fix the IR_TYPES lookup; it's still shifted by one.

cfgData.hw?.ir?.type is used verbatim here, so every non-zero IR remote is reported under the wrong name today. json-remote also belongs on code 8, not 9.

Possible fix
 	const IR_TYPES = {
-		1: "3-key",
-		2: "24-key",
-		3: "24-key-v2",
-		4: "40-key",
-		5: "44-key",
-		6: "21-key",
-		7: "6-key",
-		8: "9-key",
-		9: "json-remote",
+		1: "24-key",
+		2: "24-key-v2",
+		3: "40-key",
+		4: "44-key",
+		5: "21-key",
+		6: "6-key",
+		7: "9-key",
+		8: "json-remote",
 	};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@wled00/data/index.js` around lines 3416 - 3427, The IR_TYPES lookup is
misaligned with cfgData.hw?.ir?.type so non-zero IR types are reported wrong;
update IR_TYPES (the constant named IR_TYPES) so the values align with their
numeric codes — specifically move "json-remote" to key 8 and ensure "9-key" is
at key 9 (i.e., correct the shifted mapping so cfgData.hw?.ir?.type indexes the
right label).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@wled00/data/index.js`:
- Around line 3470-3478: The peripherals array collapses button topology to a
boolean via .some(b => b.type !== 0); instead compute the actual physical button
count from cfgData.hw?.btn?.ins (e.g. const buttonCount = (cfgData.hw?.btn?.ins
?? []).filter(b => b.type !== 0).length), use buttonCount > 0 to include
"buttons" in the peripherals list, and expose the count as a separate field
(e.g. buttonCount or buttons_count) in the payload so single-button and
multi-button installs remain distinguishable; update references to
cfgData.hw?.btn?.ins and remove the .some(...) usage.
- Around line 3429-3434: Replace the parallel Promise.all fetches with a
serialized flow: use the existing info argument if present (the local info
variable/parameter) or fetch getURL('/json/info') first, await its JSON, then
fetch getURL('/json/cfg') and await its JSON; remove Promise.all usage (and any
references to infoData/cfgData from the parallel result) and instead use
sequential variables (e.g., info and cfg) so the /json/cfg request only runs
after /json/info completes to avoid overlapping startup requests.
- Around line 3458-3467: The gamma feature is being detected by comparing
cfgData.light?.gc?.col > 1.0 which treats the boolean as numeric and prevents
"gamma" from being reported; update the ledFeatures construction (the array
assigned to ledFeatures) to treat gamma flags as booleans — check
cfgData.light?.gc?.col || cfgData.light?.gc?.bri (or similar boolean fields like
gammaCorrectCol/gammaCorrectBri) instead of numeric comparison so that "gamma"
is included when either gamma correction flag is true.

---

Outside diff comments:
In `@wled00/data/index.js`:
- Around line 3525-3528: The catch handler that logs 'Failed to report upgrade'
currently calls updateVersionInfo(info.ver, false, !!alwaysReport) which
incorrectly marks the version as handled even when telemetry POST or subsequent
/json/info and /json/cfg reads failed; modify the error path in the promise
chain around the POST (the .catch(e => { ... }) that contains showToast and
console.log) to remove the updateVersionInfo(...) call so it is only invoked
after a successful POST response or when the user explicitly opts out, or
alternatively add a success flag and call updateVersionInfo(info.ver, false,
!!alwaysReport) only inside the successful POST response handler (not in the
shared catch) to avoid suppressing future prompts; ensure references to
updateVersionInfo, showToast and the failing .catch are updated accordingly.

---

Duplicate comments:
In `@wled00/data/index.js`:
- Around line 3416-3427: The IR_TYPES lookup is misaligned with
cfgData.hw?.ir?.type so non-zero IR types are reported wrong; update IR_TYPES
(the constant named IR_TYPES) so the values align with their numeric codes —
specifically move "json-remote" to key 8 and ensure "9-key" is at key 9 (i.e.,
correct the shifted mapping so cfgData.hw?.ir?.type indexes the right label).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2b92d966-9b88-42ea-bbbd-aa8506249b20

📥 Commits

Reviewing files that changed from the base of the PR and between cf03f1a and 35c1f41.

📒 Files selected for processing (1)
  • wled00/data/index.js

Comment thread wled00/data/index.js Outdated
Comment thread wled00/data/index.js
Comment thread wled00/data/index.js
Comment thread wled00/data/index.js Outdated
Comment thread wled00/data/index.js Outdated
Comment thread wled00/data/index.js
@softhack007 softhack007 added enhancement AI Partly generated by an AI. Make sure that the contributor fully understands the code! labels Apr 11, 2026
@netmindz netmindz merged commit e2dd630 into wled:main Apr 11, 2026
24 of 25 checks passed
netmindz added a commit that referenced this pull request Apr 11, 2026
New extended data for usage report
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Partly generated by an AI. Make sure that the contributor fully understands the code! enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend the coverage of features in use

3 participants