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
91 lines (70 loc) · 2.66 KB
/
Copy pathgamedevutils.py
File metadata and controls
91 lines (70 loc) · 2.66 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
import hou
import uuid
try:
import requests
requests_enabled = True
except:
# requests library missing
requests_enabled = False
try:
from PySide2.QtCore import QSettings
settings = QSettings("SideFX", "GameDevToolset")
except:
settings = None
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):
# Generate a random user ID and store it as a setting per Google's guidelines
hou_uuid = uuid.uuid4()
if settings:
if settings.value("uuid"):
hou_uuid = settings.value("uuid")
else:
hou_uuid = uuid.uuid4()
settings.setValue("uuid", hou_uuid)
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': hou_uuid,
'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
}
if requests_enabled:
try:
response = requests.post(
'http://www.google-analytics.com/collect', data=data, timeout=0.1)
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. ")
def dislike_node(node):
if can_send_anonymous_stats():
track_event("Like Events", "dislike node", str(node.type().name()))
hou.ui.displayMessage("Thanks!\n We're sorry you're not enjoying using this tool.\n"
" If you'd like to share your thoughts, please email us at support@sidefx.com. ")
def send_on_create_analytics(node):
if can_send_anonymous_stats():
track_event("Node Created", str(node.type().name()), str(node.type().definition().version()))