New app charge (Shopify partner trigger)

Hi,
I am using as source Shopify Partner connection and cstching New app charge events. My problem is that in log I can see e.g. 20 transactions, but in the event I see recorder just the last one. Is there some way how to process as events all the transaction received? I am polling every 20 minutes.

Hi @zimous ,

Correct me if I’m wrong but it sounds like you’re trying to execute your workflow against all past transactions on your Shopify Partner account?

If so, enable the Pagination option in the source.

This will change the source to look backwards through all of your transactions of all time.

I recommend disabling your source before you enable this option, then making sure your workflow is ready because it will start emitting events immediately.

Hi Pierce,
not all my past transactions, but all transactions that happened since the last check (in my case 20min interval). I see in log e.g. 20 transaction, but on the main page of source just one event. I saw the pagination option on other Shopify events but not on this one ;-(
Martin

Hi @zimous ,

There is a timing issue I noticed that only affects when you first create a workflow.

Since creating a the Shopify Partner Source happens before you can set up and deploy your workflow, those events it polled on the source’s first ever run won’t ever trigger the workflow.

This is because they were emitted and tracked before the workflow existed.

But in new polls it will pick up future events.

Does that describe your problem?

I see the event happened and got 1 transaction. But if I look into the log I see many more transactions. they are all new and fresh not old ones. see attached screenshots:


Hi @zimous ,

The logs of the Shopify Partner Source are showing the raw HTTP responses from Shopify which don’t filter on transactions already seen in the past.

So those logs aren’t necessarily 1:1 with new transactions never seen before by the source.

But I’ve just created my own Shopify Partner New App Charges source so I can see if this problem happens on my account too.

Hi @zimous

Just an update, there are 2 things going on.

  1. There does appear to be some kind of pagination bug with the transactions source, but launching an update for that soon. Will let you know when it’s available.

  2. The individual app charges in your app details in the Partner dashboard are not the same as the app charges in the Transactions API that this source monitors. I’ve noticed there’s a significant delay from when your app records a charge to when it’s actually “posted” to the Payouts section which is what powers this source.

Hi @zimous

We just shipped a new version of the Shopify Partner - New Transaction source.

You’ll need to delete your current source and recreate it to get this newest version.

It fixes the pagination bug and it ups the max number of transactions per poll to 100.

Thanks a lot for help Pierce. Updated and testing :wink:
Martin

Hi @pierce ,

I confirm the events are now counted all. There is still a remaining issue that if there are more events in the one run, the netAmount collected is not summed up correctly. Most likely because all the events are processed at the same time and the Data Store number isn’t updated yet. Is it possible to add some random delay for each run of the flow (processing one event) ? I can send you a recording in DM that explains it better, if needed. Thanks

Hi @zimous

Oh interesting, it sounds like you’re running into a race condition where all of the transactions are triggering separate workflow executions but at the same time.

There is a $.flow.delay() function in Node.js code steps, perhaps you can add a random delay with something like this:

// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
  async run({ steps, $ }) {
    const min = 500;
    const max = 15000;
    $.flow.delay(Math.random()* (max - min) + min);
  },
})

That will delay the action from being run from a random value between half a second and 15 seconds.

Hi Pierce,

I adjusted my code but I am still getting the race condition. Could you please check if my code is ok?

export default defineComponent({

  props: {

    data: { type: 'data_store'}

  },

  async run({ steps, $ }) {

    const min = 500;

    const max = 15000;

    $.flow.delay(Math.random()* (max - min) + min);

    const number = parseInt(this.data.get('number') ?? 0);

    console.log(number)

    const amount = parseInt(Math.round(parseFloat(steps.trigger.event.netAmount.amount)));

    console.log(amount)

    const newNumber = number + amount;

    console.log(newNumber)

    this.data.set('number', newNumber);

  },

})

Hi @zimous

Your code looks good to me on the surface, but I believe I have a no code solution to this problem.

You can adjust the Concurrency settings on your workflow so only one Shopify Partner event is processed at a time:

This should guarantee the only one transaction is updating the datastore at a time.

Great, thanks a lot for your help Pierce. I set to run once in 10s and now it works fine.

1 Like

Great to hear @zimous if there’s anything else we can help you with please let us know :slight_smile:

Hi @pierce ,
do you please have any idea why my webhook now returns this?
https://eold0w9zqpr7wp1.m.pipedream.net/