Inheritance: Segmentio.Model.BaseAction
コード例 #1
0
		public void SerializationOfIdentifyIncludesContextWithLanguage()
		{
			var identify = new Identify("99",
				 new Traits() { },
						DateTime.UtcNow,
						new Context()
							.SetLanguage("fr"));

			var settings = new JsonSerializerSettings
			{
				Converters = new List<JsonConverter> { new ContextSerializer() }
			};
			string json = JsonConvert.SerializeObject(identify, settings);
			Assert.IsTrue(json.Contains("\"language\":\"fr\""));
		}
コード例 #2
0
		public void DemonstrateWhyContextSerializerIsNeeded()
		{
			var identify = new Identify("99",
				 new Traits() { },
						DateTime.UtcNow,
						new Context()
							.SetIp("12.212.12.49"));

			var settings = new JsonSerializerSettings
			{
				//notice, we are failing to specify a special converter
			};
			string json = JsonConvert.SerializeObject(identify, settings);
			Assert.IsFalse(json.Contains("12.212.12.49"));
		}
コード例 #3
0
		public void SerializationOfIdentifyIncludesContextWithIPAddress()
		{
			var identify = new Identify("99",
				 new Traits() {},
                        DateTime.UtcNow,
                        new Context()
                            .SetIp("12.212.12.49"));

			var settings = new JsonSerializerSettings
			{
				Converters = new List<JsonConverter> { new ContextSerializer() }
			};
			string json = JsonConvert.SerializeObject(identify,settings);
			Assert.IsTrue(json.Contains("\"ip\":\"12.212.12.49\""));
		}
コード例 #4
0
		public void SerializationOfIdentifyIncludesContextWithProviders()
		{
			var identify = new Identify("99",
				 new Traits() { },
						DateTime.UtcNow,
						new Context()
							.SetProviders(new Providers() {
                                { "all", false },
                                { "Mixpanel", true },
                                { "Salesforce", true }}));

			var settings = new JsonSerializerSettings
			{
				Converters = new List<JsonConverter> { new ContextSerializer() }
			};
			string json = JsonConvert.SerializeObject(identify, settings);
			Assert.IsTrue(json.Contains("\"providers\""));
		}
コード例 #5
0
ファイル: Client.cs プロジェクト: Monkimun/segmentio-unity
        /// <summary>
        /// Identifying a visitor ties all of their actions to an ID you
        /// recognize and records visitor traits you can segment by.
        /// </summary>
        ///
        /// <param name="userId">The visitor's identifier after they log in, or you know
        /// who they are. By
        /// explicitly identifying a user, you tie all of their actions to their identity.</param>
        ///
        /// <param name="traits">A dictionary with keys like "email", "name", “subscriptionPlan” or
        /// "friendCount”. You can segment your users by any trait you record.
        /// Pass in values in key-value format. String key, then its value
        /// { String, Integer, Boolean, Double, or Date are acceptable types for a value. } </param>
        ///
        /// <param name="timestamp">  If this event happened in the past, the timestamp
        /// can be used to designate when the identification happened. Careful with this one,
        /// if it just happened, leave it null.</param>
        /// <param name="context"> A dictionary with additional information thats related to the visit.
        /// Examples are userAgent, and IP address of the visitor.
        /// Feel free to pass in null if you don't have this information.</param>
        ///
        ///
        public void Identify(string userId, Traits traits,
               DateTime? timestamp, ContextSegmentIO context)
        {
            if (String.IsNullOrEmpty(userId))
                throw new InvalidOperationException("Please supply a valid userId to Identify.");

            Identify identify = new Identify(userId, traits, timestamp, context);

            Enqueue(identify);
        }