matomo-org / tag-manager

Free Open Source Matomo Tag Manager - A simple way to manage and maintain all of your (third-party) tags on your website.
https://matomo.org
GNU General Public License v3.0
168 stars 57 forks source link

Tag Manager extended plugin #729

Open Chardonneaur opened 7 months ago

Chardonneaur commented 7 months ago

Hello team,

There is an issue that the Tag Manager extended plugin is raising. When we uninstall it, as it is using some specific tags which may have been used within the previous container versions, then we cannot publish any other versions. The solution would be to be able to remove tags associated with this plugin when we are removing it. I asked to the developer to do it but he told me that it is due to the tag manager behaviour itself.

snake14 commented 7 months ago

Hi @Chardonneaur . Thank you for taking the time to create this issue. I think that I was able to recreate the issue you described. I installed the TagManagerExtended plugin, created a Hotjar tag, disabled the plugin, and tried to publish a new version of the container. I received the following error:

ERROR API[2023-11-23 20:28:01 UTC] [7989f] Uncaught exception in API: /home/jacobr/projects/matomo/plugins/TagManager/Template/Tag/TagsProvider.php(48): The tag "Hotjar" is not supported [Query: ?date=yesterday&module=API&format=json&method=TagManager.createContainerVersion&idContainer=4TJOz4fJ&idContainerVersion=&segment=&idSite=14&period=day, CLI mode: 0]

That seems like a pretty standard validation check failure, which makes sense as the tag isn't a type supported by the TagManager plugin. It seems like the TagManagerExtended plugin should implement the deactivated and/or uninstall methods to remove the tag and variable types that it added.

Edit: If the developer isn't willing to do that, I suppose we could make the validation check a unique exception type and simply ignore unsupported types. For example, we could surround the API call with a try/catch and ignore validation errors. However, if done incorrectly, that could lead to potential loss when importing a container.

Chardonneaur commented 7 months ago

Ok i am getting in contact with him right now to contribute to this ticket. Thank you for your help/support.

ronan-hello commented 7 months ago

Hi,

I'm the developer behind the TagManagerExtended plugin. And I understand the Tag Manager behavior in this situation.

I think that if we want more plugins with custom tags, Matomo should handle the situation where Tags is not recognised, and just ignore the tag in the container. A global tags check before editing the container could be useful and add to the Matomo core TagManager plugin ?

If the situation is fixed from the plugin, then the situation isn't fixed at all right ?

snake14 commented 7 months ago

Hi @ronan-hello . Thank you for reaching out. Up until this point, I believe that developers have created pull requests on this project when they wanted to add new Tag/Variable templates. This is the first case that I know of in which we've had a second plugin add more templates for the TagManager plugin.

I can see both sides. The TagManager plugin should probably handle the situation more gracefully. However, it makes sense for the make the situation known when there's a Tag/Variable type that isn't supported by the plugin. We could simply ignore them, but then customers might wonder what happened to Tags/Variables that they used to have. In that regard, I wonder if it would make more sense for the plugin that supports the types to warn the user that those types will be removed when the plugin is uninstalled?

ronan-hello commented 7 months ago

Hi @snake14 ,

Thank your for your response. For sure, I can update the plugin in order to prevent bad usage before remove/uninstall the custom plugin.

At this time, several plugins use custom Tags:

Regards, Ronan

snake14 commented 7 months ago

Thank you @ronan-hello

@Stan-vw It looks like there are already other plugins that create custom tags. With that in mind, we may want to look into a better customer experience if unsupported tag/variable types are found while importing a container or creating a new version. We could do something as simple as what I mentioned in the edit portion of my previous comment, but that would simply ignore unsupported types instead of notifying the customer.

AltamashShaikh commented 7 months ago

@ronan-hello We reviewed the work with the team, and our recommendation is for plugins to handle uninstalling gracefully

Stan-vw commented 1 week ago

We're considering if it's possible to start regularly incorporating new community created tags into the base Matomo Tag Manager library. This way, these tags will also be available in cloud, and the issue described in this ticket will be automatically resolved.

For transparency: this would still have some limitations, as we'd still need to check every tag for things like security and usability before deploying it, and this work will need to be prioritised against other product changes. However, if community tags are of high quality these checks might be small and might therefore be done reasonably quickly.

I'm keen to hear your thoughts on this @ronan-hello, as well as any other community developers that have created/want to create new tags for Matomo.