Skip to content

Commit

Permalink
Merge branch 'master' into flag-test
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkakkar authored Apr 24, 2024
2 parents 7c2ad60 + 7e2cfa2 commit 69fe016
Show file tree
Hide file tree
Showing 193 changed files with 3,225 additions and 2,172 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ jobs:
echo running_time_run_id=${run_id} >> $GITHUB_ENV
echo running_time_run_started_at=${run_started_at} >> $GITHUB_ENV
- name: Capture running time to PostHog
if: github.repository == 'PostHog/posthog'
uses: PostHog/[email protected]
with:
posthog-token: ${{secrets.POSTHOG_API_TOKEN}}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ jobs:
echo running_time_run_id=${run_id} >> $GITHUB_ENV
echo running_time_run_started_at=${run_started_at} >> $GITHUB_ENV
- name: Capture running time to PostHog
if: github.repository == 'PostHog/posthog'
uses: PostHog/[email protected]
with:
posthog-token: ${{secrets.POSTHOG_API_TOKEN}}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/report-pr-age.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
echo is_revert=false >> $GITHUB_ENV
fi
- name: Capture PR age to PostHog
if: github.repository == 'PostHog/posthog'
uses: PostHog/[email protected]
with:
posthog-token: ${{secrets.POSTHOG_API_TOKEN}}
Expand Down
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"--scheduler",
"redbeat.RedBeatScheduler",
"--without-heartbeat",
"--without-gossip",
"--without-mingle",
"--pool=solo",
"-Ofair",
Expand Down
5 changes: 0 additions & 5 deletions Procfile

This file was deleted.

File renamed without changes.
28 changes: 28 additions & 0 deletions bin/build-schema-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -e

# Generate schema.py from schema.json
datamodel-codegen \
--class-name='SchemaRoot' --collapse-root-models --target-python-version 3.10 --disable-timestamp \
--use-one-literal-as-default --use-default --use-default-kwarg --use-subclass-enum \
--input frontend/src/queries/schema.json --input-file-type jsonschema \
--output posthog/schema.py --output-model-type pydantic_v2.BaseModel

# Format schema.py
ruff format posthog/schema.py

# Check schema.py and autofix
ruff check --fix posthog/schema.py

# HACK: Datamodel-codegen output for enum-type fields with a default is invalid – the default value is a plain string,
# and not the expected enum member. We fix this using sed, which is pretty hacky, but does the job.
# Specifically, we need to replace `Optional[PropertyOperator] = "exact"`
# with `Optional[PropertyOperator] = PropertyOperator("exact")` to make the default value valid.
# Remove this when https://github.com/koxudaxi/datamodel-code-generator/issues/1929 is resolved.
if [[ "$OSTYPE" == "darwin"* ]]; then
# sed needs `-i` to be followed by `''` on macOS
sed -i '' -e 's/Optional\[PropertyOperator\] = \("[A-Za-z_]*"\)/Optional[PropertyOperator] = PropertyOperator(\1)/g' posthog/schema.py
else
sed -i -e 's/Optional\[PropertyOperator\] = \("[A-Za-z_]*"\)/Optional[PropertyOperator] = PropertyOperator(\1)/g' posthog/schema.py
fi
2 changes: 1 addition & 1 deletion bin/start-worker
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trap 'kill $(jobs -p)' EXIT
source ./bin/celery-queues.env

# start celery worker with heartbeat (-B)
SKIP_ASYNC_MIGRATIONS_SETUP=0 CELERY_WORKER_QUEUES=$CELERY_WORKER_QUEUES celery -A posthog worker -B --scheduler redbeat.RedBeatScheduler --without-heartbeat --without-mingle -Ofair -n node@%h &
SKIP_ASYNC_MIGRATIONS_SETUP=0 CELERY_WORKER_QUEUES=$CELERY_WORKER_QUEUES celery -A posthog worker -B --scheduler redbeat.RedBeatScheduler --without-heartbeat --without-mingle --pool=solo -Ofair -n node@%h &

if [[ "$PLUGIN_SERVER_IDLE" != "1" && "$PLUGIN_SERVER_IDLE" != "true" ]]; then
./bin/plugin-server
Expand Down
34 changes: 34 additions & 0 deletions cypress/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,40 @@ describe('Dashboard', () => {
cy.get('[data-attr^="breadcrumb-Dashboard:"]').should('have.text', TEST_DASHBOARD_NAME + 'UnnamedCancelSave')
})

const assertVariablesConfigurationScreenIsShown = (): void => {
cy.get('[data-attr="new-dashboard-chooser"]').contains('Unique variable name').should('exist')
}

it('Allow reselecting a dashboard after pressing back', () => {
cy.intercept('GET', /\/api\/projects\/\d+\/dashboard_templates/, (req) => {
req.reply((response) => {
response.body.results[0].variables = [
{
id: 'id',
name: 'Unique variable name',
type: 'event',
default: {},
required: true,
description: 'description',
},
]
return response
})
})

// Request templates again.
cy.clickNavMenu('dashboards')

cy.get('[data-attr="new-dashboard"]').click()
cy.get('[data-attr="create-dashboard-from-template"]').click()
assertVariablesConfigurationScreenIsShown()

cy.contains('.LemonButton', 'Back').click()

cy.get('[data-attr="create-dashboard-from-template"]').click()
assertVariablesConfigurationScreenIsShown()
})

it('Click on a dashboard item dropdown and view graph', () => {
cy.get('[data-attr=dashboard-name]').contains('Web Analytics').click()
cy.get('.InsightCard [data-attr=more-button]').first().click()
Expand Down
60 changes: 60 additions & 0 deletions cypress/e2e/surveys.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,64 @@ describe('Surveys', () => {
cy.get('[data-attr=surveys-table]').should('contain', name)
cy.get(`[data-row-key="${name}"]`).contains(name).click()
})

it('duplicates a survey', () => {
// create survey
cy.get('[data-attr=new-survey]').click()
cy.get('[data-attr=new-blank-survey]').click()
cy.get('[data-attr=survey-name]').focus().type(name).should('have.value', name)

// Add user targetting criteria
cy.get('.LemonCollapsePanel').contains('Targeting').click()
cy.contains('All users').click()
cy.get('.Popover__content').contains('Users who match').click()
cy.contains('Add user targeting').click()
cy.get('[data-attr="property-select-toggle-0"]').click()
cy.get('[data-attr="prop-filter-person_properties-0"]').click()
cy.get('[data-attr=prop-val] .LemonInput').click({ force: true })
cy.get('[data-attr=prop-val-0]').click({ force: true })
cy.get('[data-attr="rollout-percentage"]').type('100')

cy.get('[data-attr=save-survey]').first().click()

// Launch the survey first, the duplicated one should be in draft
cy.get('[data-attr="launch-survey"]').click()

// try to duplicate survey
cy.get('[data-attr=more-button]').click()
cy.get('[data-attr=duplicate-survey]').click()

// if the survey is duplicated, try to view it & verify a copy is created
cy.get('[data-attr=success-toast]').contains('duplicated').should('exist').siblings('button').click()
cy.get('[data-attr=top-bar-name]').contains(`${name} (copy)`).should('exist')

// check if it launched in a draft state
cy.get('button[data-attr="launch-survey"]').should('have.text', 'Launch')

// check if targetting criteria is copied
cy.contains('Release conditions summary').should('exist')
cy.get('.FeatureConditionCard').should('exist').should('contain.text', 'is_demo equals true')
cy.get('.FeatureConditionCard').should('contain.text', 'Rolled out to 100% of users in this set.')

// delete the duplicated survey
cy.get('[data-attr=more-button]').click()
cy.get('[data-attr=delete-survey]').click()

// Archive the original survey
cy.clickNavMenu('surveys')
cy.get('[data-attr=surveys-table]').find(`[data-row-key="${name}"]`).find('a').click()
cy.get('[data-attr=stop-survey]').click()
cy.get('[data-attr=more-button]').click()
cy.get('[data-attr=archive-survey]').click()

// check if the duplicated survey is created with draft state
cy.get('[data-attr=more-button]').click()
cy.get('[data-attr=duplicate-survey]').click()
cy.clickNavMenu('surveys')
cy.get('[data-attr=surveys-table]')
.find(`[data-row-key="${name} (copy)"]`)
.find('[data-attr=status]')
.contains('DRAFT')
.should('exist')
})
})
34 changes: 17 additions & 17 deletions cypress/fixtures/api/billing-v2/billing-v2-subscribed-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@
},
{
"key": "apps",
"name": "Apps",
"description": "Use apps to transform, filter, and modify your incoming data. (Export apps not included, see the Data pipelines addon for product analytics.)",
"name": "Transformations",
"description": "Use transformations to filter or modify your incoming data. (Destinations not included, see the Data pipelines addon for product analytics.)",
"unit": null,
"limit": null,
"note": null
},
{
"key": "app_metrics",
"name": "App metrics",
"description": "Get metrics on your apps to see their usage, reliability, and more.",
"name": "Transformation & destination metrics",
"description": "Get metrics on your transformation and destination metrics to see their usage, reliability, and more.",
"unit": null,
"limit": null,
"note": null
Expand Down Expand Up @@ -2978,7 +2978,7 @@
"image_url": "https://posthog.com/images/product/product-icons/integrations.svg",
"screenshot_url": null,
"icon_key": "IconBolt",
"docs_url": "https://posthog.com/docs/apps",
"docs_url": "https://posthog.com/docs/cdp",
"subscribed": null,
"plans": [
{
Expand All @@ -2987,7 +2987,7 @@
"name": "Integrations",
"description": "Connect PostHog to your favorite tools.",
"image_url": "https://posthog.com/images/product/product-icons/integrations.svg",
"docs_url": "https://posthog.com/docs/apps",
"docs_url": "https://posthog.com/docs/cdp",
"note": null,
"unit": null,
"free_allocation": null,
Expand Down Expand Up @@ -3026,8 +3026,8 @@
},
{
"key": "apps",
"name": "Apps",
"description": "Use apps to transform, filter, and modify your incoming data. (Export apps not included, see the Data pipelines addon for product analytics.)",
"name": "Transformations",
"description": "Use transformations to filter or modify your incoming data. (Destinations not included, see the Data pipelines addon for product analytics.)",
"unit": null,
"limit": null,
"note": null
Expand All @@ -3043,7 +3043,7 @@
"name": "Integrations",
"description": "Connect PostHog to your favorite tools.",
"image_url": "https://posthog.com/images/product/product-icons/integrations.svg",
"docs_url": "https://posthog.com/docs/apps",
"docs_url": "https://posthog.com/docs/cdp",
"note": null,
"unit": null,
"free_allocation": null,
Expand Down Expand Up @@ -3082,16 +3082,16 @@
},
{
"key": "apps",
"name": "Apps",
"description": "Use apps to transform, filter, and modify your incoming data. (Export apps not included, see the Data pipelines addon for product analytics.)",
"name": "Transformations",
"description": "Use transformations to filter or modify your incoming data. (Destinations not included, see the Data pipelines addon for product analytics.)",
"unit": null,
"limit": null,
"note": null
},
{
"key": "app_metrics",
"name": "App metrics",
"description": "Get metrics on your apps to see their usage, reliability, and more.",
"name": "Transformation & destination metrics",
"description": "Get metrics on your transformation and destination metrics to see their usage, reliability, and more.",
"unit": null,
"limit": null,
"note": null
Expand Down Expand Up @@ -3122,8 +3122,8 @@
"features": [
{
"key": "apps",
"name": "Apps",
"description": "Use apps to transform, filter, and modify your incoming data. (Export apps not included, see the Data pipelines addon for product analytics.)",
"name": "Transformations",
"description": "Use transformations to filter or modify your incoming data. (Destinations not included, see the Data pipelines addon for product analytics.)",
"images": null,
"icon_key": null,
"type": null
Expand Down Expand Up @@ -3162,8 +3162,8 @@
},
{
"key": "app_metrics",
"name": "App metrics",
"description": "Get metrics on your apps to see their usage, reliability, and more.",
"name": "Transformation & destination metrics",
"description": "Get metrics on your transformation and destination metrics to see their usage, reliability, and more.",
"images": null,
"icon_key": null,
"type": null
Expand Down
30 changes: 15 additions & 15 deletions cypress/fixtures/api/billing-v2/billing-v2-unsubscribed.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@
},
{
"key": "apps",
"name": "Apps",
"description": "Use apps to transform, filter, and modify your incoming data. (Export apps not included, see the Data pipelines addon for product analytics.)",
"name": "Transformations",
"description": "Use transformations to filter or modify your incoming data. (Destinations not included, see the Data pipelines addon for product analytics.)",
"unit": null,
"limit": null,
"note": null
Expand Down Expand Up @@ -2660,7 +2660,7 @@
"image_url": "https://posthog.com/images/product/product-icons/integrations.svg",
"screenshot_url": null,
"icon_key": "IconBolt",
"docs_url": "https://posthog.com/docs/apps",
"docs_url": "https://posthog.com/docs/cdp",
"subscribed": null,
"plans": [
{
Expand All @@ -2669,7 +2669,7 @@
"name": "Free",
"description": "Connect PostHog to your favorite tools.",
"image_url": "https://posthog.com/images/product/product-icons/integrations.svg",
"docs_url": "https://posthog.com/docs/apps",
"docs_url": "https://posthog.com/docs/cdp",
"note": null,
"unit": null,
"free_allocation": null,
Expand Down Expand Up @@ -2708,8 +2708,8 @@
},
{
"key": "apps",
"name": "Apps",
"description": "Use apps to transform, filter, and modify your incoming data. (Export apps not included, see the Data pipelines addon for product analytics.)",
"name": "Transformations",
"description": "Use transformations to filter or modify your incoming data. (Destinations not included, see the Data pipelines addon for product analytics.)",
"unit": null,
"limit": null,
"note": null
Expand All @@ -2727,7 +2727,7 @@
"name": "Paid",
"description": "Connect PostHog to your favorite tools.",
"image_url": "https://posthog.com/images/product/product-icons/integrations.svg",
"docs_url": "https://posthog.com/docs/apps",
"docs_url": "https://posthog.com/docs/cdp",
"note": null,
"unit": null,
"free_allocation": null,
Expand Down Expand Up @@ -2766,16 +2766,16 @@
},
{
"key": "apps",
"name": "Apps",
"description": "Use apps to transform, filter, and modify your incoming data. (Export apps not included, see the Data pipelines addon for product analytics.)",
"name": "Transformations",
"description": "Use transformations to filter or modify your incoming data. (Destinations not included, see the Data pipelines addon for product analytics.)",
"unit": null,
"limit": null,
"note": null
},
{
"key": "app_metrics",
"name": "App metrics",
"description": "Get metrics on your apps to see their usage, reliability, and more.",
"name": "Transformation & destination metrics",
"description": "Get metrics on your transformation and destination metrics to see their usage, reliability, and more.",
"unit": null,
"limit": null,
"note": null
Expand Down Expand Up @@ -2808,8 +2808,8 @@
"features": [
{
"key": "apps",
"name": "Apps",
"description": "Use apps to transform, filter, and modify your incoming data. (Export apps not included, see the Data pipelines addon for product analytics.)",
"name": "Transformations",
"description": "Use transformations to filter or modify your incoming data. (Destinations not included, see the Data pipelines addon for product analytics.)",
"images": null,
"icon_key": null,
"type": null
Expand Down Expand Up @@ -2848,8 +2848,8 @@
},
{
"key": "app_metrics",
"name": "App metrics",
"description": "Get metrics on your apps to see their usage, reliability, and more.",
"name": "Transformation & destination metrics",
"description": "Get metrics on your transformation and destination metrics to see their usage, reliability, and more.",
"images": null,
"icon_key": null,
"type": null
Expand Down
Loading

0 comments on commit 69fe016

Please sign in to comment.