Fixed an issue that prevented Google Tag Manager to create scripts and delete connection #4457
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4452
Fixes #4453
Summary
Both issues were found in the GTM Connector I previously contributed, but I found #4453 (Null Reference exception thrown on deletion of connection) to also occur with the GA Connector (which makes sense since the GTm Connector was initially a copy of that one).
To fix that I added null-checks in a few places.
The other issue is not a bug, but it's a valid point that it's not very friendly to make the user manually edit SiteAnalytics.config before being able to use the GTM connector.
So I added code to check siteanalytics.config for the presence of a script for it. If there is none, the default script is added. If there is any (which could be edited in the installation) it's not changed.
However, I have one issue in the code. To find SiteAnalytics.config, I wanted to use Globals.ApplicationMapPath, but that's now oboslete. The message tells me to
Use Dependency Injection to resolve 'DotNetNuke.Abstractions.IApplicationStatusInfo' instead.
but to be honest, I have no clue how. So could anyone be of assistence here? @ahoefling maybe?