Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app, app-shell, app-shell-odd): remove analytics modals and migrate analytics to default to on #15505

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions app-shell-odd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,6 @@ Random, persistent ID to use for anonymous analytics tracking if opted in.

Whether or not the user has opted into anonymous analytics tracking.

##### analytics.seenOptIn

- CLI argument: `--analytics.seenOptIn`
- Environment variable: `OT_APP_ANALYTICS__SEEN_OPT_IN`
- JSON path: `analytics.seenOptIn`
- Default: `false`

Whether or not the user has seen the initial analytics description pop-up.

##### support.userId

- CLI argument: `--support.userId`
Expand Down
10 changes: 10 additions & 0 deletions app-shell-odd/src/config/__fixtures__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
ConfigV19,
ConfigV20,
ConfigV21,
ConfigV22,
} from '@opentrons/app/src/redux/config/types'

const PKG_VERSION: string = _PKG_VERSION_
Expand Down Expand Up @@ -137,3 +138,12 @@ export const MOCK_CONFIG_V21: ConfigV21 = {
...MOCK_CONFIG_V20,
version: 21,
}

export const MOCK_CONFIG_V22: ConfigV22 = {
...MOCK_CONFIG_V21,
version: 22,
analytics: {
appId: MOCK_CONFIG_V21.analytics.appId,
optedIn: true,
},
}
36 changes: 22 additions & 14 deletions app-shell-odd/src/config/__tests__/migrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,88 +11,96 @@ import {
MOCK_CONFIG_V19,
MOCK_CONFIG_V20,
MOCK_CONFIG_V21,
MOCK_CONFIG_V22,
} from '../__fixtures__'
import { migrate } from '../migrate'

const NEWEST_VERSION = 21
const NEWEST_VERSION = 22

describe('config migration', () => {
it('should migrate version 12 to latest', () => {
const v12Config = MOCK_CONFIG_V12
const result = migrate(v12Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V21)
expect(result).toEqual(MOCK_CONFIG_V22)
})

it('should migrate version 13 to latest', () => {
const v13Config = MOCK_CONFIG_V13
const result = migrate(v13Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V21)
expect(result).toEqual(MOCK_CONFIG_V22)
})

it('should migrate version 14 to latest', () => {
const v14Config = MOCK_CONFIG_V14
const result = migrate(v14Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V21)
expect(result).toEqual(MOCK_CONFIG_V22)
})

it('should migrate version 15 to latest', () => {
const v15Config = MOCK_CONFIG_V15
const result = migrate(v15Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V21)
expect(result).toEqual(MOCK_CONFIG_V22)
})

it('should migrate version 16 to latest', () => {
const v16Config = MOCK_CONFIG_V16
const result = migrate(v16Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V21)
expect(result).toEqual(MOCK_CONFIG_V22)
})

it('should migrate version 17 to latest', () => {
const v17Config = MOCK_CONFIG_V17
const result = migrate(v17Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V21)
expect(result).toEqual(MOCK_CONFIG_V22)
})

it('should migration version 18 to latest', () => {
const v18Config = MOCK_CONFIG_V18
const result = migrate(v18Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V21)
expect(result).toEqual(MOCK_CONFIG_V22)
})

it('should migration version 19 to latest', () => {
const v19Config = MOCK_CONFIG_V19
const result = migrate(v19Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V21)
expect(result).toEqual(MOCK_CONFIG_V22)
})

it('should migration version 20 to latest', () => {
const v20Config = MOCK_CONFIG_V20
const result = migrate(v20Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V21)
expect(result).toEqual(MOCK_CONFIG_V22)
})
it('should keep version 21', () => {
const v21Config = MOCK_CONFIG_V21
const result = migrate(v21Config)
it('should migration version 21 to latest', () => {
const v20Config = MOCK_CONFIG_V21
const result = migrate(v20Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V22)
})
it('should keep version 22', () => {
const v22Config = MOCK_CONFIG_V22
const result = migrate(v22Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(v21Config)
expect(result).toEqual(v22Config)
})
})
18 changes: 17 additions & 1 deletion app-shell-odd/src/config/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
ConfigV19,
ConfigV20,
ConfigV21,
ConfigV22,
} from '@opentrons/app/src/redux/config/types'
// format
// base config v12 defaults
Expand Down Expand Up @@ -187,6 +188,18 @@ const toVersion21 = (prevConfig: ConfigV20): ConfigV21 => {
}
}

const toVersion22 = (prevConfig: ConfigV21): ConfigV22 => {
const nextConfig = {
...prevConfig,
version: 22 as const,
analytics: {
appId: prevConfig.analytics.appId,
optedIn: true,
},
}
return nextConfig
}

const MIGRATIONS: [
(prevConfig: ConfigV12) => ConfigV13,
(prevConfig: ConfigV13) => ConfigV14,
Expand All @@ -196,7 +209,8 @@ const MIGRATIONS: [
(prevConfig: ConfigV17) => ConfigV18,
(prevConfig: ConfigV18) => ConfigV19,
(prevConfig: ConfigV19) => ConfigV20,
(prevConfig: ConfigV20) => ConfigV21
(prevConfig: ConfigV20) => ConfigV21,
(prevConfig: ConfigV21) => ConfigV22
] = [
toVersion13,
toVersion14,
Expand All @@ -207,6 +221,7 @@ const MIGRATIONS: [
toVersion19,
toVersion20,
toVersion21,
toVersion22,
]

export const DEFAULTS: Config = migrate(DEFAULTS_V12)
Expand All @@ -223,6 +238,7 @@ export function migrate(
| ConfigV19
| ConfigV20
| ConfigV21
| ConfigV22
): Config {
let result = prevConfig
// loop through the migrations, skipping any migrations that are unnecessary
Expand Down
10 changes: 10 additions & 0 deletions app-shell/src/__fixtures__/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
ConfigV19,
ConfigV20,
ConfigV21,
ConfigV22,
} from '@opentrons/app/src/redux/config/types'

export const MOCK_CONFIG_V0: ConfigV0 = {
Expand Down Expand Up @@ -268,3 +269,12 @@ export const MOCK_CONFIG_V21: ConfigV21 = {
...MOCK_CONFIG_V20,
version: 21,
}

export const MOCK_CONFIG_V22: ConfigV22 = {
...MOCK_CONFIG_V21,
version: 22,
analytics: {
appId: MOCK_CONFIG_V21.analytics.appId,
optedIn: true,
},
}
Loading
Loading