NebulaLogger icon indicating copy to clipboard operation
NebulaLogger copied to clipboard

Implemet relatedLogEntries auto refresh based on CDC events + spinner + refresh button

Open andrii-solokh opened this issue 1 year ago • 4 comments

Motivation Working on new automation on a client project, I was generating logs in apex and attaching them to records. Each time I need to refresh the whole page, it was a bit annoying, so I thought it would be better to have a button for refresh or to auto refresh when new log created for currently open record.

Solution

  • I'm using 'Change Data Capture' events to track as new Log Entry records arrived, then refreshing Lighting Data Service results. Initially implemented 'RefreshView API', so after record update lwc should reload related log entries, but log were created with delay 1-2 seconds and they were not present in save refresh, only on second refresh, so I decided to use CDC.

Changes

  • Added spinner to let a user know - component is loading.
  • Added refresh button

Demo Changing account name generates log on record.

https://github.com/jongpie/NebulaLogger/assets/10558860/65697457-161b-47a1-b924-af82fcd44ce1

andrii-solokh avatar Jun 23 '24 08:06 andrii-solokh

Hi @andrii-solokh - I definitely like the idea of having a refresh button on the component, but I think using CDC is going to cause too many other problems:

  • CDC has a limit of only 5 objects per org - so orgs that already have 5 objects enabled in CDC won't be able to install Nebula Logger (if Nebula Logger included a dependency on CDC)
  • Using the empApi has already caused problems in orgs - it counts towards a daily subscriber limit, which can cause a lot of issues in orgs that rely on pub/sub for external systems

So I think the CDC-related changes needed to be removed, it should just be a simple refresh button (that a user would manually click to refresh). Let me know if that makes sense/if you have any questions.

jongpie avatar Jun 24 '24 16:06 jongpie

Hi, @jongpie. Thank you for response, I can't find docs telling 5 objects are the limit, only number of concurrent subscribes.

But, okay i will remove CDC part.

andrii-solokh-mnfd avatar Jun 24 '24 18:06 andrii-solokh-mnfd

Hi @andrii-solokh - apologies, I meant to include a source for the 5 object limit. It's documented here on the page 'Default Change Event Allocations'

image

You can also test out the limit in a scratch org/sandbox - if you try to add more than 5 objects to CDC, you'll get this error:

image

jongpie avatar Jun 24 '24 20:06 jongpie

@jongpie, thank you for the explanation, it looks like I should be more careful with using CDC and events in general.

Removed CDC part.

andrii-solokh avatar Jun 25 '24 12:06 andrii-solokh

@andrii-solokh this now has been officially released as v4.13.12! 🥳

Thanks again for taking the time to work on this, I really appreciate the help!

jongpie avatar Jul 07 '24 18:07 jongpie

@jongpie it was tiny one, I hope to be more helpful in future 👍🏼

andrii-solokh avatar Jul 08 '24 12:07 andrii-solokh