Skip to content

Commit

Permalink
referrer field for ios analytics and readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
zateutsch committed Dec 3, 2023
1 parent bee6d44 commit 08e0037
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public async Task<FileResult> 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
Expand Down
1 change: 1 addition & 0 deletions Microsoft.PWABuilder.IOS.Web/Models/AnalyticsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
}
13 changes: 5 additions & 8 deletions Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
!string.IsNullOrEmpty(this.settings.Value.ApplicationInsightsConnectionString);

Check failure on line 34 in Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs

View workflow job for this annotation

GitHub Actions / build

Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

Check failure on line 34 in Microsoft.PWABuilder.IOS.Web/Services/AnalyticsService.cs

View workflow job for this annotation

GitHub Actions / build

Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
}

public void Record(string url, bool success, IOSAppPackageOptions.Validated? packageOptions, AnalyticsInfo? analyticsInfo, string? error)
Expand Down Expand Up @@ -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);
;
}
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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.

0 comments on commit 08e0037

Please sign in to comment.