-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Calling a custom js variable within a custom js variable within a custom js variable leads to an error #869
Comments
Hi @SW-Vincent . Thank you for taking the time to create this issue. I'm not sure If I quite follow the issue. I tested nested Custom JS variables and they worked as expected. For example, I had variable 1 return a string value, variable 2 return the value of variable 1 concatenated with another string, and variable 3 return the value of variable 2 concatenated with a string. I didn't see any errors in debug mode or after publishing and variable 3 displayed the expected value. |
Hi @snake14, Considering the test you made, you understood the issue. I reproduced your test with the following custom JS on 2 Matomo Cloud accounts :
The issue occured on one of the two Matomo Cloud accounts i ran the test on. Note that for the issue occurs even when the variable is never called. I took the risk of publishing the container on the account that didn't show the issue (where CSP blocks the preview) and here is what i get :
There is no issue once published (as you can see the 1st level variable isn't decompliled within the 3rd level variable), so it may be a preview issue only. |
@SW-Vincent That looks very similar to the test that I ran. However, I didn't see any errors in the JS console while in preview mode and the string output as expected. Maybe it's browser specific. I'm testing using the Brave browser. What browser are you testing with? Also, what's the rest of your environment (version of Matomo, ...) look like? |
@snake14 I ran my previous tests on Chrome, with Matomo Helper Chrome extension active.
I used Matomo Cloud accounts for all the tests so i don't keep track of the version. |
@SW-Vincent I'm still unable to reproduce the issue. I tested on a Matomo Cloud instance (altamash.matomo.cloud), created variables nearly identical to what you described above, and I can see the variables outputting the expected values in preview mode. I tried Brave, Firefox, Chrome, and Opera; All of the browsers that I tried worked as expected. Any suggestions @AltamashShaikh ? |
@SW-Vincent I tried creating 3 variables
I can see the following output in debug window I published this changes and it seems to work fine for me too |
A few specifications about my case :
Can you confirm to me that there is no CSP error in your console ? |
@SW-Vincent No CSP error and I tested in both preview and publish mode. |
Then may i email you the matomo URL so we can check wether this is a Matomo Tag Manager issue or not ? |
@SW-Vincent sure 👍 |
@SW-Vincent Can you check again ? |
Hi @AltamashShaikh , I performed a new test and everything semms to work in both preview and live versions ! I noticed doing so that there is no error handling preventing you from deleting a variable (any type) that would be called within a custom JS variable (on the other hand, this kind of error handlin does exist for variables called in tags and triggers). |
@SW-Vincent I didn't get you, any screenshots ? |
@SW-Vincent Got your problem, thanks to @snake14, can you create a new ticket with the issue ? So that we can prioritise it |
Just created #895 |
Thanks 👍 and can we close this issue now ? @SW-Vincent |
Yes we can ! |
Matomo Tag Manager recently added a feature to import variables within custom JS variables.
This feature is great overall : you can call a custom JS variable within a custom JS variable and while Matomo UI code will look like this :
the code that is actually set by Matomo Tag Manager looks like this :
Now we're getting to the bug : you noticed that the clickHostName variable is calling the customJSFunction as an object, with TagManager._buildVariable.parameters.jFunction being a string.
If within this string there is an other custom JS function call, the " characters within the function reference will escape the string, leading to an error "Unexpected identifier 'name'"
The text was updated successfully, but these errors were encountered: