Skip to content

Conversation

@im2nguyen
Copy link
Contributor

@im2nguyen im2nguyen commented Mar 3, 2025

🔗 Relevant links

This PR updates the VideoEmbed to send a custom PostHog event video_start whenever someone starts a video play. This works on both wistia and youtube videos.

In addition, it adds VideoEmbed as an available MDX component for docs. This lets us use VideoEmbed instead of iframe for videos in documentation, so the behavior is consistent throughout the platform.

🗒️ What

🤷 Why

🛠️ How

📸 Design Screenshots

🧪 Testing

Related PR: hashicorp/terraform-docs-common#866

  1. Go to dev-portal and check out the video-embed-posthog-tracking branch
  2. Build the image locally (docker build . -t dev-portal-video-tracking)
  3. Update DOCKER_IMAGE_LOCAL="dev-portal-local" in this repo's website/Makefile file to dev-portal-video-tracking.
  4. Start local preview (make website/local). You may need to add .env.local to website.
  5. Navigate to /terraform/cloud-docs/recommended-practices
  6. Verify the videoembed works as expected, check posthog to see if video_play event is triggered
image

💭 Anything else?

@vercel
Copy link

vercel bot commented Mar 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dev-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 22, 2025 9:09pm

@github-actions
Copy link

github-actions bot commented Mar 3, 2025

📦 Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action 🤖

Forty-one Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/[productSlug]/docs 186.16 KB (🟡 +10.44 KB) 381.15 KB
/[productSlug]/integrations/[organizationSlug]/[integrationSlug] 172.22 KB (🟢 -414 B) 367.21 KB
/[productSlug]/integrations/[organizationSlug]/[integrationSlug]/[integrationVersion] 172.22 KB (🟢 -414 B) 367.21 KB
/[productSlug]/integrations/[organizationSlug]/[integrationSlug]/[integrationVersion]/components/[componentType]/[componentSlug] 178.14 KB (🟢 -414 B) 373.13 KB
/[productSlug]/tutorials/[collectionSlug] 194.82 KB (🟡 +333 B) 389.81 KB
/boundary/docs/[...page] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/consul/api-docs/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.14 KB
/consul/commands/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.14 KB
/consul/docs/[...page] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/hcp/docs/[...page] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/nomad/api-docs/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.14 KB
/nomad/docs/[...page] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/nomad/intro/[[...page]] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/nomad/plugins/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.14 KB
/nomad/tools/[[...page]] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/packer/docs/[...page] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/packer/guides/[[...page]] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/sentinel/docs/[...page] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/terraform/cdktf/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/cli/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.14 KB
/terraform/cloud-docs/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/cloud-docs/agents/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/docs/[...page] 184.16 KB (🟡 +10.44 KB) 379.14 KB
/terraform/enterprise/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/internals/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/intro/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.14 KB
/terraform/language/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/plugin/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/plugin/framework/[[...page]] 184.17 KB (🟡 +10.44 KB) 379.15 KB
/terraform/plugin/log/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/plugin/mux/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/plugin/sdkv2/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/plugin/testing/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/terraform/registry/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.15 KB
/vagrant/docs/[...page] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/vagrant/intro/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.14 KB
/vagrant/vagrant-cloud/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.14 KB
/validated-designs/[...slug] 181.67 KB (🟡 +10.83 KB) 376.65 KB
/vault/api-docs/[[...page]] 184.16 KB (🟡 +10.44 KB) 379.14 KB
/vault/docs/[...page] 184.15 KB (🟡 +10.44 KB) 379.14 KB
/waypoint/docs/[...page] 184.15 KB (🟡 +10.44 KB) 379.14 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@im2nguyen im2nguyen requested review from a team, heatlikeheatwave and prestonbourne and removed request for a team March 20, 2025 16:15
@im2nguyen im2nguyen changed the title Experiment with posthog tracking for video embeds starts Posthog tracking for video embeds starts Mar 20, 2025
Comment on lines 32 to 39
/**
* Enables PostHog video start tracking
*/
export function trackVideoStart(video_id: string) {
if (!window?.posthog) return
window.posthog.capture('video_start', { video_id })
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit picky but since this is defined in hooks/use-posthog-analytics

i'd only expect hooks and specifically the usePosthogAnalytics hook to be here

imo putting this in the lib directory lib/posthog-events or something similar sets dev-portal up quite nicely to begin scaling with posthog custom events 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just updated, thanks for the feedback 😄

@heatlikeheatwave
Copy link
Contributor

Is there an asana task for this?

Copy link
Contributor

@prestonbourne prestonbourne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good from my pov but deferring final approval to a dev portal engineer 👍🏽

@im2nguyen
Copy link
Contributor Author

@kaitlynnefuery
Copy link
Contributor

@heatlikeheatwave @im2nguyen what's needed for us to approve and merge this PR?

@im2nguyen
Copy link
Contributor Author

@kaitlynnefuery I think this is a standalone PR! once this is reviewed, we'll just add the VideoEmbeds in the downstream product repos 😄

@heatlikeheatwave
Copy link
Contributor

heatlikeheatwave commented Apr 22, 2025

@im2nguyen, where can I find the video_play (per your PR) as well as the video_start (lib/posthog-events file) event in Posthog? I went to the dev project, and searched for both terms (via add filter for the app dashboard), with no results. Can you link to a dashboard or page with these events? Thanks!

@im2nguyen im2nguyen merged commit 9eac670 into main Apr 22, 2025
9 checks passed
@im2nguyen im2nguyen deleted the video-embed-posthog-tracking branch April 22, 2025 21:16
rmainwork added a commit that referenced this pull request Apr 23, 2025
rmainwork added a commit that referenced this pull request Apr 23, 2025
Revert "Posthog tracking for video embeds starts (#2699)"

This reverts commit 9eac670.
@rmainwork rmainwork restored the video-embed-posthog-tracking branch April 28, 2025 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants