wongjiahau/ttap-web

View on GitHub
src/ts/fire.ts

Summary

Maintainability
A
0 mins
Test Coverage
declare let firebase: any; // this variable is declared in index.html
export function updateVisits() {
  if (typeof firebase === "undefined") {
    return;
  }
  const ref = firebase.database().ref("visits"); // eslint-disable-line no-undef
  ref.push().set({
    date: Date.now(),
    source: getSource(),
  });
}

export function getSource() {
  const x = window.navigator;
  return {
    os: x.platform,
    browser: x.userAgent,
  };
}