[Bug report] Interactions return nothing

Hi all,
In my plugin, I am trying to fetch all the interactions but it seems the API is always returning null.
Here is the code and I am 100% sure there is at least one interaction in the document:-

const interactions = require(‘interactions’);
async function myEntryPluginEntryPoint(selection, root) {
var allInteractions = interactions.allInteractions;
console.log(Interactions: ${allInteractions.length});
allInteractions.forEach(interaction =>{
console.log("Trigger: " + interaction.trigger.type + " -> Action: " + interaction.action.type);
})
}

Thanks,

@DavidXD - See above ^^^^

1 Like

Thank you @kerrishotts @DavidXD. Here is another exact issue reported in the comments section Aug 4th 2020, so you can close both (and to be frank, it is disappointing that it was reported for that long without a fix)(How to get the type of object that has an interaction?).

interactions.allInteractions returns an array of interactions. And each of those interactions contains a “triggerNode” and a nested “interactions” array, which is a little confusing:

{triggerNode: Ellipse ('Ellipse 1') {...}, interactions: [{trigger: [Object], action: [Object]}]}

The elements in the nested “interactions” array contain “trigger.type” and “action.type”. This code works for me in XD 34:

const interactions = require("interactions");

let allInteractions = interactions.allInteractions;
    console.log("All interactions length: " + allInteractions.length);
    allInteractions.forEach(myInt => {
        console.log("myInt: ", myInt);
        if (myInt.triggerNode) {
            console.log("myInt.triggerNode: ", myInt.triggerNode);
        }
        if (myInt.interactions) {
            console.log("   myInt.interactions.length: " + myInt.interactions.length);
            myInt.interactions.forEach(myDetailedInt => {
                console.log("   myDetailedInt: ", myDetailedInt);
                if (myDetailedInt.trigger) {
                    console.log("   myDetailedInt.trigger.type: ", myDetailedInt.trigger.type);
                }
                if (myDetailedInt.action) {
                    console.log("   myDetailedInt.action.type: ", myDetailedInt.action.type);
                }
            });
        }
    });
1 Like

@DavidXD, thank you so much for your time, I really appreciate that. I made a simple xd file, a rectangle and a circle, I have one interaction between the rectangle and the circle. I executed your code as is and I get zero length interactions.
I have xd 34.1.12.9 running on Mac.
Here is a link to the xd file that I pointed above.
As in my previous comment, there is another developer mentioning the same issue.
Any idea what to do, I am running out of options.
Thanks,
Ilam

Thank you for the XD document. That helps me better understand that your document has Scroll-To interactions, and that is the type of interaction that is missing from what is returned by the “interactions.allInteractions” API. Unfortunately that is a limitation of this API at this time as stated in the documentation:

I wrote a feature request on our internal system to make sure this issue is being tracked. And I’m sorry to say that I do not think there is any workaround.

Makes perfect sense @DavidXD. Sorry I didn’t pay attention it is a scroll type, I was thinking tap is not excluded and that is it.
Thanks for your time and excellent product.