From 60f9db97936d7d663b8e8e8f608475f173d9614b Mon Sep 17 00:00:00 2001 From: Siddhant Khare Date: Tue, 2 Jul 2024 21:33:15 +0530 Subject: [PATCH] [dashboard] Onboarding: new video onboarding for new workspace (#19987) * [dashboard] Onboarding: new video onboarding for new workspace * New button and copy text updates * Update YT Video --- components/dashboard/src/Analytics.tsx | 19 +++- .../src/workspaces/EmptyWorkspacesContent.tsx | 91 ++++++++++++++----- 2 files changed, 86 insertions(+), 24 deletions(-) diff --git a/components/dashboard/src/Analytics.tsx b/components/dashboard/src/Analytics.tsx index d75f08fac938ff..27f64d8272d1d6 100644 --- a/components/dashboard/src/Analytics.tsx +++ b/components/dashboard/src/Analytics.tsx @@ -22,7 +22,8 @@ export type Event = | "modal_dismiss" | "ide_configuration_changed" | "status_rendered" - | "error_rendered"; + | "error_rendered" + | "video_clicked"; type InternalEvent = Event | "path_changed" | "dashboard_clicked"; export type EventProperties = @@ -36,7 +37,8 @@ export type EventProperties = | TrackIDEConfigurationChanged | TrackWorkspaceClassChanged | TrackStatusRendered - | TrackErrorRendered; + | TrackErrorRendered + | TrackVideoClicked; type InternalEventProperties = EventProperties | TrackDashboardClick | TrackPathChanged; export interface TrackErrorRendered { @@ -105,6 +107,11 @@ export interface TrackBrowserExtensionPromotionInteraction { action: "chrome_navigation" | "firefox_navigation" | "manually_dismissed"; } +export interface TrackVideoClicked { + context: string; + path: string; +} + interface TrackDashboardClick { dnt?: boolean; path: string; @@ -140,6 +147,7 @@ export function trackEvent(event: "modal_dismiss", properties: TrackModalDismiss export function trackEvent(event: "ide_configuration_changed", properties: TrackIDEConfigurationChanged): void; export function trackEvent(event: "status_rendered", properties: TrackStatusRendered): void; export function trackEvent(event: "error_rendered", properties: TrackErrorRendered): void; +export function trackEvent(event: "video_clicked", properties: TrackVideoClicked): void; export function trackEvent(event: Event, properties: EventProperties): void { trackEventInternal(event, properties); } @@ -157,6 +165,13 @@ export function sendTrackEvent(message: RemoteTrackMessage): void { sendAnalytics("trackEvent", message); } +export function trackVideoClick(context: string) { + trackEvent("video_clicked", { + context: context, + path: window.location.pathname, + }); +} + export const trackButtonOrAnchor = (target: HTMLAnchorElement | HTMLButtonElement | HTMLDivElement) => { //read manually passed analytics props from 'data-analytics' attribute of event target let passedProps: TrackDashboardClick | undefined; diff --git a/components/dashboard/src/workspaces/EmptyWorkspacesContent.tsx b/components/dashboard/src/workspaces/EmptyWorkspacesContent.tsx index 70aac1ad4b38d0..d293877629b90b 100644 --- a/components/dashboard/src/workspaces/EmptyWorkspacesContent.tsx +++ b/components/dashboard/src/workspaces/EmptyWorkspacesContent.tsx @@ -4,34 +4,81 @@ * See License.AGPL.txt in the project root for license information. */ +import React, { useEffect } from "react"; import { StartWorkspaceModalKeyBinding } from "../App"; import { LinkButton } from "@podkit/buttons/LinkButton"; -import { Heading2, Subheading } from "@podkit/typography/Headings"; +import { Heading1, Heading2, Subheading } from "@podkit/typography/Headings"; +import { trackVideoClick } from "../Analytics"; + +declare global { + interface Window { + onYouTubeIframeAPIReady: () => void; + YT: any; + } +} export const EmptyWorkspacesContent = () => { + useEffect(() => { + // Load the YouTube IFrame Player API code asynchronously + const tag = document.createElement("script"); + tag.src = "https://www.youtube.com/iframe_api"; + const firstScriptTag = document.getElementsByTagName("script")[0]; + firstScriptTag.parentNode?.insertBefore(tag, firstScriptTag); + + // Create YouTube player when API is ready + window.onYouTubeIframeAPIReady = () => { + new window.YT.Player("gitpod-video", { + events: { + onStateChange: onPlayerStateChange, + }, + }); + }; + }, []); + + const onPlayerStateChange = (event: any) => { + if (event.data === window.YT.PlayerState.PLAYING) { + trackVideoClick("create-new-workspace"); + } + }; + return (
-
-
- No Workspaces - - Prefix any Git repository URL with {window.location.host}/# or create a new workspace for a - recently used project.{" "} - - Learn more - - - - - New Workspace{" "} - {StartWorkspaceModalKeyBinding} - - +
+
+ +
+
+
+ Welcome to Gitpod + + Create your first workspace + + + A workspace is a cloud development environment + + + + Try a configured demo repo + + + Open your repository{" "} + {StartWorkspaceModalKeyBinding} + + +