Skip to content

Warn on first use of deprecated resources - #279

Merged
alex-leb merged 1 commit into
masterfrom
warn-on-deprecated-resources
Oct 23, 2026
Merged

alex-leb merged 1 commit into
masterfrom
warn-on-deprecated-resources

Conversation

@alex-leb

Copy link
Copy Markdown
Collaborator

Stacked on #276: the Domainstatistics warning names Mailjet::Statistics_recipient_esp, which #276 adds. Merge #276 first, then retarget this PR to master.

Summary

Mailjet plans to shut down the endpoints on its deprecated list, and 15 resource classes still wrap them. Nothing told callers to migrate before the shutdown.

Changes

  • Add a replaced_by setting to Mailjet::Resource. A class that sets it prints one warning through Kernel.warn the first time it connects, naming its replacement. Running Ruby with -W0 silences it.
  • Mark the 15 deprecated classes with the replacements Mailjet's API reference names:
Deprecated Replacement
Newsletter, Newsletter_detailcontent, Newsletter_schedule, Newsletter_send, Newsletter_status, Newsletter_test the matching Campaigndraft* class
Apikeytotals, Campaigngraphstatistics, Campaignstatistics, Graphstatistics, Liststatistics, Messagestatistics, Openstatistics, Senderstatistics Statcounters, with the matching counter_source, counter_timing or counter_resolution
Domainstatistics Statistics_recipient_esp

What a caller sees, once per class:

[mailjet] Mailjet::Apikeytotals is deprecated and will be removed in 2.0.0. Use Mailjet::Statcounters with counter_source: "APIKey" instead.

Requests and responses are unchanged.

Testing

  • New spec/mailjet/resource_deprecation_spec.rb: a deprecated resource warns once and names its replacement; a current resource never warns; exactly 15 resources are deprecated and each names a class that exists.
  • The spec helper stubs only these [mailjet] … is deprecated warnings, so the existing specs that use deprecated classes stay quiet.
  • Full suite: 155 examples, 0 failures, 7 pending, also with no API keys set.

@alex-leb alex-leb self-assigned this Oct 23, 2026
Base automatically changed from add-statistics-recipient-esp to master October 23, 2026 10:51
Mailjet plans to shut down the endpoints on its deprecated list, and
15 resource classes still wrap them. Nothing told callers to migrate.

Add a replaced_by setting to Mailjet::Resource. A class that sets it
prints one warning through Kernel.warn the first time it connects,
naming its replacement; -W0 silences it. Mark the 15 classes with the
replacements Mailjet's API reference names.

The spec helper keeps these warnings out of the suite output.
@alex-leb
alex-leb force-pushed the warn-on-deprecated-resources branch from 932f21a to f2851f1 Compare October 23, 2026 10:52
@alex-leb
alex-leb merged commit 80c5858 into master Oct 23, 2026
5 checks passed
@alex-leb
alex-leb deleted the warn-on-deprecated-resources branch October 23, 2026 10:57
@alex-leb alex-leb mentioned this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant