How to Install and Run the Windows 8.1 Preview in Hyper-V

The big announcement from //BUILD 2013 is the pending arrival of Windows 8.1, aka “Windows Blue,” and Microsoft made Windows 8.1 available for download immediately following the //BUILD keynote on Wednesday.

Like many developers, the MarkedUp Analytics team is naturally excited to try new things; that being said – we also don’t like having to wipe a dev machine and re-image it in the event that a beta release of Windows isn’t compatible with tools we use for doing our jobs every day.

So, we use Hyper-V or VirtualBox and run Windows 8.1 in a VM until it’s released to market.

Here’s how to get Windows 8.1 running in Hyper-V:

1. Download the Windows 8.1 Preview ISO

Download any of the Windows 8.1 Preview ISO images here. Pick whichever one best suits your needs. I’m going to use the English 64-bit .ISO.

2. Open Hyper-V and create a new virtual machine

If you’re running Windows 8 already, Hyper-V comes built into the operating system. Once the Windows 8.1 preview ISO is finished downloading you’ll want to create a new VM.

step1 - new VM

We’ll name our VM “Windows 8.1 Preview” and use the default storage location.

step2 - name VM

Windows 8 needs at least 2GB of RAM on a 64-bit system; I’m going to give this VM 4GB since I plan on running Visual Studio and some other RAM-intensive software on it later.

step3 - allocate RAM to VM

For now we’re going to leave the VM’s network as “Not Connected” – we’ll create a Virtual Network Adapter for it later.

If you already have a Hyper-V virtual network adapter that can share Internet connectivity with the host machine, use it here. Otherwise we’ll add one later after the OS installation on the VM is complete.

step4 - set VM network to not connected

Windows 8 needs at least 20GB of disk space on a 64-bit system. I’m going to give this VM 40GB and I’m going to use a dynamically expanding disk.

Dynamically expanding disks will be slow initially, but it saves room on the host machine in the event that you don’t occupy the entire VHD volume immediately.

If speed is an issue, you can create a fixed-size disk up front.

step5 - set VHD creation options for VM

3. Install Windows 8.1 Preview from ISO

Now we’re going to use the Windows 8.1 Preview .ISO file we downloaded earlier to install the operating system while we finalize our VM.

stp6 - install OS via Windows 8.1 ISO

This option will have you complete the Windows 8.1 Preview installation the first time the VM boots, using the .ISO file you downloaded earlier as the bootable media.

With all of those steps complete, you should now see the “Windows 8.1 Preview” VM on your Hyper-V list:

step7 - verify that Windows 8.1 VM is available in Hyper-V

Select the Windows 8.1 Preview VM and start it, and you should see the first “Install Windows” screen after a few seconds:

step8 - start the Windows 8.1 VM and install the OS

Click next.

You’ll need to enter in a product key for Windows 8.1 Preview during the first part of the installation process.

The product key for Windows 8.1 Preview is NTTX3-RV7VB-T7X7F-WQYYY-9Y92F, according to Microsoft’s official Windows 8.1 Preview installation instructions.

step9 - enter product key for Windows 8.1 Preview

If you see the following message and it asks you to choose between an upgrade and a custom installation, Select “Custom: Install Windows only.”

step10 - select custom install for Windows 8.1 Preview

Install Windows 8.1 on the VHD that we created earlier.

step11 - install Windows 8.1 preview on VHD created earlier

Let the Windows 8.1 Preview installation run to completion. And after 30 minutes or so you should be able to create a local Windows account and log in.

step12 - verify Windows 8.1 installation

4. If you don’t have one already, create a Virtual Network Adapter for Windows 8.1

If you didn’t have a Virtual Network Adapter ready during step 2, we’ll create one now.

First, shut down your Windows 8.1 Preview VM and turn it off – we’re about to make some changes to it.

step13 - shut off Windows 8.1 VM

Open up the Hyper-V manager and go to “Virtual Switch Manager.”

step14 - go Virtual Switch Manager in Hyper-V

Select “New virtual network switch.” Give the switch a name and make it an External Network. If you have multiple physical network adapters (i.e. ethernet and WiFi), use whichever one you use most often. Check the “allow management operating system to share this network adapter” box.

step15 - create new Virtual Adapter in HyperV

Apply changes.

