Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: javascript
analyticseventsuxcorrectness
Fire analytics events at the point the action is committed
Decide whether you are tracking a click or a saved/submitted change, and place the analytics call accordingly (in the submit handler for persisted changes).
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | // fires while only editing draft form values, before submit |
| 2 | onItemToggle={() => track('item_added')} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const handleSubmit = (values) => { |
| 2 | save(values); |
| 3 | track('items_saved', values); // tracked once committed |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)