Fetch GA scripts server-side
Closed this issue · 0 comments
alansemenov commented
The app is now using three remote GA scripts: one to fetch GA API and two (one, two) to render the map. (The last two will only be used if ga.mapsApiKey
is set in the config. )
After implementation of CSP in Content Studio, these scripts will no longer work.
Replace client-side requests to these scripts with requests to local services which will in turn fetch data from the actual sources and return them to the client.
Also, since it's the validity of config which decides whether to append the scripts (and which scripts to append), we can make these scripts a part of the template and get rid of "dynamic appending" client-side. Then we don't need id
on the widget tag etc.
<widget>
<script data-th-if="${configValid}" data-th-src="${portal.serviceUrl({'_path=ga-script-1'})}"></script>
<script data-th-if="${useMapsApi}" data-th-src="${portal.serviceUrl({'_path=ga-script-2'})}"></script>
</widget>