Go back to your VMs and right click on the “Windows 8.1 Preview” VM you created – select “Settings,” then select “Network Adapter.”

step16 - Windows 8.1 VM network adapter settings

Change the Virtual switch to the new switch you just created; mine is called “Magical Switch.”

step17 - set virtual switch on Windows 8.1 Preview VM

Apply changes. Before we try starting the VM, let’s make sure that our switch was set up correctly – I often have trouble getting Hyper-V’s network adapters to behave properly the first time around.

Go to Control Panel and then to View Network Connections. Right click on the new switch you just created and select Properties.

step18 - verify virtual switch properties

Only the following properties should be set:

  • Client for Microsoft Networks
  • QoS Packet Scheduler
  • File and Printer Sharing for Microsoft Networks
  • Microsoft LLDP Protocol Driver
  • Link-layer Topology Discovery Mapper I/O Driver
  • Link-layer Topology Discovery Responder
  • Internet Protocol Version 6 (TCP/IPv6) and
  • Internet Protocol Version 4 (TCP/IPv4)

You will likely need to reboot your host machine in order to get the Internet working again. Go ahead and do that now.

5. Start Windows 8.1 Preview; Profit

You now should be able to start your Windows 8.1 VM in Hyper-V and connect to the Internet.

Install complete

Please give this guide a try and let us know if you run into any trouble!

Introduction to Parameterized Session Events

One of the most commonly requested features for MarkedUp has been the ability to support parameterized session events, and as of the release of MarkedUp Analytics SDK for .NET 1.0 this feature is now publicly available to our customers.

Parameterized session events help you group and categorize related user events that occur inside your applications; this gives you the ability to maintain a high-level view of how people are using your application while also allowing you to expose more details if needed.

For example: I have a Hacker News Windows Store application that I’ve been working on in my spare time and I want to be able to track how many articles people actually view when they use it.

So, I embedded a standard MK.SessionEvent call inside my WinJS application to track how many people viewed an article:

And this allows me to see the total number of times someone has viewed an article using my app:

Hacker News application with a simple, unparameterized event

But what if I want more information – what if I want to know which articles users are viewing? Parameterized session events can help us with that.

I’m going to modify the call to MK.SessionEvent and include a new parameter: “ArticleUrl.”

“ArticleUrl” is the name of my parameter, and the value of this is the URL of whatever article a user is viewing. In C# / XAML you can just pass in an IDictionary<string, string> object for all of your parameters and values, but in WinJS you need to use a Windows.Foundation.Collections.PropertySet collection.

Once I’ve run the app with this custom parameter included, I can drill down into the ViewArticle event and see a new parameter:

Hacker News app with an ArticleUrl parameter for the ViewArticle session event

And if I click on the “ArticleUrl” parameter, guess what we see next? A list of all of the URLs for each event!

hacker-news-viewarticle-articleurl-parameter-values

With that simple change, our ViewArticle event becomes much more informative and valuable – we can even use the date picker to see which articles were most popular amongst our userbase during each month or week!

Advanced Example: Distinct Session Event Parameters

Let’s take our usage of parameterized session events a step further. One of the features of my Hacker News application is the ability for it cache articles to the local filesystem in order to conserve bandwidth. I’m considering extending this capability to enable the app to run entirely offline – so my question is: how often do people really look at cached articles?

Parameterized session events can help us answer this question.

I’m going to move my MK.SessionEvent call from viewItem.js and into my caching layer – that way I can tell if the article I am serving is cached or not. Here’s my code looks like for that:

I have to different methods that are called by my app when we need to view an article – one that checks if the content is cached and serves it if it is, and another that downloads the content from the Internet.

Whenever we serve the content from cache, I pass in a ps[“Cached”] = true parameter and a ps[“NotCached”] = true whenever we don’t.

So after running the app a few times, it looks like most users don’t view cached articles very often:

Hacker News WinJS app - cached vs. uncached articles

I’m doing it this way so I can see directly at the ViewArticle view how many articles are served from cache versus those who aren’t without having to drill down any further.

But the choice is yours – parameterized session events are designed to be flexible and allow you to use them however you wish.

Make sure you check out our tutorial on using parameterized events with MarkedUp Analytics, and please let us know if you have feedback!

Using Cassandra for Real-time Analytics: Part 1

