Questions and discussions about using the Shopify CLI and Shopify-built libraries.
We've been trying to use the ShopifyQL using both the legacy Embedded App SDK and the Shopify App Bridge, and neither seems to work.
Code tested for Embedded App SDK:
ShopifyApp.ready(function(){
var shopifyQL = "SHOW count() FROM visits SINCE -2w UNTIL today";
var renderData = function(response) {
// do amazing things here
};
var handleError = function(response) {
// handle missing API errors here (missing scopes, back shopifyql, etc...)
};
ShopifyApp.Analytics.fetch({
query: shopifyQL,
success: renderData,
error: handleError
});
});Code tested for Shopify App Bridge: var AppBridge = window['app-bridge'];
var createApp = AppBridge.default; var app = createApp({
apiKey: "xxxxxxxxxxxxx",
shopOrigin: "xxxxxxxxxxxxxxxxxx",
}); console.log(app); console.log(AppBridge); AppBridge.actions.Analytics.fetch({
query: 'SHOW count() FROM visits SINCE -2w UNTIL today',
success: () => { console.info('success'); },
error: () => { console.info('error'); },
});(xxxxxxx in above example are filled with correct data, and app is correctly created)This code does not work because
Analytics does not exist in actions (correct according to https://help.shopify.com/en/api/embedded-apps/app-bridge/actions).
Question is: how do you initialize and query the ShopifyQL object using either the Shopify App Bridge or Embedde App SDK.
Hi Trendmo,
ShopifyQL is not supported in App Bridge, but it is supported using the Embedded App SDK. Make sure that the shop you’re trying to query is on the Advanced Shopify plan, and that your app has the reports_editing permission (https://help.shopify.com/en/api/guides/analytics-api#shop-requirements).
To learn more visit the Shopify Help Center or the Community Blog.
Hi there, thanks for getting back to us so quickly!
We are currently using a dev store to work on connecting the API. Do dev stores allow for this endpoint to be tested? Or is the reason we are getting this error because we are not on the advanced plan?
We were under the impression that dev plans can test these endpoints, rather than us upgrading to the advanced plan to pull in test data.
Development stores should have access to all advanced plan features; that shouldn’t be the issue. What is the error you’re getting?
To learn more visit the Shopify Help Center or the Community Blog.