diff --git a/Microsoft.PWABuilder.IOS.Web/Controllers/PackagesController.cs b/Microsoft.PWABuilder.IOS.Web/Controllers/PackagesController.cs index 1dab235..8f58545 100644 --- a/Microsoft.PWABuilder.IOS.Web/Controllers/PackagesController.cs +++ b/Microsoft.PWABuilder.IOS.Web/Controllers/PackagesController.cs @@ -37,6 +37,7 @@ public async Task Create(IOSAppPackageOptions options) analyticsInfo.platformId = HttpContext.Request.Headers.TryGetValue("platform-identifier", out var id) ? id.ToString() : null; analyticsInfo.platformIdVersion = HttpContext.Request.Headers.TryGetValue("platform-identifier-version", out var version) ? version.ToString() : null; analyticsInfo.correlationId = HttpContext.Request.Headers.TryGetValue("correlation-id", out var corrId) ? corrId.ToString() : null; + analyticsInfo.referrer = HttpContext.Request.Query.TryGetValue("ref", out var referrer) ? referrer.ToString() : null; } try diff --git a/Microsoft.PWABuilder.IOS.Web/Models/AnalyticsInfo.cs b/Microsoft.PWABuilder.IOS.Web/Models/AnalyticsInfo.cs index a64e8fd..db8f7a8 100644 --- a/Microsoft.PWABuilder.IOS.Web/Models/AnalyticsInfo.cs +++ b/Microsoft.PWABuilder.IOS.Web/Models/AnalyticsInfo.cs @@ -5,6 +5,6 @@ public class AnalyticsInfo public string? platformId { get; set; } = null; public string? platformIdVersion { get; set; } = null; public string? correlationId { get; set; } = null; - + public string? referrer { get; set; } = null; } } diff --git a/Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs b/Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs index 38d2874..65aa9c1 100644 --- a/Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs +++ b/Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs @@ -31,14 +31,7 @@ public class AnalyticsService this.http = httpClientFactory.CreateClient(); this.logger = logger; this.telemetryClient = telemetryClient; - if (!string.IsNullOrEmpty(this.settings.Value.ApplicationInsightsConnectionString)) - { - this.isAppInsightsEnabled = true; - } - else - { - this.isAppInsightsEnabled = false; - } + this.isAppInsightsEnabled = !string.IsNullOrEmpty(this.settings.Value.ApplicationInsightsConnectionString); } public void Record(string url, bool success, IOSAppPackageOptions.Validated? packageOptions, AnalyticsInfo? analyticsInfo, string? error) @@ -82,6 +75,10 @@ record = new() { { "URL", url.ToString() }, { "IOSPackageError", error ?? "" } } record.Add("PlatformVersion", analyticsInfo.platformIdVersion); } } + if(analyticsInfo?.referrer != null) + { + record.Add("Referrer", analyticsInfo.referrer); + } telemetryClient.TrackEvent(name, record); ; } diff --git a/README.md b/README.md index 5d2c288..1d7d6ba 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,19 @@ The iOS PWA template code is located in [/Microsoft.PWABuilder.IOS.Web/Resources The code is a fork of https://github.com/khmyznikov/ios-pwa-wrap, licensed under [The Unlicense](https://unlicense.org/). A big thanks to Gleb for permitting PWABuilder to to use, fork, and improve on his PWA template. -# Running locally +# Running Locally -Open the solution in Visual Studio and hit F5 to run. https://localhost:44314 will open with a page allowing you to test the service. +You will need [Docker](https://www.docker.com/products/docker-desktop/) and the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) to run this service locally. -You may also generate a package manually by POSTing to `/packages/create` with the following JSON body: +Steps: + +1. Run `az acr login -n pwabuilder` to authenticate with our Azure Container Registry. + +2. Run `docker-compose up` to start the service. + +3. Visit `localhost:5000` to see the iOS packaging testing interface. + +Alternately, you can POST to `/packages/create` with the following JSON body: ```json {