本文整理汇总了C#中Tracker.TrackPageView方法的典型用法代码示例。如果您正苦于以下问题:C# Tracker.TrackPageView方法的具体用法?C# Tracker.TrackPageView怎么用?C# Tracker.TrackPageView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tracker
的用法示例。
在下文中一共展示了Tracker.TrackPageView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testTrackPageView
public void testTrackPageView()
{
using (Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create())
{
ShimHttpWebRequest.AllInstances.GetResponse = fake;
var t = new Tracker(new Emitter("d3rkrsqld9gmqf.cloudfront.net"));
t.TrackPageView("http://www.example.com", "title page", "http://www.referrer.com");
var expected = new Dictionary<string, string>
{
{"e", "pv"},
{"url", "http://www.example.com"},
{"page", "title page"},
{"refr", "http://www.referrer.com"}
};
checkResult(expected, payloads[payloads.Count - 1]);
}
}
示例2: testAsyncPostOnFailure
public void testAsyncPostOnFailure()
{
using (Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create())
{
ShimHttpWebRequest.AllInstances.GetResponse = badFake;
int? successes = null;
List<Dictionary<string, string>> failureList = null;
var e = new AsyncEmitter("d3rkrsqld9gmqf.cloudfront.net", HttpProtocol.HTTP, null, HttpMethod.POST, 10, null, (successCount, failures) =>
{
successes = successCount;
failureList = failures;
});
var t = new Tracker(e);
t.TrackPageView("first");
t.TrackPageView("second");
t.Flush(true);
Assert.AreEqual(0, successes);
Assert.AreEqual("first", failureList[0]["url"]);
Assert.AreEqual("second", failureList[1]["url"]);
}
}
示例3: testContext
public void testContext()
{
using (Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create())
{
ShimHttpWebRequest.AllInstances.GetResponse = fake;
var pageContext = new Dictionary<string, object>
{
{"schema", "iglu:com.snowplowanalytics.snowplow/page/jsonschema/1-0-0"},
{"data", new Dictionary<string, object>
{
{ "type", "test" },
{ "public", false }
}
}
};
var userContext = new Dictionary<string, object>
{
{"schema", "iglu:com.snowplowanalytics.snowplow/user/jsonschema/1-0-0"},
{"data", new Dictionary<string, object>
{
{ "age", 40 },
{ "name", "Ned" }
}
}
};
var context = new List<Dictionary<string, object>>
{
pageContext,
userContext
};
var t = new Tracker(new Emitter("d3rkrsqld9gmqf.cloudfront.net"));
t.TrackPageView("http://www.example.com", null, null, context);
var expected = new Dictionary<string, string>
{
{"e", "pv"},
{"url", "http://www.example.com"}
};
checkResult(expected, payloads[payloads.Count - 1]);
var expectedJsonString = @"{""schema"":""iglu:com.snowplowanalytics.snowplow/contexts/1-0-0"",""data"":[{""schema"":""iglu:com.snowplowanalytics.snowplow/page/jsonschema/1-0-0"",""data"":{""type"":""test"",""public"":false}},{""schema"":""iglu:com.snowplowanalytics.snowplow/user/jsonschema/1-0-0"",""data"":{""age"":40,""name"":""Ned""}}]}";
byte[] data = Convert.FromBase64String(payloads[payloads.Count - 1]["cx"]);
string actualJsonString = Encoding.UTF8.GetString(data);
Assert.AreEqual(expectedJsonString, actualJsonString);
}
}
示例4: testAsyncPostOnSuccess
public void testAsyncPostOnSuccess()
{
using (Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create())
{
ShimHttpWebRequest.AllInstances.GetResponse = fake;
int successes = -1;
var e = new AsyncEmitter("d3rkrsqld9gmqf.cloudfront.net", HttpProtocol.HTTP, null, HttpMethod.POST, 10, (successCount) =>
{
successes = successCount;
});
var t = new Tracker(e);
t.TrackPageView("first");
t.TrackPageView("second");
t.Flush(true);
Assert.AreEqual(2, successes);
}
}
示例5: testSetterMethods
public void testSetterMethods()
{
using (Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create())
{
ShimHttpWebRequest.AllInstances.GetResponse = fake;
var t = new Tracker(new Emitter("d3rkrsqld9gmqf.cloudfront.net"), null, "cf", "train simulator");
t.SetPlatform(Platform.Mob);
t.SetUserId("malcolm");
t.SetScreenResolution(100, 200);
t.SetViewport(50, 60);
t.SetColorDepth(24);
t.SetTimezone("Europe London");
t.SetLang("en");
t.TrackPageView("http://www.example.com", "title page", "http://www.referrer.com", null, 1000000000000);
var expected = new Dictionary<string, string>
{
{"e", "pv"},
{"url", "http://www.example.com"},
{"page", "title page"},
{"refr", "http://www.referrer.com"},
{"tv", Version.VERSION},
{"tna", "cf"},
{"aid", "train simulator"},
{"p", "mob"},
{"res", "100x200"},
{"vp", "50x60"},
{"cd", "24"},
{"tz", "Europe London"},
{"lang", "en"},
{"dtm", "1000000000000"}
};
checkResult(expected, payloads[payloads.Count - 1]);
}
}