Pier Angelo Vendrame pushed to branch tor-browser-146.0a1-16.0-2 at The Tor Project / Applications / Tor Browser

Commits:

2 changed files:

Changes:

  • python/mach/mach/sentry.py
    ... ... @@ -8,7 +8,7 @@ import sys
    8 8
     from pathlib import Path
    
    9 9
     from threading import Thread
    
    10 10
     
    
    11
    -# import sentry_sdk
    
    11
    +import sentry_sdk
    
    12 12
     from mozversioncontrol import (
    
    13 13
         InvalidRepoPath,
    
    14 14
         MissingUpstreamRepo,
    
    ... ... @@ -35,8 +35,7 @@ class SentryErrorReporter(ErrorReporter):
    35 35
         """Reports errors using Sentry."""
    
    36 36
     
    
    37 37
         def report_exception(self, exception):
    
    38
    -        pass
    
    39
    -        # return sentry_sdk.capture_exception(exception)
    
    38
    +        return sentry_sdk.capture_exception(exception)
    
    40 39
     
    
    41 40
     
    
    42 41
     class NoopErrorReporter(ErrorReporter):
    
    ... ... @@ -62,10 +61,10 @@ def register_sentry(argv, settings, topsrcdir: Path):
    62 61
         )
    
    63 62
         _is_unmodified_mach_core_thread.start()
    
    64 63
     
    
    65
    -    # sentry_sdk.init(
    
    66
    -    #     _SENTRY_DSN, before_send=lambda event, _: _process_event(event, topsrcdir)
    
    67
    -    # )
    
    68
    -    # sentry_sdk.add_breadcrumb(message="./mach {}".format(" ".join(argv)))
    
    64
    +    sentry_sdk.init(
    
    65
    +        _SENTRY_DSN, before_send=lambda event, _: _process_event(event, topsrcdir)
    
    66
    +    )
    
    67
    +    sentry_sdk.add_breadcrumb(message="./mach {}".format(" ".join(argv)))
    
    69 68
         return SentryErrorReporter()
    
    70 69
     
    
    71 70
     
    

  • python/mach/mach/telemetry.py
    ... ... @@ -7,9 +7,11 @@ import importlib.util
    7 7
     import os
    
    8 8
     import subprocess
    
    9 9
     import sys
    
    10
    +import urllib.parse as urllib_parse
    
    10 11
     from pathlib import Path
    
    11 12
     from textwrap import dedent
    
    12 13
     
    
    14
    +import requests
    
    13 15
     from mozbuild.base import BuildEnvironmentNotFoundException, MozbuildObject
    
    14 16
     from mozbuild.telemetry import filter_args
    
    15 17
     from mozfile import json
    
    ... ... @@ -90,7 +92,10 @@ def is_applicable_telemetry_environment():
    90 92
     
    
    91 93
     
    
    92 94
     def is_telemetry_enabled(settings):
    
    93
    -    return False
    
    95
    +    if os.environ.get("DISABLE_TELEMETRY") == "1":
    
    96
    +        return False
    
    97
    +
    
    98
    +    return settings.mach_telemetry.is_enabled
    
    94 99
     
    
    95 100
     
    
    96 101
     def arcrc_path():
    
    ... ... @@ -127,7 +132,40 @@ def resolve_setting_from_arcconfig(topsrcdir: Path, setting):
    127 132
     
    
    128 133
     
    
    129 134
     def resolve_is_employee_by_credentials(topsrcdir: Path):
    
    130
    -    return None
    
    135
    +    try:
    
    136
    +        phabricator_uri = resolve_setting_from_arcconfig(topsrcdir, "phabricator.uri")
    
    137
    +
    
    138
    +        if not phabricator_uri:
    
    139
    +            return None
    
    140
    +
    
    141
    +        with arcrc_path().open() as arcrc_file:
    
    142
    +            arcrc = json.load(arcrc_file)
    
    143
    +
    
    144
    +        phabricator_token = (
    
    145
    +            arcrc.get("hosts", {})
    
    146
    +            .get(urllib_parse.urljoin(phabricator_uri, "api/"), {})
    
    147
    +            .get("token")
    
    148
    +        )
    
    149
    +
    
    150
    +        if not phabricator_token:
    
    151
    +            return None
    
    152
    +
    
    153
    +        bmo_uri = (
    
    154
    +            resolve_setting_from_arcconfig(topsrcdir, "bmo_url")
    
    155
    +            or "https://bugzilla.mozilla.org"
    
    156
    +        )
    
    157
    +        bmo_api_url = urllib_parse.urljoin(bmo_uri, "rest/whoami")
    
    158
    +        bmo_result = requests.get(
    
    159
    +            bmo_api_url, headers={"X-PHABRICATOR-TOKEN": phabricator_token}
    
    160
    +        )
    
    161
    +
    
    162
    +        return "mozilla-employee-confidential" in bmo_result.json().get("groups", [])
    
    163
    +    except (
    
    164
    +        FileNotFoundError,
    
    165
    +        json.JSONDecodeError,
    
    166
    +        requests.exceptions.RequestException,
    
    167
    +    ):
    
    168
    +        return None
    
    131 169
     
    
    132 170
     
    
    133 171
     def resolve_is_employee_by_vcs(topsrcdir: Path):