Access to incoming URL in REMOTE_DISPATCH

255 views
Skip to first unread message

Don Morrison

unread,
Apr 5, 2022, 5:20:13 PM4/5/22
to nodeGame
When using REMOTE_DISPATCH, is there anyway inside the preprocess
property/function of that object to gain access to the URL that was
used to reach the waiting room, or at least the incoming query
parameters from that URL? The issue is that typically we do various
bits of preliminary work like surveys and so on in Qualtrics or
something similar, and need to pass along an ID from that earlier work
that will then be passed into the experiment proper. With access to
the incoming URL Ι could, I think, easily parse out such an ID and
pass it along using the preprocess function.

Thanks!


--
Don Morrison <df...@cmu.edu>
“Bugs are not going to inherit the earth. They own it now.”
– Neil A Campbell, Jane B Reece, et al., /Biology/

Stefano Balietti

unread,
Apr 5, 2022, 5:46:39 PM4/5/22
to node...@googlegroups.com
Hi Don,

It's possible, but a bit tricky. You could do this:

- Enable authorization (e.g., external mode)
- Get the headers in the decorator function in auth/auth.js

function decorateClientObj(clientObj, info) {
        clientObj.headers = info.headers ?? {};
}

- Get the headers back in the dispatch function through the registry

preprocess: (url, treatment, group, waitRoom) => {
    // Pseudocode
    let headers = waitRoom.channel.registry.getClient(ID).headers;
    // Do something 
    // headers.referer contains the full url, including parameters (need parsing). 
}

This procedure should be simplified in future releases.

Cheers,
Stefano

--
You received this message because you are subscribed to the Google Groups "nodeGame" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodegame+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodegame/CAO9hiFUR5tuO4VH6b2-hgo1ZAsh9KTAfaGFtGb84oHgaMuR3%2BA%40mail.gmail.com.

Don Morrison

unread,
Apr 11, 2022, 1:02:34 PM4/11/22
to nodeGame
On Tue, Apr 5, 2022 at 5:46 PM Stefano Balietti <futur...@gmail.com> wrote:
> - Get the headers back in the dispatch function through the registry
>
> preprocess: (url, treatment, group, waitRoom) => {
> // Pseudocode
> let headers = waitRoom.channel.registry.getClient(ID).headers;
> // Do something
> // headers.referer contains the full url, including parameters (need parsing).
> }

It appears to me that preprocess() is only being called once per
group, returning the same URL for all members of that group. If true,
that makes it unable to pass through each group member’s ID, no? Am I
missing something?


--
Don Morrison <d...@ringing.org>
“The future came and went in the mildly discouraging way that futures
do.” — Neil Gaiman and Terry Pratchett, /Good Omens/

Stefano B

unread,
Apr 11, 2022, 1:41:16 PM4/11/22
to node...@googlegroups.com
That's correct, it's called once per group, and you have all the IDs inside the group array (third parameter). 
Do you want to modify the URL for each group participant? The idea is that once they arrive at a third-party server they have only their unique ID as parameter? 


--
You received this message because you are subscribed to the Google Groups "nodeGame" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodegame+u...@googlegroups.com.

Don Morrison

unread,
Apr 11, 2022, 1:46:03 PM4/11/22
to nodeGame
On Mon, Apr 11, 2022 at 1:41 PM Stefano B <stefanoba...@gmail.com> wrote:
> Do you want to modify the URL for each group participant? The idea
> is that once they arrive at a third-party server they have only
> their unique ID as parameter?

Correct. We need to be able to tie the participants back to what they
entered, individually, in Qualtics surveys and the like before being
redirected to the waiting room to be bunched up with others.

Thanks!


--
Don Morrison <d...@ringing.org>
“London was not designed for cars. Come to that, it wasn’t designed
for people. It just sort of happened. This created problems, and the
solutions that were implemented became the next problems, five
or ten or a hundred years down the line.”

Stefano B

unread,
Apr 11, 2022, 1:50:13 PM4/11/22
to node...@googlegroups.com
I could implement that feature, but could then a group size of 1 and a pool size of, e.g., 4 achieve what you want? 
If you need to keep track of the group id you could manually add keeping a local variable (or variable in the waitRoom) being incremented every 4 dispatches.


