Browse files

Merge pull request #513 from NuGet/configurable-google-analytics

making the Google Analytics script configurable (fixes #455 and #511)
  • Loading branch information...
2 parents 683d7c4 + 723f814 commit 61c571bb4f1ad6d501bd23fe556b9c5d1c5a96f7 @half-ogre half-ogre committed Jun 5, 2012
Showing with 14 additions and 2 deletions.
  1. +4 −1 Scripts/Package.ps1
  2. +8 −0 Website/App_Code/ViewHelpers.cshtml
  3. +1 −1 Website/Views/Shared/Layout.cshtml
  4. +1 −0 Website/Web.config
View
5 Scripts/Package.ps1
@@ -11,6 +11,7 @@
$validationKey = $env:NUGET_GALLERY_VALIDATION_KEY,
$decryptionKey = $env:NUGET_GALLERY_DECRYPTION_KEY,
$vmSize = $env:NUGET_GALLERY_AZURE_VM_SIZE,
+ $googleAnalyticsPropertyId = $env:NUGET_GALLERY_GOOGLE_ANALYTICS_PROPERTY_ID,
$commitSha,
$commitBranch
)
@@ -32,6 +33,7 @@ require-param -value $sslCertificateThumbprint -paramName "sslCertificateThumbpr
require-param -value $validationKey -paramName "validationKey"
require-param -value $decryptionKey -paramName "decryptionKey"
require-param -value $vmSize -paramName "vmSize"
+require-param -value $googleAnalyticsPropertyId -paramName "googleAnalyticsPropertyId"
#Helper Functions
function set-certificatethumbprint {
@@ -153,6 +155,7 @@ set-machinekey $webConfigPath
#Release Tag stuff
print-message("Setting the release tags")
+set-appsetting -path $webConfigPath -name "Gallery:GoogleAnalyticsPropertyId" -value $googleAnalyticsPropertyId
set-appsetting -path $webConfigPath -name "Gallery:ReleaseName" -value "NuGet 1.6 'Hershey'"
set-appsetting -path $webConfigPath -name "Gallery:ReleaseTime" -value (Get-Date -format "dd/MM/yyyy HH:mm:ss")
set-appsetting -path $webConfigPath -name "Gallery:ReleaseSha" -value $commitSha
@@ -173,4 +176,4 @@ rm $compressionCmdBinPath
print-success("Azure package and configuration dropped to $cspkgFolder.")
write-host ""
-Exit 0
+Exit 0
View
8 Website/App_Code/ViewHelpers.cshtml
@@ -1,5 +1,6 @@
@* Generator: MvcHelper Namespace: NuGetGallery*@
+@using System.Configuration
@using System.Linq;
@using System.Collections;
@using System.Web.Mvc;
@@ -90,4 +91,11 @@
at @time.
</p>
}
+}
+
+@helper AnalyticsScript() {
+ var propertyId = ConfigurationManager.AppSettings["Gallery:GoogleAnalyticsPropertyId"];
+ if (propertyId != null) {
+ @Analytics.GetGoogleHtml(propertyId);
+ }
}
View
2 Website/Views/Shared/Layout.cshtml
@@ -11,7 +11,7 @@
<script src="@Url.Content("~/Scripts/modernizr-2.0.6-development-only.js")"></script>
<script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")"></script>
@MiniProfiler.RenderIncludes()
- @Analytics.GetGoogleHtml("UA-177588-7")
+ @ViewHelpers.AnalyticsScript()
@RenderSection("TopScripts", required: false)
</head>
<body>
View
1 Website/Web.config
@@ -22,6 +22,7 @@
<add key="Gallery:ReleaseSha" value="" />
<add key="Gallery:ReleaseBranch" value="" />
<add key="Gallery:ReleaseTime" value="" />
+ <add key="Gallery:GoogleAnalyticsPropertyId" value="" />
<add key="Configuration:SiteRoot" value="http://nuget.org/" />
</appSettings>
<connectionStrings>

0 comments on commit 61c571b

Please sign in to comment.