mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-26 17:17:24 -04:00
app version in analytics
This commit is contained in:
parent
cd7168527f
commit
6b383dad34
3 changed files with 17 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue