feat: add google analytics

This commit is contained in:
Stevan Freeborn
2024-04-14 10:49:57 -05:00
parent 110c79a05e
commit 1c512e6875
7 changed files with 15 additions and 2 deletions
+1
View File
@@ -66,5 +66,6 @@ jobs:
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
export GOOGLE_ANALYTICS_TAG="${{ secrets.GOOGLE_ANALYTICS_TAG }}"
chmod +x blog.stevanfreeborn.com/deploy.ps1
sudo pwsh ./blog.stevanfreeborn.com/deploy.ps1 ${{ needs.build.outputs.version }}
+2 -1
View File
@@ -8,7 +8,8 @@ function StartContainer {
$containerName = "blog.stevanfreeborn.com.$containerColor"
$postDirEnv = "FilePostServiceOptions__PostsDirectory=wwwroot/posts"
$containerId = docker run -d -p 8080 --name $containerName --env $postDirEnv $dockerTag
$googleTagEnv = "GoogleAnalyticsTag=$env:GOOGLE_ANALYTICS_TAG"
$containerId = docker run -d -p 8080 --name $containerName --env $postDirEnv --env $googleTagEnv $dockerTag
if ($LASTEXITCODE -ne 0)
{
+1
View File
@@ -8,6 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blazor-Analytics" Version="3.12.0" />
<PackageReference Include="Markdig" Version="0.36.2" />
<PackageReference Include="System.ServiceModel.Syndication" Version="8.0.0" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="21.0.2" />
+2
View File
@@ -13,10 +13,12 @@
<body>
<Routes />
<NavigationTracker />
<script src="https://cdn.jsdelivr.net/npm/anchor-js/anchor.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js"></script>
<script src="prism.js"></script>
<script src="_framework/blazor.web.js"></script>
<script src="_content/Blazor-Analytics/blazor-analytics.js"></script>
</body>
</html>
+2
View File
@@ -9,3 +9,5 @@
@using Blog
@using Blog.Components
@using Blog.Components.Utils
@using Blazor.Analytics
@using Blazor.Analytics.Components
+5
View File
@@ -1,3 +1,5 @@
using Blazor.Analytics;
var builder = WebApplication.CreateBuilder(args);
builder.Services.ConfigureOptions<FilePostServiceOptionsSetup>();
@@ -6,6 +8,9 @@ builder.Services.AddScoped<IPostService, FilePostService>();
builder.Services.AddRazorComponents();
var googleTag = builder.Configuration["GoogleAnalyticsTag"];
builder.Services.AddGoogleAnalytics(googleTag);
var app = builder.Build();
if (app.Environment.IsProduction())
+2 -1
View File
@@ -10,5 +10,6 @@
"FilePostServiceOptions": {
"PostsDirectory": "wwwroot/posts"
},
"DetailedErrors": "true"
"DetailedErrors": "true",
"GoogleAnalyticsTag": ""
}