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

Created new LoggerScenario__c custom object #356

Merged
merged 18 commits into from
Sep 8, 2022

Conversation

jongpie
Copy link
Owner

@jongpie jongpie commented Aug 29, 2022

Closes #349 by deprecating the field Log__c.Scenario__c and replacing it with a new optional lookup Log__c.TransactionScenario__c that leverages the new custom object LoggerScenario__c . The LoggerScenario__c object does not currently have any automation built-in - this PR is focused on just getting the object introduced, more features will be added later.

  • Added LoggerScenario__c object with a uniqued external ID field LoggerScenario__c .Unique__c - this is set based on the value LogEntryEvent__e.Scenario__c (which can be set using Logger.setScenario(String)

  • Added new "Logger Scenarios" tab to the Logger Console app, and rearranged the ordering of the included tabs

    image

  • Added skeleton trigger handler class LoggerScenarioHandler - there's currently no object-specific logic implemented, but this provides an entry point for plugins. Additional logic will probably also be incorporated as part of Add more fields to LogScenarioRule__mdt #355

  • Added flexipage, page layout, compact layout, etc for the new object. I've arranged the UI to mimic the UI of the Log__c object's flexipage/layout

    image

  • Added an Apex script ./scripts/data/migrate-log-scenario-field-to-logger-scenario-object.apex that migrates existing data from the text field Log__c.Scenario__c to the new object & lookup Log__c.TransactionScenario__c.

    • Existing orgs can run the script after upgrading to update existing records - but depending on how many Log__c records need to be updated, the script may need to be executed multiple times. It's not ideal, but this approach is easier that deploying a new, temporary batch job to do it in bulk.
  • Updated LoggerAdmin, LoggerLogViewer, and LoggerEndUserpermission sets to have access to the newLoggerScenario__c` object

  • Updated LoggerEndUser permission set to have read-only access to the tagging & scenario custom objects

@jongpie jongpie added Type: Enhancement New feature or request Salesforce Feature: Reporting Anything related to reports, dashboards, and the underlying data model Layer: Log Management Items related to the custom objects & Logger Console app Feature: Scenario-Based Logging Items related to Logger.setScenario(), LoggerScenarioRule__mdt, etc. labels Aug 29, 2022
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org August 29, 2022 22:32 Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org August 29, 2022 22:32 Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org August 29, 2022 23:01 Inactive
@jongpie jongpie temporarily deployed to Base Scratch Org August 29, 2022 23:01 Inactive
@jongpie jongpie temporarily deployed to Demo Org August 29, 2022 23:20 Inactive
@jongpie jongpie temporarily deployed to Demo Org August 29, 2022 23:43 Inactive
…liases, cleaned up sfdx-project.json & README files
…legacy support - it may get removed in a future release, but will keep it for now
…io__c.UniqueId__c a required field, added a 'My Assigned Log Scenarios' list view
@jongpie jongpie force-pushed the feature/log-scenario-custom-object branch 3 times, most recently from be018d2 to 201b7ac Compare August 31, 2022 05:37
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org August 31, 2022 05:40 Error
…ueId__c is required, and Name is auto-populated (when null) to a truncated version of UniqueId__c
@jongpie jongpie force-pushed the feature/log-scenario-custom-object branch from 201b7ac to 4c25045 Compare August 31, 2022 05:45
@@ -836,7 +908,12 @@ private class LogEntryEventHandler_Tests {
System.assertEquals(logEntryEvent.ParentLogTransactionId__c, log.ParentLogTransactionId__c, 'log.ParentLogTransactionId__c was not properly set');
System.assertEquals(logEntryEvent.ProfileId__c, log.ProfileId__c, 'log.ProfileId__c was not properly set');
System.assertEquals(logEntryEvent.ProfileName__c, log.ProfileName__c, 'log.ProfileName__c was not properly set');
System.assertEquals(logEntryEvent.Scenario__c, log.Scenario__c, 'log.Scenario__c was not properly set');
System.assertEquals(
logEntryEvent.Scenario__c?.left(Schema.LogScenario__c.Name.getDescribe().getLength()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the mechanism here that's setting the Scenario here? I didn't see anything in setup creating a scenario record, and the assert makes it seem like there could be truncation at play here, as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh maybe it's just not part of the diff because I see you were previously asserting on the Scenario being set ...

Copy link
Collaborator

@jamessimone jamessimone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jongpie LGTM! Just a couple of comments here and there but everything looks great!

@jongpie
Copy link
Owner Author

jongpie commented Sep 2, 2022

@jamessimone thanks for reviewing! I'll finish the object rename & incorporating your comments, and then I'll publish this release today or tomorrow!

@jongpie jongpie force-pushed the feature/log-scenario-custom-object branch from 6cf5b75 to a2b6b1e Compare September 7, 2022 16:00
@jongpie jongpie changed the title Created new LogScenario__c custom object Created new LoggerScenario__c custom object Sep 7, 2022
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org September 7, 2022 16:03 Failure
@jongpie jongpie force-pushed the feature/log-scenario-custom-object branch from a2b6b1e to 1477eb2 Compare September 7, 2022 16:17
@jongpie jongpie temporarily deployed to Base Scratch Org September 7, 2022 16:20 Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org September 7, 2022 16:20 Inactive
@jongpie jongpie temporarily deployed to Demo Org September 7, 2022 16:44 Inactive
@jongpie jongpie temporarily deployed to Demo Org September 7, 2022 17:23 Inactive
@jongpie jongpie force-pushed the feature/log-scenario-custom-object branch 2 times, most recently from 1bcd2e9 to b70f6e6 Compare September 7, 2022 23:05
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org September 7, 2022 23:08 Error
@jongpie jongpie force-pushed the feature/log-scenario-custom-object branch from b70f6e6 to 5608e6f Compare September 7, 2022 23:13
@jongpie jongpie temporarily deployed to Base Scratch Org September 7, 2022 23:15 Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org September 7, 2022 23:15 Inactive
@jongpie jongpie temporarily deployed to Demo Org September 7, 2022 23:36 Inactive
@jongpie jongpie temporarily deployed to Demo Org September 7, 2022 23:49 Inactive
@codecov
Copy link

codecov bot commented Sep 8, 2022

Codecov Report

Base: 95.14% // Head: 95.18% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (5608e6f) compared to base (3f20f6f).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 5608e6f differs from pull request most recent head 6d11972. Consider uploading reports for the commit 6d11972 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #356      +/-   ##
==========================================
+ Coverage   95.14%   95.18%   +0.03%     
==========================================
  Files          51       52       +1     
  Lines        4989     5023      +34     
  Branches       96       96              
==========================================
+ Hits         4747     4781      +34     
  Misses        238      238              
  Partials        4        4              
Flag Coverage Δ
Apex 95.71% <100.00%> (+0.03%) ⬆️
LWC 91.86% <ø> (ø)

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

Impacted Files Coverage Δ
...-logger/core/main/logger-engine/classes/Logger.cls 95.16% <ø> (ø)
...in/log-management/classes/LogEntryEventHandler.cls 93.31% <100.00%> (+0.27%) ⬆️
...er/core/main/log-management/classes/LogHandler.cls 98.70% <100.00%> (+0.15%) ⬆️
...g-management/classes/LogManagementDataSelector.cls 100.00% <100.00%> (ø)
...n/log-management/classes/LoggerScenarioHandler.cls 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jongpie jongpie merged commit 5f59b7a into main Sep 8, 2022
@jongpie jongpie deleted the feature/log-scenario-custom-object branch September 8, 2022 02:06
jongpie added a commit that referenced this pull request Sep 22, 2022
* Closed #347 & #356 by deprecating LogScenarioRule__mdt object & replacing it with a new object LoggerScenarioRule__mdt that provides optional overrides for all fields on LoggerSettings__c

* Added new Apex class LogScenarioRule to manage accessing LoggerScenarioRule__mdt CMDT records

* Incorporated the stellar idea from @jamessimone to tie LogEntry__c records to the new LoggerScenario__c object via a new lookup field LogEntry__c.EntryScenario__c

* Added new method Logger.endScenario(String) so that Apex developers can explicitly end a scenario, which then automatically rolls back to the previous scenario (and re-applies the previous scenario rule, if one exists) - another fantastic suggestion from @jamessimone

* Renamed LoggerSettings__c.DefaultLogScenario__c to LoggerSettings__c.DefaultScenario__c for consistency

* Fixed #360 by changing Logger.logDatabaseErrors() overloads to always return a non-null instance of LogEntryEventBuilder

* Updated some formatting in SlackLoggerPlugin to better format stack traces & create new plugin package version v1.5.0

* Fixed #363 by correcting some references in the migration script ./scripts/data/migrate-log-scenario-field-to-logger-scenario-object.apex

* Added content in README that links to the wiki's architecture overview

* Removed build numbers for package versions in sfdx-project.json, upgraded some packages in package.json to resolve some GitHub security alerts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Scenario-Based Logging Items related to Logger.setScenario(), LoggerScenarioRule__mdt, etc. Layer: Log Management Items related to the custom objects & Logger Console app Salesforce Feature: Reporting Anything related to reports, dashboards, and the underlying data model Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add new object LogScenario__c
3 participants