예제 #1
0
        /// <summary>
        /// Adds the tracker payload to the emitter.
        /// </summary>
        /// <param name="payload">The base event payload.</param>
        /// <param name="contexts">The list of contexts from the event.</param>
        private void AddTrackerPayload(TrackerPayload payload, List <IContext> contexts, string eventId)
        {
            // Add default parameters to the payload
            payload.Add(Constants.PLATFORM, this.platform.Value);
            payload.Add(Constants.APP_ID, this.appId);
            payload.Add(Constants.NAMESPACE, this.trackerNamespace);
            payload.Add(Constants.TRACKER_VERSION, Version.VERSION);

            // Add the subject data if available
            if (subject != null)
            {
                payload.AddDict(subject.GetPayload().GetDictionary());
            }

            // Add the session context if available
            if (session != null)
            {
                contexts.Add(session.GetSessionContext(eventId));
            }

            // Build the final context and add it to the payload
            if (contexts != null && contexts.Count > 0)
            {
                SelfDescribingJson envelope = GetFinalContext(contexts);
                payload.AddJson(envelope.GetDictionary(), this.base64Encoded, Constants.CONTEXT_ENCODED, Constants.CONTEXT);
            }

            Log.Verbose("Tracker: Sending event to the emitter.");
            Log.Verbose(" + Event: " + payload.ToString());

            // Add the event to the emitter.
            emitter.Add(payload);
        }
예제 #2
0
        // --- Interface Methods

        /// <summary>
        /// Gets the event payload.
        /// </summary>
        /// <returns>The event payload</returns>
        public override IPayload GetPayload()
        {
            TrackerPayload payload = new TrackerPayload();

            payload.Add(Constants.EVENT, Constants.EVENT_UNSTRUCTURED);
            SelfDescribingJson envelope = new SelfDescribingJson(Constants.SCHEMA_UNSTRUCT_EVENT, this.eventData.GetDictionary());

            payload.AddJson(envelope.GetDictionary(), this.base64Encode, Constants.UNSTRUCTURED_ENCODED, Constants.UNSTRUCTURED);
            return(AddDefaultPairs(payload));
        }