-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Felix
committed
Nov 20, 2016
1 parent
e627dc1
commit 4f1a38b
Showing
14 changed files
with
160 additions
and
51 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
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 @@ | ||
node_modules |
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package util | ||
|
||
import util.logger.log | ||
|
||
import scala.scalajs.js | ||
|
||
// Analytics using https://www.npmjs.com/package/universal-analytics | ||
object ElectronAnalytics { | ||
|
||
import js.Dynamic.{global => g} | ||
|
||
val ua = g.require("universal-analytics") | ||
|
||
def sendEvent(category: String, action: String, label: String): Unit = { | ||
val visitor = ua(GoogleUA, userId()) | ||
visitor.event(category, action, label).send() | ||
log.info(s"sendEvent: $category, $action, $label") | ||
} | ||
|
||
def sendPageView(name: String): Unit = { | ||
val visitor = ua(GoogleUA, userId()) | ||
visitor.pageview(name).send() | ||
log.info(s"sendAppView: $name") | ||
} | ||
|
||
def sendException(ex: String): Unit = { | ||
val visitor = ua(GoogleUA, userId()) | ||
log.info(s"sendException: $ex") | ||
visitor.exception(s"sendException: $ex").send() | ||
} | ||
|
||
val GoogleUA = "UA-61270183-1" | ||
|
||
// TODO Use custom user id | ||
// https://www.npmjs.com/package/electron-machine-id | ||
def userId(): String = "dev-1" | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=0.13.12 | ||
sbt.version=0.13.13 |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package util | ||
|
||
import org.scalajs.dom.ext.{Ajax, AjaxException} | ||
import upickle.default._ | ||
|
||
import scala.concurrent.Future | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import logger.log | ||
|
||
object CheckIsLatestVersion { | ||
def installedVersion(): String = PlatformService.current.appVersion | ||
|
||
case class Release(name: String) | ||
|
||
val Url = "https://api.github.com/repos/felixgborrego/docker-ui-chrome-app/releases/latest" | ||
|
||
def latestVersion(): Future[String] = { | ||
Ajax.get(Url, timeout = 500).map { xhr => | ||
read[Release](xhr.responseText) | ||
}.map(_.name) | ||
} | ||
|
||
var alreadyChecked = false | ||
|
||
def check(callback: (String => Unit)): Unit = if (!alreadyChecked) { | ||
alreadyChecked = true | ||
val installed = installedVersion() | ||
latestVersion().map { | ||
case `installed` => log.info(s"Installed version $installed is the latest version") | ||
case latest => callback(s"There is a new version available $latest") | ||
}.onFailure { | ||
case ex: AjaxException => log.info(s"Unable to fetch latest version - ${ex.xhr.responseText}") | ||
} | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.