app-tutor-ai-consumer 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +2 -1
- package/src/config/optimizely/index.ts +1 -0
- package/src/config/optimizely/optimizely-provider.tsx +31 -0
- package/src/config/optimizely/optimizely.ts +9 -0
- package/src/lib/utils/constants.ts +2 -0
- package/src/main/main.tsx +11 -16
- package/src/modules/global-providers/global-providers.tsx +16 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# [1.2.0](https://github.com/Hotmart-Org/app-tutor-ai-consumer/compare/v1.1.0...v1.2.0) (2025-06-20)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- add Optimizely Config ([ad2162f](https://github.com/Hotmart-Org/app-tutor-ai-consumer/commit/ad2162f6e92b606cb72078d75a972067a8988e6f))
|
|
6
|
+
|
|
1
7
|
# [1.1.0](https://github.com/Hotmart-Org/app-tutor-ai-consumer/compare/v1.0.1...v1.1.0) (2025-06-18)
|
|
2
8
|
|
|
3
9
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "app-tutor-ai-consumer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "rspack serve --env=development --config config/rspack/rspack.config.js",
|
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
103
|
"@hot-observability-js/react": "~1.1.0",
|
|
104
|
+
"@optimizely/react-sdk": "~3.2.4",
|
|
104
105
|
"@tanstack/query-sync-storage-persister": "~5.80.7",
|
|
105
106
|
"@tanstack/react-query": "~5.80.6",
|
|
106
107
|
"@tanstack/react-query-persist-client": "~5.80.7",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as OptimizelyProvider } from './optimizely-provider'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { OptimizelyProvider as Provider } from '@optimizely/react-sdk'
|
|
2
|
+
import type { PropsWithChildren } from 'react'
|
|
3
|
+
|
|
4
|
+
import { APP_SYSTEM, APP_VERSION, productionMode } from '@/src/lib/utils'
|
|
5
|
+
import type { WidgetSettingProps } from '@/src/types'
|
|
6
|
+
|
|
7
|
+
import optimizelyClient from './optimizely'
|
|
8
|
+
|
|
9
|
+
function OptimizelyProvider({
|
|
10
|
+
settings,
|
|
11
|
+
children,
|
|
12
|
+
}: PropsWithChildren<{ settings: WidgetSettingProps }>) {
|
|
13
|
+
const userInfo = {
|
|
14
|
+
id: settings.user?.ucode ?? '',
|
|
15
|
+
attributes: {
|
|
16
|
+
appVersion: APP_VERSION,
|
|
17
|
+
appSystem: APP_SYSTEM,
|
|
18
|
+
appDebug: !productionMode,
|
|
19
|
+
locale: settings.locale ?? '',
|
|
20
|
+
slug: settings.membershipSlug ?? '',
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Provider optimizely={optimizelyClient} user={userInfo}>
|
|
26
|
+
{children}
|
|
27
|
+
</Provider>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default OptimizelyProvider
|
|
@@ -2,3 +2,5 @@ export const devMode = process.env.NODE_ENV === 'development'
|
|
|
2
2
|
export const productionMode = process.env.NODE_ENV === 'production'
|
|
3
3
|
export const RELEASE_FULL_NAME = `${process.env.RELEASE_FULL_NAME}_${process.env.NODE_ENV}`
|
|
4
4
|
export const DEFAULT_STALE_TIME = 1000 * 60 * 30 // 30 minutes
|
|
5
|
+
export const APP_VERSION = process.env.PROJECT_VERSION ?? ''
|
|
6
|
+
export const APP_SYSTEM = 'Web'
|
package/src/main/main.tsx
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import '@/config/styles/index.css'
|
|
2
2
|
|
|
3
|
-
import { useEffect } from 'react'
|
|
4
3
|
import clsx from 'clsx'
|
|
5
4
|
|
|
5
|
+
import { ErrorBoundary, GenericError } from '@/src/lib/components/errors'
|
|
6
6
|
import { useDefaultId } from '@/src/lib/hooks'
|
|
7
7
|
import { useAppLang } from '../config/i18n'
|
|
8
8
|
import { ChatInput } from '../modules/create-message/components'
|
|
9
9
|
import { GlobalProviders } from '../modules/global-providers'
|
|
10
|
-
import { useWidgetSettingsAtom } from '../modules/widget'
|
|
11
10
|
import { GreetingsCard } from '../modules/widget/components'
|
|
12
11
|
import type { WidgetSettingProps } from '../types'
|
|
13
12
|
|
|
@@ -16,23 +15,19 @@ import styles from './styles.module.css'
|
|
|
16
15
|
function Main({ settings }: { settings: WidgetSettingProps }) {
|
|
17
16
|
useDefaultId()
|
|
18
17
|
useAppLang(settings.locale)
|
|
19
|
-
const [, setWidgetSettings] = useWidgetSettingsAtom()
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (!settings || !Object.keys(settings)?.length) return
|
|
23
|
-
|
|
24
|
-
setWidgetSettings(settings)
|
|
25
|
-
}, [setWidgetSettings, settings])
|
|
26
18
|
|
|
27
19
|
return (
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
<div
|
|
31
|
-
|
|
32
|
-
<
|
|
20
|
+
<ErrorBoundary fallback={<GenericError />}>
|
|
21
|
+
<GlobalProviders settings={settings}>
|
|
22
|
+
<div
|
|
23
|
+
className={clsx('flex min-h-svh flex-col items-center justify-center p-5', styles.main)}>
|
|
24
|
+
<div className='flex flex-1 flex-col justify-center gap-6 lg:max-w-sm'>
|
|
25
|
+
<GreetingsCard author={settings.author ?? ''} tutorName={settings.tutorName ?? ''} />
|
|
26
|
+
<ChatInput name='new-chat-msg-input' />
|
|
27
|
+
</div>
|
|
33
28
|
</div>
|
|
34
|
-
</
|
|
35
|
-
</
|
|
29
|
+
</GlobalProviders>
|
|
30
|
+
</ErrorBoundary>
|
|
36
31
|
)
|
|
37
32
|
}
|
|
38
33
|
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PropsWithChildren, useEffect } from 'react'
|
|
2
2
|
|
|
3
|
+
import { OptimizelyProvider } from '@/src/config/optimizely'
|
|
3
4
|
import { QueryProvider } from '@/src/config/tanstack'
|
|
4
|
-
import {
|
|
5
|
+
import { useWidgetSettingsAtom } from '@/src/modules/widget'
|
|
6
|
+
import type { WidgetSettingProps } from '@/src/types'
|
|
5
7
|
|
|
6
|
-
export type GlobalProvidersProps = PropsWithChildren
|
|
8
|
+
export type GlobalProvidersProps = PropsWithChildren<{ settings: WidgetSettingProps }>
|
|
9
|
+
|
|
10
|
+
function GlobalProviders({ children, settings }: GlobalProvidersProps) {
|
|
11
|
+
const [, setWidgetSettings] = useWidgetSettingsAtom()
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!settings || !Object.keys(settings)?.length) return
|
|
15
|
+
|
|
16
|
+
setWidgetSettings(settings)
|
|
17
|
+
}, [setWidgetSettings, settings])
|
|
7
18
|
|
|
8
|
-
function GlobalProviders({ children }: GlobalProvidersProps) {
|
|
9
19
|
return (
|
|
10
|
-
<
|
|
20
|
+
<OptimizelyProvider settings={settings}>
|
|
11
21
|
<QueryProvider>{children}</QueryProvider>
|
|
12
|
-
</
|
|
22
|
+
</OptimizelyProvider>
|
|
13
23
|
)
|
|
14
24
|
}
|
|
15
25
|
|