Skip to content

Commit

Permalink
update source to handle 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CLEMENTINATOR committed Feb 4, 2025
1 parent a05afc1 commit ceb3649
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions DataCollectionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ This is the main class that you will need to implement. It should inherit from
These functions are called by the Edgee runtime to get the HTTP request to make to the provider's API for each event type.
*/
public class DataCollectionImpl: IDataCollection {
public static IDataCollection.EdgeeRequest Page(IDataCollection.Event e, List<(string, string)> creds) {
public static IDataCollection.EdgeeRequest Page(IDataCollection.Event e, List<(string, string)> settings) {
/*
cred is a list of tuple, which contains each key and secret for the provider
settings is a list of tuple, which contains each key and secret for the provider
for example, if your component is set to use
[[components.data_collection]]
name = "my_component"
component = "outpout.wasm"
credentials.test_project_id = "123456789"
credentials.test_write_key = "abcdefg"
settings.test_project_id = "123456789"
settings.test_write_key = "abcdefg"
then
foreach (var cred in creds)
foreach (var settings in settings)
{
Console.WriteLine($"{cred.Item1}: {cred.Item2}");
Console.WriteLine($"{settings.Item1}: {cred.Item2}");
}
will print:
test_project_id: 123456789
Expand All @@ -32,27 +32,30 @@ public static IDataCollection.EdgeeRequest Page(IDataCollection.Event e, List<(s
("Content-Type", "application/json")
};
string body = "{\"event\": \"page\"}";
return new IDataCollection.EdgeeRequest(IDataCollection.HttpMethod.POST, url, headers, body);
boolean forward_client_headers = true;
return new IDataCollection.EdgeeRequest(IDataCollection.HttpMethod.POST, url, headers, forward_client_headers, body);
}
public static IDataCollection.EdgeeRequest Track(IDataCollection.Event e, List<(string, string)> creds) {
public static IDataCollection.EdgeeRequest Track(IDataCollection.Event e, List<(string, string)> settings) {
string url = "https://example.com/";
var headers = new List<(string, string)>
{
("Authorization", "Bearer exampleToken123"),
("Content-Type", "application/json")
};
string body = "{\"event\": \"track\"}";
return new IDataCollection.EdgeeRequest(IDataCollection.HttpMethod.POST, url, headers, body);
boolean forward_client_headers = true;
return new IDataCollection.EdgeeRequest(IDataCollection.HttpMethod.POST, url, headers, forward_client_headers, body);
}
public static IDataCollection.EdgeeRequest User(IDataCollection.Event e, List<(string, string)> creds) {
public static IDataCollection.EdgeeRequest User(IDataCollection.Event e, List<(string, string)> settings) {
string url = "https://example.com/";
var headers = new List<(string, string)>
{
("Authorization", "Bearer exampleToken123"),
("Content-Type", "application/json")
};
string body = "{\"event\": \"user\"}";
return new IDataCollection.EdgeeRequest(IDataCollection.HttpMethod.POST, url, headers, body);
boolean forward_client_headers = true;
return new IDataCollection.EdgeeRequest(IDataCollection.HttpMethod.POST, url, headers, forward_client_headers, body);
}
}

0 comments on commit ceb3649

Please sign in to comment.