Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jongpie
Copy link
Owner

@jongpie jongpie commented Apr 9, 2024

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:

      image

  • Populate their own custom fields in Apex by calling the instance method LogEntryEventBuilder.setField(Schema.SObjectField field, Object fieldValue) or setFields(Map<Schema.SObjectField, Object> fieldToValue).

    • For now, this functionality will only be available in Apex. Long-term, Flow & Lightning Components might also benefit from having equivalent functionality, but that will be handled separately.
    • Example: Logger.info('hello, world').setField(LogEntryEvent__e.SomeCustomField__c, 'some value');

Adding custom fields to the custom objects Log__c, LogEntry__c, and LoggerScenario__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, and LoggerScenario__c are supported.

    • In this example, a custom text field also called SomeCustomField__c has been added to Log__c object - this will be used to store the value of the field LogEntryEvent__e.SomeCustomField__c:

      image

  • Create a record in the new CMDT LoggerFieldMapping__mdt to map the LogEntryEvent__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 source LogEntryEvent__e field.

    • In this example, a custom text field called SomeCustomField__c has been added to both LogEntryEvent__e and Log__c.

      image

@jongpie jongpie added enhancement New feature or request reporting Anything related to reports, dashboards, and the underlying data model apex Items related to using Logger within Apex configurations Items related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type log management Items related to the custom objects & Logger Console app logger engine Items related to the core logging engine labels Apr 9, 2024
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org April 9, 2024 17:09 — with GitHub Actions Failure
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org April 9, 2024 18:26 — with GitHub Actions Inactive
…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)
@jongpie jongpie force-pushed the feature/custom-field-mappings branch from 9fbc519 to 12f77cb Compare April 24, 2024 03:12
…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
Copy link

codecov bot commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 74.02597% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 95.38%. Comparing base (18b4b52) to head (4ece9ca).

❗ Current head 4ece9ca differs from pull request most recent head 36b8ea7. Consider uploading reports for the commit 36b8ea7 to get more accurate results

Files Patch % Lines
.../main/log-management/classes/LoggerFieldMapper.cls 71.42% 18 Missing ⚠️
...ain/logger-engine/classes/LogEntryEventBuilder.cls 81.81% 2 Missing ⚠️
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     
Flag Coverage Δ
Apex 95.38% <74.02%> (-0.30%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apex Items related to using Logger within Apex configurations Items related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type enhancement New feature or request log management Items related to the custom objects & Logger Console app logger engine Items related to the core logging engine reporting Anything related to reports, dashboards, and the underlying data model
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for setting custom fields in LogEntryEventBuilder class
2 participants