コード例 #1
0
ファイル: PingTypeTest.cs プロジェクト: suryatmodulus/glean
        public void SendCustomPingsWithSnakeCase()
        {
            PingType <NoReasonCodes> customPing = new PingType <NoReasonCodes>(
                name: "custom_ping",
                includeClientId: true,
                sendIfEmpty: false,
                reasonCodes: null
                );

            BooleanMetricType sampleMetric = new BooleanMetricType(
                disabled: false,
                category: "test",
                lifetime: Lifetime.Ping,
                name: "boolean_metric",
                sendInPings: new string[] { "custom_ping" }
                );

            sampleMetric.Set(true);
            Assert.True(sampleMetric.TestHasValue());

            customPing.Submit();

            MockUploader.UploadRequest request = mockUploader.GetPendingUpload();
            Assert.Equal("custom_ping", request.docType);

            // Check that we have a non-null client id.
            JsonDocument jsonPayload = JsonDocument.Parse(request.payload);
            JsonElement  root        = jsonPayload.RootElement;

            Assert.NotNull(root.GetProperty("client_info").GetProperty("client_id").GetString());

            // TODO: Check the ping schema.
            // checkPingSchema(pingJson)
        }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        // Redirect third party library logs to Unity panel.
        SystemConsoleRedirector.Redirect();

        Console.WriteLine("Begin Glean test.");

        GleanInstance.Initialize(
            applicationId: "org.mycompany.glean.tests",
            applicationVersion: "0.1",
            uploadEnabled: true,
            configuration: new Configuration(channel: "debug", maxEvents: 500),
            dataDir: "data"
            );

        // Create a custom ping.
        var ping = new PingType <NoReasonCodes>(
            name: "custom",
            includeClientId: true,
            sendIfEmpty: false,
            reasonCodes: null
            );

        // Init launch ping.
        var metric = new StringMetricType(
            category: "hello_world",
            disabled: false,
            lifetime: Lifetime.Application,
            name: "test",
            sendInPings: new string[] { "custom" }
            );

        metric.Set("my_data");
        ping.Submit();

        Console.WriteLine("End of Glean test.");
    }