Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"action_wait_max": 4,
"debug": false,
"test": false,
"health_record": true,
"location_cache": true,
"distance_unit": "km",
"reconnecting_timeout": 15,
Expand Down
1 change: 1 addition & 0 deletions configs/config.json.pokemons.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"action_wait_max": 4,
"debug": false,
"test": false,
"health_record": true,
"location_cache": true,
"distance_unit": "km",
"item_filter": {
Expand Down
7 changes: 7 additions & 0 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ def init_config():
type=float,
default=15.0
)
parser.add_argument(
"-hr",
"--health_record",
help="Send anonymous bot event to GA for bot health record. Set \"health_record\":false if you need disable it.",
type=bool,
default=True
)

# Start to parse other attrs
config = parser.parse_args()
Expand Down
3 changes: 3 additions & 0 deletions pokemongo_bot/health_record/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from bot_event import BotEvent
31 changes: 31 additions & 0 deletions pokemongo_bot/health_record/bot_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
from UniversalAnalytics import Tracker
from pokemongo_bot import logger
from time import sleep

class BotEvent(object):
def __init__(self,bot):
self.bot = bot
# UniversalAnalytics can be reviewed here:
# https://github.com/analytics-pros/universal-analytics-python
# For central TensorFlow training, forbiden any personally information
# report to server
# Review Very Carefully for the following line, forbiden ID changed PR:
if bot.config.health_record:
logger.log('Send anonymous bot health report to server, it can be disabled by config \"health_record\":false in config file', 'red')
logger.log('Wait for 2 seconds ', 'red')
sleep(3)
self.tracker = Tracker.create('UA-81469507-1', use_post=True)
# No RAW send function to be added here, to keep everything clean
def login_success(self):
if self.bot.config.health_record:
self.tracker.send('pageview', '/loggedin', title='succ')
def login_failed(self):
if self.bot.config.health_record:
self.tracker.send('pageview', '/login', title='fail')
def login_retry(self):
if self.bot.config.health_record:
self.tracker.send('pageview', '/relogin', title='relogin')
def logout(self):
if self.bot.config.health_record:
self.tracker.send('pageview', '/logout', title='logout')
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ enum34==1.1.6
pyyaml==3.11
haversine==0.4.5
polyline==1.3.1
universal-analytics-python==0.2.4