R/matomo_hostname.R

Defines functions matomo_hostname

Documented in matomo_hostname

#' Matomo hostname
#'
#' This function returns the Matomo hostname that is set in the environment variable MATOMO_HOST.
#'
#' @return A character string containing the Matomo hostname.
#' @export
#' @examples
#' Sys.setenv(MATOMO_HOST = "https://demo.matomo.org")
#'
#' matomo_hostname()
matomo_hostname <- function() {
  matomo_hostname <- Sys.getenv("MATOMO_HOST")
  matomo_hostname <- paste0(matomo_hostname, "/index.php")
  if (identical(matomo_hostname, "/index.php")) {
    stop("Please set env var MATOMO_HOST to your Matomo host.",
      call. = FALSE
    )
  }
  matomo_hostname
}
ebbertd/matomoR documentation built on Oct. 25, 2021, 2:09 p.m.