Skip to content

Commit

Permalink
Merge branch 'master' into feat/flag-db-operations-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarticus committed Aug 2, 2024
2 parents 9bb5ffb + b3ee8ec commit f741a94
Show file tree
Hide file tree
Showing 47 changed files with 1,083 additions and 338 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ We <3 contributions big and small. In priority order (although everything is app

Our mission is to increase the number of successful products in the world. To do that, we build product and data tools that help you understand user behavior without losing control of your data.

In our view, third-party analytics tools do not work in a world of cookie deprecation, GDPR, HIPAA, CCPA, and many other four-letter acronyms. PostHog is the alternative to sending all of your customers' personal information and usage data to third-parties.
In our view, third-party analytics tools do not work in a world of cookie deprecation, GDPR, HIPAA, CCPA, and many other four-letter acronyms. PostHog is the alternative to sending all of your customers' personal information and usage data to third parties.

PostHog gives you every tool you need to understand user behavior, develop and test improvements, and release changes to make your product more successful.

PostHog operates in public as much as possible. We detail how we work and our learning on building and running a fast-growing, product-focused startup in our [handbook](https://posthog.com/handbook/getting-started/start-here).

## Open-source vs. paid

This repo is available under the [MIT expat license](https://github.com/PostHog/posthog/blob/master/LICENSE), except for the `ee` directory (which has it's [license here](https://github.com/PostHog/posthog/blob/master/ee/LICENSE)) if applicable.
This repo is available under the [MIT expat license](https://github.com/PostHog/posthog/blob/master/LICENSE), except for the `ee` directory (which has its [license here](https://github.com/PostHog/posthog/blob/master/ee/LICENSE)) if applicable.

Need *absolutely 💯% FOSS*? Check out our [posthog-foss](https://github.com/PostHog/posthog-foss) repository, which is purged of all proprietary code and features.

Expand Down
9 changes: 6 additions & 3 deletions cypress/e2e/billing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ describe('Billing', () => {

cy.get('[data-attr=more-button]').first().click()
cy.contains('.LemonButton', 'Unsubscribe').click()
cy.get('.LemonModal h3').should('contain', 'Why are you unsubscribing from Product analytics?')
cy.get('.LemonModal h3').should('contain', 'Unsubscribe from Product analytics')
cy.get('[data-attr=unsubscribe-reason-too-expensive]').click()
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Product analytics')
cy.contains('.LemonModal .LemonButton', 'Unsubscribe').click()

Expand All @@ -26,6 +27,8 @@ describe('Billing', () => {
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')
expect(matchingEvent.properties.$survey_reasons.length).to.equal(1)
expect(matchingEvent.properties.$survey_reasons[0]).to.equal('Too expensive')
})

cy.get('.LemonModal').should('not.exist')
Expand All @@ -35,14 +38,14 @@ describe('Billing', () => {
it('Unsubscribe survey text area maintains unique state between product types', () => {
cy.get('[data-attr=more-button]').first().click()
cy.contains('.LemonButton', 'Unsubscribe').click()
cy.get('.LemonModal h3').should('contain', 'Why are you unsubscribing from Product analytics?')
cy.get('.LemonModal h3').should('contain', 'Unsubscribe from Product analytics')

cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Product analytics')
cy.contains('.LemonModal .LemonButton', 'Cancel').click()

cy.get('[data-attr=more-button]').eq(1).click()
cy.contains('.LemonButton', 'Unsubscribe').click()
cy.get('.LemonModal h3').should('contain', 'Why are you unsubscribing from Session replay?')
cy.get('.LemonModal h3').should('contain', 'Unsubscribe from Session replay')
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Session replay')
cy.contains('.LemonModal .LemonButton', 'Cancel').click()

Expand Down
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.
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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ import { LemonBanner } from 'lib/lemon-ui/LemonBanner'

import { versionCheckerLogic } from './versionCheckerLogic'

export function VersionCheckerBanner({ minVersionAccepted }: { minVersionAccepted?: string }): JSX.Element | null {
export function VersionCheckerBanner(): JSX.Element | null {
const { versionWarning } = useValues(versionCheckerLogic)
// We don't want to show a message if the diff is too small (we might be still deploying the changes out)
if (
!versionWarning ||
(minVersionAccepted && versionWarning.currentVersion
? versionWarning.currentVersion.localeCompare(minVersionAccepted) >= 0
: versionWarning.diff < 5)
) {
if (!versionWarning) {
return null
}

const dismissKey = `version-checker-${versionWarning.latestVersion}-${versionWarning.currentVersion}`
const dismissKey = `version-checker-${versionWarning.latestAvailableVersion}-${versionWarning.latestUsedVersion}`

return (
<LemonBanner
Expand All @@ -29,7 +23,8 @@ export function VersionCheckerBanner({ minVersionAccepted }: { minVersionAccepte
className="mb-4"
>
<b>Your PostHog SDK needs updating.</b> The latest version of <code>posthog-js</code> is{' '}
<b>{versionWarning.latestVersion}</b>, but you're using <b>{versionWarning.currentVersion}</b>. <br />
<b>{versionWarning.latestAvailableVersion}</b>, but you're using <b>{versionWarning.latestUsedVersion}</b>.{' '}
<br />
{versionWarning.level === 'error' ? (
<>
If something is not working as expected, try updating the SDK to the latest version where new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@ import { expectLogic } from 'kea-test-utils'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'

import { SDKVersion, versionCheckerLogic } from './versionCheckerLogic'
import { PosthogJSDeprecation, versionCheckerLogic } from './versionCheckerLogic'

const useMockedVersions = (githubVersions: SDKVersion[], usedVersions: SDKVersion[]): void => {
const useMockedVersions = (
githubVersions: { version: string }[],
usedVersions: { version: string; timestamp: string }[],
deprecateBeforeVersion: string
): void => {
useMocks({
get: {
'https://api.github.com/repos/posthog/posthog-js/tags': () => [
200,
githubVersions.map((x) => ({ name: x.version })),
],
'https://raw.githubusercontent.com/PostHog/posthog-js/main/deprecation.json': () => [
200,
{
deprecateBeforeVersion,
} as PosthogJSDeprecation,
],
},
post: {
'/api/projects/:team/query': () => [
Expand All @@ -29,7 +39,7 @@ describe('versionCheckerLogic', () => {
let logic: ReturnType<typeof versionCheckerLogic.build>

beforeEach(() => {
useMockedVersions([{ version: '1.0.0' }], [{ version: '1.0.0', timestamp: '2023-01-01T12:00:00Z' }])
useMockedVersions([{ version: '1.0.0' }], [{ version: '1.0.0', timestamp: '2023-01-01T12:00:00Z' }], '1.0.0')
initKeaTests()
localStorage.clear()
logic = versionCheckerLogic()
Expand All @@ -44,14 +54,13 @@ describe('versionCheckerLogic', () => {
await expectLogic(logic)
.toFinishAllListeners()
.toMatchValues({
availableVersions: [
{
version: '1.0.0',
},
],
availableVersions: {
sdkVersions: [{ major: 1, minor: 0, patch: 0 }],
deprecation: { deprecateBeforeVersion: '1.0.0' },
},
usedVersions: [
{
version: '1.0.0',
version: { major: 1, minor: 0, patch: 0 },
timestamp: '2023-01-01T12:00:00Z',
},
],
Expand All @@ -65,27 +74,27 @@ describe('versionCheckerLogic', () => {
{
versionCount: 10,
expectation: {
currentVersion: '1.0.0',
latestVersion: '1.0.9',
diff: 9,
latestUsedVersion: '1.0.0',
latestAvailableVersion: '1.0.9',
numVersionsBehind: 9,
level: 'info',
},
},
{
versionCount: 15,
expectation: {
currentVersion: '1.0.0',
latestVersion: '1.0.14',
diff: 14,
latestUsedVersion: '1.0.0',
latestAvailableVersion: '1.0.14',
numVersionsBehind: 14,
level: 'warning',
},
},
{
versionCount: 25,
expectation: {
currentVersion: '1.0.0',
latestVersion: '1.0.24',
diff: 24,
latestUsedVersion: '1.0.0',
latestAvailableVersion: '1.0.24',
numVersionsBehind: 24,
level: 'error',
},
},
Expand All @@ -95,12 +104,16 @@ describe('versionCheckerLogic', () => {
version: `1.0.${i}`,
})).reverse()

useMockedVersions(versionsList, [
{
version: '1.0.0',
timestamp: '2023-01-01T12:00:00Z',
},
])
useMockedVersions(
versionsList,
[
{
version: '1.0.0',
timestamp: '2023-01-01T12:00:00Z',
},
],
'1.0.0'
)

logic.mount()

Expand All @@ -115,10 +128,10 @@ describe('versionCheckerLogic', () => {
{ version: '1.83.1', timestamp: '2023-01-01T10:00:00Z' },
],
expectation: {
currentVersion: '1.83.1',
latestVersion: '1.84.0',
diff: 1,
latestAvailableVersion: '1.84.0',
latestUsedVersion: '1.83.1',
level: 'info',
numVersionsBehind: 1,
},
},
{
Expand All @@ -139,14 +152,38 @@ describe('versionCheckerLogic', () => {
{ version: '1.83.1-beta', timestamp: '2023-01-01T10:00:00Z' },
{ version: '1.84.0-delta', timestamp: '2023-01-01T08:00:00Z' },
],
expectation: { currentVersion: '1.84.0-delta', diff: 1, latestVersion: '1.84.0', level: 'info' },
expectation: {
latestUsedVersion: '1.84.0-delta',
numVersionsBehind: 1,
latestAvailableVersion: '1.84.0',
level: 'warning',
},
},
])('when having multiple versions used, should match with the latest one', async (options) => {
useMockedVersions([{ version: '1.84.0' }], options.usedVersions)
useMockedVersions([{ version: '1.84.0' }], options.usedVersions, '1.0.0')

logic.mount()

await expectLogic(logic).toFinishAllListeners()
expectLogic(logic).toMatchValues({ versionWarning: options.expectation })
})

it('should show an error if the current version is below the deprecation version', async () => {
useMockedVersions(
[{ version: '1.0.1' }, { version: '1.0.0' }],
[{ version: '1.0.0', timestamp: '2023-01-01T12:00:00Z' }],
'1.0.1'
)

logic.mount()

await expectLogic(logic).toFinishAllListeners()
expectLogic(logic).toMatchValues({
versionWarning: {
latestUsedVersion: '1.0.0',
latestAvailableVersion: '1.0.1',
level: 'error',
},
})
})
})
Loading

0 comments on commit f741a94

Please sign in to comment.