fractaledmind / solid_errors

database-backed, app-internal exception tracker for Rails applications
MIT License
332 stars 17 forks source link

Add one_email_per_occurrence option and migration task #53

Closed imageaid closed 4 weeks ago

imageaid commented 4 months ago

Motivation:

We are happily using Solid Errors in our production app but because that app connects to some external APIs we can run into situations where we are sent a lot of emails for the same error's reoccurrence.

Details:

Introduced a new configuration option one_email_per_occurrence that serves to limit email notifications to one per occurrence. If an error is resolved but reoccurs, an email will be sent, again, for that first reoccurrence.

In order to do this, a migration was created to add a new column/attribute to the solid_errors table called prev_resolved_at.

This column/attribute is updated to match the resolved_at value whenever it is set - but it is never nill'ed out like resolved_at is when the issue is resolved.

A Rake task, solid_errors:install_migrations, was also added to copy any new migrations from the lib/solid_errors/db/migrate directory and then immediately run them.

The README was updated as was the error controller to support the new feature.

The .gemspec was also updated to add a note reminding users to ensure they've run the task to copy over the migration(s).

Please let me know if there's anything you'd change, do better, etc. Thank you for your excellent work on Solid Errors. We are grateful to have it!

imageaid commented 4 months ago

I like this! Thanks for such a clear and thorough PR. I've made a few comments for things to tweak to get it over the line.

Thank you so much for taking the time to review this and to add all your helpful edits and comments. Much much appreciated!

I am not sure if you need me to/if I should make some commits in my branch and redo my PR (this is my first PR to a gem so please forgive any stupidity or missteps on my part!).

Thanks, again, so much for your work. Please know how much my team appreciates Solid Errors!

fractaledmind commented 4 months ago

Yeah, you've done such a great job with the PR that I'd like you to finish it yourself and have full credit!

imageaid commented 4 months ago

Yeah, you've done such a great job with the PR that is like you to finish it yourself and have full credit!

AWESOME! Man, really appreciate it. I will make the changes and commit them shortly

imageaid commented 4 months ago

For the prev_resolved_at, I just made a commit that might be a better way? Let me know your thoughts.

Basically, I removed that element from the buttons in the _action and _row view files as well as the controller. Instead, I set it in the Subscriber just before the resolved_at value is nilled out.

Maybe less intrusive and more seamless?

Totally open to other alternatives of course!

Finally, for the migration, I just kept the rake task the same in terms of copying the migration files over. But, I killed the running of them (I have some commented out code as an alternative approach to run just the specific migration if desired) because Rails will, of course, scream and yell at us that we have pending migrations to run ... duh on my part 🤣

fractaledmind commented 4 months ago

We still need a note in the README explaining the behavior for email sending

imageaid commented 4 months ago

We still need a note in the README explaining the behavior for email sending

Just pushed a commit with an edited note about sending emails. Let me know if you think that fits the bill or needs some added massaging, etc.

fractaledmind commented 4 months ago

I know we are taking a while polishing the final exacting details, but we are close and this is a great PR. Thanks for the patience

imageaid commented 4 months ago

I know we are taking a while polishing the final exacting details, but we are close and this is a great PR. Thanks for the patience

Happy to! I like getting things polished and as close to ideal as possible. No problems at all on my end! I'll commit again later tonight. Time to go walk and feed the pups!

imageaid commented 4 months ago

Ok, Stephen, I think I got that last round of changes in place. Thanks for catching the spelling error(s) 🤦🏻

Let me know how that README line sounds about the post-install message, etc. Or any other changes you find need made. Thanks!

fractaledmind commented 4 months ago

I want to chat with @bensheldon some about how he manages versions with schema changes before merging and releasing. I want a clear plan.

bensheldon commented 4 months ago

👋🏻 Happy to chat. I can try to sketch out a few things (I've been wanting to blog about this forever!) and maybe invite further chatting.

Upfront: GoodJob does a lot of migrations. A lot! I want to say there have been about 30 migration files over its lifespan so far. That's more than like Active Storage which has... 4. So take this with a grain of salt if your gem is more like Active Storage than GoodJob.

Sorry, that's a wall of text 😅

imageaid commented 4 months ago

I pushed a small update (well, two) yesterday evening. These two ensure that, in the current approach to the migration, it does copy over correctly.

Note: I did bump the version on this branch (0.4.3.003) so I could ensure that my bundle update grabbed the newest code. That can, of course, be reverted any time.

Let me know, please, if you have any thoughts or approaches you'd like for this PR's final push. Thanks!

fractaledmind commented 4 months ago

I'm on vacation for the week. Will wrap up when I get back. Thanks for the great work.