Skip to content

Commit

Permalink
Anonymous login succ/failed/relogin/logout info to GA. (PokemonGoF#1312)
Browse files Browse the repository at this point in the history
* There's a big warning before bot login and 2s wait for exit if the health report is turned on.
Anonymous login succ/failed/relogin/logout info without any user account info will be sent to GA.
The function is not called to wait Signal system merge.

* Fixed page view is not true.

* Removed [x] since we ditched it.
  • Loading branch information
solderzzc authored and MFizz committed Jul 29, 2016
1 parent ac0760e commit 68068c1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 0 deletions.
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

0 comments on commit 68068c1

Please sign in to comment.