Skip to content

Instantly share code, notes, and snippets.

@daoshengmu
Last active July 20, 2020 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daoshengmu/5c5f77135cb5a6f4f1d66701a748bcab to your computer and use it in GitHub Desktop.
Save daoshengmu/5c5f77135cb5a6f4f1d66701a748bcab to your computer and use it in GitHub Desktop.
Glean Unity Hello world
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