Last active
July 20, 2020 22:24
-
-
Save daoshengmu/5c5f77135cb5a6f4f1d66701a748bcab to your computer and use it in GitHub Desktop.
Glean Unity Hello world
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Mozilla.Glean; | |
using Mozilla.Glean.Private; | |
using System; | |
using UnityEngine; | |
using static Mozilla.Glean.Glean; | |
public class main : MonoBehaviour | |
{ | |
// Start is called before the first frame update | |
void Start() | |
{ | |
GleanInstance.Initialize( | |
applicationId: "org.mycompany.glean.tests", | |
applicationVersion: "0.1", | |
uploadEnabled: true, | |
configuration: new Configuration(), | |
dataDir: "data" | |
); | |
// Create a custom ping. | |
var ping = new PingType<NoReasonCodes>( | |
name: "custom", | |
includeClientId: true, | |
sendIfEmpty: false, | |
reasonCodes: null | |
); | |
// Init our first metric, test metric in hello_world category. | |
// It wil be uploaded in the custom ping. | |
var metric = new StringMetricType( | |
category: "hello_world", | |
disabled: false, | |
lifetime: Lifetime.Application, | |
name: "test", | |
sendInPings: new string[] { "custom" } | |
); | |
// Set data to the test metric. | |
metric.Set("my_data"); | |
// Submit the custom ping. | |
ping.Submit(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment