Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4542: Added referrer field to ios analytics and updated readme #62

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion Microsoft.PWABuilder.IOS.Web/Models/AnalyticsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
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 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)
Expand Down Expand Up @@ -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);
;
}
Expand Down
14 changes: 11 additions & 3 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
Loading