public InstrumentationEvent BuildEvent()
        {
            string eventId = Guid.NewGuid().ToString();

            if (string.IsNullOrEmpty(Name))
            {
                throw new EventBuilderException("Mandatory field 'name' not set!");
            }
            var deviceAppAttributes = AnalyticsManager.GetDeviceAppAttributes();

            if (deviceAppAttributes == null)
            {
                throw new EventBuilderException("Mandatory field 'device app attributes' not set!");
            }
            if (SchemaType != InstrumentationEvent.SchemaType.LightningPerformance && Page == null)
            {
                throw new EventBuilderException("Mandatory field 'page' not set!");
            }

            var sequenceId = AnalyticsManager.GetGlobalSequenceId() + 1;

            AnalyticsManager.SetGlobalSequenceId(sequenceId);

            // Defaults to current time if not explicitly set.
            long curTime = DateTime.Now.Ticks;

            StartTime        = StartTime == 0 ? curTime : StartTime;
            SessionStartTime = SessionStartTime == 0 ? curTime : SessionStartTime;
            return(new InstrumentationEvent(eventId, StartTime, EndTime, Name, Attributes, SessionId,
                                            sequenceId, SenderId, SenderContext, SchemaType, EventType, ErrorType,
                                            deviceAppAttributes, GetConnectionType(), SenderParentId, SessionStartTime, Page,
                                            PreviousPage, Marks));
        }