-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Text; | ||
using System.Text.Json; | ||
|
||
namespace lib { | ||
public class AnalyticsPayload { | ||
public string api_key { get; set; } | ||
public string @event { get; set; } | ||
public string distinct_id { get; set; } | ||
} | ||
|
||
public class Analytics { | ||
public static async Task SendEvent(Settings settings) { | ||
string url = "https://eu.i.posthog.com/capture/"; | ||
|
||
var payload = new AnalyticsPayload { | ||
api_key = "phc_2zbUPXXhnelCYP2VLXeWZvKy0hykzQA7edSOsFrYZaa", | ||
distinct_id = settings.userId, | ||
@event = "service" | ||
}; | ||
|
||
try { | ||
using var httpClient = new HttpClient(); | ||
var content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json"); | ||
|
||
var response = await httpClient.PostAsync(url, content); | ||
|
||
response.EnsureSuccessStatusCode(); | ||
|
||
var responseContent = await response.Content.ReadAsStringAsync(); | ||
} | ||
catch (Exception ex) { | ||
Console.WriteLine($"An error occurred: {ex.Message}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters