Skip to content

Beta

These App Bridge components are new, and their API may change in a minor release while in beta. Their behaviour is checked in a live Shopify admin by a local E2E suite. If something doesn't work, please open an issue.

Other APIs and types ​

APIs that shopify.dev does not list under a category, and the types used by more than one category. On this page: AppEventsApi, ShopifyQLApi.

Other APIs ​

AppEventsApi ​

interface

emit(eventHandle: string, attributes?: Record<string, AppEventAttributeValue>): Promise<AppEventEmitResult>

Sends an event to Shopify. The Promise never rejects. It resolves after App Bridge connects to the Shopify admin, and stays pending while the Shopify admin hasn't answered App Bridge's handshake. Don't await it before a save, a navigation, or another step the app user waits for.

eventHandle is the name of the event. Use a descriptive name, such as report_exported or campaign_published. To send a standard event for Shopify Analytics, use the full standard registry handle that you declared, including the shopify. prefix. The name has a maximum of 128 characters and can contain only alphanumeric ASCII characters, underscores, periods, hyphens, and forward slashes.

attributes is an optional object of key/value pairs that contains the event data. Don't include any data that, alone or in combination with other data, could identify an individual, such as names, email addresses, phone numbers, staff member IDs, and customer IDs. The object has the following restrictions:

  • Maximum 15 keys.
  • Keys are limited to 64 characters and can contain only alphanumeric ASCII characters, underscores, periods, and hyphens.
  • String values are limited to 128 characters (UTF-8).
  • Only scalar values are allowed: strings, finite numbers, and Boolean values. Arrays and nested objects aren't supported.

The Promise resolves with an object:

  • {success: true}: The Shopify admin accepted the event. An accepted event can still go unsent. {success: true} doesn't confirm that Shopify received it.
  • {success: false, error}: The Shopify admin didn't send the event, and error describes why.

For example, error describes the failure in these cases:

  • If the eventHandle or attributes don't meet the restrictions, then error describes each violation.
  • If the app exceeded the rate limit, then error is Exceeded emission rate limit.
  • If the app runs where the Shopify admin doesn't offer App Events, such as Shopify Point of Sale (POS), then error is Emit is unavailable.

The Shopify admin sends the event as soon as your app calls emit(), without asking the app user for consent. It doesn't send the event in these cases, and emit() resolves {success: false}:

  • If a Shopify employee is logged in to the store's Shopify admin, then the Shopify admin doesn't send the event.
  • If the logged-in staff member doesn't have access to your app, then the Shopify admin doesn't send the event, and it doesn't ask them to request access.

Each app can send a burst of up to 20 events from one Shopify admin tab, then 2 events per second. Your app's pages, modals, and app intents in that tab share this limit. After the limit is exceeded, emit() resolves {success: false} and doesn't send the event, until the rate falls below the limit.

Shopify records the time that it receives each event. Events from App Bridge have no timestamp or idempotency_key, so each call to emit() creates a separate event. Call emit() once for each occurrence.

Shopify validates each event again after the Shopify admin sends it. Shopify drops an event that fails this validation. Dropped events don't appear in the Dev Dashboard, and your app isn't notified. Shopify drops an event in these cases:

  • The eventHandle or attributes don't meet the restrictions above.
  • The eventHandle starts with shopify. but isn't in the standard event registry.
  • Your app isn't installed on the shop.
  • Shopify can't verify the app's session token.

To check that your events arrive, go to the Dev Dashboard and open Logs.

Used in: ShopifyGlobal

AppEventAttributeValue ​

type
ts
type AppEventAttributeValue = string | number | boolean;

Used in: AppEventsApi

AppEventEmitResult ​

type
ts
type AppEventEmitResult = {
    success: true;
} | {
    success: false;
    error: string;
};

Used in: AppEventsApi

ShopifyQLApi ​

interface

available(): Promise<boolean>

Not described in the types.

ready(): Promise<ShopifyQLStatus>

Not described in the types.

ShopifyQLStatus ​

type
ts
type ShopifyQLStatus = typeof SHOPIFYQL_AVAILABLE_STATUS | typeof SHOPIFYQL_MISSING_PERMISSIONS_STATUS | typeof SHOPIFYQL_SERVER_ERROR_STATUS;

SHOPIFYQL_AVAILABLE_STATUS ​

const
ts
declare const SHOPIFYQL_AVAILABLE_STATUS: {
    readonly status: "available";
    readonly isAvailable: true;
    readonly isError: false;
};

SHOPIFYQL_MISSING_PERMISSIONS_STATUS ​

const
ts
declare const SHOPIFYQL_MISSING_PERMISSIONS_STATUS: {
    readonly status: "error";
    readonly errorType: "MISSING_PERMISSIONS";
    readonly isAvailable: false;
    readonly isError: true;
};

SHOPIFYQL_SERVER_ERROR_STATUS ​

const
ts
declare const SHOPIFYQL_SERVER_ERROR_STATUS: {
    readonly status: "error";
    readonly errorType: "SERVER_ERROR";
    readonly isAvailable: false;
    readonly isError: true;
};

Released under the MIT License. Vue logo by Evan You, CC BY-NC-SA 4.0.