Skip to content

Commit 46c4de3

Browse files
committed
Merge branch 'master' into dev
2 parents e75fcde + b6881b4 commit 46c4de3

4 files changed

Lines changed: 326 additions & 364 deletions

File tree

‎apps/codebility/app/applicant/onboarding/README.md‎

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This module implements a video-based onboarding system for applicants with seque
66

77
- **Sequential Video Watching**: Users must complete videos in order (1 → 2 → 3 → 4)
88
- **Progress Tracking**: Real-time tracking of video watch progress
9-
- **Validation**: Users must watch at least 90% of each video to unlock the next one
9+
- **Validation**: Users must watch at least 98% of each video to unlock the next one
1010
- **Visual Progress**: Stepper UI showing completion status
1111
- **Database Persistence**: All progress is saved to the database
1212

@@ -26,34 +26,25 @@ Or use Supabase Dashboard:
2626

2727
## Video Setup
2828

29-
### Option 1: Supabase Storage (Recommended)
29+
Onboarding videos are hosted as **unlisted YouTube videos** and embedded via the
30+
YouTube IFrame Player API. They are **not** stored on Supabase Storage — doing so
31+
generated excessive cached egress and repeatedly restricted the whole project.
3032

31-
1. Create a storage bucket named `onboarding-videos` in Supabase
32-
2. Upload your 4 videos with the following naming convention:
33-
- `onboarding-1.mp4` - Introduction
34-
- `onboarding-2.mp4` - Company Culture
35-
- `onboarding-3.mp4` - Tools & Processes
36-
- `onboarding-4.mp4` - Getting Started
33+
Each video is referenced by its **YouTube ID** through environment variables:
3734

