-
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.
Update documentation
- Loading branch information
Showing
18 changed files
with
420 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
^_pkgdown\.yml$ | ||
^docs$ | ||
^pkgdown$ | ||
^LICENSE\.md$ |
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 |
---|---|---|
|
@@ -39,3 +39,4 @@ vignettes/*.pdf | |
.Renviron | ||
.Rproj.user | ||
docs | ||
inst/doc |
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 |
---|---|---|
@@ -1,15 +1,27 @@ | ||
Package: googleErrorReportingR | ||
Title: This packages allows you to send error reports to Google Error Reporting service | ||
Version: 0.0.1 | ||
Authors@R: | ||
person("First", "Last", , "first.last@example.com", role = c("aut", "cre"), | ||
comment = c(ORCID = "YOUR-ORCID-ID")) | ||
Authors@R: | ||
c(person(given = "ixpantia, | ||
family = SRL", | ||
role = "cph", | ||
email = "hola@ixpantia.com"), | ||
person(given = "Frans", | ||
family = "van Dunné", | ||
role = c("cre", "aut"), | ||
email = "frans@ixpantia.com", | ||
comment = c(ORCID = "0000-0002-7853-2811"))) | ||
Description: What the package does (one paragraph). | ||
License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a | ||
license | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.0 | ||
Imports: | ||
jsonlite, | ||
httr | ||
Suggests: | ||
knitr, | ||
rmarkdown, | ||
testthat (>= 3.0.0) | ||
Config/testthat/edition: 3 | ||
VignetteBuilder: knitr |
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 |
---|---|---|
@@ -1,21 +1,2 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 ixpantia | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
YEAR: 2022 | ||
COPYRIGHT HOLDER: ixpantia S.R.L. |
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,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2022 ixpantia S.R.L. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(format_error_message) | ||
export(report_error) |
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,56 @@ | ||
#' Format Error Message for Google Error Reporting | ||
#' | ||
#' @param message the error message you want in the logs | ||
#' @param service the name of your service | ||
#' @param version the version of the service | ||
#' @param method the http method used for hte call | ||
#' @param url hte unique resource identifier that was called | ||
#' @param user_agent the user agente identifier | ||
#' @param referrer the referrer to the service | ||
#' @param response_status_code http response code | ||
#' @param remote_ip remote ip | ||
#' @param user_id user id | ||
#' @param filepath filepath of the code where the error originates | ||
#' @param line_number line number where the error originates | ||
#' @param function_name function name where the error originates | ||
#' | ||
#' @return message object, a list to be formated as JSON in the error report body | ||
#' @export | ||
format_error_message <- function( | ||
message = "Error description", | ||
service = "My Service", | ||
version = "0.0.1", | ||
method = "GET", | ||
url = "https://example.com", | ||
user_agent = "", | ||
referrer = "", | ||
response_status_code = "500", | ||
remote_ip = "192.178.0.0.1", | ||
user_id = "UserID", | ||
filepath = "/", | ||
line_number = 0, | ||
function_name = "my_function" | ||
) { | ||
|
||
|
||
error_message <- list() | ||
error_message$message <- message | ||
|
||
error_message$serviceContext$service <- service | ||
error_message$serviceContext$version <- version | ||
|
||
error_message$context$httpRequest$method <- method | ||
error_message$context$httpRequest$url <- url | ||
error_message$context$httpRequest$userAgent <- user_agent | ||
error_message$context$httpRequest$referrer <- referrer | ||
error_message$context$httpRequest$responseStatusCode <- response_status_code | ||
error_message$context$httpRequest$remoteIp <- remote_ip | ||
|
||
error_message$context$user <- user_id | ||
|
||
error_message$context$reportLocation$filePath <- filepath | ||
error_message$context$reportLocation$lineNumber <- line_number | ||
error_message$context$reportLocation$functionName <- function_name | ||
|
||
return(error_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#' Get list of errors from Google Error Reporting | ||
#' | ||
#' @param project_id the project ID of your project on GCP | ||
#' @param api_key an API key with permissions to write to Google Error Reporting | ||
#' @param message the error report to be written out to the | ||
#' | ||
#' @return No return, we focus on side effect | ||
list_errors <- function(project_id, | ||
api_key) { | ||
|
||
base_url <- "https://clouderrorreporting.googleapis.com/v1beta1/" | ||
project_name <- paste0("projects/", project_id) | ||
endpoint <- "/events?key=" | ||
|
||
url <- paste0(base_url, project_name, endpoint, api_key) | ||
|
||
httr::GET(url) | ||
} | ||
|
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
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
Oops, something went wrong.