add more metrics

This commit is contained in:
Alberto Xamin 2022-03-26 12:12:16 +01:00
parent dcfdacc6df
commit 20819cedd0
3 changed files with 7 additions and 2 deletions

View File

@ -258,7 +258,7 @@ class Game:
self.choose_characters() self.choose_characters()
if 'gold_rush' in self.expansions: if 'gold_rush' in self.expansions:
self.notify_gold_rush_shop() self.notify_gold_rush_shop()
Metrics.send_metric('start_game', points=[1], tags=([f"exp:{e}" for e in self.expansions] + [f"players:{self.initial_players}"])) Metrics.send_metric('start_game', points=[1], tags=([f"exp:{e}" for e in self.expansions] + [f"players:{self.initial_players}", f"competitive:{self.is_competitive}"]))
def distribute_roles(self): def distribute_roles(self):
available_roles: List[roles.Role] = [] available_roles: List[roles.Role] = []
@ -465,6 +465,7 @@ class Game:
def play_turn(self): def play_turn(self):
self.incremental_turn += 1 self.incremental_turn += 1
Metrics.send_metric('incremental_turn', points=[self.incremental_turn], tags=[f'game:{self.SEED}'])
if self.players[self.turn].is_dead: if self.players[self.turn].is_dead:
pl = sorted(self.get_dead_players(), key=lambda x:x.death_turn)[0] pl = sorted(self.get_dead_players(), key=lambda x:x.death_turn)[0]
if self.check_event(ce.DeadMan) and not self.did_resuscitate_deadman and pl == self.players[self.turn]: if self.check_event(ce.DeadMan) and not self.did_resuscitate_deadman and pl == self.players[self.turn]:

View File

@ -648,7 +648,7 @@ class Player:
self.hand.insert(hand_index, card) self.hand.insert(hand_index, card)
else: else:
did_play_card = True did_play_card = True
Metrics.send_metric('play_card', points=[1], tags=[f'success:{did_play_card}', f'card:{card.name}', f'bot:{self.is_bot}']) Metrics.send_metric('play_card', points=[1], tags=[f'success:{did_play_card}', f'card:{card.name}', f'bot:{self.is_bot}', f'exp:{card.expansion}'])
print("did play card:", did_play_card) print("did play card:", did_play_card)
self.notify_self() self.notify_self()
if self.is_bot: if self.is_bot:

View File

@ -49,6 +49,7 @@ def advertise_lobbies():
sio.emit('lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if not g.started and len(g.players) < 10 and not g.is_hidden]) sio.emit('lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if not g.started and len(g.players) < 10 and not g.is_hidden])
sio.emit('spectate_lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if g.started]) sio.emit('spectate_lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if g.started])
Metrics.send_metric('lobbies', points=[len(games)]) Metrics.send_metric('lobbies', points=[len(games)])
Metrics.send_metric('online_players', points=[online_players])
@sio.event @sio.event
def connect(sid, environ): def connect(sid, environ):
@ -546,6 +547,8 @@ def chat_message(sid, msg, pl=None):
else: else:
color = sid.encode('utf-8').hex()[-3:] color = sid.encode('utf-8').hex()[-3:]
sio.emit('chat_message', room=ses.game.name, data={'color': f'#{color}','text':f'[{ses.name}]: {msg}'}) sio.emit('chat_message', room=ses.game.name, data={'color': f'#{color}','text':f'[{ses.name}]: {msg}'})
Metrics.send_metric('chat_message', points=[1], tags=[f'game:{ses.game.name.replace(" ","_")}'])
""" """
@ -562,6 +565,7 @@ def get_cards(sid):
cards_dict[ca.name] = ca cards_dict[ca.name] = ca
cards = [cards_dict[i] for i in cards_dict] cards = [cards_dict[i] for i in cards_dict]
sio.emit('cards_info', room=sid, data=json.dumps(cards, default=lambda o: o.__dict__)) sio.emit('cards_info', room=sid, data=json.dumps(cards, default=lambda o: o.__dict__))
Metrics.send_metric('help_screen_viewed', points=[1])
@sio.event @sio.event
def get_characters(sid): def get_characters(sid):