Skip to content

Commit

Permalink
dc_component: update for 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CLEMENTINATOR committed Feb 4, 2025
1 parent 67a8f6c commit 7021c29
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions dc_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
You should set your request parameters in the `ret` struct and return true if the request was successful.
*/

bool exports_edgee_protocols_data_collection_page(exports_edgee_protocols_data_collection_event_t *e, exports_edgee_protocols_data_collection_dict_t *cred, exports_edgee_protocols_data_collection_edgee_request_t *ret, data_collection_string_t *err) {
bool exports_edgee_protocols_data_collection_page(exports_edgee_protocols_data_collection_event_t *e, exports_edgee_protocols_data_collection_dict_t *settings, exports_edgee_protocols_data_collection_edgee_request_t *ret, data_collection_string_t *err) {
/*
If your credentials are set as:
If your settings are set as:
[[components.data_collection]]
name = "my_component"
component = "outpout.wasm"
credentials.test_project_id = "123456789"
credentials.test_write_key = "abcdefg"
id = "my_component"
component = "output.wasm"
settings.test_project_id = "123456789"
settings.test_write_key = "abcdefg"
Then the following code:
for (int i = 0; i < cred.len; i++) {
printf("%s: %s\n", cred.ptr[i].f0.ptr, cred.ptr[i].f1.ptr);
for (int i = 0; i < settings.len; i++) {
printf("%s: %s\n", settings.ptr[i].f0.ptr, settings.ptr[i].f1.ptr);
}
Will print:
test_project_id: 123456789
Expand All @@ -34,10 +34,10 @@ bool exports_edgee_protocols_data_collection_page(exports_edgee_protocols_data_c
ret->headers.len = 1;
data_collection_string_dup(&ret->headers.ptr[0].f0, "Content-Type");
data_collection_string_dup(&ret->headers.ptr[0].f1, "application/json");

ret->forward_client_headers = true;
return true;
}
bool exports_edgee_protocols_data_collection_track(exports_edgee_protocols_data_collection_event_t *e, exports_edgee_protocols_data_collection_dict_t *cred, exports_edgee_protocols_data_collection_edgee_request_t *ret, data_collection_string_t *err) {
bool exports_edgee_protocols_data_collection_track(exports_edgee_protocols_data_collection_event_t *e, exports_edgee_protocols_data_collection_dict_t *settings, exports_edgee_protocols_data_collection_edgee_request_t *ret, data_collection_string_t *err) {
data_collection_string_dup(&ret->url, "https://example.com");

data_collection_string_dup(&ret->body, "{\"key\":\"value\"}");
Expand All @@ -48,9 +48,10 @@ bool exports_edgee_protocols_data_collection_track(exports_edgee_protocols_data_
ret->headers.len = 1;
data_collection_string_dup(&ret->headers.ptr[0].f0, "Content-Type");
data_collection_string_dup(&ret->headers.ptr[0].f1, "application/json");
ret->forward_client_headers = true;
return true;
}
bool exports_edgee_protocols_data_collection_user(exports_edgee_protocols_data_collection_event_t *e, exports_edgee_protocols_data_collection_dict_t *cred, exports_edgee_protocols_data_collection_edgee_request_t *ret, data_collection_string_t *err) {
bool exports_edgee_protocols_data_collection_user(exports_edgee_protocols_data_collection_event_t *e, exports_edgee_protocols_data_collection_dict_t *settings, exports_edgee_protocols_data_collection_edgee_request_t *ret, data_collection_string_t *err) {
data_collection_string_dup(&ret->url, "https://example.com");

data_collection_string_dup(&ret->body, "{\"key\":\"value\"}");
Expand All @@ -61,5 +62,6 @@ bool exports_edgee_protocols_data_collection_user(exports_edgee_protocols_data_c
ret->headers.len = 1;
data_collection_string_dup(&ret->headers.ptr[0].f0, "Content-Type");
data_collection_string_dup(&ret->headers.ptr[0].f1, "application/json");
ret->forward_client_headers = true;
return true;
}

0 comments on commit 7021c29

Please sign in to comment.