Example #1
0
        public void SendEvent([NotNull] EventBuilder builder)
        {
            try
            {
                var body = builder.ToArray();
                var req  = new RawMercuryRequest("hm://event-service/v1/events", "POST");
                req._payload.Add(body);
                req.AddUserField("Accept-Language", "en");
                req.AddUserField("X-ClientTimeStamp", TimeProvider.CurrentTimeMillis().ToString());

                MercuryResponse resp = _session.Mercury().SendSync(req);
                Debug.WriteLine(
                    $"Event sent. body: {EventBuilder.ToString(body)}, result: {resp.StatusCode.ToString()}");
            }
            catch (IOException ex)
            {
                Debug.WriteLine("Failed sending event: " + builder + ex.ToString());
            }
        }