(
+ null,
+ );
+ const handleFeedbackFinished = () => {
+ const wasLeaving = feedbackMode === "leaving";
+ setFeedbackMode(null);
+ if (wasLeaving) navigate({ to: "/code" });
+ };
const {
isOpen: commandMenuOpen,
setOpen: setCommandMenuOpen,
@@ -214,15 +230,22 @@ function RootLayout() {
-
+
-
+
+
@@ -245,6 +268,10 @@ function RootLayout() {
/>
{billingEnabled && }
+
{import.meta.env.DEV && (
diff --git a/packages/ui/src/shell/analytics.ts b/packages/ui/src/shell/analytics.ts
index 84797b9930..7768ca64c8 100644
--- a/packages/ui/src/shell/analytics.ts
+++ b/packages/ui/src/shell/analytics.ts
@@ -30,6 +30,11 @@ export interface AnalyticsTracker {
identifyUser(userId: string, properties?: UserIdentifyProperties): void;
setUserGroups(user: AnalyticsUserGroups): void;
resetUser(): void;
+ captureSurveyResponse(params: {
+ surveyId: string;
+ questionId: string;
+ response: string;
+ }): void;
}
export const ANALYTICS_TRACKER = Symbol.for("posthog.ui.AnalyticsTracker");
@@ -74,3 +79,13 @@ export function setUserGroups(user: AnalyticsUserGroups): void {
export function resetUser(): void {
resolveService(ANALYTICS_TRACKER).resetUser();
}
+
+export function captureSurveyResponse(params: {
+ surveyId: string;
+ questionId: string;
+ response: string;
+}): void {
+ resolveService(ANALYTICS_TRACKER).captureSurveyResponse(
+ params,
+ );
+}
diff --git a/packages/ui/src/shell/posthogAnalyticsImpl.ts b/packages/ui/src/shell/posthogAnalyticsImpl.ts
index e4ddbada6d..ab3d65b768 100644
--- a/packages/ui/src/shell/posthogAnalyticsImpl.ts
+++ b/packages/ui/src/shell/posthogAnalyticsImpl.ts
@@ -218,6 +218,34 @@ export function track(
posthog.capture(eventName, args[0]);
}
+/**
+ * Record a survey response via posthog-js's `survey sent` event. The survey
+ * must already exist (and be launched) in the project the app reports to, or
+ * the response will not attach to it.
+ */
+export function captureSurveyResponse({
+ surveyId,
+ questionId,
+ response,
+}: {
+ surveyId: string;
+ questionId: string;
+ response: string;
+}) {
+ if (!isInitialized) {
+ return;
+ }
+
+ posthog.capture("survey sent", {
+ $survey_id: surveyId,
+ $survey_questions: [{ id: questionId }],
+ // Newer ingestion keys responses by question id; `$survey_response` is the
+ // legacy single-question key. Send both so the response attaches either way.
+ [`$survey_response_${questionId}`]: response,
+ $survey_response: response,
+ });
+}
+
/**
* Build tool metadata for analytics on permission requests
*/
@@ -318,6 +346,7 @@ export const posthogAnalyticsTracker: AnalyticsTracker = {
identifyUser,
setUserGroups,
resetUser,
+ captureSurveyResponse,
};
/**