Skip to content

Commit

Permalink
Merge branch 'master' into update_hobby_test
Browse files Browse the repository at this point in the history
  • Loading branch information
fuziontech authored Mar 26, 2024
2 parents 3de7259 + 7148e2c commit ac930f7
Show file tree
Hide file tree
Showing 52 changed files with 467 additions and 323 deletions.
4 changes: 4 additions & 0 deletions bin/docker-worker-celery
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ FLAGS+=("-n node@%h")
# On Heroku $WEB_CONCURRENCY contains suggested number of forks per dyno type
# https://github.com/heroku/heroku-buildpack-python/blob/main/vendor/WEB_CONCURRENCY.sh
[[ -n "${WEB_CONCURRENCY}" ]] && FLAGS+=" --concurrency $WEB_CONCURRENCY"
# Restart worker process after it processes this many tasks (to mitigate memory leaks)
[[ -n "${CELERY_MAX_TASKS_PER_CHILD}" ]] && FLAGS+=" --max-tasks-per-child $CELERY_MAX_TASKS_PER_CHILD"
# Restart worker process after it exceeds this much memory usage (to mitigate memory leaks)
[[ -n "${CELERY_MAX_MEMORY_PER_CHILD}" ]] && FLAGS+=" --max-memory-per-child $CELERY_MAX_MEMORY_PER_CHILD"

if [[ -z "${CELERY_WORKER_QUEUES}" ]]; then
source ./bin/celery-queues.env
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/featureFlags.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ describe('Feature Flags', () => {
// select "add filter" and "property"
cy.get('[data-attr=property-select-toggle-0').click()

// select the third property
// select the first property
cy.get('[data-attr=taxonomic-filter-searchfield]').click()
cy.get('[data-attr=taxonomic-filter-searchfield]').type('is_demo')
cy.get('[data-attr=taxonomic-tab-person_properties]').click()
// select numeric $browser_version
cy.get('[data-attr=prop-filter-person_properties-2]').click({ force: true })
Expand Down
34 changes: 23 additions & 11 deletions cypress/e2e/trends.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Trends', () => {
cy.get('[data-attr=trend-element-subject-1]').click()
cy.get('[data-attr=taxonomic-tab-actions]').click()
cy.get('[data-attr=taxonomic-filter-searchfield]').click().type('home')
cy.contains('Hogflix homepage view').click({ force: true })
cy.contains('Hogflix homepage view').click()

// then
cy.get('[data-attr=trend-line-graph]').should('exist')
Expand Down Expand Up @@ -66,15 +66,15 @@ describe('Trends', () => {
it('Apply specific filter on default pageview event', () => {
cy.get('[data-attr=trend-element-subject-0]').click()
cy.get('[data-attr=taxonomic-filter-searchfield]').click().type('Pageview')
cy.get('.taxonomic-infinite-list').find('.taxonomic-list-row').contains('Pageview').click({ force: true })
cy.get('.taxonomic-infinite-list').find('.taxonomic-list-row').contains('Pageview').click()
cy.get('[data-attr=trend-element-subject-0]').should('have.text', 'Pageview')

// Apply a property filter
cy.get('[data-attr=show-prop-filter-0]').click()
cy.get('[data-attr=property-select-toggle-0]').click()
cy.get('[data-attr=prop-filter-event_properties-1]').click({ force: true })
cy.get('[data-attr=prop-filter-event_properties-1]').click()

cy.get('[data-attr=prop-val]').click({ force: true })
cy.get('[data-attr=prop-val]').click()
// cypress is odd and even though when a human clicks this the right dropdown opens
// in the test that doesn't happen
cy.get('body').then(($body) => {
Expand All @@ -88,22 +88,22 @@ describe('Trends', () => {
it('Apply 1 overall filter', () => {
cy.get('[data-attr=trend-element-subject-0]').click()
cy.get('[data-attr=taxonomic-filter-searchfield]').click().type('Pageview')
cy.get('.taxonomic-infinite-list').find('.taxonomic-list-row').contains('Pageview').click({ force: true })
cy.get('.taxonomic-infinite-list').find('.taxonomic-list-row').contains('Pageview').click()
cy.get('[data-attr=trend-element-subject-0]').should('have.text', 'Pageview')

cy.get('[data-attr$=add-filter-group]').click()
cy.get('[data-attr=property-select-toggle-0]').click()
cy.get('[data-attr=taxonomic-filter-searchfield]').click()
cy.get('[data-attr=prop-filter-event_properties-1]').click({ force: true })
cy.get('[data-attr=prop-val]').click({ force: true })
cy.get('[data-attr=prop-filter-event_properties-1]').click()
cy.get('[data-attr=prop-val]').click()
// cypress is odd and even though when a human clicks this the right dropdown opens
// in the test that doesn't happen
cy.get('body').then(($body) => {
if ($body.find('[data-attr=prop-val-0]').length === 0) {
cy.get('[data-attr=taxonomic-value-select]').click()
}
})
cy.get('[data-attr=prop-val-0]').click({ force: true })
cy.get('[data-attr=prop-val-0]').click()

cy.get('[data-attr=trend-line-graph]', { timeout: 8000 }).should('exist')
})
Expand All @@ -117,14 +117,14 @@ describe('Trends', () => {

it('Apply pie filter', () => {
cy.get('[data-attr=chart-filter]').click()
cy.get('.Popover').find('.LemonButton').contains('Pie').click({ force: true })
cy.get('.Popover').find('.LemonButton').contains('Pie').click()

cy.get('[data-attr=trend-pie-graph]').should('exist')
})

it('Apply table filter', () => {
cy.get('[data-attr=chart-filter]').click()
cy.get('.Popover').find('.LemonButton').contains('Table').click({ force: true })
cy.get('.Popover').find('.LemonButton').contains('Table').click()

cy.get('[data-attr=insights-table-graph]').should('exist')

Expand All @@ -144,7 +144,7 @@ describe('Trends', () => {

it('Apply property breakdown', () => {
cy.get('[data-attr=add-breakdown-button]').click()
cy.get('[data-attr=prop-filter-event_properties-1]').click({ force: true })
cy.get('[data-attr=prop-filter-event_properties-1]').click()
cy.get('[data-attr=trend-line-graph]').should('exist')
})

Expand All @@ -154,4 +154,16 @@ describe('Trends', () => {
cy.contains('All Users*').click()
cy.get('[data-attr=trend-line-graph]').should('exist')
})

it('Show warning on MAU math in total value insight', () => {
cy.get('[data-attr=chart-filter]').click()
cy.get('.Popover').find('.LemonButton').contains('Pie').click()
cy.get('[data-attr=trend-pie-graph]').should('exist') // Make sure the pie chart is loaded before proceeding

cy.get('[data-attr=math-selector-0]').click()
cy.get('[data-attr=math-monthly_active-0] .LemonIcon').should('exist') // This should be the warning icon

cy.get('[data-attr=math-monthly_active-0]').trigger('mouseenter') // Activate warning tooltip
cy.get('.Tooltip').contains('we recommend using "Unique users" here instead').should('exist')
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expectLogic } from 'kea-test-utils'
import { MOCK_DEFAULT_USER } from 'lib/api.mock'
import { userLogic } from 'scenes/userLogic'

import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'

import { featurePreviewsLogic } from './featurePreviewsLogic'
Expand All @@ -10,6 +11,11 @@ describe('featurePreviewsLogic', () => {
let logic: ReturnType<typeof featurePreviewsLogic.build>

beforeEach(() => {
useMocks({
post: {
'https://posthoghelp.zendesk.com/api/v2/requests.json': [200, {}],
},
})
initKeaTests()
logic = featurePreviewsLogic()
logic.mount()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { actions, connect, events, kea, listeners, path, reducers, selectors } f
import { loaders } from 'kea-loaders'
import { router } from 'kea-router'
import api from 'lib/api'
import { reverseProxyCheckerLogic } from 'lib/components/ReverseProxyChecker/reverseProxyCheckerLogic'
import { permanentlyMount } from 'lib/utils/kea-logic-builders'
import posthog from 'posthog-js'
import { membersLogic } from 'scenes/organization/membersLogic'
Expand Down Expand Up @@ -58,6 +59,8 @@ export const activationLogic = kea<activationLogicType>([
['insights'],
dashboardsModel,
['rawDashboards'],
reverseProxyCheckerLogic,
['hasReverseProxy'],
],
actions: [
inviteLogic,
Expand Down Expand Up @@ -193,6 +196,7 @@ export const activationLogic = kea<activationLogicType>([
s.customEventsCount,
s.installedPlugins,
s.currentTeamSkippedTasks,
s.hasReverseProxy,
],
(
currentTeam,
Expand All @@ -202,7 +206,8 @@ export const activationLogic = kea<activationLogicType>([
dashboards,
customEventsCount,
installedPlugins,
skippedTasks
skippedTasks,
hasReverseProxy
) => {
const tasks: ActivationTaskType[] = []
for (const task of Object.values(ActivationTasks)) {
Expand Down Expand Up @@ -286,7 +291,7 @@ export const activationLogic = kea<activationLogicType>([
id: ActivationTasks.SetUpReverseProxy,
name: 'Set up a reverse proxy',
description: 'Send your events from your own domain to avoid tracking blockers',
completed: false,
completed: hasReverseProxy || false,
canSkip: true,
skipped: skippedTasks.includes(ActivationTasks.SetUpReverseProxy),
url: 'https://posthog.com/docs/advanced/proxy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function useInsightMocks(interval: string = 'day', timezone: string = 'UTC'): vo
[`/api/projects/:team_id/insights/${MOCK_INSIGHT_NUMERIC_ID}`]: () => {
return [200, insight]
},
'/api/users/@me/': [200, {}],
},
})
}
Expand All @@ -162,6 +163,7 @@ function useAnnotationsMocks(): void {
MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3,
],
},
'/api/users/@me/': [200, {}],
},
})
}
Expand All @@ -171,15 +173,14 @@ describe('annotationsOverlayLogic', () => {

beforeEach(() => {
useAnnotationsMocks()
initKeaTests()
})

afterEach(() => {
logic.unmount()
})

it('loads annotations on mount', async () => {
initKeaTests()

useInsightMocks()

logic = annotationsOverlayLogic({
Expand All @@ -193,8 +194,6 @@ describe('annotationsOverlayLogic', () => {
})

describe('relevantAnnotations', () => {
initKeaTests()

it('returns annotations scoped to the insight for a saved insight', async () => {
useInsightMocks()

Expand Down Expand Up @@ -224,8 +223,6 @@ describe('annotationsOverlayLogic', () => {
})

it('returns annotations scoped to the project for a new insight', async () => {
initKeaTests()

useInsightMocks()

logic = annotationsOverlayLogic({
Expand All @@ -250,8 +247,6 @@ describe('annotationsOverlayLogic', () => {
})

it('excludes annotations that are outside of insight date range', async () => {
initKeaTests()

useInsightMocks()

logic = annotationsOverlayLogic({
Expand Down Expand Up @@ -506,8 +501,6 @@ describe('annotationsOverlayLogic', () => {
}

it(`merges groups when one tick covers more than one date (UTC)`, async () => {
initKeaTests(true, MOCK_DEFAULT_TEAM)

useInsightMocks()

logic = annotationsOverlayLogic({
Expand Down Expand Up @@ -572,8 +565,6 @@ describe('annotationsOverlayLogic', () => {
})

it(`merges groups when one tick covers more than one hour (UTC)`, async () => {
initKeaTests(true, MOCK_DEFAULT_TEAM)

useInsightMocks('hour')

logic = annotationsOverlayLogic({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ describe('the authorized urls list logic', () => {
return [200, { result: ['result from api'] }]
},
},
patch: {
'/api/projects/:team': [200, {}],
},
})
initKeaTests()
logic = authorizedUrlListLogic({
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/lib/components/CustomerLogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
interface CustomerProps {
image: string
alt: string
className?: string
}

interface LogoProps {
src: string
alt: string
className?: string
}

const Logo = ({ src, alt, className = '' }: LogoProps): JSX.Element => (
<img className={`bg-transparent w-full px-3 py-3 h-10 ${className}`} src={src} alt={alt} />
)

export const CustomerLogo = ({ image, alt, className = '' }: CustomerProps): JSX.Element => {
return (
<li className="flex items-center justify-center w-full">
<Logo className={className} src={image} alt={alt} />
</li>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { propertyFilterLogic } from 'lib/components/PropertyFilters/propertyFilt
import { PropertyFilterInternalProps } from 'lib/components/PropertyFilters/types'
import {
isGroupPropertyFilter,
isPersonPropertyFilter,
isPropertyFilterWithOperator,
PROPERTY_FILTER_TYPE_TO_TAXONOMIC_FILTER_GROUP_TYPE,
propertyFilterTypeToTaxonomicFilterType,
Expand Down Expand Up @@ -64,7 +63,7 @@ export function TaxonomicPropertyFilter({
value,
item
) => {
selectItem(taxonomicGroup, value, item)
selectItem(taxonomicGroup, value, item?.propertyFilterType)
if (
taxonomicGroup.type === TaxonomicFilterGroupType.Cohorts ||
taxonomicGroup.type === TaxonomicFilterGroupType.HogQLExpression
Expand Down Expand Up @@ -215,7 +214,6 @@ export function TaxonomicPropertyFilter({
value: newValue || null,
operator: newOperator,
type: filter?.type,
...(isPersonPropertyFilter(filter) ? { table: filter?.table } : {}),
...(isGroupPropertyFilter(filter)
? { group_type_index: filter.group_type_index }
: {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ export const taxonomicPropertyFilterLogic = kea<taxonomicPropertyFilterLogicType
],
})),
actions({
selectItem: (taxonomicGroup: TaxonomicFilterGroup, propertyKey?: TaxonomicFilterValue, item?: any) => ({
selectItem: (
taxonomicGroup: TaxonomicFilterGroup,
propertyKey?: TaxonomicFilterValue,
itemPropertyFilterType?: PropertyFilterType
) => ({
taxonomicGroup,
propertyKey,
item,
itemPropertyFilterType,
}),
openDropdown: true,
closeDropdown: true,
Expand Down Expand Up @@ -89,8 +93,7 @@ export const taxonomicPropertyFilterLogic = kea<taxonomicPropertyFilterLogicType
],
}),
listeners(({ actions, values, props }) => ({
selectItem: ({ taxonomicGroup, propertyKey, item }) => {
const itemPropertyFilterType = item?.propertyFilterType as PropertyFilterType
selectItem: ({ taxonomicGroup, propertyKey, itemPropertyFilterType }) => {
const propertyType = itemPropertyFilterType ?? taxonomicFilterTypeToPropertyFilterType(taxonomicGroup.type)
if (propertyKey && propertyType) {
if (propertyType === PropertyFilterType.Cohort) {
Expand Down Expand Up @@ -126,8 +129,8 @@ export const taxonomicPropertyFilterLogic = kea<taxonomicPropertyFilterLogicType
}
const operator =
property_name_to_default_operator_override[propertyKey] ||
property_value_type_to_default_operator_override[propertyValueType ?? ''] ||
(isPropertyFilterWithOperator(values.filter) ? values.filter.operator : null) ||
property_value_type_to_default_operator_override[propertyValueType ?? ''] ||
PropertyOperator.Exact

const isGroupNameFilter = taxonomicGroup.type.startsWith(TaxonomicFilterGroupType.GroupNamesPrefix)
Expand All @@ -139,7 +142,6 @@ export const taxonomicPropertyFilterLogic = kea<taxonomicPropertyFilterLogicType
operator,
type: propertyType as AnyPropertyFilter['type'] as any, // bad | pipe chain :(
group_type_index: taxonomicGroup.groupTypeIndex,
table: item.table,
}
props.propertyFilterLogic.actions.setFilter(props.filterIndex, property)
}
Expand Down
Loading

0 comments on commit ac930f7

Please sign in to comment.