unity-wakatime
unity-wakatime copied to clipboard
Send current OS
Now it's Unknown OS

Great! Unity has SystemInfo.operatingSystem. Should its output be formatted before sent to WakaTime? For example, "Windows 7 (6.1.7601) 64bit"...
The User Agent API Endpoint is a good way to see how the user agent string sent from plugins (aka value) is translated into an operating system (aka os). The three operating systems supported on WakaTime dashboards are Mac, Windows, and Linux. Here's the Python code used on the server to translate user agent value string into an os:
class UserAgent(Model):
id = db.Column(UUID(), primary_key=True, default=uuid.uuid4)
user_id = db.Column(UUID(), db.ForeignKey('user.id'), nullable=False)
value = db.Column(db.String(600), nullable=False)
last_seen = db.Column(db.DateTime())
created_at = db.Column(db.DateTime(), nullable=False, default=datetime.utcnow)
__table_args__ = (
db.UniqueConstraint('user_id', 'value'),
)
@property
def os(self):
os = None
try:
ua = self.value.lower()
if 'darwin' in ua or 'macintosh' in ua:
os = 'Mac'
elif 'windows' in ua:
os = 'Windows'
elif 'linux' in ua or 'bsd' in ua or 'unix' in ua:
os = 'Linux'
except:
pass
return os