mozilla_schema_generator.main_ping

 1# -*- coding: utf-8 -*-
 2
 3# This Source Code Form is subject to the terms of the Mozilla Public
 4# License, v. 2.0. If a copy of the MPL was not distributed with this
 5# file, You can obtain one at http://mozilla.org/MPL/2.0/.
 6
 7from .common_ping import CommonPing
 8from .utils import prepend_properties
 9
10
11class MainPing(CommonPing):
12    schema_url = (
13        "https://raw.githubusercontent.com/mozilla-services/mozilla-pipeline-schemas"
14        "/{branch}/schemas/telemetry/main/main.4.schema.json"
15    )
16
17    def __init__(self, **kwargs):
18        super().__init__(self.schema_url, **kwargs)
19
20    def _update_env(self, schema):
21        integer = {"type": "integer"}
22        simple_measurements = prepend_properties(("payload", "simpleMeasurements", ""))[
23            :-1
24        ]
25
26        schema.set_schema_elem(simple_measurements + ("activeTicks",), integer)
27        schema.set_schema_elem(simple_measurements + ("blankWindowShown",), integer)
28        schema.set_schema_elem(simple_measurements + ("firstPaint",), integer)
29        schema.set_schema_elem(simple_measurements + ("main",), integer)
30        schema.set_schema_elem(simple_measurements + ("sessionRestored",), integer)
31        schema.set_schema_elem(simple_measurements + ("totalTime",), integer)
32
33        return super()._update_env(schema)
12class MainPing(CommonPing):
13    schema_url = (
14        "https://raw.githubusercontent.com/mozilla-services/mozilla-pipeline-schemas"
15        "/{branch}/schemas/telemetry/main/main.4.schema.json"
16    )
17
18    def __init__(self, **kwargs):
19        super().__init__(self.schema_url, **kwargs)
20
21    def _update_env(self, schema):
22        integer = {"type": "integer"}
23        simple_measurements = prepend_properties(("payload", "simpleMeasurements", ""))[
24            :-1
25        ]
26
27        schema.set_schema_elem(simple_measurements + ("activeTicks",), integer)
28        schema.set_schema_elem(simple_measurements + ("blankWindowShown",), integer)
29        schema.set_schema_elem(simple_measurements + ("firstPaint",), integer)
30        schema.set_schema_elem(simple_measurements + ("main",), integer)
31        schema.set_schema_elem(simple_measurements + ("sessionRestored",), integer)
32        schema.set_schema_elem(simple_measurements + ("totalTime",), integer)
33
34        return super()._update_env(schema)
MainPing(**kwargs)
18    def __init__(self, **kwargs):
19        super().__init__(self.schema_url, **kwargs)
schema_url = 'https://raw.githubusercontent.com/mozilla-services/mozilla-pipeline-schemas/{branch}/schemas/telemetry/main/main.4.schema.json'