Skip to content

Commit

Permalink
traking users with google firebase authentication on #156
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielvazdemelo committed Jan 9, 2024
1 parent c950959 commit 8fb3adc
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ library(htmltools)
library(officer)
library(rvg)
library(openxlsx)
library(firebase)


options(dplyr.summarise.inform = FALSE)
Expand Down
20 changes: 20 additions & 0 deletions app/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
server <- function(input, output, session) {
# Handle inputs ======================================================================

## Fisebase ---------------------------------------------------------------
f <- FirebaseUI$
new()$
set_providers(
email = TRUE,
google = TRUE
)$
launch()

a <- Analytics$
new()$
launch()

observeEvent(f$get_signed_in(), {
f$req_sign_in()

a$log_event('notification_received');
a$set_user_properties(level = "free")
})

## Hide save inputs button at onset
shinyjs::hide("save_inputs")
shinyjs::disable("preset_order")
Expand Down
67 changes: 45 additions & 22 deletions app/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ $('#threshold').on('shown.bs.select', function() {
});
});"




ui <-
dashboardPage(

Expand All @@ -38,30 +35,56 @@ ui <-
status = "info",
skin = "light",
elevation = 5,

sidebarMenu(
menuItem("Home", tabName = "home", icon = icon("home")),
menuItem("Country benchmarking", tabName = "benchmark", icon = icon("sort-amount-up")),
menuItem("Cross-country comparison", tabName = "country", icon = icon("chart-bar")),
menuItem("Bivariate correlation", tabName = "scatter", icon = icon("search-dollar")),
menuItem("World map", tabName = "world_map", icon = icon("globe-americas")),
menuItem("Time trends", tabName = "trends", icon = icon("chart-line")),
menuItem("Data", tabName = "data", icon = icon("table")),
menuItem("Methodology", tabName = "methodology", icon = icon("book")),
menuItem("Publications", tabName = "pubs", icon = icon("list")),
menuItem("Terms of use and Disclaimers", tabName = "terms", icon = icon("handshake")),
menuItem("FAQ", tabName = "faq", icon = icon("question")),
menuItem("Contact Us",
icon = icon("comments", lib = "font-awesome"),
href = "mailto:[email protected]"),
menuItem("Source code",
icon = icon("github", lib = "font-awesome"),
href = "https://github.com/worldbank/institutional-assessment-dashboard/")

useFirebase(), # import dependencies
firebaseUIContainer(),

reqSignin(
h4("Logged in!"),

sidebarMenu(
menuItem("Home", tabName = "home", icon = icon("home")),
menuItem("Country benchmarking", tabName = "benchmark", icon = icon("sort-amount-up")),
menuItem("Cross-country comparison", tabName = "country", icon = icon("chart-bar")),
menuItem("Bivariate correlation", tabName = "scatter", icon = icon("search-dollar")),
menuItem("World map", tabName = "world_map", icon = icon("globe-americas")),
menuItem("Time trends", tabName = "trends", icon = icon("chart-line")),
menuItem("Data", tabName = "data", icon = icon("table")),
menuItem("Methodology", tabName = "methodology", icon = icon("book")),
menuItem("Publications", tabName = "pubs", icon = icon("list")),
menuItem("Terms of use and Disclaimers", tabName = "terms", icon = icon("handshake")),
menuItem("FAQ", tabName = "faq", icon = icon("question")),
menuItem("Contact Us",
icon = icon("comments", lib = "font-awesome"),
href = "mailto:[email protected]"),
menuItem("Source code",
icon = icon("github", lib = "font-awesome"),
href = "https://github.com/worldbank/institutional-assessment-dashboard/")
)

)

),

dashboardBody(

tags$head(HTML("
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src='https://www.googletagmanager.com/gtag/js?id=G-CDFJLHD42K'></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-CDFJLHD42K');
</script>
"

)),

## universal css styles
tags$style(HTML("
Expand Down

0 comments on commit 8fb3adc

Please sign in to comment.