-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add meta with codes on warnings to allow conditional logging #1826
feat: add meta with codes on warnings to allow conditional logging #1826
Conversation
9f9deb6
to
914ebad
Compare
914ebad
to
ff509ba
Compare
e478b8d
to
57f58fe
Compare
not necessary, since you can now inject your own logger: i18next/react-i18next-gitbook#150 (comment) |
57f58fe
to
2b3bd6e
Compare
@adrai I saw your changes just now, cool!, this PR now just adds meta so I can filter what to log or not |
I suggest, you move this logic out to your custom logger... else this will bloat the code size even more... //cc @VIKTORVAV99 |
2b3bd6e
to
8848b1e
Compare
fair enough, I reworked the changes to includes only what is needed to do that from the logger |
Do you really need extra error codes? The whole i18next core code base has no error codes... |
the error codes is to be able to identify the warnings in the code. the i18nkey also allow to add a logic to warnOnce per key in the custom logger, now it warn on each renders. for the code I could do some string regexp on the messages to figure out the cause of the error, |
Maybe there are benefits from this but I would like you to consider two things: First this will increase the overhead and bundle size for all users of i18next, I've been trying to push this bundle down as it's one of the bigger parts of our app we can't change at the moment. Secondly it feels like this is just duplicating the error message. If we do this I would switch to something what react does and only log the error codes with a link to look up what they mean. But that requires other changes as well. That is just my thought on the matter though but I would really like to avoid duplicating any information or functionality for the sake of making it a little more convenient for one project or developer. |
33243a3
to
6b11535
Compare
I replaced the error map with a tuple, and reduced duplicates, it's adding 201 bytes to moving the error messages to the documentation might be a good idea. They can be better explained in the docs, and changed without worrying of breaking someone code. |
If you ask me, I think it's needed for sanity.
But the code can run without it and the type can be removed to accept any string as code.
|
6b11535
to
8fe0b03
Compare
good news @adrai I moved the error code to a type declaration file so its not in the code. the minify js is now 20 bytes less than master 🎉 |
8375d3d
to
3faabc8
Compare
added types for the warning args along an example of usage in the logger plugin edit: typo in example |
3faabc8
to
8ee8463
Compare
TS tests seems to fail: https://github.com/i18next/react-i18next/actions/runs/12542746999/job/34976361013?pr=1826 |
8ee8463
to
4be7a37
Compare
it should be fixed, but I can't make the test fail locally, npm run test pass |
it's included in v15.4.0 |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [react-i18next](https://github.com/i18next/react-i18next) | dependencies | minor | [`15.3.0` -> `15.4.0`](https://renovatebot.com/diffs/npm/react-i18next/15.3.0/15.4.0) | --- ### Release Notes <details> <summary>i18next/react-i18next (react-i18next)</summary> ### [`v15.4.0`](https://github.com/i18next/react-i18next/blob/HEAD/CHANGELOG.md#1540) [Compare Source](i18next/react-i18next@v15.3.0...v15.4.0) feat: add meta with codes on warnings to allow conditional logging [1826](i18next/react-i18next#1826) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS44Ni4wIiwidXBkYXRlZEluVmVyIjoiMzkuODYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19--> Reviewed-on: https://git.tristess.app/alexandresoro/ouca/pulls/434 Reviewed-by: Alexandre Soro <[email protected]> Co-authored-by: renovate <[email protected]> Co-committed-by: renovate <[email protected]>
Checklist
npm run test
Checklist (for documentation change)