Skip to content

Add App Events logging API - #1459

Open
kristianpd wants to merge 3 commits into
Shopify:mainfrom
kristianpd:app-events-log
Open

Add App Events logging API#1459
kristianpd wants to merge 3 commits into
Shopify:mainfrom
kristianpd:app-events-log

Conversation

@kristianpd

@kristianpd kristianpd commented Aug 24, 2026

Copy link
Copy Markdown

Description

Adds the Ruby SDK counterpart to shopify-app-js App Events logging:

  • ShopifyAPI.log validates and posts one App Event to the Global API.
  • ShopifyAPI::Auth::GlobalApiClientCredentials.global_api_client_credentials mints and caches the app-level JWT.
  • ShopifyAPI::Context.global_api_url supports HTTPS-only non-production Global API hosts.
  • Tokens refresh within a 60-second expiry skew and once after an event 401.
  • Concurrent stale-token failures reuse a replacement token, while rejected tokens clear conditionally from the cache.
  • Documented expires_in and scope response fields take precedence over JWT claim fallbacks.

The request contract uses snake_case JSON, string shop IDs, the 2026-07 API version floor, and both actual and documented idempotent replay headers.

JavaScript reference: Shopify/shopify-app-js#3368

How has this been tested?

  • bundle exec ruby -Ilib -Itest test/app_events_test.rb
  • bundle exec ruby -Ilib -Itest test/app_events/event_payload_test.rb
  • bundle exec ruby -Ilib -Itest test/auth/global_api_client_credentials_test.rb
  • bundle exec ruby -Ilib -Itest test/context_test.rb
  • bundle exec rake test:library — 396 runs, 791 assertions
  • bundle exec rubocop — 119 files, no offenses

bundle exec srb tc cannot run on this Apple Silicon host because the locked sorbet-static binary is x86_64-only: Bad CPU type in executable. CI must provide the typecheck result.

Local Core smoke validation minted tokens, ingested events, and reported idempotent replays for 2026-07, 2026-10, and unstable. The local installation cache was primed because the Query Engine apps.app_installations view is unavailable in this environment.

Checklist:

  • My commit message follows the documented pattern.
  • I have performed a self-review of my own code.
  • I have added tests that prove my feature works.
  • I have updated the project documentation.
  • I have added a changelog line.

@github-actions github-actions Bot added the devtools-gardener Post the issue or PR to Slack for the gardener label Aug 24, 2026
@kristianpd kristianpd closed this Aug 25, 2026
@kristianpd kristianpd reopened this Aug 25, 2026
@kristianpd
kristianpd force-pushed the app-events-log branch 6 times, most recently from a49948b to 4350227 Compare August 27, 2026 14:46
@kristianpd
kristianpd marked this pull request as ready for review August 27, 2026 14:55
Add ShopifyAPI.log to send one App Event through the Global API using
app-level client credentials, without a shop session.

- Mint, cache, and refresh the Global API token from the configured
  api_key and api_secret_key, coalescing concurrent refreshes.
- Retry once after a 401 and clear the exact rejected token.
- Validate the documented payload limits before any HTTP request.
- Pin GLOBAL_API_VERSION instead of following Context.api_version.
- Report idempotent replays from the response header value.
- Add a configurable HTTPS global_api_url for non-production hosts.
is_private:,
is_embedded:,
global_api_version: DEFAULT_GLOBAL_API_VERSION,
global_api_url: DEFAULT_GLOBAL_API_URL,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

advice welcome here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devtools-gardener Post the issue or PR to Slack for the gardener

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant