Thanks @koulesali, you could try the following, which should work.
As well as replacing analytics
with window.analytics
,
Go to the script provided by segment.
At the start of the script you’ll find this expression:
var analytics=window.analytics=window.analytics||[];
replace it with
var analytics=window.analytics=window.analytics||Object.create(Array.prototype);
This is a bit of hack, but it should work.
It tells Anvil’s Javascript <-> Python bridge to not treat window.analytics as a Python list
Segment does some unconventional overloading of a Javascript Array, which we’re not able to handle when we convert it to a Python list