app version in analytics

This commit is contained in:
Nordup 2025-08-15 23:15:37 +07:00
parent cd7168527f
commit 6b383dad34
3 changed files with 17 additions and 8 deletions

View file

@ -12,6 +12,7 @@ config_version=5
config/name="TheGates"
config/description="Building new Internet"
config/version="0.16.0"
config/tags=PackedStringArray("thegates")
run/main_scene="res://scenes/app.tscn"
run/enable_alt_space_menu=true

View file

@ -1,22 +1,19 @@
extends Node
class_name Analitycs
@export var api: ApiSettings
signal analytics_ready
@export var api: ApiSettings
func _ready() -> void:
get_app_version()
await get_user_id()
analytics_ready.emit()
func send_event(body: Dictionary = {}) -> void:
var url = api.analytics_event
var callback = func(_result, code, _headers, _body):
if code != 200: Debug.logclr("Request send_event failed. Code " + str(code), Color.RED)
var err = await Backend.request(url, callback, body, HTTPClient.METHOD_POST)
if err != HTTPRequest.RESULT_SUCCESS: Debug.logclr("Cannot send request send_event", Color.RED)
func get_app_version() -> void:
AnalyticsEvents.app_version = ProjectSettings.get_setting("application/config/version")
func get_user_id() -> void:
@ -33,3 +30,12 @@ func get_user_id() -> void:
var err = await Backend.request(url, callback)
if err != HTTPRequest.RESULT_SUCCESS: Debug.logclr("Cannot send request create_user_id", Color.RED)
func send_event(body: Dictionary = {}) -> void:
var url = api.analytics_event
var callback = func(_result, code, _headers, _body):
if code != 200: Debug.logclr("Request send_event failed. Code " + str(code), Color.RED)
var err = await Backend.request(url, callback, body, HTTPClient.METHOD_POST)
if err != HTTPRequest.RESULT_SUCCESS: Debug.logclr("Cannot send request send_event", Color.RED)

View file

@ -2,12 +2,14 @@ extends Node
#class_name AnalyticsEvents
var user_id := "none"
var app_version := "none"
func base(event_name: String) -> Dictionary:
var event = {}
event.event_name = event_name
event.user_id = user_id
event.app_version = app_version
return event