From 966c74ee5f44879db498a769e06b672e298b00a3 Mon Sep 17 00:00:00 2001 From: David Tittsworth Date: Sun, 23 Sep 2018 20:26:14 -0700 Subject: [PATCH] Add telemetry (#2) * Added a fix for tsconfig, was missing lib for some reason * Added basic telemetry * Added a check for instrumentation key * Update app version to correct version --- _config.yml | 1 + _includes/head.html | 43 ++++++++++++++++++++++++++ _includes/header.html | 2 +- _layouts/gallery.html | 2 +- index.html | 4 +-- tutorials/viewer/src/telemetry.ts | 11 +++++++ tutorials/viewer/src/tsconfig.json | 1 + tutorials/viewer/src/tutorial_view.tsx | 12 +++++-- tutorials/viewer/src/video_view.tsx | 2 ++ 9 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 tutorials/viewer/src/telemetry.ts diff --git a/_config.yml b/_config.yml index ed71791..477b6ab 100644 --- a/_config.yml +++ b/_config.yml @@ -18,6 +18,7 @@ email: charticulator@microsoft.com description: > # this means to ignore newlines until "baseurl:" Charticulator's Website baseurl: "" # the subpath of your site, e.g. /blog +instrumentation_key: "" url: "https://charticulator.com" # the base hostname & protocol for your site, e.g. http://example.com # Enable CDN when deploying the site. diff --git a/_includes/head.html b/_includes/head.html index c1c2991..b989282 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -4,4 +4,47 @@ {{ page.title }} | Charticulator + + \ No newline at end of file diff --git a/_includes/header.html b/_includes/header.html index 3f84018..155d61d 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -26,7 +26,7 @@ Gallery Getting Started About - Launch + Launch {% endif %} diff --git a/_layouts/gallery.html b/_layouts/gallery.html index bc58246..a0617af 100644 --- a/_layouts/gallery.html +++ b/_layouts/gallery.html @@ -28,7 +28,7 @@ layout: default {% if page.video %}

Creation Process

diff --git a/index.html b/index.html index c52c43a..65de38d 100644 --- a/index.html +++ b/index.html @@ -8,13 +8,13 @@ title: Home

Charticulator

Interactive Construction of Bespoke Chart Layouts

-

Launch Charticulator

+

Launch Charticulator

Charticulator requires the use of a mouse or touch screen.

Compatatible with Google Chrome, Mozilla Firefox, and Microsoft Edge.

Fork the Github repository of this project.

-

diff --git a/tutorials/viewer/src/telemetry.ts b/tutorials/viewer/src/telemetry.ts new file mode 100644 index 0000000..bceadb1 --- /dev/null +++ b/tutorials/viewer/src/telemetry.ts @@ -0,0 +1,11 @@ +/** + * Tracks the given event + * @param event The event name + * @param data The data for the event + */ +export function trackEvent(event: string, data?: any) { + const ai = (window as any).appInsights; + if (ai) { + ai.trackEvent(event, data || {}); + } +} \ No newline at end of file diff --git a/tutorials/viewer/src/tsconfig.json b/tutorials/viewer/src/tsconfig.json index 75532cc..29555e0 100644 --- a/tutorials/viewer/src/tsconfig.json +++ b/tutorials/viewer/src/tsconfig.json @@ -8,6 +8,7 @@ "moduleResolution": "node", "target": "es5", "jsx": "react", + "lib": ["es5", "es6", "dom"], "noImplicitAny": true, "sourceMap": true } diff --git a/tutorials/viewer/src/tutorial_view.tsx b/tutorials/viewer/src/tutorial_view.tsx index 23a6584..57e71a1 100644 --- a/tutorials/viewer/src/tutorial_view.tsx +++ b/tutorials/viewer/src/tutorial_view.tsx @@ -10,6 +10,7 @@ import { VideoView } from "./video_view"; import { TutorialCaption, TutorialMetadata } from "./data"; import { classNames } from "./utils"; import * as marked from "marked"; +import { trackEvent } from "./telemetry"; marked.setOptions({ smartypants: true @@ -131,6 +132,7 @@ export class TutorialView extends React.Component this.videoView = e} - source={this.props.tutorial.videoSource} + source={tutorial.videoSource} width={this.props.width - 440} height={(this.props.height - 40)} renderTimeAxis={this.renderTimeAxis.bind(this)} @@ -151,6 +153,12 @@ export class TutorialView extends React.Component { let index = this.getCaptionAtTimestamp(this.videoView.time); + trackEvent("play-video", { + type: "tutorial", + name: tutorial.name || "Unknown", + url: tutorial.videoSource.mp4 || tutorial.videoSource.webm, + index, + }); this.setState({ currentCaptionIndex: index, keepCurrentInView: true @@ -166,7 +174,7 @@ export class TutorialView extends React.Component - {this.props.tutorial.captions.map((caption, index) => ( + {tutorial.captions.map((caption, index) => (