@@ -6,52 +6,55 @@ This is the main class that you will need to implement. It should inherit from
6
6
Page, Track, User
7
7
These functions are called by the Edgee runtime to get the HTTP request to make to the provider's API for each event type.
8
8
*/
9
+
10
+ public struct Settings {
11
+ public string Example { get ; }
12
+
13
+ public Settings ( List < ( string , string ) > settings ) {
14
+ Example = string . Empty ;
15
+ foreach ( var setting in settings ) {
16
+ if ( setting . Item1 == "example" ) {
17
+ Example = setting . Item2 ;
18
+ }
19
+ }
20
+ }
21
+ }
22
+
9
23
public class DataCollectionImpl : IDataCollection {
10
24
public static IDataCollection . EdgeeRequest Page ( IDataCollection . Event e , List < ( string , string ) > settings ) {
11
- /*
12
- settings is a list of tuple, which contains each key and secret for the provider
13
- for example, if your component is set to use
14
- [[components.data_collection]]
15
- name = "my_component"
16
- component = "outpout.wasm"
17
- settings.test_project_id = "123456789"
18
- settings.test_write_key = "abcdefg"
19
- then
20
- foreach (var settings in settings)
21
- {
22
- Console.WriteLine($"{settings.Item1}: {cred.Item2}");
23
- }
24
- will print:
25
- test_project_id: 123456789
26
- test_write_key: abcdefg
27
- */
28
25
string url = "https://example.com/" ;
26
+ Settings s = new Settings ( settings ) ;
29
27
var headers = new List < ( string , string ) >
30
28
{
31
29
( "Authorization" , "Bearer exampleToken123" ) ,
32
- ( "Content-Type" , "application/json" )
30
+ ( "Content-Type" , "application/json" ) ,
31
+ ( "example" , s . Example )
33
32
} ;
34
33
string body = "{\" event\" : \" page\" }" ;
35
34
bool forward_client_headers = true ;
36
35
return new IDataCollection . EdgeeRequest ( IDataCollection . HttpMethod . POST , url , headers , forward_client_headers , body ) ;
37
36
}
38
37
public static IDataCollection . EdgeeRequest Track ( IDataCollection . Event e , List < ( string , string ) > settings ) {
39
38
string url = "https://example.com/" ;
39
+ Settings s = new Settings ( settings ) ;
40
40
var headers = new List < ( string , string ) >
41
41
{
42
42
( "Authorization" , "Bearer exampleToken123" ) ,
43
- ( "Content-Type" , "application/json" )
43
+ ( "Content-Type" , "application/json" ) ,
44
+ ( "example" , s . Example )
44
45
} ;
45
46
string body = "{\" event\" : \" track\" }" ;
46
47
bool forward_client_headers = true ;
47
48
return new IDataCollection . EdgeeRequest ( IDataCollection . HttpMethod . POST , url , headers , forward_client_headers , body ) ;
48
49
}
49
50
public static IDataCollection . EdgeeRequest User ( IDataCollection . Event e , List < ( string , string ) > settings ) {
50
51
string url = "https://example.com/" ;
52
+ Settings s = new Settings ( settings ) ;
51
53
var headers = new List < ( string , string ) >
52
54
{
53
55
( "Authorization" , "Bearer exampleToken123" ) ,
54
- ( "Content-Type" , "application/json" )
56
+ ( "Content-Type" , "application/json" ) ,
57
+ ( "example" , s . Example )
55
58
} ;
56
59
string body = "{\" event\" : \" user\" }" ;
57
60
bool forward_client_headers = true ;
0 commit comments