Skip to content

Commit

Permalink
Merge branch 'master' into chore/update-to-python-3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Oct 13, 2023
2 parents 0cc5988 + 453ae75 commit 161278f
Show file tree
Hide file tree
Showing 724 changed files with 20,334 additions and 18,390 deletions.
24 changes: 12 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ module.exports = {
element: 'Divider',
message: 'use <LemonDivider> instead',
},
{
element: 'Typography',
message: 'use utility classes instead',
},
{
element: 'Card',
message: 'use utility classes instead',
Expand All @@ -124,10 +120,6 @@ module.exports = {
element: 'Button',
message: 'use <LemonButton> instead',
},
{
element: 'Input.TextArea',
message: 'use <LemonTextArea> instead',
},
{
element: 'Input',
message: 'use <LemonInput> instead',
Expand All @@ -148,10 +140,6 @@ module.exports = {
element: 'a',
message: 'use <Link> instead',
},
{
element: 'ReactMarkdown',
message: 'use <LemonMarkdown> instead',
},
],
},
],
Expand Down Expand Up @@ -183,6 +171,18 @@ module.exports = {
element: 'MonacoEditor',
message: 'use <CodeEditor> instead',
},
{
element: 'Typography',
message: 'use utility classes instead',
},
{
element: 'Input.TextArea',
message: 'use <LemonTextArea> instead',
},
{
element: 'ReactMarkdown',
message: 'use <LemonMarkdown> instead',
},
],
},
],
Expand Down
8 changes: 0 additions & 8 deletions .github/ISSUE_TEMPLATE/sprint_planning_retro.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ title: Sprint 1.n.0 m/2 - Jan 1 to Jan 12
2.
3.

## Retro: What can we do better next sprint?

1.
2.
3.
4.
5.


# Team sprint planning

Expand Down
2 changes: 2 additions & 0 deletions .github/actions/build-n-cache-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ runs:
load: ${{ inputs.load }}
tags: ${{ steps.emit.outputs.tag }}
platforms: linux/amd64,linux/arm64
build-args: COMMIT_HASH=${{ github.sha }}
env:
ACTIONS_ID_TOKEN_REQUEST_URL: ${{ inputs.actions-id-token-request-url }}

