mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-23 08:17:34 -04:00
analytics: first_frame event, floats
This commit is contained in:
parent
74e165b174
commit
6528dffe57
8 changed files with 43 additions and 29 deletions
|
@ -17,13 +17,13 @@ func app_open() -> Dictionary:
|
|||
return base("application_open")
|
||||
|
||||
|
||||
func heartbeat(time_spend: int) -> Dictionary:
|
||||
func heartbeat(time_spend: float) -> Dictionary:
|
||||
var event = base("heartbeat")
|
||||
event.time_spend = time_spend
|
||||
return event
|
||||
|
||||
|
||||
func app_exit(time_spend: int) -> Dictionary:
|
||||
func app_exit(time_spend: float) -> Dictionary:
|
||||
var event = base("application_exit")
|
||||
event.time_spend = time_spend
|
||||
return event
|
||||
|
@ -43,14 +43,21 @@ func gate_open(url: String) -> Dictionary:
|
|||
return event
|
||||
|
||||
|
||||
func gate_enter(url: String, download_time: int) -> Dictionary:
|
||||
func gate_enter(url: String, download_time: float) -> Dictionary:
|
||||
var event = base("gate_enter")
|
||||
event.gate_url = url
|
||||
event.download_time = download_time
|
||||
return event
|
||||
|
||||
|
||||
func gate_exit(url: String, time_spend: int) -> Dictionary:
|
||||
func first_frame(url: String, loading_time: float) -> Dictionary:
|
||||
var event = base("first_frame")
|
||||
event.gate_url = url
|
||||
event.loading_time = loading_time
|
||||
return event
|
||||
|
||||
|
||||
func gate_exit(url: String, time_spend: float) -> Dictionary:
|
||||
var event = base("gate_exit")
|
||||
event.gate_url = url
|
||||
event.time_spend = time_spend
|
||||
|
|
|
@ -26,12 +26,12 @@ func start_heartbeat() -> void:
|
|||
|
||||
|
||||
func send_hearbeat() -> void:
|
||||
var time_spend = int(Time.get_ticks_msec() / 1000)
|
||||
var time_spend = float(Time.get_ticks_msec()) / 1000
|
||||
analytics.send_event(AnalyticsEvents.heartbeat(time_spend))
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
# Save to send on open
|
||||
var time_spend = int(Time.get_ticks_msec() / 1000)
|
||||
var time_spend = float(Time.get_ticks_msec()) / 1000
|
||||
var event = AnalyticsEvents.app_exit(time_spend)
|
||||
DataSaver.set_value("analytics", "app_exit", JSON.stringify(event))
|
||||
|
|
|
@ -3,7 +3,8 @@ class_name AnalyticsSenderGate
|
|||
|
||||
@export var gate_events: GateEvents
|
||||
|
||||
var gate_open_time: int
|
||||
var gate_open_tick: int
|
||||
var gate_enter_tick: int
|
||||
var gate_url: String
|
||||
|
||||
|
||||
|
@ -13,6 +14,7 @@ func start() -> void:
|
|||
gate_events.search.connect(send_search)
|
||||
gate_events.open_gate.connect(send_gate_open)
|
||||
gate_events.gate_entered.connect(send_gate_enter)
|
||||
gate_events.first_frame.connect(send_first_frame)
|
||||
gate_events.exit_gate.connect(send_gate_exit)
|
||||
|
||||
# Send latest exit event
|
||||
|
@ -23,29 +25,34 @@ func start() -> void:
|
|||
|
||||
|
||||
func send_search(query: String) -> void:
|
||||
if not gate_url.is_empty(): send_gate_exit()
|
||||
send_gate_exit()
|
||||
|
||||
analytics.send_event(AnalyticsEvents.search(query))
|
||||
|
||||
|
||||
func send_gate_open(url: String) -> void:
|
||||
if not gate_url.is_empty(): send_gate_exit()
|
||||
send_gate_exit()
|
||||
|
||||
gate_url = url
|
||||
gate_open_time = int(Time.get_ticks_msec() / 1000)
|
||||
gate_open_tick = Time.get_ticks_msec()
|
||||
analytics.send_event(AnalyticsEvents.gate_open(url))
|
||||
|
||||
|
||||
func send_gate_enter() -> void:
|
||||
var download_time = int(Time.get_ticks_msec() / 1000) - gate_open_time
|
||||
gate_open_time = int(Time.get_ticks_msec() / 1000)
|
||||
var download_time = get_delta_sec(gate_open_tick)
|
||||
gate_enter_tick = Time.get_ticks_msec()
|
||||
analytics.send_event(AnalyticsEvents.gate_enter(gate_url, download_time))
|
||||
|
||||
|
||||
func send_first_frame() -> void:
|
||||
var loading_time = get_delta_sec(gate_enter_tick)
|
||||
analytics.send_event(AnalyticsEvents.first_frame(gate_url, loading_time))
|
||||
|
||||
|
||||
func send_gate_exit() -> void:
|
||||
if gate_url.is_empty(): return
|
||||
|
||||
var time_spend = int(Time.get_ticks_msec() / 1000) - gate_open_time
|
||||
var time_spend = get_delta_sec(gate_open_tick)
|
||||
analytics.send_event(AnalyticsEvents.gate_exit(gate_url, time_spend))
|
||||
gate_url = ""
|
||||
|
||||
|
@ -54,6 +61,10 @@ func _exit_tree() -> void:
|
|||
if gate_url.is_empty(): return
|
||||
|
||||
# Save to send on open
|
||||
var time_spend = int(Time.get_ticks_msec() / 1000) - gate_open_time
|
||||
var time_spend = get_delta_sec(gate_open_tick)
|
||||
var event = AnalyticsEvents.gate_exit(gate_url, time_spend)
|
||||
DataSaver.set_value("analytics", "send_gate_exit", JSON.stringify(event))
|
||||
|
||||
|
||||
func get_delta_sec(from_msec: int) -> float:
|
||||
return float(Time.get_ticks_msec() - from_msec) / 1000
|
||||
|
|
|
@ -3,7 +3,6 @@ class_name CommandEvents
|
|||
|
||||
signal send_filehandle(filehandle_path: String)
|
||||
signal ext_texture_format(format: RenderingDevice.DataFormat)
|
||||
signal first_frame_drawn()
|
||||
signal set_mouse_mode(mode: int)
|
||||
|
||||
|
||||
|
@ -15,9 +14,5 @@ func ext_texture_format_emit(format: RenderingDevice.DataFormat) -> void:
|
|||
ext_texture_format.emit(format)
|
||||
|
||||
|
||||
func first_frame_drawn_emit() -> void:
|
||||
first_frame_drawn.emit()
|
||||
|
||||
|
||||
func set_mouse_mode_emit(mode: int) -> void:
|
||||
set_mouse_mode.emit(mode)
|
||||
|
|
|
@ -7,6 +7,7 @@ signal gate_config_loaded(url: String, config: ConfigGate)
|
|||
signal gate_info_loaded(gate: Gate, is_cached: bool)
|
||||
signal gate_loaded(gate: Gate)
|
||||
signal gate_entered
|
||||
signal first_frame
|
||||
signal exit_gate
|
||||
|
||||
signal download_progress(url: String, body_size: int, downloaded_bytes: int)
|
||||
|
@ -57,6 +58,10 @@ func gate_entered_emit() -> void:
|
|||
gate_entered.emit()
|
||||
|
||||
|
||||
func first_frame_emit() -> void:
|
||||
first_frame.emit()
|
||||
|
||||
|
||||
func exit_gate_emit() -> void:
|
||||
current_search_query = ""
|
||||
current_gate_url = ""
|
||||
|
|
|
@ -26,7 +26,7 @@ func _execute_function(command: Command) -> Variant:
|
|||
|
||||
"first_frame_drawn":
|
||||
if wrong_args_count(command, 0): return ERR_INVALID_PARAMETER
|
||||
command_events.first_frame_drawn_emit()
|
||||
gate_events.first_frame_emit()
|
||||
|
||||
"set_mouse_mode":
|
||||
if wrong_args_count(command, 1): return ERR_INVALID_PARAMETER
|
||||
|
|
|
@ -15,8 +15,8 @@ var texture_rid: RID
|
|||
func _ready() -> void:
|
||||
gate_events.gate_entered.connect(create_external_texture)
|
||||
command_events.send_filehandle.connect(send_filehandle)
|
||||
command_events.ext_texture_format.connect(ext_texture_format)
|
||||
command_events.first_frame_drawn.connect(first_frame_drawn)
|
||||
command_events.ext_texture_format.connect(set_texture_format)
|
||||
gate_events.first_frame.connect(show_render)
|
||||
|
||||
# Create empty texture with window size
|
||||
var image = Image.create(width, height, false, Image.FORMAT_RGBA8)
|
||||
|
@ -57,7 +57,7 @@ func send_filehandle(filehandle_path: String) -> void:
|
|||
Debug.logclr("filehandle was sent", Color.DIM_GRAY)
|
||||
|
||||
|
||||
func ext_texture_format(format: RenderingDevice.DataFormat) -> void:
|
||||
func set_texture_format(format: RenderingDevice.DataFormat) -> void:
|
||||
match format:
|
||||
RenderingDevice.DATA_FORMAT_R8G8B8A8_UNORM:
|
||||
set_param("ext_texture_is_bgra", false)
|
||||
|
@ -69,7 +69,7 @@ func ext_texture_format(format: RenderingDevice.DataFormat) -> void:
|
|||
Debug.logerr("Texture format %d is not supported" % [format])
|
||||
|
||||
|
||||
func first_frame_drawn() -> void:
|
||||
func show_render() -> void:
|
||||
set_param("show_render", true)
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class_name SplashScreen
|
|||
func _ready():
|
||||
gate_events.gate_info_loaded.connect(show_thumbnail)
|
||||
gate_events.gate_entered.connect(show_splash_screen)
|
||||
command_events.first_frame_drawn.connect(first_frame_drawn)
|
||||
gate_events.first_frame.connect(func(): hide())
|
||||
|
||||
# Change size
|
||||
show_splash_screen()
|
||||
|
@ -36,10 +36,6 @@ func show_splash_screen() -> void:
|
|||
self.texture = ImageTexture.create_from_image(image)
|
||||
|
||||
|
||||
func first_frame_drawn() -> void:
|
||||
hide()
|
||||
|
||||
|
||||
func resize_and_convert(image: Image, format: Image.Format) -> Image:
|
||||
image.resize(width, height)
|
||||
image.convert(format)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue