Skip to content

Commit

Permalink
Merge branch 'master' into show-only-js-sevents
Browse files Browse the repository at this point in the history
  • Loading branch information
Phanatic committed Jun 17, 2024
2 parents ba1fc1a + 9497229 commit 821854a
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 18 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions frontend/src/lib/utils/eventUsageLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
InsightShortId,
InsightType,
ItemMode,
MultipleSurveyQuestion,
PersonType,
PropertyFilterType,
PropertyFilterValue,
Expand Down Expand Up @@ -1210,13 +1211,23 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
})
},
reportSurveyCreated: ({ survey, isDuplicate }) => {
const questionsWithShuffledOptions = survey.questions.filter((question) => {
return question.hasOwnProperty('shuffleOptions') && (question as MultipleSurveyQuestion).shuffleOptions
})

posthog.capture('survey created', {
name: survey.name,
id: survey.id,
survey_type: survey.type,
questions_length: survey.questions.length,
question_types: survey.questions.map((question) => question.type),
is_duplicate: isDuplicate ?? false,
events_count: survey.conditions?.events?.values.length,
recurring_survey_iteration_count: survey.iteration_count == undefined ? 0 : survey.iteration_count,
recurring_survey_iteration_interval:
survey.iteration_frequency_days == undefined ? 0 : survey.iteration_frequency_days,
shuffle_questions_enabled: !!survey.appearance.shuffleQuestions,
shuffle_question_options_enabled_count: questionsWithShuffledOptions.length,
})
},
reportSurveyLaunched: ({ survey }) => {
Expand Down Expand Up @@ -1265,11 +1276,21 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
})
},
reportSurveyEdited: ({ survey }) => {
const questionsWithShuffledOptions = survey.questions.filter((question) => {
return question.hasOwnProperty('shuffleOptions') && (question as MultipleSurveyQuestion).shuffleOptions
})

posthog.capture('survey edited', {
name: survey.name,
id: survey.id,
created_at: survey.created_at,
start_date: survey.start_date,
events_count: survey.conditions?.events?.values.length,
recurring_survey_iteration_count: survey.iteration_count == undefined ? 0 : survey.iteration_count,
recurring_survey_iteration_interval:
survey.iteration_frequency_days == undefined ? 0 : survey.iteration_frequency_days,
shuffle_questions_enabled: !!survey.appearance.shuffleQuestions,
shuffle_question_options_enabled_count: questionsWithShuffledOptions.length,
})
},
reportSurveyTemplateClicked: ({ template }) => {
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/scenes/surveys/SurveyCustomization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { LemonButton, LemonCheckbox, LemonInput, LemonSelect } from '@posthog/le
import { useValues } from 'kea'
import { PayGateMini } from 'lib/components/PayGateMini/PayGateMini'
import { upgradeModalLogic } from 'lib/components/UpgradeModal/upgradeModalLogic'
import { surveyLogic } from 'scenes/surveys/surveyLogic'

import {
AvailableFeature,
Expand All @@ -25,6 +26,10 @@ interface WidgetCustomizationProps extends Omit<CustomizationProps, 'surveyQuest

export function Customization({ appearance, surveyQuestionItem, onAppearanceChange }: CustomizationProps): JSX.Element {
const { surveysStylingAvailable } = useValues(surveysLogic)
const { surveyShufflingQuestionsAvailable } = useValues(surveyLogic)
const surveyShufflingQuestionsDisabledReason = surveyShufflingQuestionsAvailable
? ''
: 'Please add more than one question to the survey to enable shuffling questions'
const { guardAvailableFeature } = useValues(upgradeModalLogic)
return (
<>
Expand Down Expand Up @@ -117,9 +122,9 @@ export function Customization({ appearance, surveyQuestionItem, onAppearanceChan
checked={appearance?.whiteLabel}
/>
</div>

<div className="mt-2">
<LemonCheckbox
disabledReason={surveyShufflingQuestionsDisabledReason}
label={
<div className="flex items-center">
<span>Shuffle questions</span>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/scenes/surveys/SurveyEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export default function SurveyEdit(): JSX.Element {
setFlagPropertyErrors,
setSchedule,
} = useActions(surveyLogic)
const { surveysMultipleQuestionsAvailable, surveysRecurringScheduleAvailable } = useValues(surveysLogic)
const { surveysMultipleQuestionsAvailable, surveysRecurringScheduleAvailable, surveysEventsAvailable } =
useValues(surveysLogic)
const { featureFlags } = useValues(enabledFeaturesLogic)
const sortedItemIds = survey.questions.map((_, idx) => idx.toString())
const { thankYouMessageDescriptionContentType } = survey.appearance
Expand Down Expand Up @@ -619,7 +620,7 @@ export default function SurveyEdit(): JSX.Element {
)}
</BindLogic>
</LemonField.Pure>
{featureFlags[FEATURE_FLAGS.SURVEYS_EVENTS] && (
{featureFlags[FEATURE_FLAGS.SURVEYS_EVENTS] && surveysEventsAvailable && (
<LemonField.Pure label="User sends events">
<EventSelect
filterGroupTypes={[TaxonomicFilterGroupType.CustomEvents]}
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/scenes/surveys/surveyLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,12 @@ export const surveyLogic = kea<surveyLogicType>([
return !!(survey.start_date && !survey.end_date)
},
],
surveyShufflingQuestionsAvailable: [
(s) => [s.survey],
(survey: Survey): boolean => {
return survey.questions.length > 1
},
],
showSurveyRepeatSchedule: [(s) => [s.schedule], (schedule: ScheduleType) => schedule == 'recurring'],
descriptionContentType: [
(s) => [s.survey],
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/scenes/surveys/surveysLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ export const surveysLogic = kea<surveysLogicType>([
(s) => [s.hasAvailableFeature],
(hasAvailableFeature) => hasAvailableFeature(AvailableFeature.SURVEYS_RECURRING),
],
surveysEventsAvailable: [
(s) => [s.hasAvailableFeature],
(hasAvailableFeature) => hasAvailableFeature(AvailableFeature.SURVEYS_EVENTS),
],
showSurveysDisabledBanner: [
(s) => [s.currentTeam, s.currentTeamLoading, s.surveys],
(currentTeam, currentTeamLoading, surveys) => {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export enum AvailableFeature {
SURVEYS_SLACK_NOTIFICATIONS = 'surveys_slack_notifications',
SURVEYS_WAIT_PERIODS = 'surveys_wait_periods',
SURVEYS_RECURRING = 'surveys_recurring',
SURVEYS_EVENTS = 'survey_events',
TRACKED_USERS = 'tracked_users',
TEAM_MEMBERS = 'team_members',
API_ACCESS = 'api_access',
Expand Down
15 changes: 0 additions & 15 deletions posthog/temporal/data_imports/pipelines/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from asgiref.sync import async_to_sync
import asyncio
import os
from posthog.settings.base_variables import TEST
from structlog.typing import FilteringBoundLogger
from dlt.sources import DltSource
Expand Down Expand Up @@ -55,18 +54,6 @@ def _get_pipeline_name(self):

return f"{base}_{self.inputs.run_id}"

@property
def _get_pipelines_dir_base(self):
return f"{os.getcwd()}/.dlt/{self.inputs.team_id}"

def _get_pipelines_dir(self):
base = self._get_pipelines_dir_base

if self._incremental:
return f"{base}/{self.inputs.source_id}/{self.inputs.job_type}"

return f"{base}/{self.inputs.run_id}/{self.inputs.job_type}"

def _get_destination(self):
if TEST:
credentials = {
Expand All @@ -88,12 +75,10 @@ def _get_destination(self):

def _create_pipeline(self):
pipeline_name = self._get_pipeline_name()
pipelines_dir = self._get_pipelines_dir()
destination = self._get_destination()

return dlt.pipeline(
pipeline_name=pipeline_name,
pipelines_dir=pipelines_dir,
destination=destination,
dataset_name=self.inputs.dataset_name,
)
Expand Down

0 comments on commit 821854a

Please sign in to comment.