Expand All @@ -45,5 +46,6 @@ runs:
file: production-unit.Dockerfile
tags: ${{ steps.emit.outputs.tag }}
platforms: linux/amd64
build-args: COMMIT_HASH=${{ github.sha }}
env:
ACTIONS_ID_TOKEN_REQUEST_URL: ${{ inputs.actions-id-token-request-url }}
12 changes: 10 additions & 2 deletions .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
# version changes
- docker-compose.dev.yml
- Dockerfile
- cypress/**
# Job that lists and chunks spec file names and caches node modules
chunks:
Expand Down Expand Up @@ -211,7 +212,10 @@ jobs:
- name: Wait for PostHog
# these are required checks so, we can't skip entire sections
if: needs.changes.outputs.shouldTriggerCypress == 'true'
uses: iFaxity/wait-on-action@v1
# this action might be abandoned - but v1 doesn't point to latest of v1 (which it should)
# so pointing to v1.1.0 to remove warnings about node version with v1
# todo check https://github.com/iFaxity/wait-on-action/releases for new releases
uses: iFaxity/[email protected]
timeout-minutes: 3
with:
verbose: true
Expand All @@ -221,12 +225,16 @@ jobs:
- name: Cypress run
# these are required checks so, we can't skip entire sections
if: needs.changes.outputs.shouldTriggerCypress == 'true'
uses: cypress-io/github-action@v5
uses: cypress-io/github-action@v6
with:
config-file: cypress.e2e.config.ts
config: retries=2
spec: ${{ matrix.chunk }}
install: false
env:
E2E_TESTING: 1
OPT_OUT_CAPTURE: 0
GITHUB_ACTION_RUN_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'

- name: Archive test screenshots
uses: actions/upload-artifact@v3
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ci-plugin-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ jobs:
fail-fast: false
matrix:
POE_EMBRACE_JOIN_FOR_TEAMS: ['', '*']
KAFKA_CONSUMPTION_USE_RDKAFKA: ['true', 'false']

env:
REDIS_URL: 'redis://localhost'
Expand All @@ -199,7 +198,6 @@ jobs:
KAFKA_HOSTS: 'kafka:9092'
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog'
POE_EMBRACE_JOIN_FOR_TEAMS: ${{matrix.POE_EMBRACE_JOIN_FOR_TEAMS}}
KAFKA_CONSUMPTION_USE_RDKAFKA: ${{matrix.KAFKA_CONSUMPTION_USE_RDKAFKA}}

steps:
- name: Code check out
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/container-images-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
push: true
tags: posthog/posthog:${{ github.sha }},posthog/posthog:latest,${{ steps.aws-ecr.outputs.registry }}/posthog-cloud:master
platforms: linux/arm64,linux/amd64
build-args: COMMIT_HASH=${{ github.sha }}

- name: Build and push unit container image
id: build-unit
Expand All @@ -80,6 +81,7 @@ jobs:
file: production-unit.Dockerfile
tags: ${{ steps.aws-ecr.outputs.registry }}/posthog-cloud:unit
platforms: linux/amd64
build-args: COMMIT_HASH=${{ github.sha }}

- name: get deployer token
id: deployer
Expand Down
9 changes: 7 additions & 2 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,22 @@ const LOADER_SELECTORS = [

const customSnapshotsDir = `${process.cwd()}/frontend/__snapshots__`

const TEST_TIMEOUT_MS = 10000
const BROWSER_DEFAULT_TIMEOUT_MS = 9000 // Reduce the default timeout down from 30s, to pre-empt Jest timeouts
const SCREENSHOT_TIMEOUT_MS = 9000

module.exports = {
setup() {
expect.extend({ toMatchImageSnapshot })
jest.retryTimes(RETRY_TIMES, { logErrorsBeforeRetry: true })
jest.setTimeout(TEST_TIMEOUT_MS)
},
async postRender(page, context) {
const browserContext = page.context()
const storyContext = (await getStoryContext(page, context)) as StoryContext
const { skip = false, snapshotBrowsers = ['chromium'] } = storyContext.parameters?.testOptions ?? {}

browserContext.setDefaultTimeout(5000) // Reduce the default timeout from 30 s to 5 s to pre-empt Jest timeouts
browserContext.setDefaultTimeout(BROWSER_DEFAULT_TIMEOUT_MS)
if (!skip) {
const currentBrowser = browserContext.browser()!.browserType().name() as SupportedBrowserName
if (snapshotBrowsers.includes(currentBrowser)) {
Expand Down Expand Up @@ -198,7 +203,7 @@ async function expectLocatorToMatchStorySnapshot(
browser: SupportedBrowserName,
options?: LocatorScreenshotOptions
): Promise<void> {
const image = await locator.screenshot({ timeout: 3000, ...options })
const image = await locator.screenshot({ timeout: SCREENSHOT_TIMEOUT_MS, ...options })
let customSnapshotIdentifier = context.id
if (browser !== 'chromium') {
customSnapshotIdentifier += `--${browser}`
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "Celery",
"type": "python",
"request": "launch",
"module": "celery",
"program": "${workspaceFolder}/env/bin/celery",
"console": "integratedTerminal",
"python": "${workspaceFolder}/env/bin/python",
"cwd": "${workspaceFolder}",
Expand Down
8 changes: 1 addition & 7 deletions bin/docker-server
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ trap 'rm -rf "$PROMETHEUS_MULTIPROC_DIR"' EXIT
export PROMETHEUS_METRICS_EXPORT_PORT=8001
export STATSD_PORT=${STATSD_PORT:-8125}

if [[ -n $INJECT_EC2_CLIENT_RACK ]]; then
# To avoid cross-AZ Kafka traffic, set KAFKA_CLIENT_RACK from the EC2 metadata endpoint.
# TODO: switch to the downwards API when https://github.com/kubernetes/kubernetes/issues/40610 is released
TOKEN=$(curl --max-time 0.1 -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
export KAFKA_CLIENT_RACK=$(curl --max-time 0.1 -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/placement/availability-zone-id)
fi

exec gunicorn posthog.wsgi \
--config gunicorn.config.py \
--bind 0.0.0.0:8000 \
Expand All @@ -27,6 +20,7 @@ exec gunicorn posthog.wsgi \
--worker-tmp-dir /dev/shm \
--workers=2 \
--threads=8 \
--keep-alive=60 \
--backlog=${GUNICORN_BACKLOG:-1000} \
--worker-class=gthread \
${STATSD_HOST:+--statsd-host $STATSD_HOST:$STATSD_PORT} \
Expand Down
35 changes: 24 additions & 11 deletions bin/install-macosx_arm64
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
#!/bin/bash

# Install scripts for M1 Macs
# See https://github.com/PostHog/posthog/issues/2916
# NB: use cryptography==3.4.7
## NOTE: This is a helper script to simplify the process of getting setup on macOS. If in doubt check https://posthog.com/handbook/engineering/developing-locally

# Set ld flags to use OpenSSL installed with brew
export LDFLAGS="-L$(brew --prefix openssl)/lib"
export CPPFLAGS="-I$(brew --prefix openssl)/include"
set -e

# Use system OpenSSL instead of BoringSSL for GRPC
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
echo "Attempting to install all dependencies and setup virtualenv..."
echo ""

pip cache purge
pip install -r requirements.txt
# Ensure we are in a directory ending with "posthog"
if [[ "$PWD" != *"/posthog" ]]; then
echo "Please run this script from a directory ending with 'posthog'"
exit 1
fi

if [[ $* == *--reset* ]]; then
rm -rf env/
fi

python3.10 -m venv env
source env/bin/activate

brew install openssl
CFLAGS="-I /opt/homebrew/opt/openssl/include $(python3.10-config --includes)" LDFLAGS="-L /opt/homebrew/opt/openssl/lib" GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 pip install -r requirements.txt

pip install -r requirements-dev.txt

echo ""
echo "🚀 Done!"
8 changes: 5 additions & 3 deletions bin/migrate-check
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -e

python manage.py migrate --check
python manage.py migrate_clickhouse --check
python manage.py run_async_migrations --check
if [ -z "$POSTHOG_SKIP_MIGRATION_CHECKS" ]; then
python manage.py migrate --check
python manage.py migrate_clickhouse --check
python manage.py run_async_migrations --check
fi
2 changes: 2 additions & 0 deletions cypress.e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export default defineConfig({
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
config.env.E2E_TESTING = !!process.env.E2E_TESTING

const options = {
webpackOptions: createEntry('cypress'),
watchOptions: {},
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/a11y.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('a11y', () => {
'persons',
'cohorts',
'annotations',
'plugins',
'apps',
'toolbarlaunch',
'projectsettings',
]
Expand Down
19 changes: 19 additions & 0 deletions cypress/e2e/cohorts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,24 @@ describe('Cohorts', () => {
cy.url().should('include', '/cohorts/')
cy.get('[data-attr="cohort-name"]').should('have.value', 'Test Cohort')
})

// back into cohort
cy.get('tbody').contains('Test Cohort').click()

// duplicate cohort (dynamic)
cy.get('[data-attr="more-button"]').click()
cy.get('.Popover__content').contains('Duplicate as dynamic cohort').click()
cy.get('.Toastify__toast-body').contains('View cohort').click()

// duplicate cohort (static)
cy.get('[data-attr="more-button"]').click()
cy.get('.Popover__content').contains('Duplicate as static cohort').click()
cy.get('.Toastify__toast-body').contains('View cohort').click()

// delete cohort
cy.get('[data-attr="more-button"]').click()
cy.get('.Popover__content').contains('Delete cohort').click()
cy.clickNavMenu('cohorts')
cy.get('tbody').should('not.have.text', 'Test Cohort (dynamic copy) (static copy)')
})
})
2 changes: 2 additions & 0 deletions cypress/e2e/dashboard-duplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ describe('duplicating dashboards', () => {
let dashboardName, insightName, expectedCopiedDashboardName, expectedCopiedInsightName

beforeEach(() => {
cy.intercept('POST', /\/api\/projects\/\d+\/dashboards/).as('createDashboard')

dashboardName = randomString('dashboard-')
expectedCopiedDashboardName = `${dashboardName} (Copy)`

Expand Down
55 changes: 55 additions & 0 deletions cypress/e2e/early-access-management.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
describe('Early Access Management', () => {
beforeEach(() => {
cy.visit('/early_access_features')
})

it('Early access feature new and list', () => {
// load an empty early access feature page
cy.get('h1').should('contain', 'Early Access Management')
cy.title().should('equal', 'Early Access Management • PostHog')
cy.get('h2').should('contain', 'Create your first feature')
cy.get('[data-attr="product-introduction-docs-link"]').should(
'contain',
'Learn more about Early access features'
)

// go to create a new feature
cy.get('[data-attr="create-feature"]').click()

// New Feature Release page
cy.get('h1').should('contain', 'New Feature Release')

// cancel new feature
cy.get('[data-attr="cancel-feature"]').click()
cy.get('h1').should('contain', 'Early Access Management')

// set feature name & description
cy.get('[data-attr="create-feature"]').click()
cy.get('[data-attr="feature-name"]').type('Test Feature')
cy.get('[data-attr="save-feature').should('contain.text', 'Save as draft')

// save
cy.get('[data-attr="save-feature"]').click()
cy.get('[data-attr=success-toast]').contains('Early Access Feature saved').should('exist')

// back to features
cy.visit('/early_access_features')
cy.get('tbody').contains('Test Feature')
cy.get('h2').should('not.have.text', 'Create your first feature')

// edit feature
cy.get('a.Link').contains('.row-name', 'Test Feature').click()
cy.get('[data-attr="edit-feature"]').click()
cy.get('h1').should('contain', 'Test Feature')
cy.get('[data-attr="save-feature"]').should('contain.text', 'Save')

// delete feature
cy.get('[data-attr="save-feature"]').click()
cy.get('[data-attr="delete-feature"]').click()
cy.get('h3').should('contain', 'Permanently delete feature?')
cy.get('[data-attr="confirm-delete-feature"]').click()
cy.get('[data-attr=info-toast]')
.contains('Early access feature deleted. Remember to delete corresponding feature flag if necessary')
.should('exist')
})
})
8 changes: 6 additions & 2 deletions cypress/e2e/events.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { dayjs } from 'lib/dayjs'

const interceptPropertyDefinitions = (): void => {
cy.intercept('/api/event/values/?key=%24browser').as('getBrowserValues')

cy.intercept('api/projects/@current/property_definitions/?limit=5000', {
fixture: 'api/event/property_definitions',
})
Expand Down Expand Up @@ -71,8 +73,10 @@ describe('Events', () => {
cy.get('[data-attr=taxonomic-filter-searchfield]').click()
cy.get('[data-attr=prop-filter-event_properties-0]').click()
cy.get('[data-attr=prop-val] .ant-select-selector').click({ force: true })
cy.get('[data-attr=prop-val-0]').click()
cy.get('.DataTable').should('exist')
cy.wait('@getBrowserValues').then(() => {
cy.get('[data-attr=prop-val-0]').click()
cy.get('.DataTable').should('exist')
})
})

it('separates feature flag properties into their own tab', () => {
Expand Down
Loading

0 comments on commit 161278f

Please sign in to comment.