From 08e0037a80be5d5e8061df788574f501f22fa6eb Mon Sep 17 00:00:00 2001 From: Zach Teutsch <88554871+zateutsch@users.noreply.github.com> Date: Sun, 3 Dec 2023 14:59:00 -0800 Subject: [PATCH 1/3] referrer field for ios analytics and readme update --- .../Controllers/PackagesController.cs | 1 + .../Models/AnalyticsInfo.cs | 1 + .../Services/AnalyticsService.cs | 13 +++++-------- README.md | 16 ++++++++++++---- 4 files changed, 19 insertions(+), 12 deletions(-) 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..07ff9f6 100644 --- a/Microsoft.PWABuilder.IOS.Web/Models/AnalyticsInfo.cs +++ b/Microsoft.PWABuilder.IOS.Web/Models/AnalyticsInfo.cs @@ -5,6 +5,7 @@ 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..eaca75c 100644 --- a/Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs +++ b/Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs @@ -31,14 +31,7 @@ public 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; - } + !string.IsNullOrEmpty(this.settings.Value.ApplicationInsightsConnectionString); } public void Record(string url, bool success, IOSAppPackageOptions.Validated? packageOptions, AnalyticsInfo? analyticsInfo, string? error) @@ -82,6 +75,10 @@ public void Record(string url, bool success, IOSAppPackageOptions.Validated? pac 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..09d41e0 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 { @@ -107,4 +115,4 @@ You may also generate a package manually by POSTing to `/packages/create` with t For more information about the JSON arguments, see [IOSPackageOptions](https://github.com/pwa-builder/pwabuilder-ios/blob/main/Microsoft.PWABuilder.IOS.Web/Models/IOSAppPackageOptions.cs). -The response will be a zip file containing the generated app solution, which can be compiled in Xcode. +The response will be a zip file containing the generated app solution, which can be compiled in Xcode. \ No newline at end of file From 209972b1286f37e7846887521e6c9c61404e74ab Mon Sep 17 00:00:00 2001 From: Zach Teutsch <88554871+zateutsch@users.noreply.github.com> Date: Sun, 3 Dec 2023 15:02:34 -0800 Subject: [PATCH 2/3] revert main from accidental commit --- .../Controllers/PackagesController.cs | 1 - .../Models/AnalyticsInfo.cs | 1 - .../Services/AnalyticsService.cs | 13 ++++++++----- README.md | 16 ++++------------ 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Microsoft.PWABuilder.IOS.Web/Controllers/PackagesController.cs b/Microsoft.PWABuilder.IOS.Web/Controllers/PackagesController.cs index 8f58545..1dab235 100644 --- a/Microsoft.PWABuilder.IOS.Web/Controllers/PackagesController.cs +++ b/Microsoft.PWABuilder.IOS.Web/Controllers/PackagesController.cs @@ -37,7 +37,6 @@ 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 07ff9f6..a64e8fd 100644 --- a/Microsoft.PWABuilder.IOS.Web/Models/AnalyticsInfo.cs +++ b/Microsoft.PWABuilder.IOS.Web/Models/AnalyticsInfo.cs @@ -5,7 +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 eaca75c..38d2874 100644 --- a/Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs +++ b/Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs @@ -31,7 +31,14 @@ public AnalyticsService( this.http = httpClientFactory.CreateClient(); this.logger = logger; this.telemetryClient = telemetryClient; - !string.IsNullOrEmpty(this.settings.Value.ApplicationInsightsConnectionString); + if (!string.IsNullOrEmpty(this.settings.Value.ApplicationInsightsConnectionString)) + { + this.isAppInsightsEnabled = true; + } + else + { + this.isAppInsightsEnabled = false; + } } public void Record(string url, bool success, IOSAppPackageOptions.Validated? packageOptions, AnalyticsInfo? analyticsInfo, string? error) @@ -75,10 +82,6 @@ public void Record(string url, bool success, IOSAppPackageOptions.Validated? pac 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 09d41e0..5d2c288 100644 --- a/README.md +++ b/README.md @@ -17,19 +17,11 @@ 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 -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. +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. -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: +You may also generate a package manually by POSTing to `/packages/create` with the following JSON body: ```json { @@ -115,4 +107,4 @@ Alternately, you can POST to `/packages/create` with the following JSON body: For more information about the JSON arguments, see [IOSPackageOptions](https://github.com/pwa-builder/pwabuilder-ios/blob/main/Microsoft.PWABuilder.IOS.Web/Models/IOSAppPackageOptions.cs). -The response will be a zip file containing the generated app solution, which can be compiled in Xcode. \ No newline at end of file +The response will be a zip file containing the generated app solution, which can be compiled in Xcode. From 824d2bf2f3145f53e236cd17b937da20d63e02b8 Mon Sep 17 00:00:00 2001 From: Zach Teutsch <88554871+zateutsch@users.noreply.github.com> Date: Sun, 3 Dec 2023 15:10:15 -0800 Subject: [PATCH 3/3] added referrer field to ios analytics and updated readme --- .../Controllers/PackagesController.cs | 1 + .../Models/AnalyticsInfo.cs | 2 +- .../Services/AnalyticsService.cs | 13 +++++-------- README.md | 14 +++++++++++--- 4 files changed, 18 insertions(+), 12 deletions(-) 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 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 @@ public void Record(string url, bool success, IOSAppPackageOptions.Validated? pac 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 {