-
Notifications
You must be signed in to change notification settings - Fork 148
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
Added support for custom field mappings #664
base: main
Are you sure you want to change the base?
Conversation
…FieldMapping__mdt and a new instance methods LogEntryEventBuilder.setField() & setFields()
…new dedicated class in extra-tests, along with a few custom fields to do a proper test (instead of using fields/overwriting existing field values)
9fbc519
to
12f77cb
Compare
…l in a few scenarios Mappings for some objects (but not all objects) would cause failures String values that exceed the target field's length would cause failures Field mappings for incompatible data types (e.g., String --> Datetime) would cause failures
12f77cb
to
4ece9ca
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #664 +/- ##
==========================================
- Coverage 95.67% 95.38% -0.30%
==========================================
Files 50 51 +1
Lines 5597 5674 +77
==========================================
+ Hits 5355 5412 +57
- Misses 242 262 +20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Resolves #655 by adding support for defining, setting, and mapping custom fields within Nebula Logger's data model. This is helpful in orgs that want to extend Nebula Logger's included data model by creating their own org/project-specific fields.
Adding custom fields to the platform event
LogEntryEvent__e
For orgs that only use
LogEntryEvent__e
(and don't leverage the custom objects), they can now...Create their own custom fields on
LogEntryEvent__e
. Any data type supported by platform events can be used.In this example, a custom text field called
SomeCustomField__c
has been added:Populate their own custom fields in Apex by calling the instance method
LogEntryEventBuilder.setField(Schema.SObjectField field, Object fieldValue)
orsetFields(Map<Schema.SObjectField, Object> fieldToValue)
.Logger.info('hello, world').setField(LogEntryEvent__e.SomeCustomField__c, 'some value');
Adding custom fields to the custom objects
Log__c
,LogEntry__c
, andLoggerScenario__c
For orgs that want to store the data in one of Nebula Logger's custom objects, they can follow the above steps, and also...
Create their own custom fields on one of Nebula Logger's custom objects - right now, only
Log__c
,LogEntry__c
, andLoggerScenario__c
are supported.In this example, a custom text field also called
SomeCustomField__c
has been added toLog__c
object - this will be used to store the value of the fieldLogEntryEvent__e.SomeCustomField__c
:Create a record in the new CMDT
LoggerFieldMapping__mdt
to map theLogEntryEvent__e
custom field to the custom object's custom field, shown below. Nebula Logger will automatically populate the custom object's target field with the value of the sourceLogEntryEvent__e
field.In this example, a custom text field called
SomeCustomField__c
has been added to bothLogEntryEvent__e
andLog__c
.