--
You received this message because you are subscribed to the Google Groups "nodeGame" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodegame+u...@googlegroups.com.

Don Morrison

unread,
Apr 11, 2022, 1:57:41 PM4/11/22
to nodeGame
On Mon, Apr 11, 2022 at 1:50 PM Stefano B <stefanoba...@gmail.com> wrote:
> could then a group size of 1 and a pool size of, e.g., 4 achieve
> what you want? If you need to keep track of the group id you could
> manually add keeping a local variable (or variable in the waitRoom)
> being incremented every 4 dispatches.

That sounds like it might work, thanks!

I presume this all happens in serial fashion so I don’t have to worry
about a possible race condition with that variable that defines the
groups or anything nasty and subtle like that?


--
Don Morrison <d...@ringing.org>
“The pool of starving actors is larger than the one of
starving accountants, even if you assume that, on average,
they earn the same income.”
— Nassim Nocholas Taleb, /The Black Swan/

Stefano B

unread,
Apr 11, 2022, 2:03:24 PM4/11/22
to node...@googlegroups.com
I can't think of any such issues happening for this use case. However, I haven't tried it out before, please let me know if you observe something weird.

--
You received this message because you are subscribed to the Google Groups "nodeGame" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodegame+u...@googlegroups.com.

Don Morrison

unread,
Apr 12, 2022, 2:15:26 PM4/12/22
to nodeGame
On Mon, Apr 11, 2022 at 2:03 PM Stefano B <stefanoba...@gmail.com> wrote:
> Am Mo., 11. Apr. 2022 um 19:57 Uhr schrieb Don Morrison <d...@ringing.org>:
> > On Mon, Apr 11, 2022 at 1:50 PM Stefano B <stefanoba...@gmail.com> wrote:
> > > could then a group size of 1 and a pool size of, e.g., 4 achieve
> > > what you want? If you need to keep track of the group id you could
> > > manually add keeping a local variable (or variable in the waitRoom)
> > > being incremented every 4 dispatches.
> >
> > That sounds like it might work, thanks!
> >
> > I presume this all happens in serial fashion so I don’t have to worry
> > about a possible race condition with that variable that defines the
> > groups or anything nasty and subtle like that?
>
> I can't think of any such issues happening for this use case.
> However, I haven't tried it out before, please let me know if you
> observe something weird.

It seems to be working fine. I’ve only tested it with just myself
working in multiple panes in one browser, not the potentially more
stressful condition of lots of MTurkers from all over the place
roughly simultaneously. When we try that in a few weeks I’ll let you
know if we encounter any problems.

Thanks!


--
Don Morrison <d...@ringing.org>
“The very powerful and the very stupid have one thing in common. They
don’t alter their views to fit the facts. They alter the facts to fit
their views.” — /Dr Who/ (“The Face of Evil” episode)

Stefano B

unread,
Apr 12, 2022, 2:37:45 PM4/12/22
to node...@googlegroups.com
If I have some time, I will test it or implement a new feature. In the meantime you could also use:

waitingRoom.numberOfDispatches

to count groups

--
You received this message because you are subscribed to the Google Groups "nodeGame" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodegame+u...@googlegroups.com.

Don Morrison

unread,
Apr 12, 2022, 4:07:21 PM4/12/22
to nodeGame
On Tue, Apr 12, 2022 at 2:37 PM Stefano B <stefanoba...@gmail.com> wrote:
> In the meantime you could also use:
>
> waitingRoom.numberOfDispatches
>
> to count groups

Many thanks! I’ve changed things to use that, as does seem a little
tidier and safer than maintaining my own counter.



--
Don Morrison <d...@ringing.org>
“He waited for the onset of sleep, against a chorus of howls, shrieks,
mysterious distant bangs, surreptitious rustlings, screeches,
disconcerting ticking noises, dreadful scratching sounds, terrible
flapping of wings very close, and all the rest of the unholy
orchestra that is known as the peace of the countryside.”
— Terry Pratchett, /Snuff/
Reply all
Reply to author
Forward
0 new messages