#' ios_logger_data
#'
#' Import iOS log data
#' @param file The iOS log file in JSON format
#' @export
ios_logger_data <- function(file) {
require(jsonlite)
require(tidyverse)
require(purrr)
x <- fromJSON(file,simplifyVector = FALSE)
big_tbl <- tibble()
for (i in 1:length(x)) {
y <- x[[i]]
tbl <- tibble(event_name = y$event)
z <- y$parameters
new_tbl <- do.call('bind_rows',map(z,as_tibble)) %>%
pivot_wider(names_from = name,values_from = value) %>%
mutate_all(~ ifelse(as.character(.)!="", ., NA))
tbl <- cbind(tbl,new_tbl)
big_tbl <- bind_rows(big_tbl,tbl)
}
big_tbl <- big_tbl %>%
tidycols() %>%
#reorganize
select(event_name, timestamp,screen_name, app_session_hit_count, app_session_id,date,device_model,everything()) %>%
#add a screen count
arrange(app_session_id,event_name,timestamp) %>%
group_by(app_session_id) %>%
mutate(screen_count = ifelse(event_name == 'screen_view',row_number(),NA)) %>%
ungroup() %>%
select(1:7,screen_count,everything()) %>%
arrange(desc(timestamp))
return(big_tbl)
}
#' android_logger_data
#'
#' Import Android log data
#' @param file The Android log file in JSON format
#' @export
android_logger_data <- function(file) {
require(jsonlite)
require(tidyverse)
require(purrr)
x <- fromJSON(file,simplifyVector = FALSE)
logger_details <- as_tibble(x$logger)
big_tbl <- tibble()
for (val in 1:length(x$events)) {
y <- x$events[[val]]
if (y$type == 'screenView') {
tbl <- as_tibble(y) %>%
rename(screen_name = event) %>%
mutate(event = 'screen_view')
big_tbl <- bind_rows(big_tbl,tbl)
} else if (y$type %in% c('userProperty','event')) {
params <- do.call('bind_cols',map(y$parameters,as_tibble))
tbl <- as_tibble(y) %>%
select(-parameters) %>%
distinct() %>%
bind_cols(params)
big_tbl <- bind_rows(big_tbl,tbl)
} else {
next()
}
}
final <- bind_cols(logger_details,big_tbl) %>%
rename(event_name = event)
return(final)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.