Analytics API with Shopify App Bridge?

Nicole_Tan
Shopify Partner
11 0 3

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

KarlOffenberger
Shopify Partner
1867 182 777

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!

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
0 Likes
Alex
Shopify Staff
Shopify Staff
1555 81 293

Just chiming in to say that at this time you cannot use the analytics API at the same time as App Bridge. We're currently working on finding a path forward with handling the analytics API working with App Bridge.

0 Likes
ClementBR
Shopify Partner
110 2 18

@Alex  are there any updates with that?

 

0 Likes
ClementBR
Shopify Partner
110 2 18

@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?

0 Likes
ClementBR
Shopify Partner
110 2 18

Any updates on this?

How are we expected to upgrade to Bridge otherwise?

0 Likes
hassain
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 134

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 

0 Likes
ClementBR
Shopify Partner
110 2 18

So you are saying that we can use both Bridge and EASDK at the same time?

 

Are there no plans of implementing ShopifyQL/Analytics in Bridge?

0 Likes
ClementBR
Shopify Partner
110 2 18

@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?

0 Likes
ClementBR
Shopify Partner
110 2 18

@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.  

0 Likes