forked from sideeffects/GameDevelopmentToolset
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgamedevutils.py
More file actions
53 lines (42 loc) · 1.58 KB
/
gamedevutils.py
File metadata and controls
53 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import requests
import hou
home = os.environ["HOUDINI_USER_PREF_DIR"]
config = os.path.join(home, "hcommon.pref")
GA_TRACKING_ID = "UA-2947225-8"
def can_send_anonymous_stats():
can_share = False
f = open(config, "r")
for line in f.readlines():
if line.startswith("sendAnonymousStats"):
if line.strip().strip(";").split(":=")[1].strip() == "1":
can_share = True
break
f.close()
override = os.getenv("HOUDINI_ANONYMOUS_STATISTICS", 1)
if int(override) == 0:
can_share = False
return can_share
def track_event(category, action, label=None, value=0):
data = {
'v': '1', # API Version.
'tid': GA_TRACKING_ID, # Tracking ID / Property ID.
# Anonymous Client Identifier. Ideally, this should be a UUID that
# is associated with particular user, device, or browser instance.
'cid': '555',
't': 'event', # Event hit type.
'ec': category, # Event category.
'ea': action, # Event action.
'el': label, # Event label.
'ev': value, # Event value, must be an integer
}
try:
response = requests.post(
'http://www.google-analytics.com/collect', data=data, timeout=0.001)
except:
pass
def like_node(node):
if can_send_anonymous_stats():
track_event("Like Events", "liked node", str(node.type().name()))
hou.ui.displayMessage("Thanks!\n We're glad you like using this tool.\n"
" Letting us know will help us prioritize which tools get focused on. ")