diff --git a/.run/PostHog.run.xml b/.run/PostHog.run.xml
index 52fb8d37317..74afb10cd62 100644
--- a/.run/PostHog.run.xml
+++ b/.run/PostHog.run.xml
@@ -4,15 +4,16 @@
-
+
+
+
-
@@ -41,4 +42,4 @@
-
+
\ No newline at end of file
diff --git a/frontend/__snapshots__/components-subscriptions--subscriptions.png b/frontend/__snapshots__/components-subscriptions--subscriptions.png
index 9735b1c4a56..877a06e52f0 100644
Binary files a/frontend/__snapshots__/components-subscriptions--subscriptions.png and b/frontend/__snapshots__/components-subscriptions--subscriptions.png differ
diff --git a/frontend/__snapshots__/scenes-app-dashboards--create-template.png b/frontend/__snapshots__/scenes-app-dashboards--create-template.png
index 95ef4b2697d..8be94095384 100644
Binary files a/frontend/__snapshots__/scenes-app-dashboards--create-template.png and b/frontend/__snapshots__/scenes-app-dashboards--create-template.png differ
diff --git a/frontend/__snapshots__/scenes-app-feature-flags--feature-flags-list.png b/frontend/__snapshots__/scenes-app-feature-flags--feature-flags-list.png
index 1a145d3805c..e6b437defcc 100644
Binary files a/frontend/__snapshots__/scenes-app-feature-flags--feature-flags-list.png and b/frontend/__snapshots__/scenes-app-feature-flags--feature-flags-list.png differ
diff --git a/frontend/__snapshots__/scenes-app-insights--retention.png b/frontend/__snapshots__/scenes-app-insights--retention.png
index 9c9e1db35a1..66eb589dc24 100644
Binary files a/frontend/__snapshots__/scenes-app-insights--retention.png and b/frontend/__snapshots__/scenes-app-insights--retention.png differ
diff --git a/frontend/src/globals.d.ts b/frontend/src/globals.d.ts
index 475d0c52d6d..4982fe8a787 100644
--- a/frontend/src/globals.d.ts
+++ b/frontend/src/globals.d.ts
@@ -7,6 +7,7 @@ declare global {
JS_POSTHOG_HOST?: string
JS_POSTHOG_SELF_CAPTURE?: boolean
JS_CAPTURE_TIME_TO_SEE_DATA?: boolean
+ JS_KEA_VERBOSE_LOGGING?: boolean
posthog?: posthog
ESBUILD_LOAD_SCRIPT: (name) => void
ESBUILD_LOAD_CHUNKS: (name) => void
diff --git a/frontend/src/initKea.ts b/frontend/src/initKea.ts
index 8078eba0f5a..df2fb307dcd 100644
--- a/frontend/src/initKea.ts
+++ b/frontend/src/initKea.ts
@@ -34,51 +34,74 @@ interface InitKeaProps {
// Used in some tests to make life easier
let errorsSilenced = false
+
export function silenceKeaLoadersErrors(): void {
errorsSilenced = true
}
+
export function resumeKeaLoadersErrors(): void {
errorsSilenced = false
}
+export const loggerPlugin: () => KeaPlugin = () => ({
+ name: 'verbose-kea-logger',
+ events: {
+ beforeReduxStore(options) {
+ options.middleware.push((store) => (next) => (action) => {
+ const response = next(action)
+ console.groupCollapsed('KEA LOGGER', action)
+ console.log(store.getState())
+ console.groupEnd()
+ return response
+ })
+ },
+ },
+})
+
export function initKea({ routerHistory, routerLocation, beforePlugins }: InitKeaProps = {}): void {
+ const plugins = [
+ ...(beforePlugins || []),
+ localStoragePlugin,
+ windowValuesPlugin({ window: window }),
+ routerPlugin({
+ history: routerHistory,
+ location: routerLocation,
+ urlPatternOptions: {
+ // :TRICKY: We override default url segment matching characters.
+ // This list includes all characters which are not escaped by encodeURIComponent
+ segmentValueCharset: "a-zA-Z0-9-_~ %.@()!'",
+ },
+ }),
+ formsPlugin,
+ loadersPlugin({
+ onFailure({ error, reducerKey, actionKey }: { error: any; reducerKey: string; actionKey: string }) {
+ // Toast if it's a fetch error or a specific API update error
+ if (
+ !ERROR_FILTER_WHITELIST.includes(actionKey) &&
+ (error?.message === 'Failed to fetch' || // Likely CORS headers errors (i.e. request failing without reaching Django)
+ (error?.status !== undefined && ![200, 201, 204].includes(error.status)))
+ ) {
+ lemonToast.error(
+ `${identifierToHuman(actionKey)} failed: ${
+ error.detail || error.statusText || 'PostHog may be offline'
+ }`
+ )
+ }
+ if (!errorsSilenced) {
+ console.error({ error, reducerKey, actionKey })
+ }
+ ;(window as any).Sentry?.captureException(error)
+ },
+ }),
+ subscriptionsPlugin,
+ waitForPlugin,
+ ]
+
+ if (window.JS_KEA_VERBOSE_LOGGING) {
+ plugins.push(loggerPlugin)
+ }
+
resetContext({
- plugins: [
- ...(beforePlugins || []),
- localStoragePlugin,
- windowValuesPlugin({ window: window }),
- routerPlugin({
- history: routerHistory,
- location: routerLocation,
- urlPatternOptions: {
- // :TRICKY: We override default url segment matching characters.
- // This list includes all characters which are not escaped by encodeURIComponent
- segmentValueCharset: "a-zA-Z0-9-_~ %.@()!'",
- },
- }),
- formsPlugin,
- loadersPlugin({
- onFailure({ error, reducerKey, actionKey }: { error: any; reducerKey: string; actionKey: string }) {
- // Toast if it's a fetch error or a specific API update error
- if (
- !ERROR_FILTER_WHITELIST.includes(actionKey) &&
- (error?.message === 'Failed to fetch' || // Likely CORS headers errors (i.e. request failing without reaching Django)
- (error?.status !== undefined && ![200, 201, 204].includes(error.status)))
- ) {
- lemonToast.error(
- `${identifierToHuman(actionKey)} failed: ${
- error.detail || error.statusText || 'PostHog may be offline'
- }`
- )
- }
- if (!errorsSilenced) {
- console.error({ error, reducerKey, actionKey })
- }
- ;(window as any).Sentry?.captureException(error)
- },
- }),
- subscriptionsPlugin,
- waitForPlugin,
- ],
+ plugins: plugins,
})
}
diff --git a/posthog/settings/__init__.py b/posthog/settings/__init__.py
index 074a06dda89..c8d0790c890 100644
--- a/posthog/settings/__init__.py
+++ b/posthog/settings/__init__.py
@@ -75,6 +75,9 @@ NPM_TOKEN = os.getenv("NPM_TOKEN", None)
# Whether to capture time-to-see-data metrics
CAPTURE_TIME_TO_SEE_DATA = get_from_env("CAPTURE_TIME_TO_SEE_DATA", False, type_cast=str_to_bool)
+# Whether kea should be act in verbose mode
+KEA_VERBOSE_LOGGING = get_from_env("KEA_VERBOSE_LOGGING", False, type_cast=str_to_bool)
+
# Only written in specific scripts - do not use outside of them.
PERSON_ON_EVENTS_OVERRIDE = get_from_env("PERSON_ON_EVENTS_OVERRIDE", optional=True, type_cast=str_to_bool)
diff --git a/posthog/templates/head.html b/posthog/templates/head.html
index 5406b766bc9..07bde575e61 100644
--- a/posthog/templates/head.html
+++ b/posthog/templates/head.html
@@ -34,4 +34,5 @@
// frontent JS from a CDN
window.JS_URL = "{{ js_url|default:"" }}";
window.JS_CAPTURE_TIME_TO_SEE_DATA = {{js_capture_time_to_see_data | yesno:"true,false"}};
+ window.JS_KEA_VERBOSE_LOGGING = {{js_kea_verbose_logging | yesno:"true,false"}};
diff --git a/posthog/utils.py b/posthog/utils.py
index c2f24236ea2..5d2b7a9029f 100644
--- a/posthog/utils.py
+++ b/posthog/utils.py
@@ -333,6 +333,7 @@ def render_template(template_name: str, request: HttpRequest, context: Dict = {}
context["js_posthog_host"] = "'https://app.posthog.com'"
context["js_capture_time_to_see_data"] = settings.CAPTURE_TIME_TO_SEE_DATA
+ context["js_kea_verbose_logging"] = settings.KEA_VERBOSE_LOGGING
context["js_url"] = get_js_url(request)
posthog_app_context: Dict[str, Any] = {