In a previous blog post titled “Cassandra, Hive, and Hadoop: How We Picked Our Analytics Stack” we talked about our process for selecting Cassandra as our data system of choice for supporting our real-time analytics platform.

We’ve been live with Cassandra in production for a couple of months now and shared some of the lessons and best practices for implementing it at the Los Angeles Cassandra Users Group on March 12, 2013. You can see the presentation on slideshare if you’d like to view our slides.

We wanted to expand on what we shared in the presentation itself and share some of our applied knowledge on how to put Cassandra to work in the field of real-time analytics.

Let’s start by helping you understand how an analytics system needs to be built.

Real-time Analytics and the CAP Theorem

For those of you who aren’t familiar with Brewer’s CAP theorem, it stipulates that it is impossible for any distributed computer system to simultaneously provide all three of the following guarantees:

  1. Consistency;

  2. Availability; and

  3. Partition tolerance.

In the real-world all distributed systems fall on a gradient with each of these three guarantees, but the kernel of truth is that there are trade offs. A system with high partition tolerance and availability (like Cassandra) will sacrifice some consistency in order do it.

When it comes to analytics, there’s a transitive application of the CAP theorem to analytic systems – we call it SCV:

analytics cap theorem

  1. Speed is how quickly you can return an appropriate analytic result from the time it was first observed – a “real-time” system will have an updated analytic result within a relatively short time of an observed event, whereas a non-real-time system might take hours or even days to process all of the observations into an analytic result.

  2. Consistency is how accurate or precise (two different things) the analytic outcome is. A totally consistent result accounts for 100% of observed data accounted for with complete accuracy and some tunable degree of precision. A less consistent system might use statistical sampling or approximations to produce a reasonably precise but less accurate result.

  3. Data Volume refers to the total amount of observed events and data that need to be analyzed. At the point when data starts to exceed the bounds of what can be fit into memory is when this starts to become a factor. Massive or rapidly growing data sets have to be analyzed by distributed systems.

If your working data set is never going to grow beyond 40-50GB over the course of its lifetime, then you can use an RDBMS like SQL Server or MySQL and have 100% consistent analytic results delivered to you in real-time – because your entire working set can fit into memory on a single machine and doesn’t need to be distributed.

Or if you’re building an application like MarkedUp Analytics, which has a rapidly growing data set and unpredictable burst loads, you’re going to need a system that sacrifices some speed or consistency in order to be distributed so it can handle the large volume of raw data.

Think about this trade off carefully before you go about building a real-time analytics system.

What Data Needs to be Real-time?

“Egads, ALL DATA SHOULD BE ALWAYS REPORTED IN REAL-TIME!” shouted every software developer ever.

Hold your horses! Real-time analytics forces a trade off between other important factors like accuracy / precision and data size. Therefore, real-time analytics isn’t inherently superior or better for every conceivable use case.

Real-time analysis is important for operational metrics and anything else you or your users need to respond to in real-time:

  • Error rates or health monitoring;

  • Dynamic prices, like stock prices or ticket fares;

  • On-the-spot personalizations and recommendations, like the product recommendations you might see when browsing Netflix or Ebay.

In these scenarios, the exact price or the exact error rate isn’t as important the rate of change or confidence interval, which can be done in real-time.

Retrospective or batch analysis is important for product / behavior analysis – these are metrics that tell you how you should or shouldn’t do something, and they are data that you can’t or shouldn’t respond to in real-time.

You don’t want to redesign your product based on fluctuations during day-to-day use – you want to redesign it based on long-term trends over all of your cohorts, and it naturally takes a long time for that data to accrue and be analyzed / studied.

In this type of analysis it’s more important for the data to be comprehensive (large) and accounted consistently.

Analytic speed is always a trade-off between data volume and consistency – you have to be concious of that when you design your system.

The one property you’re never going to want to intentionally sacrifice is data volume – data is a business asset. Data has inherent value. You want to design your analytic systems to consume and retain as much of it as possible.

At MarkedUp we use a blend of both real-time and retrospective analytics:

markedup analytics blend

In this post and the next we’re going to focus on how we use Cassandra for real-time analytics – we use Hive and Hadoop for our retrospective analysis.

Why Cassandra for Real-time Analytics?

