summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/service/telemetry.lua10
-rw-r--r--script/version.lua30
2 files changed, 40 insertions, 0 deletions
diff --git a/script/service/telemetry.lua b/script/service/telemetry.lua
index 419589e7..978adee4 100644
--- a/script/service/telemetry.lua
+++ b/script/service/telemetry.lua
@@ -9,6 +9,7 @@ local proto = require 'proto.proto'
local lang = require 'language'
local define = require 'proto.define'
local await = require 'await'
+local version = require 'version'
local tokenPath = (ROOT / 'log' / 'token'):string()
local token = util.loadFile(tokenPath)
@@ -49,6 +50,14 @@ local function pushPlatformInfo(link)
))
end
+local function pushVersion(link)
+ send(link, string.pack('zzz'
+ , 'version'
+ , token
+ , version.getVersion()
+ ))
+end
+
local function pushErrorLog(link)
if not log.firstError then
return
@@ -78,6 +87,7 @@ timer.wait(5, function ()
function link:on_connect()
pushClientInfo(link)
pushPlatformInfo(link)
+ pushVersion(link)
pushErrorLog(link)
self:close()
end
diff --git a/script/version.lua b/script/version.lua
new file mode 100644
index 00000000..fa178564
--- /dev/null
+++ b/script/version.lua
@@ -0,0 +1,30 @@
+local fsu = require 'fs-utility'
+
+local function loadVersion()
+ local changelog = fsu.loadFile(ROOT / 'changelog.md')
+ if not changelog then
+ return
+ end
+
+ local version, pos = changelog:match '%#%# (%d+%.%d+%.%d+)()'
+ if not version then
+ return
+ end
+
+ if not changelog:find('^[\r\n]+`', pos) then
+ version = version .. '-dev'
+ end
+ return version
+end
+
+local m = {}
+
+function m.getVersion()
+ if not m.version then
+ m.version = loadVersion() or '<Unknown>'
+ end
+
+ return m.version
+end
+
+return m