-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
Add support for setting custom fields in LogEntryEventBuilder class #655
Comments
Hi @pankaj0509 - that is not feasible for the managed package, nor recommended for the unlocked package as it will make it difficult to upgrade to new releases. Can you share some info on what the new method does that you're adding? |
Hey @jongpie let me provide some additional context about what we are working on with @pankaj0509. I was thinking about a generic way of adding additional fields without impacting the core logic of the Nebula Framework. That's why Pankaj was asking for new builder methods for the LogEntryEventBuilder and new fields on the Log Entry object. We found some workarounds that allow us to use the unmanaged package, but even in that case, we need to make some minor changes to Nebula to add new fields to the Log Entry. As this does not modify the existing metadata, it will allow us to keep up with the latest releases of Nebula without any problems. Let me describe my solution:
Then, in the before insert plugin, I search for the JSON structure in the message and map the fields to my custom fields added to the log message. After that, I remove all data from the error message (starting from ## or any other specific set of characters). It might work fine, but as you can see, this is not the cleanest solution ever created, and furthermore, it requires creating custom fields, which makes it impossible in managed package distribution. So after this long introduction, let me ask a question: I was thinking about two potential, generic solutions for that. Here are my thoughts:
Custom data could be saved in JSON (some new field on LogEntryEvent__e) and then in after insert plugin dynamically mapped to custom fields. Log Entry should also have a new field - Id of the custom record containing additional log data. The problem here would be presenting that data - they will be not available on standard page layouts, so they would require some component that dynamically retrieves the additional log data and presents them.
|
Hi @codejester90, thanks for the explanation! The only existing features that might work for your purposes are (in addition to what you've already tried):
So, tagging is maybe the only existing functionality that would possibly work for your use case, but I think that it would have a lot of downsides in terms of reporting on the data (compared to using custom fields with distinct data types, etc.). Conceptually, I think it does make sense to provide a way to support custom fields in Nebula Logger, there are a lot of projects/orgs that could benefit from having a place to store their own data, in a structured way. I see this working a little bit differently from the 2 options you provided - I think it should support custom fields on Nebula Logger's own objects (instead of using a separate custom object as described in your 1st option). I built a prototype of this functionality a while back, but never released it - this approach would have 3 changes in Nebula Logger's codebase:
To use the approach, you would then make a few changes in your org
This approach would have a couple of benefits:
Let me know what you and @pankaj0509 think of this approach! |
@jongpie, thanks for the quick and detailed response! Let me express my thoughts: Tagging: Your Idea of Implementing Custom Fields: The only aspect that I'm not entirely happy with is the need to create a field both on LogEntryEvent__e and Log__c/LogEntry__c. If there is a mapping in LoggerFieldMapping__mdt, then we could simply have one field on LogEntryEvent__e and store all custom fields as JSON. I understand the necessity of not doing this on Log__c/LogEntry__c due to the benefits derived from existing fields rather than a JSON structure. However, LogEntryEvent__e is only a means to transport the data, and I believe users should not manipulate or maintain this object. This is an internal object, and thus far, you've protected the API values of it by employing the builder pattern, which is commendable. It theoretically allows you to replace LogEntryEvent__e with something else without impacting the client code. Hence, I suggest maintaining this level of protection. Exposing the internals to the client via:
I believe that a dynamic JSON LogEntryEvent__e and reference to Log__c/LogEntry__c instead of LogEntryEvent__e could potentially be a good solution. Summary: Please let me know if there's any way we can assist you in making this happen. We would be more than happy to contribute, whether it's through coding, testing, or any other means. Additionally, if there's a timeline for when this could happen, even having it on the beta branch would be great so that we could start testing it in our environments. |
Hi @codejester90, thanks for the feedback! I definitely see your point about
I think I'm still leaning towards the approach I outlined of using custom fields on If you're interested in testing beta version of the package, that would also be really helpful. The prototype I made a few years ago already has some of the functionality built, so I think I can make fairly quick progress on this enhancement. I might be able to have a beta version ready to test in a week or two. |
@jongpie thanks for the response, I do appreciate the time you dedicated to consider the points I raised I completely understand your concerns regarding using a single JSON long text area field on LogEntryEvent__e, your explanation makes perfect sense, especially regarding potential scalability issues and the importance of accommodating orgs that heavily rely on/ integrate with LogEntryEvent__e. It's important to keep the solution flexible and robust enough to meet various use cases and integration scenarios. Your approach seems more versatile I'm super glad to hear that you'll be working on this enhancement further this week, and I'm looking forward to seeing the finalized approach. Your dedication to improving the Nebula Logger is really impressive. Regarding testing the beta version of the package, count us in! We'd love to participate and provide feedback. Please keep us updated on your progress and let us know when the beta version is available for testing (no pressure though :) ) |
@codejester90 awesome, thanks for the feedback (again!) - I'm moving forward with the approach of having matching fields on I've already made progress on this enhancement, and I'm aiming to have a beta version ready in the next few days. There are 2-3 other smaller releases that I'm going to finish first, then I'll create a PR with this enhancement. I'll let you know when it's ready & available to test out! |
@jongpie Awesome to know that Thanks for your update. |
@pankaj0509 and @codejester90 - I have an initial beta of the unlocked package ready to try out! 🥳
There are a couple of things I may change in the PR, so there may be some breaking changes before this is officially released, but you should be able to use this beta to test out the new functionality in a scratch org or sandbox. If/when you have a chance to test it out, please let me know if you have any feedback! |
@jongpie I implemented the same using Beta version however It is not working . I created one abc__c on LogEntryEvent__e and same custom field i.e abc__c on logEntry__c and i also created one entry to provided CMDT . It is not working ,Not only this but logs itself are not generating which means no log__c record are generating as part of our investigation i found one behavior if i unchecked IsEnabled__c on CMDT entry then log __c records will be generating but again our custom field population feature is not working. is there any other thing that I am missing ? kindly suggest |
Hi @pankaj0509 - could you tell me what field type(s) you're using on |
hi @jongpie thanks for your reply !!. I am using text field type in both LogEntryEvent__e and logEntry__c . For our scenario , We need to populate data in logEntry__c object's custom field. In essence , let me summarize it for you. To populate custom field on logEntry__c, We need to use create custom metadata entry on LoggerFieldMapping__mdt but when i create an entry by following to steps mentioned in above with IsEnabled__c is true. log__c records are not generating . However I can see logs in debug logs but no log__c records are generating . but incase there is not entry in LoggerFieldMapping__mdt or if there is entry in LoggerFieldMapping__mdt with IsEnabled__c is false then log__C records will be created but this new feature won't work. fyi i am using below link to install nebula. https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001MkHHQA0 Your prompt response will be much appreciated . Thanks again for your valuable support . |
Hi @pankaj0509 thanks for the feedback! I was able to reproduce and fix several issues that could occur with the field mappings. Could you install & test this new version? https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000027L0EQAU Hopefully this resolves the issues, but please let me know if you run into any more problems. |
@jongpie Thanks, I am on it . Let me give u feedback |
@jongpie I have installed nebula using below provided link and it is working as expected. Thanks a ton!! https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000027L0EQAU just out of curiosity , when are you planning to merge new feature changes in main ? |
@pankaj0509 thanks for trying it out & glad to hear it's working as expected! There are still a couple things I want to improve & finalize before this is released, so my hope is to merge this sometime in the coming weeks/next month or so, after I've addressed a few things:
In the meantime, if you see any other bugs or have any other feedback, please let me know! |
@pankaj0509 just wanted to (finally) give you an update on this enhancement
So, I think the |
Related discussion in #681. |
@pankaj0509 and @codejester90, another update on this - contrary to my previous comment, I am going to release this today for the unlocked package, and it will then be included in the next managed package release ( There are a few small changes to this functionality (compared to the beta version that you've been using). I think the only notable change that could impact your code is that the name of the method |
This has now been released in |
We are working on the custom field mapping from Lightning Web Components, we are currently encountering a blocker. The logger component passes details to the controller class, which then creates a new platform event record, adds the details, and executes the save log process. Unfortunately, there is no room for custom logic to somehow retrieve the platform event or the Log Entry record and map our custom fields. I am open to any suggestions or guidance on how to tackle this blocker. Can you also clear up some of my concerns for logger
|
@JaskiratSingh29 in order to make this work in lightning components, there are changes needed in the
There is not a specific timeline yet for adding it to lightning components & Flow (please keep in mind that this is a free project that I maintain as a hobby), but I've created issues #718 and #719 to track the progress of these enhancements...
|
@jongpie thanks for the quick response and the detailed update! I appreciate the effort you’re putting into enhancing the logger functionality for Lightning components and Flow. I completely understand the need for thorough testing and cleanup, and I’m excited about the benefits this feature will bring once it’s ready. I look forward to the progress on issues #718 and #719. Can you share the early prototype version for Logger with this functionality implemented for LWC? |
Hi Team,
I want to use managed packaged version of nebula logger. I want to know is there any plugin available
so that i can create my custom method in LogEntryEventBuilder class.
I am able to so that in unmanaged package and my expected functionality is working fine .
but i want to archive the same in managed package version of nebula so i need plugin information to explore the possibilities.
Pankaj
The text was updated successfully, but these errors were encountered: