Skip to content

Commit

Permalink
Merge branch 'master' into fix-zero-decimal-places
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes authored Mar 13, 2024
2 parents f573823 + 5146227 commit c07d22a
Show file tree
Hide file tree
Showing 494 changed files with 25,593 additions and 7,267 deletions.
21 changes: 18 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ module.exports = {
'plugin:eslint-comments/recommended',
'plugin:storybook/recommended',
'plugin:compat/recommended',
'prettier', // Disables any formatting rules to let prettier do its job
'prettier',
],
globals,
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
project: true,
tsconfigRootDir: __dirname,
},
plugins: [
'react',
Expand Down Expand Up @@ -119,7 +120,17 @@ module.exports = {
},
{
name: 'antd',
importNames: ['Card', 'Col', 'Row', 'Alert', 'Tooltip', 'Progress', 'Radio', 'Divider'],
importNames: [
'Card',
'Col',
'Row',
'Alert',
'Tooltip',
'Progress',
'Radio',
'Divider',
'Popconfirm',
],
message: 'please use the Lemon equivalent instead',
},
],
Expand Down Expand Up @@ -252,6 +263,10 @@ module.exports = {
element: 'Divider',
message: 'use <LemonDivider> instead',
},
{
element: 'Popconfirm',
message: 'use <LemonDialog> instead',
},
],
},
],
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ jobs:
- name: Read benchmark output
if: ${{ github.event_name == 'pull_request' }}
id: pr_vs_master_changed
uses: juliangruber/read-file-action@v1.0.0
uses: juliangruber/read-file-action@v1
with:
path: pr_vs_master_changed.txt

- name: Read benchmark output (full)
if: ${{ github.event_name == 'pull_request' }}
id: pr_vs_master
uses: juliangruber/read-file-action@v1.0.0
uses: juliangruber/read-file-action@v1
with:
path: pr_vs_master.txt

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:

- name: Set up Node.js
if: needs.changes.outputs.shouldTriggerCypress == 'true'
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.12.1

Expand Down Expand Up @@ -183,7 +183,6 @@ jobs:
DISABLE_SECURE_SSL_REDIRECT=1
SECURE_COOKIES=0
OPT_OUT_CAPTURE=0
SELF_CAPTURE=1
E2E_TESTING=1
SKIP_SERVICE_VERSION_REQUIREMENTS=1
EMAIL_HOST=email.test.posthog.net
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- name: Set up Node.js
if: needs.changes.outputs.frontend == 'true'
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.12.1

Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:

- name: Set up Node.js
if: needs.changes.outputs.frontend == 'true'
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.12.1
cache: pnpm
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-plugin-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
version: 8.x.x

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.12.1
cache: pnpm
Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:

- name: Set up Node.js
if: needs.changes.outputs.plugin-server == 'true'
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.12.1
cache: pnpm
Expand Down Expand Up @@ -242,7 +242,7 @@ jobs:
version: 8.x.x

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.12.1
cache: pnpm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codespaces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
# Install QEMU so we can target x86_64 (github codespaces)
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/container-images-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Depot CLI
uses: depot/setup-action@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/customer-data-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
version: 8.x.x

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Depot CLI
uses: depot/setup-action@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/storybook-chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
version: 8.x.x

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.12.1
cache: pnpm
Expand All @@ -42,7 +42,7 @@ jobs:
run: pnpm i -D chromatic

- name: Publish to Chromatic
uses: chromaui/action@v10
uses: chromaui/action@v11
id: publish
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/storybook-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
version: 8.x.x

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.12.1
cache: pnpm
Expand Down
8 changes: 5 additions & 3 deletions .storybook/app-context.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { AppContext } from '~/types'
import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
import { AppContext } from '~/types'

export const getStorybookAppContext = (): AppContext => ({
anonymous: false,
// Ideally we wouldn't set `current_team` here, the same way we don't set `current_user`, but unfortunately
// as of March 2024, a bunch of logics make the assumption that this is set, via `AppConfig`
current_team: MOCK_DEFAULT_TEAM,
current_user: undefined as any, // undefined triggers a fetch and lets us mock the data
current_user: undefined as any, // `undefined` triggers a fetch and lets us mock the data
default_event_name: '$pageview',
persisted_feature_flags: [],
commit_sha: undefined,
preflight: null as any, // null triggers a fetch and lets us mock the data
preflight: null as any, // `null` triggers a fetch and lets us mock the data
switched_team: null,
})
2 changes: 1 addition & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import type { Meta, Parameters, Preview } from '@storybook/react'
import { Title, Subtitle, Description, Primary, Controls, Stories } from '@storybook/blocks'
import { worker } from '~/mocks/browser'
import { loadPostHogJS } from '~/loadPostHogJS'
import { getStorybookAppContext } from './app-context'
import { withKea } from './decorators/withKea'
import { withMockDate } from './decorators/withMockDate'
import { defaultMocks } from '~/mocks/handlers'
import { withFeatureFlags } from './decorators/withFeatureFlags'
import { withTheme } from './decorators/withTheme'
import { apiHostOrigin } from 'lib/utils/apiHost'
import { getStorybookAppContext } from './app-context'

const setupMsw = () => {
// Make sure the msw worker is started
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

PostHog is available with hosting in the EU or US and is fully SOC 2 compliant. It's free to get started and comes with a generous monthly free tier:
- 1 million product analytics events
- 15k session replays
- 5k session replays
- 1 million feature flag requests
- 250 survey responses

Expand All @@ -45,7 +45,7 @@ We're constantly adding new features, with web analytics and data warehouse now

### PostHog Cloud (Recommended)

The fastest and most reliable way to get started with PostHog is signing up for free to [PostHog Cloud](https://us.posthog.com/signup) or [PostHog Cloud EU](https://eu.posthog.com/signup). Your first 1 million events (and 15k replays) are free every month, after which you pay based on usage.
The fastest and most reliable way to get started with PostHog is signing up for free to [PostHog Cloud](https://us.posthog.com/signup) or [PostHog Cloud EU](https://eu.posthog.com/signup). Your first 1 million events (and 5k replays) are free every month, after which you pay based on usage.

### Open-source hobby deploy (Advanced)

Expand Down
1 change: 0 additions & 1 deletion bin/e2e-test-runner
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ done
export DEBUG=1
export NO_RESTART_LOOP=1
export CYPRESS_BASE_URL=http://localhost:8080
export OPT_OUT_CAPTURE="${OPT_OUT_CAPTURE:=1}"
export SECURE_COOKIES=0
export SKIP_SERVICE_VERSION_REQUIREMENTS=1
export KAFKA_HOSTS=kafka:9092
Expand Down
2 changes: 1 addition & 1 deletion cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ To test feature flags you can intercept the call to the `decide` endpoint
```javascript
// sometimes the system under test calls `/decide`
// and sometimes it calls https://app.posthog.com/decide
cy.intercept('https://app.posthog.com/decide/*', (req) =>
cy.intercept('**/decide/*', (req) =>
req.reply(
decideResponse({
// add feature flags here, for e.g.
Expand Down
11 changes: 11 additions & 0 deletions cypress/e2e/auth.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,15 @@ describe('Auth', () => {
cy.visit('/signup')
cy.location('pathname').should('eq', '/project/1')
})

it('Logout in another tab results in logout in the current tab too', () => {
cy.window().then(async (win) => {
// Hit /logout *in the background* by using fetch()
await win.fetch('/logout')
})

cy.clickNavMenu('dashboards') // This should cause logout bacause of new data fetching being initiated

cy.location('pathname').should('eq', '/login') // We should be quickly redirected to the login page
})
})
15 changes: 4 additions & 11 deletions cypress/e2e/billingv2.cy.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import * as fflate from 'fflate'

const UNSUBSCRIBE_SURVEY_ID = '018b6e13-590c-0000-decb-c727a2b3f462'

describe('Billing', () => {
beforeEach(() => {
cy.intercept('/api/billing-v2/', { fixture: 'api/billing-v2/billing-v2.json' })

cy.visit('/organization/billing')

cy.intercept('POST', '**/e/?compression=gzip-js*').as('capture')
})

it('Show and submit unsubscribe survey', () => {
Expand All @@ -22,19 +18,16 @@ describe('Billing', () => {
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Product analytics')
cy.contains('.LemonModal .LemonButton', 'Unsubscribe').click()

cy.wait('@capture').then(({ request }) => {
const data = new Uint8Array(request.body)
const decoded = fflate.strFromU8(fflate.decompressSync(data))
const decodedJSON = JSON.parse(decoded)

// These should be a 'survey sent' event somewhere in the decodedJSON
const matchingEvents = decodedJSON.filter((event) => event.event === 'survey sent')
cy.window().then((win) => {
const events = (win as any)._cypress_posthog_captures
const matchingEvents = events.filter((event) => event.event === 'survey sent')
expect(matchingEvents.length).to.equal(1)
const matchingEvent = matchingEvents[0]
expect(matchingEvent.properties.$survey_id).to.equal(UNSUBSCRIBE_SURVEY_ID)
expect(matchingEvent.properties.$survey_response).to.equal('Product analytics')
expect(matchingEvent.properties.$survey_response_1).to.equal('product_analytics')
})

cy.get('.LemonModal').should('not.exist')
cy.wait(['@unsubscribeProductAnalytics'])
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/dashboard-deletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('deleting dashboards', () => {

// load the named insight
cy.contains('.saved-insights tr', insightToKeepName).within(() => {
cy.get('.row-name a').click()
cy.get('.Link').click()
})

insight.addInsightToDashboard(dashboardName, { visitAfterAdding: true })
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ describe('Dashboard', () => {
cy.get('[data-attr=breadcrumb-Dashboards]').should('have.text', 'Dashboards')
})

// FIXME: this test works in real, but not in cypress
it.skip('Adding new insight to dashboard works', () => {
const dashboardName = randomString('to add an insight to')
it('Adding new insight to dashboard works', () => {
const dashboardName = randomString('Dashboard with insight A')
const insightName = randomString('insight to add to dashboard')

// create and visit a dashboard to get it into turbomode cache
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/early-access-management.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Early Access Management', () => {
cy.contains('Create your first feature').should('not.exist')

// edit feature
cy.get('a.Link').contains('.row-name', 'Test Feature').click()
cy.get('a.Link').contains('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')
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/events.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ const interceptPropertyDefinitions = (): void => {
fixture: 'api/event/property_definitions',
})

cy.intercept('/api/projects/1/property_definitions?is_feature_flag=false&search=&*', {
cy.intercept('/api/projects/*/property_definitions?is_feature_flag=false&search=&*', {
fixture: 'api/event/property_definitions',
})

cy.intercept('/api/projects/1/property_definitions?is_feature_flag=false&search=%24time*', {
cy.intercept('/api/projects/*/property_definitions?is_feature_flag=false&search=%24time*', {
fixture: 'api/event/only_time_property_definition',
})

cy.intercept('/api/projects/1/property_definitions?is_feature_flag=false&search=%24browser*', {
cy.intercept('/api/projects/*/property_definitions?is_feature_flag=false&search=%24browser*', {
fixture: 'api/event/only_browser_version_property_definition',
})

cy.intercept('/api/projects/1/property_definitions?is_feature_flag=true*', {
cy.intercept('/api/projects/*/property_definitions?is_feature_flag=true*', {
fixture: 'api/event/feature_flag_property_definition',
})
}
Expand Down
Loading

0 comments on commit c07d22a

Please sign in to comment.