Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(livestream): Enable custom livestream host (#26106) #27667

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions frontend/src/lib/utils/apiHost.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getAppContext } from './getAppContext';

export function apiHostOrigin(): string {
const appOrigin = window.location.origin
if (appOrigin === 'https://us.posthog.com') {
Expand All @@ -10,6 +12,8 @@ export function apiHostOrigin(): string {

export function liveEventsHostOrigin(): string | null {
const appOrigin = window.location.origin
const appContext = getAppContext()

if (appOrigin === 'https://us.posthog.com') {
return 'https://live.us.posthog.com'
} else if (appOrigin === 'https://eu.posthog.com') {
Expand All @@ -19,6 +23,6 @@ export function liveEventsHostOrigin(): string | null {
} else if (process.env.STORYBOOK) {
return 'http://localhost:6006'
}

return 'http://localhost:8666'
return appContext?.livestream_host || 'http://localhost:8666'
}
1 change: 1 addition & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3455,6 +3455,7 @@ export interface AppContext {
year_in_hog_url?: string
/** Support flow aid: a staff-only list of users who may be impersonated to access this resource. */
suggested_users_with_access?: UserBasicType[]
livestream_host?: string
}

export type StoredMetricMathOperations = 'max' | 'min' | 'sum'
Expand Down
3 changes: 3 additions & 0 deletions posthog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ def render_template(
context["sentry_environment"] = sentry_environment
if stripe_public_key := os.environ.get("STRIPE_PUBLIC_KEY"):
context["stripe_public_key"] = stripe_public_key
if livestream_host := os.environ.get("LIVESTREAM_HOST"):
context["livestream_host"] = livestream_host

context["git_rev"] = get_git_commit_short() # Include commit in prod for the `console.info()` message
if settings.DEBUG and not settings.TEST:
Expand Down Expand Up @@ -411,6 +413,7 @@ def render_template(
"switched_team": getattr(request, "switched_team", None),
"suggested_users_with_access": getattr(request, "suggested_users_with_access", None),
"commit_sha": context["git_rev"],
"livestream_host": context["livestream_host"],
**posthog_app_context,
}

Expand Down