Cassandra is an excellent choice for real-time analytic workloads, if you value speed and data volume over consistency (which we do for many of our metrics.)

So what makes Cassandra attractive?

    • Cassandra is highly available and distributed; it has high tolerance to individual node failures and makes it possible to add multi-data center support easily if data affinity or sovereignty is an issue. On top of that it’s easy to expand a Cassandra cluster with new nodes if necessary (although this shouldn’t be done frivolously since there is a high cost to rebalancing a cluster.)
    • It has amazing write performance; we’ve clocked Cassandra writes taking up to  200µs on average for us, and that’s doubly impressive considering that most of our writes are big, heavily denormalized batch mutations.
    • Batch mutations give us the ability to denormalize data heavily and update lots of counters at once – in Cassandra it’s generally a good idea to write your data to make it easy to read back out, even if that means writing it multiple times. Batch mutations make this really easy and inexpensive for our front-end data collection servers.
    • Distributed counters were added to Cassandra due at Twitter’s insistence, and they’re a major boon to anyone trying to build real-time analytic systems. Most of MarkedUp’s real time analytics are implemented using counters – they provide a simple, inexpensive, and remarkably consistent mechanism to update metrics and statistics at write time. There are some trade offs (namely the loss of idempotency) but they make up for it in simplicity and speed.
    • Physically sorted columns are one of the Cassandra database implementation details worth learning, because with it you can create easily predictable and pre-sorted slices of data. This makes for really efficient storage of time-series data and other common types of analytic output. When you combined physically sorted columns with dynamic columns and slice predicates you can create lookup systems which retrieve large data sets in constant time.
    • Dynamic columns are a Cassandra feature that takes getting used to, but they are enormously powerful for analytic workloads when coupled with sorted columns – they allow you to create flexible, predictable data structures that are easy to read and extend.

We’re going to publish a series of posts about working with Cassandra for real-time analytics. Make sure you read part 2 where we go into detail on our read / write strategy with Cassandra for analytics!

How-to: Tracking Page Navigation in Your WinRT or WinJS Applications

Today MarkedUp released a new report type which shows how often users view all of the distinct pages inside your Windows Store applications on Windows 8; so how do you how to actually capture all of this page navigation information in your app using MarkedUp?

Easy! You can use a single method to automatically track all of the page navigation information inside of your C# / C++ / HTML5 Windows Store apps: RegisterNavigationFrame.

The RegisterNavigationFrame method allows MarkedUp to automatically detect how users navigate between pages inside your application and eliminates the need for developers to have to write their own handler code and call the PageEnter event manually.

Calling RegisterNavigationFrame in C# / XAML

If you’re using C# and XAML to develop your Windows Store applications, you’ll want to call MarkedUp.AnalyticClient.RegisterNavigationFrame inside the Application.OnLaunched method, as shown below:

Calling registerNavigationFrame in HTML5 / JavaScript

If you’re using HTML5 and JavaScript to develop your Windows Store applications, you’ll want to call MK.registerNavigationFrame inside the WinJS app.onactivated method, as shown below:

Pretty simple! If you add this single line of code to your Windows Store applications you’ll see data light up on your application page views report and on others that we’re actively developing right now!

Let us know in the comments if you have any questions.

How-to: Logging Crashes Using MarkedUp

One of the most useful use-cases for MarkedUp is the ability for it to log and analyze all of the crashes users experience when consuming your apps in the Windows Store. As a developer, your number one priority is to ensure that your users are able to consume your app!

log-browser-with-crashes

Rather than just give you a big crash dump file, MarkedUp gives you some context around why and how the crash occurred. We have a bunch of new reports and stats built around this feature specifically that we’ll be rolling out over the next few weeks ;)

I’ve written before about how to handle last-chance exceptions using WinJS, and today I’m going to show you how to use MarkedUp to capture last-chance exceptions in both C# / XAML and HTML5 / JavaScript.

How to Set Up MarkedUp Crash Logging in WinJS and WinRT

In the most recent version of MarkedUp (0.5.5 as of writing this) we expose a new method called LogLastChanceException – this is a special method designed to persist crash dumps to disk at the very last possible moment when an application crashes.

Both C# / XAML and WinJS provide a last-chance exception handler as an event off of the Application (WinRT | WinJS) object, and this is the tool you can use to log crashes.

In C# / XAML, you can log crashes using MarkedUp’s LogLastChanceException method and the Application.UnhandledException event like this:

In WinJS (HTML5 / JavaScript), you can do the same thing using Application.onerror event:

Easy!

MarkedUp writes the crash dump to disk on your user’s machine when the app crashes, and the next time the user starts your application we transmit their crash dump data back to our servers for analysis and reporting.

We preserve the time that it happened locally on that user’s machine so you’ll always have completely verifiable data to accurately correlate when a crash did or did not happen.

Further Reading

If you have any additional questions about how to set up crash logging, please refer to MarkedUp’s SDK reference documentation on crash logging or contact support at support@markedup.com!

New MarkedUp Feature: Track Custom Events for Your Windows 8 Applications

Today we’re excited to announce a major new feature for MarkedUp Analytics: the ability to track custom session events for your application.

A “session event,” as defined by us, is simply something that happens in the course of a user running your application.

MarkedUp has a number of built-in session events like navigation events, life cycle events, and so forth. However, custom session events are defined by you, the developer.

How to Use Custom Session Events

To create a custom session event, you just need to install MarkedUp into your Windows 8 application and call the following method anywhere in your code where something you want to track occurs:

C# / XAML
MarkedUp.AnalyticClient.SessionEvent(“{Name of Your Custom Event}”);

WinJS
MK.sessionEvent(“{Name of Your Custom Event}”);

Once you’ve added that code into your application, you’ll start seeing these session events show up on your dashboard once you or any other user runs your app and triggers the custom event.

You can see the custom events by going to Engagement –> Custom Events on your app’s MarkedUp dashboard:

custom events nav

Once there, you’ll see a list of all of your app’s custom events along with some high-level data about how they’ve trended over time.

custom events view

You can change the date range and see how all of your custom events trended over any period of time.

If you want to view a higher-resolution chart of a particular event, just click the event’s name and you’ll be able to view the absolute number of event occurrences and the the per-session average over time.

custom events drilldown

That’s it! Rinse and repeat for every event you want to track!

If you want more details, take a look at our MarkedUp SDK reference documentation for custom session events.

Note to Existing MarkedUp Users: to take advantage of custom session events, you will need to upgrade your MarkedUp installation to the latest version.

Run the following command in the NuGet Package Manager Console and your installation will be upgraded automatically:

PM> Update-Package MarkedUp

Use Cases for Custom Events

So when would you need to use custom events?

The best way to think about analytics is in terms of questions and answers.

How would you get the data to answer the following questions?

  • How many games or levels do my users complete each time they start my game?
  • How many articles do users read each time they use my RSS reader?
  • How many of my users successfully recommend the app to a friend using our built-in “recommend this app” dialog? To how many friends?
  • Etc..

Any time you need to measure something specific to what your app does, use a custom event. If you have any other questions about use cases for custom events, feel free to ask us in the comments below or at support@markedup.com.

How-To: Last Chance Exception Handling in WinJS Applications

One of the things we designed MarkedUp to do was to be able to capture and save fatal errors that crash your Windows 8 applications and to reliably transmit them back to the developer for analysis and diagnosis.

Most fatal errors fall into one of two categories:

  1. Something went wrong with the environment outside the application, like an OS / driver error or an hardware issue; or
  2. The application failed to handle an exception thrown by the application itself.

Fatal errors in category #1 are impossible to recover from (usually because the application runtime or OS crashed) and are typically outside the control of the developer anyway.

Errors in category #2 are firmly in the control of the developer, however – and I’m going to show you how to tackle them in WinJS.

Sometimes you’re going to forget to handle an error in-context in your application – so what can you do to stop unhandled exceptions from crashing your application? Use the last-chance exception handler.

If you’ve done any serious Windows Phone 7 development, then you might have worked with LittleWatson at some point for simple last-chance exception handling and reporting – like this:

So how do you tackle this in WinJS?

The answer is fairly simple – in your default.js file you just need to chain an event handler to WinJS.Application.onerror event, like this:

In this instance I’m just using MarkedUp to transmit the fatal error message back to our servers next time the app starts (which is really the only safe way to capture a fatal error message.)

This technique has worked well for me for my Windows Phone 7 applications and should work fine for WinJS / Win8 too!