38-
3. Update the `VIDEO_URLS` in `_components/OnboardingClient.tsx`:
39-
```typescript
40-
const VIDEO_URLS = {
41-
1: "https://your-project.supabase.co/storage/v1/object/public/onboarding-videos/onboarding-1.mp4",
42-
2: "https://your-project.supabase.co/storage/v1/object/public/onboarding-videos/onboarding-2.mp4",
43-
3: "https://your-project.supabase.co/storage/v1/object/public/onboarding-videos/onboarding-3.mp4",
44-
4: "https://your-project.supabase.co/storage/v1/object/public/onboarding-videos/onboarding-4.mp4",
45-
};
35+
```bash
36+
NEXT_PUBLIC_ONBOARDING_VIDEO_ID_1=<id> # Introduction - About Codebility
37+
NEXT_PUBLIC_ONBOARDING_VIDEO_ID_2=<id> # Benefits, Culture & Expectations
38+
NEXT_PUBLIC_ONBOARDING_VIDEO_ID_3=<id> # Roadmaps, Milestones & Tech Stack
39+
NEXT_PUBLIC_ONBOARDING_VIDEO_ID_4=<id> # Portal Tour - Gamification & Workflow
4640
```
4741

48-
### Option 2: Public Folder
49-
50-
1. Create a `public/videos` folder in the root of your Next.js app
51-
2. Add your 4 videos with the naming convention above
52-
3. The current URLs in `OnboardingClient.tsx` are already configured for this option
53-
54-
### Option 3: External Video Hosting
42+
`OnboardingClient.tsx` reads these into `VIDEO_IDS` and passes them to
43+
`VideoPlayer.tsx`. To swap a video, upload a new **Unlisted** (not Private) video
44+
to YouTube and update the matching env var — no code change needed. Remember that
45+
`NEXT_PUBLIC_*` vars are inlined at build time, so production must be rebuilt.
5546

56-
Use any video hosting service (Vimeo, YouTube, AWS S3, etc.) and update the URLs accordingly.
47+
See `apps/codebility/docs/VIDEO_UPLOAD_GUIDE.md` for full upload steps.
5748

5849
## Flow
5950

@@ -65,7 +56,7 @@ Use any video hosting service (Vimeo, YouTube, AWS S3, etc.) and update the URLs
6556
2. **Video Watching** (`/applicant/onboarding` - Step 1-4):
6657
- Shows progress stepper with 5 steps
6758
- Displays current video with player controls
68-
- Tracks watch progress (must watch 90%+ to complete)
59+
- Tracks watch progress (must watch 98%+ to complete)
6960
- Next video unlocks only after completing previous one
7061
- "Proceed to Quiz" button appears after all 4 videos
7162

@@ -124,9 +115,9 @@ Main client component that manages the complete onboarding flow:
124115

125116
### `VideoPlayer.tsx`
126117
Video player component with:
127-
- HTML5 video controls
128-
- Progress tracking
129-
- Watch validation (90% threshold)
118+
- YouTube IFrame Player API embed (unlisted videos)
119+
- Progress tracking (polls playback position)
120+
- Watch validation (98% threshold)
130121
- Locked state for sequential videos
131122
- Auto-save progress to database
132123

@@ -186,10 +177,8 @@ const VIDEO_DESCRIPTIONS = {
186177
### Watch Threshold
187178
Change the completion percentage in `VideoPlayer.tsx`:
188179
```typescript
189-
// Current: 90% threshold
190-
if (percentWatched >= 90 && !hasWatched) {
191-
// Change 90 to your desired percentage
192-
}
180+
// Current: 98% threshold
181+
const COMPLETION_THRESHOLD = 98; // change to your desired percentage
193182
```
194183

195184
### Styling
@@ -198,17 +187,16 @@ All components use Tailwind CSS and can be customized by modifying the className
198187
## Security Features
199188

200189
- Row Level Security (RLS) policies ensure users can only access their own progress
201-
- Video right-click disabled to prevent easy downloading
202-
- Download controls disabled
190+
- Videos are unlisted on YouTube (not indexed/searchable) and embedded without a direct download path
203191
- Progress validation on server-side
204192

205193
## Troubleshooting
206194

207195
### Videos not loading
208-
- Check video URLs in `VIDEO_URLS`
209-
- Ensure videos are in correct format (MP4 recommended)
210-
- Check browser console for network errors
211-
- Verify Supabase storage bucket permissions (if using Supabase)
196+
- Check the YouTube IDs in the `NEXT_PUBLIC_ONBOARDING_VIDEO_ID_*` env vars (IDs, not URLs)
197+
- Ensure each YouTube video is **Unlisted** (not Private) and allows embedding
198+
- In production, confirm you rebuilt after setting/changing the env vars
199+
- Check browser console for IFrame API errors
212200

213201
### Progress not saving
214202
- Check database connection

‎apps/codebility/app/applicant/onboarding/_components/OnboardingClient.tsx‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ interface OnboardingClientProps {
1616
applicantData: any;
1717
}
1818

19-
const VIDEO_URLS = {
20-
1: "https://hibnlysaokybrsufrdwp.supabase.co/storage/v1/object/public/codebility/onboarding-videos/part1.mp4", // Introduction - About Codebility
21-
2: "https://hibnlysaokybrsufrdwp.supabase.co/storage/v1/object/public/codebility/onboarding-videos/part2.mp4", // Benefits, Culture & Expectations
22-
3: "https://hibnlysaokybrsufrdwp.supabase.co/storage/v1/object/public/codebility/onboarding-videos/part3.mp4", // Roadmaps, Milestones & Tech Stack
23-
4: "https://hibnlysaokybrsufrdwp.supabase.co/storage/v1/object/public/codebility/onboarding-videos/part4.mp4", // Portal Tour - Gamification & Workflow
19+
// Onboarding videos are hosted as UNLISTED YouTube videos to avoid Supabase
20+
// Storage egress costs. Each value is a YouTube video ID (the part after
21+
// `watch?v=` or `youtu.be/`), configured per environment via env vars:
22+
// NEXT_PUBLIC_ONBOARDING_VIDEO_ID_1 ... _4
23+
const VIDEO_IDS: Record<number, string> = {
24+
1: process.env.NEXT_PUBLIC_ONBOARDING_VIDEO_ID_1 ?? "", // Introduction - About Codebility
25+
2: process.env.NEXT_PUBLIC_ONBOARDING_VIDEO_ID_2 ?? "", // Benefits, Culture & Expectations
26+
3: process.env.NEXT_PUBLIC_ONBOARDING_VIDEO_ID_3 ?? "", // Roadmaps, Milestones & Tech Stack
27+
4: process.env.NEXT_PUBLIC_ONBOARDING_VIDEO_ID_4 ?? "", // Portal Tour - Gamification & Workflow
2428
};
2529

2630
const VIDEO_TITLES = {
@@ -236,7 +240,7 @@ export default function OnboardingClient({
236240

237241
<VideoPlayer
238242
videoNumber={progress.currentVideo}
239-
videoUrl={VIDEO_URLS[progress.currentVideo as keyof typeof VIDEO_URLS]}
243+
videoId={VIDEO_IDS[progress.currentVideo] ?? ""}
240244
applicantId={applicantId}
241245
onVideoComplete={handleVideoComplete}
242246
canWatch={canWatchVideo(progress.currentVideo)}

0 commit comments

Comments
 (0)