unity-wakatime icon indicating copy to clipboard operation
unity-wakatime copied to clipboard

Send current OS

Open Hermesiss opened this issue 6 years ago • 3 comments

Now it's Unknown OS

alt text alt text

Hermesiss avatar Mar 27 '19 15:03 Hermesiss

Great! Unity has SystemInfo.operatingSystem. Should its output be formatted before sent to WakaTime? For example, "Windows 7 (6.1.7601) 64bit"...

vladfaust avatar Mar 27 '19 17:03 vladfaust

  1. I need a list of operating systems that are in use in Wakatime. Rider and VsCode use Windows, we cant break this by adding details. Or maybe we should?
  2. I found only 2 ways to monitor OSs - in Timeless android app and embedded section, both are not quite convenient for testing

Hermesiss avatar Mar 27 '19 18:03 Hermesiss

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

alanhamlett avatar Jul 16 '19 15:07 alanhamlett