-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from snowplow/release/1.3.0
Release/1.3.0
- Loading branch information
Showing
30 changed files
with
594 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,97 @@ | ||
/* | ||
* Copyright (c) 2023 Snowplow Analytics Ltd. All rights reserved. | ||
* This program is licensed to you under the Apache License Version 2.0, | ||
* and you may not use this file except in compliance with the Apache License | ||
* Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the Apache License Version 2.0 is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the Apache License Version 2.0 for the specific | ||
* language governing permissions and limitations there under. | ||
*/ | ||
|
||
using Snowplow.Tracker; | ||
using Snowplow.Tracker.Logging; | ||
using Snowplow.Tracker.Models; | ||
using Snowplow.Tracker.Models.Events; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace Snowplow.Demo.Console | ||
string collectorHostname = "http://localhost:9090"; | ||
int port = 80; | ||
|
||
// help the user out a bit with ports | ||
if (Uri.IsWellFormedUriString(collectorHostname, UriKind.Absolute)) | ||
{ | ||
public class Program | ||
Uri tmp; | ||
if (Uri.TryCreate(collectorHostname, UriKind.Absolute, out tmp)) | ||
Check warning on line 13 in Snowplow.Demo.Console/Program.cs
|
||
{ | ||
|
||
/// <summary> | ||
/// Runs the Console Demo application | ||
/// </summary> | ||
/// <param name="args"></param> | ||
public static void Main(string[] args) | ||
if (tmp.Scheme == "http" || tmp.Scheme == "https") | ||
{ | ||
string collectorHostname = "<invalid>"; | ||
int port = 80; | ||
collectorHostname = tmp.Host; | ||
port = tmp.Port; | ||
} | ||
} | ||
} | ||
|
||
int count = 100; | ||
Console.WriteLine("Demo app started - sending events to " + collectorHostname + " port " + port); | ||
|
||
switch (args.Count()) | ||
{ | ||
case 2: | ||
count = Int32.Parse(args[1]); | ||
goto case 1; | ||
case 1: | ||
collectorHostname = args[0]; | ||
break; | ||
default: | ||
System.Console.WriteLine("Invalid arguments. Usage: <app> <collector-hostname> [number of events to send]"); | ||
return; | ||
} | ||
var logger = new ConsoleLogger(); | ||
|
||
// help the user out a bit with ports | ||
if (Uri.IsWellFormedUriString(collectorHostname, UriKind.Absolute)) | ||
{ | ||
Uri tmp; | ||
if (Uri.TryCreate(collectorHostname, UriKind.Absolute, out tmp)) | ||
{ | ||
if (tmp.Scheme == "http" || tmp.Scheme == "https") | ||
{ | ||
collectorHostname = tmp.Host; | ||
port = tmp.Port; | ||
} | ||
} | ||
} | ||
Tracker.Instance.Start(collectorHostname, "snowplow-demo-app.db", l: logger, endpointPort: port); | ||
|
||
System.Console.WriteLine("Demo app started - sending " + count + " events to " + collectorHostname + " port " + port); | ||
// page view | ||
Tracker.Instance.Track(new PageView().SetPageUrl("http://helloworld.com/sample/sample.php").Build()); | ||
|
||
var logger = new ConsoleLogger(); | ||
// mobile screen view | ||
MobileScreenView msv = new MobileScreenView("00000000-0000-0000-0000-000000000000", "name") | ||
.SetType("type") | ||
.SetPreviousName("previousName") | ||
.SetPreviousId("00000000-0000-0000-0000-000000000000") | ||
.SetPreviousType("previousType") | ||
.SetTransitionType("transitionType") | ||
.Build(); | ||
Tracker.Instance.Track(msv); | ||
|
||
Tracker.Tracker.Instance.Start(collectorHostname, "snowplow-demo-app.db", l: logger, endpointPort: port); | ||
// old screen view | ||
Tracker.Instance.Track(new ScreenView() | ||
Check warning on line 43 in Snowplow.Demo.Console/Program.cs
|
||
.SetId("example-screen-id") | ||
.SetName("Example Screen") | ||
.Build()); | ||
|
||
for (int i = 0; i < count; i++) | ||
{ | ||
Tracker.Tracker.Instance.Track(new PageView().SetPageUrl("http://helloworld.com/sample/sample.php").Build()); | ||
} | ||
// self-describing event | ||
SelfDescribingJson sdj = new SelfDescribingJson("iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0", new Dictionary<string, object> { | ||
{ "category", "SdjTimingCategory" }, | ||
{ "variable", "SdjTimingVariable" }, | ||
{ "timing", 0 }, | ||
{ "label", "SdjTimingLabel" } | ||
}); | ||
Tracker.Instance.Track(new SelfDescribing() | ||
.SetEventData(sdj) | ||
.Build()); | ||
|
||
Tracker.Tracker.Instance.Flush(); | ||
Tracker.Tracker.Instance.Stop(); | ||
// timing event | ||
Tracker.Instance.Track(new Timing() | ||
.SetCategory("category") | ||
.SetVariable("variable") | ||
.SetTiming(5) | ||
.SetLabel("label") | ||
.Build()); | ||
|
||
System.Console.WriteLine("Demo app finished"); | ||
System.Console.Out.Flush(); | ||
} | ||
} | ||
} | ||
// structured event | ||
Tracker.Instance.Track(new Structured() | ||
.SetCategory("exampleCategory") | ||
.SetAction("exampleAction") | ||
.SetLabel("exampleLabel") | ||
.SetProperty("exampleProperty") | ||
.SetValue(17) | ||
.Build()); | ||
|
||
// ecommerce transaction | ||
var item1 = new EcommerceTransactionItem().SetSku("pbz0026").SetPrice(20).SetQuantity(1).Build(); | ||
var item2 = new EcommerceTransactionItem().SetSku("pbz0038").SetPrice(15).SetQuantity(1).SetName("shirt").SetCategory("clothing").Build(); | ||
var items = new List<EcommerceTransactionItem> { item1, item2 }; | ||
Tracker.Instance.Track(new EcommerceTransaction() | ||
.SetOrderId("6a8078be") | ||
.SetTotalValue(35) | ||
.SetAffiliation("affiliation") | ||
.SetTaxValue(3) | ||
.SetShipping(0) | ||
.SetCity("Phoenix") | ||
.SetState("Arizona") | ||
.SetCountry("US") | ||
.SetCurrency("USD") | ||
.SetItems(items) | ||
.Build()); | ||
|
||
Tracker.Instance.Flush(); | ||
Tracker.Instance.Stop(); | ||
|
||
Console.WriteLine("Demo app finished"); | ||
Console.Out.Flush(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...atformExtensions/Snowplow.Tracker.PlatformExtensions.Droid/Resources/Resource.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.