feat: emit :reauthorization_required telemetry event - #2
Closed
helording wants to merge 1 commit into
Closed
Conversation
Surface a dedicated `[:ex_shopify_app, :access_token, :refresh,
:reauthorization_required]` event whenever a call resolves to
`:reauthorization_required`, so host apps can react to chains that can no
longer be refreshed (the merchant must relaunch the app to reauthorize).
It fires on every path that produces the result:
* `valid_token/2` short-circuiting on an already-expired refresh token
before any HTTP call (previously emitted no telemetry at all);
* the locked refresh re-checking expiry under the row lock;
* Shopify rejecting a refresh with `invalid_grant`.
The latter two flow through `refresh_stop/3`, which now emits the event when
the classified result is `:reauthorization_required`. Metadata carries
`:shopify_domain` only — never token values.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
Superseded by the upstream PR against NexPB/ex_shopify_app, stacked on NexPB#3 (keepalive-refresher). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a dedicated telemetry event,
[:ex_shopify_app, :access_token, :refresh, :reauthorization_required], that fires whenever an access-token operation resolves to:reauthorization_required— i.e. the token chain can no longer be refreshed and the merchant must relaunch the app to reauthorize.Why
:reauthorization_requiredis the one outcome a host app genuinely needs to act on (prompt re-auth, alert, flag the shop), but until now it was easy to miss:valid_token/2short-circuits on an already-expired refresh token beforerefresh_token/2, so it emitted no telemetry at all.:stopevent's:resultmetadata, alongside every successful refresh — there was no event a handler could subscribe to directly.How
A single public emitter,
Telemetry.reauthorization_required/1, is now called on every path that yields the result:valid_token/2's early short-circuit (explicit call, since it never enters the refresh span).invalid_grant— both flow throughrefresh_stop/3, which emits the event when the classified result is:reauthorization_required.Metadata carries
:shopify_domainonly — never token values, consistent with the other events in this module.Tests
Adds coverage for all three paths in
RepoTest(already-expired refresh token viavalid_token/2and viarefresh_token/2, and a Shopifyinvalid_grant). Full suite green (63 tests),mix formatclean, compiles with--warnings-as-errors.🤖 Generated with Claude Code