I would like to use the Analytics API with the Shopify App Bridge instead of the Embedded App SDK.
Setup in Embedded App SDK code would like this based on the documentation:
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
});
});
From the old Embedded App SDK documentation, it mentions that ShopifyApp.ready(fn)
has " no equivalent method in Shopify App Bridge, as this functionality is no longer necessary."
I tried to migrate the code to use the Shopify App Bridge, however it did not work:
import createApp from '@shopify/app-bridge';
const app = createApp({
apiKey: '<api key>',
shopOrigin: '<origin>',
});
// This works
app.getState().then((state) => {
console.info('App State: %o', state);
});
// This doesn't work
app.Analytics.fetch({
query: 'SHOW count() FROM visits SINCE -2w UNTIL today',
success: () => { console.info('success'); },
error: () => { console.info('error'); },
});
Is it possible to use the Analytics API with the App Bridge? If not, what would be wrong with my syntax? Any documentation on this would be a big help :D
Thank you!
Regards,
Nicole
Hi Nicole,
I've noticed you seem to be having issues with Analytics API using either newer AppBridge or its predecessor EASDK.
Regarding AppBridge, I am afraid you're out of luck for now according to this issue on Github.
As for EASDK issues from your other post, I wouldn't know, never played around with EASDK or Analytics API (for the time being).
Best wishes!
@Alex can you please provide an update on this?
It's been over a year. Shopify is saying that the embedded sdk is deprecated yet we can't find a way to query ShopifyQL in bridge.
What's the status/plan?
Hi @ClementBR ,
To give you a straight update here, as of right now the Analytics API is still not supported directly by the App Bridge.
However this feature is supported through the backwards compatibility layer. So if you are looking to use this feature in your app, you can use the EASDK to write your code and then enable the App Bridge backward compatibility layer to kick in. That way you can still utilize the Analytics API and ShopiQL from your app. Read here for more details on the backward compatibility layer: https://shopify.dev/tools/app-bridge/migrating
(Note I believe some users using the backward compatibility layer are seeing and error about "StaffMember ID is missing". We are looking into this currently, and there is another ongoing thread providing support for this: https://community.shopify.com/c/Shopify-APIs-SDKs/What-s-meaning-quot-StaffMember-ID-is-missing-quot...)
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
@hassain can you please provide more details or an example?
The docs are extremely light and there is nothing about using ShopifyQL with Bridge.
Do we have to include BOTH easdk AND bridge to make this work?
@hassain we are working through our migration to Bridge but we can't get this to work.
We initialized both bridge and EASDK but when we call the fetch method, neither the success callback nor the error callback is called.
ShopifyApp.Analytics.fetch({
query: strSql,
success: onSuccess,
error: onError
});
Can you help us out here?
Not sure how we expected to migrate to Bridge.
User | Count |
---|---|
13 | |
12 | |
7 | |
4 | |
4 |