app-tutor-ai-consumer 1.23.0 → 1.24.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 +1 -1
- package/src/config/datahub/actions.ts +8 -1
- package/src/config/datahub/constants.ts +8 -1
- package/src/config/datahub/schemas/base-click-product-schema.ts +51 -0
- package/src/config/datahub/schemas/base-close-schema.ts +52 -0
- package/src/config/datahub/schemas/base-product-schema.ts +37 -0
- package/src/config/datahub/schemas/base-schema.ts +0 -2
- package/src/config/datahub/schemas/constants.ts +5 -0
- package/src/config/datahub/schemas/tutor/__tests__/click-hotmart-tutor.spec.ts +0 -6
- package/src/config/datahub/schemas/tutor/__tests__/click-tutor-back.spec.ts +32 -0
- package/src/config/datahub/schemas/tutor/__tests__/click-tutor-history.spec.ts +32 -0
- package/src/config/datahub/schemas/tutor/__tests__/click-tutor-info.spec.ts +32 -0
- package/src/config/datahub/schemas/tutor/__tests__/click-tutor-know-more.spec.ts +32 -0
- package/src/config/datahub/schemas/tutor/__tests__/click-tutor-onboarding-start.spec.ts +32 -0
- package/src/config/datahub/schemas/tutor/__tests__/click-tutor-test-knowledge.spec.ts +32 -0
- package/src/config/datahub/schemas/tutor/__tests__/close-tutor-onboarding.spec.ts +32 -0
- package/src/config/datahub/schemas/tutor/click-tutor-back.ts +26 -0
- package/src/config/datahub/schemas/tutor/click-tutor-history.ts +26 -0
- package/src/config/datahub/schemas/tutor/click-tutor-info.ts +26 -0
- package/src/config/datahub/schemas/tutor/click-tutor-know-more.ts +26 -0
- package/src/config/datahub/schemas/tutor/click-tutor-minimize.ts +2 -2
- package/src/config/datahub/schemas/tutor/click-tutor-onboarding-start.ts +26 -0
- package/src/config/datahub/schemas/tutor/click-tutor-test-knowledge.ts +26 -0
- package/src/config/datahub/schemas/tutor/close-tutor-onboarding.ts +33 -0
- package/src/config/datahub/schemas/tutor/index.ts +7 -0
- package/src/config/datahub/schemas/types.ts +3 -1
- package/src/config/datahub/store.ts +24 -2
- package/src/config/datahub/types.ts +4 -0
- package/src/config/tests/handlers.ts +3 -0
- package/src/development-bootstrap.tsx +1 -1
- package/src/modules/widget/components/header/widget-header.tsx +14 -2
- package/src/modules/widget/components/quick-action-buttons/index.ts +2 -0
- package/src/modules/widget/components/quick-action-buttons/quick-action-buttons.tsx +74 -0
- package/src/modules/widget/components/starter-page/starter-page.tsx +8 -37
- package/src/modules/widget/hooks/use-init-widget/use-init-widget.tsx +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# [1.24.0](https://github.com/Hotmart-Org/app-tutor-ai-consumer/compare/v1.23.0...v1.24.0) (2025-08-11)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- add user actions on Tutor Datahub events ([e4281b1](https://github.com/Hotmart-Org/app-tutor-ai-consumer/commit/e4281b14a2b2158bfa6711a55cfaf926d2caa747))
|
|
6
|
+
|
|
1
7
|
# [1.23.0](https://github.com/Hotmart-Org/app-tutor-ai-consumer/compare/v1.22.3...v1.23.0) (2025-08-11)
|
|
2
8
|
|
|
3
9
|
### Features
|
package/package.json
CHANGED
|
@@ -12,5 +12,12 @@ export type DataHubActionTypes = (typeof DataHubActions)[keyof typeof DataHubAct
|
|
|
12
12
|
export const ActionNames = {
|
|
13
13
|
CLICK_HOTMART_TUTOR: `${DataHubActions.CLICK}_hotmart_tutor`,
|
|
14
14
|
CLICK_TUTOR_MINIMIZE: `${DataHubActions.CLICK}_tutor_minimize`,
|
|
15
|
-
TRY_PRODUCT_TUTOR: `${DataHubActions.TRY}_product_tutor
|
|
15
|
+
TRY_PRODUCT_TUTOR: `${DataHubActions.TRY}_product_tutor`,
|
|
16
|
+
CLICK_TUTOR_BACK: `${DataHubActions.CLICK}_tutor_back`,
|
|
17
|
+
CLICK_TUTOR_HISTORY: `${DataHubActions.CLICK}_tutor_history`,
|
|
18
|
+
CLICK_TUTOR_INFO: `${DataHubActions.CLICK}_tutor_info`,
|
|
19
|
+
CLICK_TUTOR_KNOW_MORE: `${DataHubActions.CLICK}_tutor_know_more`,
|
|
20
|
+
CLICK_TUTOR_ONBOARDING_START: `${DataHubActions.CLICK}_tutor_onboarding_start`,
|
|
21
|
+
CLICK_TUTOR_TEST_KNOWLEDGE: `${DataHubActions.CLICK}_tutor_test_knowledge`,
|
|
22
|
+
CLOSE_TUTOR_ONBOARDING: `${DataHubActions.CLOSE}_tutor_onboarding`
|
|
16
23
|
} as const
|
|
@@ -24,7 +24,14 @@ export const Result = {
|
|
|
24
24
|
export const ComponentNames = {
|
|
25
25
|
BUTTON_LIKE_ANSWER: 'BUTTON_LIKE_ANSWER',
|
|
26
26
|
BUTTON_DISLIKE_ANSWER: 'BUTTON_DISLIKE_ANSWER',
|
|
27
|
-
BUTTON_CLOSE_TUTOR_CHAT: 'BUTTON_CLOSE_TUTOR_CHAT'
|
|
27
|
+
BUTTON_CLOSE_TUTOR_CHAT: 'BUTTON_CLOSE_TUTOR_CHAT',
|
|
28
|
+
PRODUCT_CONSUME_CLICK_TUTOR_BACK: 'product_consume_click_tutor_back',
|
|
29
|
+
PRODUCT_CONSUME_CLICK_TUTOR_HISTORY: 'product_consume_click_tutor_history',
|
|
30
|
+
PRODUCT_CONSUME_CLICK_TUTOR_INFO: 'product_consume_click_tutor_info',
|
|
31
|
+
PRODUCT_CONSUME_CLICK_TUTOR_KNOW_MORE: 'product_consume_click_tutor_know_more',
|
|
32
|
+
PRODUCT_CONSUME_CLICK_TUTOR_ONBOARDING_START: 'product_consume_click_tutor_onboarding_start',
|
|
33
|
+
PRODUCT_CONSUME_CLICK_TUTOR_TEST_KNOWLEDGE: 'product_consume_click_tutor_test_knowledge',
|
|
34
|
+
PRODUCT_CONSUME_CLOSE_TUTOR_ONBOARDING: 'product_consume_close_tutor_onboarding'
|
|
28
35
|
} as const
|
|
29
36
|
|
|
30
37
|
export const ComponentSource = {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ScreenNames } from '../constants'
|
|
2
|
+
import { DataHubEntities } from '../entities'
|
|
3
|
+
import type { ComponentNamesType, DataHubEntityTypes, ScreenNamesType } from '../types'
|
|
4
|
+
|
|
5
|
+
import BaseProductSchema from './base-product-schema'
|
|
6
|
+
import { ProductCategories } from './constants'
|
|
7
|
+
import type { ProductCategoriesType } from './types'
|
|
8
|
+
|
|
9
|
+
export type ConstructorArgs = {
|
|
10
|
+
componentName: ComponentNamesType
|
|
11
|
+
entity?: DataHubEntityTypes
|
|
12
|
+
isLogged?: boolean
|
|
13
|
+
screenName?: ScreenNamesType
|
|
14
|
+
productType?: ProductCategoriesType
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
abstract class BaseClickProductSchema extends BaseProductSchema {
|
|
18
|
+
protected componentName: ComponentNamesType
|
|
19
|
+
protected screenName: ScreenNamesType
|
|
20
|
+
|
|
21
|
+
entity: DataHubEntityTypes
|
|
22
|
+
isLogged: boolean
|
|
23
|
+
|
|
24
|
+
constructor(args: ConstructorArgs) {
|
|
25
|
+
const {
|
|
26
|
+
componentName,
|
|
27
|
+
entity = DataHubEntities.HOME,
|
|
28
|
+
isLogged = true,
|
|
29
|
+
screenName = ScreenNames.HOME_CONSUMER,
|
|
30
|
+
productType = ProductCategories.OnlineServices
|
|
31
|
+
} = args
|
|
32
|
+
|
|
33
|
+
super({ productType })
|
|
34
|
+
|
|
35
|
+
this.componentName = componentName
|
|
36
|
+
this.entity = entity
|
|
37
|
+
this.isLogged = isLogged
|
|
38
|
+
this.screenName = screenName
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
prepare() {
|
|
42
|
+
return {
|
|
43
|
+
...super.prepare(),
|
|
44
|
+
componentName: this.componentName,
|
|
45
|
+
isLogged: this.isLogged,
|
|
46
|
+
screenName: this.screenName
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default BaseClickProductSchema
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DataHubStore } from '..'
|
|
2
|
+
import { ScreenNames } from '../constants'
|
|
3
|
+
import { DataHubEntities } from '../entities'
|
|
4
|
+
import type { ComponentNamesType, DataHubEntityTypes, ScreenNamesType } from '../types'
|
|
5
|
+
|
|
6
|
+
import BaseSchema from './base-schema'
|
|
7
|
+
|
|
8
|
+
export type BaseCloseSchemaConstructorProps = {
|
|
9
|
+
componentName: ComponentNamesType
|
|
10
|
+
entity?: DataHubEntityTypes
|
|
11
|
+
isLogged?: boolean
|
|
12
|
+
screenName?: ScreenNamesType
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
abstract class BaseCloseSchema extends BaseSchema {
|
|
16
|
+
protected componentName: ComponentNamesType
|
|
17
|
+
protected screenName: ScreenNamesType
|
|
18
|
+
|
|
19
|
+
entity: DataHubEntityTypes
|
|
20
|
+
isLogged: boolean
|
|
21
|
+
|
|
22
|
+
constructor(args: BaseCloseSchemaConstructorProps) {
|
|
23
|
+
const {
|
|
24
|
+
componentName,
|
|
25
|
+
entity = DataHubEntities.HOME,
|
|
26
|
+
isLogged = true,
|
|
27
|
+
screenName = ScreenNames.HOME_CONSUMER
|
|
28
|
+
} = args
|
|
29
|
+
|
|
30
|
+
super()
|
|
31
|
+
|
|
32
|
+
this.componentName = componentName
|
|
33
|
+
this.entity = entity
|
|
34
|
+
this.isLogged = isLogged
|
|
35
|
+
this.screenName = screenName
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
prepare() {
|
|
39
|
+
return {
|
|
40
|
+
...super.prepare(),
|
|
41
|
+
componentName: this.componentName,
|
|
42
|
+
connectionStatus: 'ONLINE',
|
|
43
|
+
entity: this.entity,
|
|
44
|
+
isLogged: this.isLogged,
|
|
45
|
+
productCategory: DataHubStore.product.category,
|
|
46
|
+
productId: DataHubStore.product.id,
|
|
47
|
+
screenName: this.screenName
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default BaseCloseSchema
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DataHubStore } from '..'
|
|
2
|
+
|
|
3
|
+
import BaseSchema from './base-schema'
|
|
4
|
+
import type { ProductCategoriesType } from './types'
|
|
5
|
+
|
|
6
|
+
type ConstructorArgs = {
|
|
7
|
+
productType?: ProductCategoriesType
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
abstract class BaseProductSchema extends BaseSchema {
|
|
11
|
+
private productId: number
|
|
12
|
+
private productCategory: ProductCategoriesType
|
|
13
|
+
private connectionStatus: 'ONLINE' | 'OFFLINE'
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
{ productType = DataHubStore.product.category as ProductCategoriesType }: ConstructorArgs = {
|
|
17
|
+
productType: DataHubStore.product.category as ProductCategoriesType
|
|
18
|
+
}
|
|
19
|
+
) {
|
|
20
|
+
super()
|
|
21
|
+
|
|
22
|
+
this.productId = DataHubStore.product.id
|
|
23
|
+
this.productCategory = productType
|
|
24
|
+
this.connectionStatus = 'ONLINE'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
prepare() {
|
|
28
|
+
return {
|
|
29
|
+
...super.prepare(),
|
|
30
|
+
productId: this.productId,
|
|
31
|
+
productCategory: this.productCategory,
|
|
32
|
+
connectionStatus: this.connectionStatus
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default BaseProductSchema
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { chance } from '@/src/config/tests'
|
|
2
2
|
import { DataHubStore } from '../../..'
|
|
3
|
-
import { ActionNames } from '../../../actions'
|
|
4
3
|
import { ComponentNames, ScreenNames } from '../../../constants'
|
|
5
|
-
import { DataHubEntities } from '../../../entities'
|
|
6
4
|
import { UserRole } from '../../constants'
|
|
7
5
|
import ClickHotmartTutor from '../click-hotmart-tutor'
|
|
8
6
|
import { ButtonReactions } from '../constants'
|
|
@@ -17,11 +15,9 @@ describe('ClickHotmartTutor', () => {
|
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
expect(new ClickHotmartTutor(event).getDataHubEventData()).toMatchObject({
|
|
20
|
-
action: ActionNames.CLICK_HOTMART_TUTOR,
|
|
21
18
|
appVersion: '',
|
|
22
19
|
clubVersion: 'MEMBERSHIP',
|
|
23
20
|
componentName: ComponentNames.BUTTON_DISLIKE_ANSWER,
|
|
24
|
-
entity: DataHubEntities.HOME,
|
|
25
21
|
hasAccess: event.hasAccess,
|
|
26
22
|
isLogged: event.isLogged,
|
|
27
23
|
membershipId: 'UNDEFINED',
|
|
@@ -58,11 +54,9 @@ describe('ClickHotmartTutor', () => {
|
|
|
58
54
|
DataHubStore.initData(store)
|
|
59
55
|
|
|
60
56
|
expect(new ClickHotmartTutor(event).getDataHubEventData()).toMatchObject({
|
|
61
|
-
action: ActionNames.CLICK_HOTMART_TUTOR,
|
|
62
57
|
appVersion: '',
|
|
63
58
|
clubVersion: 'MEMBERSHIP',
|
|
64
59
|
componentName: ComponentNames.BUTTON_LIKE_ANSWER,
|
|
65
|
-
entity: DataHubEntities.HOME,
|
|
66
60
|
hasAccess: event.hasAccess,
|
|
67
61
|
isLogged: event.isLogged,
|
|
68
62
|
membershipId: store.membershipId,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActionNames } from '../../../actions'
|
|
2
|
+
import { ComponentNames, ScreenNames } from '../../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../../entities'
|
|
4
|
+
import { ProductCategories, UserRole } from '../..'
|
|
5
|
+
import ClickTutorBackSchema from '../click-tutor-back'
|
|
6
|
+
|
|
7
|
+
describe('ClickTutorBackSchema', () => {
|
|
8
|
+
it('should return the event correct data', () => {
|
|
9
|
+
expect(new ClickTutorBackSchema()).toMatchObject({
|
|
10
|
+
action: ActionNames.CLICK_TUTOR_BACK,
|
|
11
|
+
appVersion: '',
|
|
12
|
+
clubVersion: 'MEMBERSHIP',
|
|
13
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_BACK,
|
|
14
|
+
entity: DataHubEntities.PRODUCT_CONSUME,
|
|
15
|
+
isLogged: true,
|
|
16
|
+
membershipId: 'UNDEFINED',
|
|
17
|
+
membershipSlug: 'UNDEFINED',
|
|
18
|
+
osVersion: '537.36',
|
|
19
|
+
platform: 'WEB',
|
|
20
|
+
platformDetail: 'WebKit',
|
|
21
|
+
screenName: ScreenNames.HOME_CONSUMER,
|
|
22
|
+
sessionId: 'UNDEFINED',
|
|
23
|
+
ucode: 'UNDEFINED',
|
|
24
|
+
url: 'http://localhost:3000/',
|
|
25
|
+
userId: 0,
|
|
26
|
+
userRole: UserRole.CONSUMER,
|
|
27
|
+
productId: 0,
|
|
28
|
+
productCategory: ProductCategories.OnlineServices,
|
|
29
|
+
connectionStatus: 'ONLINE'
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActionNames } from '../../../actions'
|
|
2
|
+
import { ComponentNames, ScreenNames } from '../../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../../entities'
|
|
4
|
+
import { ProductCategories, UserRole } from '../../constants'
|
|
5
|
+
import ClickTutorHistorySchema from '../click-tutor-history'
|
|
6
|
+
|
|
7
|
+
describe('ClickTutorHistorySchema', () => {
|
|
8
|
+
it('should return the event correct data', () => {
|
|
9
|
+
expect(new ClickTutorHistorySchema()).toMatchObject({
|
|
10
|
+
action: ActionNames.CLICK_TUTOR_HISTORY,
|
|
11
|
+
appVersion: '',
|
|
12
|
+
clubVersion: 'MEMBERSHIP',
|
|
13
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_HISTORY,
|
|
14
|
+
entity: DataHubEntities.PRODUCT_CONSUME,
|
|
15
|
+
isLogged: true,
|
|
16
|
+
membershipId: 'UNDEFINED',
|
|
17
|
+
membershipSlug: 'UNDEFINED',
|
|
18
|
+
osVersion: '537.36',
|
|
19
|
+
platform: 'WEB',
|
|
20
|
+
platformDetail: 'WebKit',
|
|
21
|
+
screenName: ScreenNames.HOME_CONSUMER,
|
|
22
|
+
sessionId: 'UNDEFINED',
|
|
23
|
+
ucode: 'UNDEFINED',
|
|
24
|
+
url: 'http://localhost:3000/',
|
|
25
|
+
userId: 0,
|
|
26
|
+
userRole: UserRole.CONSUMER,
|
|
27
|
+
productId: 0,
|
|
28
|
+
productCategory: ProductCategories.OnlineServices,
|
|
29
|
+
connectionStatus: 'ONLINE'
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActionNames } from '../../../actions'
|
|
2
|
+
import { ComponentNames, ScreenNames } from '../../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../../entities'
|
|
4
|
+
import { ProductCategories, UserRole } from '../../constants'
|
|
5
|
+
import ClickTutorInfoSchema from '../click-tutor-info'
|
|
6
|
+
|
|
7
|
+
describe('ClickTutorInfoSchema', () => {
|
|
8
|
+
it('should return the event correct data', () => {
|
|
9
|
+
expect(new ClickTutorInfoSchema()).toMatchObject({
|
|
10
|
+
action: ActionNames.CLICK_TUTOR_INFO,
|
|
11
|
+
appVersion: '',
|
|
12
|
+
clubVersion: 'MEMBERSHIP',
|
|
13
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_INFO,
|
|
14
|
+
entity: DataHubEntities.PRODUCT_CONSUME,
|
|
15
|
+
isLogged: true,
|
|
16
|
+
membershipId: 'UNDEFINED',
|
|
17
|
+
membershipSlug: 'UNDEFINED',
|
|
18
|
+
osVersion: '537.36',
|
|
19
|
+
platform: 'WEB',
|
|
20
|
+
platformDetail: 'WebKit',
|
|
21
|
+
screenName: ScreenNames.HOME_CONSUMER,
|
|
22
|
+
sessionId: 'UNDEFINED',
|
|
23
|
+
ucode: 'UNDEFINED',
|
|
24
|
+
url: 'http://localhost:3000/',
|
|
25
|
+
userId: 0,
|
|
26
|
+
userRole: UserRole.CONSUMER,
|
|
27
|
+
productId: 0,
|
|
28
|
+
productCategory: ProductCategories.OnlineServices,
|
|
29
|
+
connectionStatus: 'ONLINE'
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActionNames } from '../../../actions'
|
|
2
|
+
import { ComponentNames, ScreenNames } from '../../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../../entities'
|
|
4
|
+
import { ProductCategories, UserRole } from '../../constants'
|
|
5
|
+
import ClickTutorKnowMoreSchema from '../click-tutor-know-more'
|
|
6
|
+
|
|
7
|
+
describe('ClickTutorKnowMoreSchema', () => {
|
|
8
|
+
it('should return the event correct data', () => {
|
|
9
|
+
expect(new ClickTutorKnowMoreSchema()).toMatchObject({
|
|
10
|
+
action: ActionNames.CLICK_TUTOR_KNOW_MORE,
|
|
11
|
+
appVersion: '',
|
|
12
|
+
clubVersion: 'MEMBERSHIP',
|
|
13
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_KNOW_MORE,
|
|
14
|
+
entity: DataHubEntities.PRODUCT_CONSUME,
|
|
15
|
+
isLogged: true,
|
|
16
|
+
membershipId: 'UNDEFINED',
|
|
17
|
+
membershipSlug: 'UNDEFINED',
|
|
18
|
+
osVersion: '537.36',
|
|
19
|
+
platform: 'WEB',
|
|
20
|
+
platformDetail: 'WebKit',
|
|
21
|
+
screenName: ScreenNames.HOME_CONSUMER,
|
|
22
|
+
sessionId: 'UNDEFINED',
|
|
23
|
+
ucode: 'UNDEFINED',
|
|
24
|
+
url: 'http://localhost:3000/',
|
|
25
|
+
userId: 0,
|
|
26
|
+
userRole: UserRole.CONSUMER,
|
|
27
|
+
productId: 0,
|
|
28
|
+
productCategory: ProductCategories.OnlineServices,
|
|
29
|
+
connectionStatus: 'ONLINE'
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActionNames } from '../../../actions'
|
|
2
|
+
import { ComponentNames, ScreenNames } from '../../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../../entities'
|
|
4
|
+
import { ProductCategories, UserRole } from '../../constants'
|
|
5
|
+
import ClickTutorOnboardingStartSchema from '../click-tutor-onboarding-start'
|
|
6
|
+
|
|
7
|
+
describe('ClickTutorOnboardingStartSchema', () => {
|
|
8
|
+
it('should return the event correct data', () => {
|
|
9
|
+
expect(new ClickTutorOnboardingStartSchema()).toMatchObject({
|
|
10
|
+
action: ActionNames.CLICK_TUTOR_ONBOARDING_START,
|
|
11
|
+
appVersion: '',
|
|
12
|
+
clubVersion: 'MEMBERSHIP',
|
|
13
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_ONBOARDING_START,
|
|
14
|
+
entity: DataHubEntities.PRODUCT_CONSUME,
|
|
15
|
+
isLogged: true,
|
|
16
|
+
membershipId: 'UNDEFINED',
|
|
17
|
+
membershipSlug: 'UNDEFINED',
|
|
18
|
+
osVersion: '537.36',
|
|
19
|
+
platform: 'WEB',
|
|
20
|
+
platformDetail: 'WebKit',
|
|
21
|
+
screenName: ScreenNames.HOME_CONSUMER,
|
|
22
|
+
sessionId: 'UNDEFINED',
|
|
23
|
+
ucode: 'UNDEFINED',
|
|
24
|
+
url: 'http://localhost:3000/',
|
|
25
|
+
userId: 0,
|
|
26
|
+
userRole: UserRole.CONSUMER,
|
|
27
|
+
productId: 0,
|
|
28
|
+
productCategory: ProductCategories.OnlineServices,
|
|
29
|
+
connectionStatus: 'ONLINE'
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActionNames } from '../../../actions'
|
|
2
|
+
import { ComponentNames, ScreenNames } from '../../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../../entities'
|
|
4
|
+
import { ProductCategories, UserRole } from '../../constants'
|
|
5
|
+
import ClickTutorTestKnowledgeSchema from '../click-tutor-test-knowledge'
|
|
6
|
+
|
|
7
|
+
describe('ClickTutorTestKnowledgeSchema', () => {
|
|
8
|
+
it('should return the event correct data', () => {
|
|
9
|
+
expect(new ClickTutorTestKnowledgeSchema()).toMatchObject({
|
|
10
|
+
action: ActionNames.CLICK_TUTOR_TEST_KNOWLEDGE,
|
|
11
|
+
appVersion: '',
|
|
12
|
+
clubVersion: 'MEMBERSHIP',
|
|
13
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_TEST_KNOWLEDGE,
|
|
14
|
+
entity: DataHubEntities.PRODUCT_CONSUME,
|
|
15
|
+
isLogged: true,
|
|
16
|
+
membershipId: 'UNDEFINED',
|
|
17
|
+
membershipSlug: 'UNDEFINED',
|
|
18
|
+
osVersion: '537.36',
|
|
19
|
+
platform: 'WEB',
|
|
20
|
+
platformDetail: 'WebKit',
|
|
21
|
+
screenName: ScreenNames.HOME_CONSUMER,
|
|
22
|
+
sessionId: 'UNDEFINED',
|
|
23
|
+
ucode: 'UNDEFINED',
|
|
24
|
+
url: 'http://localhost:3000/',
|
|
25
|
+
userId: 0,
|
|
26
|
+
userRole: UserRole.CONSUMER,
|
|
27
|
+
productId: 0,
|
|
28
|
+
productCategory: ProductCategories.OnlineServices,
|
|
29
|
+
connectionStatus: 'ONLINE'
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActionNames } from '../../../actions'
|
|
2
|
+
import { ComponentNames, ScreenNames } from '../../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../../entities'
|
|
4
|
+
import { ProductCategories, UserRole } from '../../constants'
|
|
5
|
+
import CloseTutorOnboardingSchema from '../close-tutor-onboarding'
|
|
6
|
+
|
|
7
|
+
describe('CloseTutorOnboardingSchema', () => {
|
|
8
|
+
it('should return the event correct data', () => {
|
|
9
|
+
expect(new CloseTutorOnboardingSchema()).toMatchObject({
|
|
10
|
+
action: ActionNames.CLOSE_TUTOR_ONBOARDING,
|
|
11
|
+
appVersion: '',
|
|
12
|
+
clubVersion: 'MEMBERSHIP',
|
|
13
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLOSE_TUTOR_ONBOARDING,
|
|
14
|
+
entity: DataHubEntities.PRODUCT_CONSUME,
|
|
15
|
+
isLogged: true,
|
|
16
|
+
membershipId: 'UNDEFINED',
|
|
17
|
+
membershipSlug: 'UNDEFINED',
|
|
18
|
+
osVersion: '537.36',
|
|
19
|
+
platform: 'WEB',
|
|
20
|
+
platformDetail: 'WebKit',
|
|
21
|
+
screenName: ScreenNames.HOME_CONSUMER,
|
|
22
|
+
sessionId: 'UNDEFINED',
|
|
23
|
+
ucode: 'UNDEFINED',
|
|
24
|
+
url: 'http://localhost:3000/',
|
|
25
|
+
userId: 0,
|
|
26
|
+
userRole: UserRole.CONSUMER,
|
|
27
|
+
productId: 0,
|
|
28
|
+
productCategory: ProductCategories.OnlineServices,
|
|
29
|
+
connectionStatus: 'ONLINE'
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActionNames } from '../../actions'
|
|
2
|
+
import { ComponentNames } from '../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../entities'
|
|
4
|
+
import type { ActionNamesType } from '../../types'
|
|
5
|
+
import BaseClickProductSchema from '../base-click-product-schema'
|
|
6
|
+
|
|
7
|
+
class ClickTutorBackSchema extends BaseClickProductSchema {
|
|
8
|
+
action: ActionNamesType
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_BACK
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
this.action = ActionNames.CLICK_TUTOR_BACK
|
|
16
|
+
this.entity = DataHubEntities.PRODUCT_CONSUME
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getDataHubEventData(): Record<string, unknown> {
|
|
20
|
+
return {
|
|
21
|
+
...super.prepare()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default ClickTutorBackSchema
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActionNames } from '../../actions'
|
|
2
|
+
import { ComponentNames } from '../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../entities'
|
|
4
|
+
import type { ActionNamesType } from '../../types'
|
|
5
|
+
import BaseClickProductSchema from '../base-click-product-schema'
|
|
6
|
+
|
|
7
|
+
class ClickTutorHistorySchema extends BaseClickProductSchema {
|
|
8
|
+
action: ActionNamesType
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_HISTORY
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
this.action = ActionNames.CLICK_TUTOR_HISTORY
|
|
16
|
+
this.entity = DataHubEntities.PRODUCT_CONSUME
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getDataHubEventData(): Record<string, unknown> {
|
|
20
|
+
return {
|
|
21
|
+
...super.prepare()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default ClickTutorHistorySchema
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActionNames } from '../../actions'
|
|
2
|
+
import { ComponentNames } from '../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../entities'
|
|
4
|
+
import type { ActionNamesType } from '../../types'
|
|
5
|
+
import BaseClickProductSchema from '../base-click-product-schema'
|
|
6
|
+
|
|
7
|
+
class ClickTutorInfoSchema extends BaseClickProductSchema {
|
|
8
|
+
action: ActionNamesType
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_INFO
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
this.action = ActionNames.CLICK_TUTOR_INFO
|
|
16
|
+
this.entity = DataHubEntities.PRODUCT_CONSUME
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getDataHubEventData(): Record<string, unknown> {
|
|
20
|
+
return {
|
|
21
|
+
...super.prepare()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default ClickTutorInfoSchema
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActionNames } from '../../actions'
|
|
2
|
+
import { ComponentNames } from '../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../entities'
|
|
4
|
+
import type { ActionNamesType } from '../../types'
|
|
5
|
+
import BaseClickProductSchema from '../base-click-product-schema'
|
|
6
|
+
|
|
7
|
+
class ClickTutorKnowMoreSchema extends BaseClickProductSchema {
|
|
8
|
+
action: ActionNamesType
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_KNOW_MORE
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
this.action = ActionNames.CLICK_TUTOR_KNOW_MORE
|
|
16
|
+
this.entity = DataHubEntities.PRODUCT_CONSUME
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getDataHubEventData(): Record<string, unknown> {
|
|
20
|
+
return {
|
|
21
|
+
...super.prepare()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default ClickTutorKnowMoreSchema
|
|
@@ -2,9 +2,9 @@ import { ActionNames } from '../../actions'
|
|
|
2
2
|
import { ComponentNames } from '../../constants'
|
|
3
3
|
import { DataHubEntities } from '../../entities'
|
|
4
4
|
import type { ActionNamesType } from '../../types'
|
|
5
|
-
import
|
|
5
|
+
import BaseClickProductSchema from '../base-click-product-schema'
|
|
6
6
|
|
|
7
|
-
class ClickTutorMinimizeSchema extends
|
|
7
|
+
class ClickTutorMinimizeSchema extends BaseClickProductSchema {
|
|
8
8
|
action: ActionNamesType
|
|
9
9
|
|
|
10
10
|
constructor() {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActionNames } from '../../actions'
|
|
2
|
+
import { ComponentNames } from '../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../entities'
|
|
4
|
+
import type { ActionNamesType } from '../../types'
|
|
5
|
+
import BaseClickProductSchema from '../base-click-product-schema'
|
|
6
|
+
|
|
7
|
+
class ClickTutorOnboardingStartSchema extends BaseClickProductSchema {
|
|
8
|
+
action: ActionNamesType
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_ONBOARDING_START
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
this.action = ActionNames.CLICK_TUTOR_ONBOARDING_START
|
|
16
|
+
this.entity = DataHubEntities.PRODUCT_CONSUME
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getDataHubEventData(): Record<string, unknown> {
|
|
20
|
+
return {
|
|
21
|
+
...super.prepare()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default ClickTutorOnboardingStartSchema
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActionNames } from '../../actions'
|
|
2
|
+
import { ComponentNames } from '../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../entities'
|
|
4
|
+
import type { ActionNamesType } from '../../types'
|
|
5
|
+
import BaseClickProductSchema from '../base-click-product-schema'
|
|
6
|
+
|
|
7
|
+
class ClickTutorTestKnowledgeSchema extends BaseClickProductSchema {
|
|
8
|
+
action: ActionNamesType
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLICK_TUTOR_TEST_KNOWLEDGE
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
this.action = ActionNames.CLICK_TUTOR_TEST_KNOWLEDGE
|
|
16
|
+
this.entity = DataHubEntities.PRODUCT_CONSUME
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getDataHubEventData(): Record<string, unknown> {
|
|
20
|
+
return {
|
|
21
|
+
...super.prepare()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default ClickTutorTestKnowledgeSchema
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ActionNames } from '../../actions'
|
|
2
|
+
import { ComponentNames, ScreenNames } from '../../constants'
|
|
3
|
+
import { DataHubEntities } from '../../entities'
|
|
4
|
+
import type { ActionNamesType } from '../../types'
|
|
5
|
+
import BaseClickProductSchema from '../base-click-product-schema'
|
|
6
|
+
|
|
7
|
+
class CloseTutorOnboardingSchema extends BaseClickProductSchema {
|
|
8
|
+
action: ActionNamesType
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
{ componentName, screenName, entity } = {
|
|
12
|
+
componentName: ComponentNames.PRODUCT_CONSUME_CLOSE_TUTOR_ONBOARDING,
|
|
13
|
+
screenName: ScreenNames.HOME_CONSUMER,
|
|
14
|
+
entity: DataHubEntities.PRODUCT_CONSUME
|
|
15
|
+
}
|
|
16
|
+
) {
|
|
17
|
+
super({
|
|
18
|
+
componentName,
|
|
19
|
+
screenName,
|
|
20
|
+
entity
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
this.action = ActionNames.CLOSE_TUTOR_ONBOARDING
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getDataHubEventData(): Record<string, unknown> {
|
|
27
|
+
return {
|
|
28
|
+
...this.prepare()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default CloseTutorOnboardingSchema
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export { default as ClickHotmartTutor } from './click-hotmart-tutor'
|
|
2
|
+
export { default as ClickTutorBackSchema } from './click-tutor-back'
|
|
3
|
+
export { default as ClickTutorHistorySchema } from './click-tutor-history'
|
|
4
|
+
export { default as ClickTutorInfoSchema } from './click-tutor-info'
|
|
5
|
+
export { default as ClickTutorKnowMoreSchema } from './click-tutor-know-more'
|
|
2
6
|
export { default as ClickTutorMinimizeSchema } from './click-tutor-minimize'
|
|
7
|
+
export { default as ClickTutorOnboardingStartSchema } from './click-tutor-onboarding-start'
|
|
8
|
+
export { default as ClickTutorTestKnowledgeSchema } from './click-tutor-test-knowledge'
|
|
9
|
+
export { default as CloseTutorOnboardingSchema } from './close-tutor-onboarding'
|
|
3
10
|
export * from './constants'
|
|
4
11
|
export * from './types'
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { ClubVersion, UserRole } from './constants'
|
|
1
|
+
import type { ClubVersion, ProductCategories, UserRole } from './constants'
|
|
2
2
|
|
|
3
3
|
export type UserRoleType = (typeof UserRole)[keyof typeof UserRole]
|
|
4
4
|
|
|
5
5
|
export type ClubVersionType = (typeof ClubVersion)[keyof typeof ClubVersion]
|
|
6
6
|
|
|
7
|
+
export type ProductCategoriesType = (typeof ProductCategories)[keyof typeof ProductCategories]
|
|
8
|
+
|
|
7
9
|
export type SchemaBasedProps = {
|
|
8
10
|
membershipSlug?: string
|
|
9
11
|
membershipId?: string
|
|
@@ -2,6 +2,11 @@ import { UAParser } from 'ua-parser-js'
|
|
|
2
2
|
|
|
3
3
|
import type { InitDataParams } from './types'
|
|
4
4
|
|
|
5
|
+
const defaultProduct = {
|
|
6
|
+
id: 0,
|
|
7
|
+
category: 'unknown'
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
class DataHubStore {
|
|
6
11
|
private instanceObj?: {
|
|
7
12
|
userAgentParser: UAParser.IResult
|
|
@@ -14,13 +19,24 @@ class DataHubStore {
|
|
|
14
19
|
userId: number
|
|
15
20
|
membershipSlug: string
|
|
16
21
|
membershipId: string
|
|
22
|
+
product: {
|
|
23
|
+
id: number
|
|
24
|
+
category: string
|
|
25
|
+
}
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
private get instance() {
|
|
20
29
|
return this.instanceObj ?? this.resetData()
|
|
21
30
|
}
|
|
22
31
|
|
|
23
|
-
initData({
|
|
32
|
+
initData({
|
|
33
|
+
ucode,
|
|
34
|
+
membershipId,
|
|
35
|
+
membershipSlug,
|
|
36
|
+
sessionId,
|
|
37
|
+
userId,
|
|
38
|
+
product = defaultProduct
|
|
39
|
+
}: InitDataParams) {
|
|
24
40
|
this.instance.userAgentParser = UAParser(navigator.userAgent)
|
|
25
41
|
this.instance.browserInfo = this.instance.userAgentParser.browser
|
|
26
42
|
this.instance.deviceType =
|
|
@@ -32,6 +48,7 @@ class DataHubStore {
|
|
|
32
48
|
this.instance.userId = userId || 0
|
|
33
49
|
this.instance.membershipSlug = membershipSlug
|
|
34
50
|
this.instance.membershipId = membershipId
|
|
51
|
+
this.instance.product = product
|
|
35
52
|
}
|
|
36
53
|
|
|
37
54
|
resetData() {
|
|
@@ -47,7 +64,8 @@ class DataHubStore {
|
|
|
47
64
|
sessionId: 'UNDEFINED',
|
|
48
65
|
userId: 0,
|
|
49
66
|
membershipSlug: 'UNDEFINED',
|
|
50
|
-
membershipId: 'UNDEFINED'
|
|
67
|
+
membershipId: 'UNDEFINED',
|
|
68
|
+
product: defaultProduct
|
|
51
69
|
}
|
|
52
70
|
|
|
53
71
|
this.instanceObj = clearData
|
|
@@ -82,6 +100,10 @@ class DataHubStore {
|
|
|
82
100
|
get membershipId() {
|
|
83
101
|
return this.instance.membershipId
|
|
84
102
|
}
|
|
103
|
+
|
|
104
|
+
get product() {
|
|
105
|
+
return this.instance.product
|
|
106
|
+
}
|
|
85
107
|
}
|
|
86
108
|
|
|
87
109
|
export default new DataHubStore()
|
|
@@ -10,6 +10,9 @@ export const handlers = [
|
|
|
10
10
|
http.all('https://tracking-api.buildstaging.com/rest/track/event/json/sync', () => {
|
|
11
11
|
return HttpResponse.json({ ok: true })
|
|
12
12
|
}),
|
|
13
|
+
http.all('https://tracking-api.buildstaging.com/rest/track/event/json', () => {
|
|
14
|
+
return HttpResponse.json({ ok: true })
|
|
15
|
+
}),
|
|
13
16
|
http.all('https://c3po-api-auth.buildstaging.com/v1/auth/sparkie', () => {
|
|
14
17
|
return HttpResponse.json({ ok: true })
|
|
15
18
|
}),
|
|
@@ -20,7 +20,7 @@ if (devMode) {
|
|
|
20
20
|
container.setAttribute('id', rootId)
|
|
21
21
|
container.setAttribute(
|
|
22
22
|
'class',
|
|
23
|
-
'
|
|
23
|
+
'fixed bottom-5 right-5 w-[27rem] h-[min(43rem,calc(100vh-2.5rem))] max-h-[calc(100vh-2.5rem)] z-10 rounded-[0.625rem] border border-neutral-200 shadow-lg overflow-hidden flex flex-col'
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
// Theme setter
|
|
@@ -3,7 +3,12 @@ import clsx from 'clsx'
|
|
|
3
3
|
import { useTranslation } from 'react-i18next'
|
|
4
4
|
|
|
5
5
|
import { DataHubService } from '@/src/config/datahub'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ClickTutorBackSchema,
|
|
8
|
+
ClickTutorHistorySchema,
|
|
9
|
+
ClickTutorInfoSchema,
|
|
10
|
+
ClickTutorMinimizeSchema
|
|
11
|
+
} from '@/src/config/datahub/schemas/tutor'
|
|
7
12
|
import { Button, Icon, Tooltip } from '@/src/lib/components'
|
|
8
13
|
import { useMediaQuery } from '@/src/lib/hooks'
|
|
9
14
|
import { TutorWidgetEvents } from '../../events'
|
|
@@ -25,10 +30,12 @@ function WidgetHeaderActions({
|
|
|
25
30
|
|
|
26
31
|
const handleClickArchive = () => {
|
|
27
32
|
setTab('chat')
|
|
33
|
+
DataHubService.sendEvent({ schema: new ClickTutorHistorySchema() })
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
const handleClickInfo = () => {
|
|
31
37
|
setTab('information')
|
|
38
|
+
DataHubService.sendEvent({ schema: new ClickTutorInfoSchema() })
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
const handleClickExpand = () => {
|
|
@@ -98,6 +105,11 @@ function WidgetHeader({
|
|
|
98
105
|
|
|
99
106
|
const hasToShowActions = useMemo(() => Number(actionButtons?.length) > 0, [actionButtons?.length])
|
|
100
107
|
|
|
108
|
+
const handleGoBack = () => {
|
|
109
|
+
goBack()
|
|
110
|
+
DataHubService.sendEvent({ schema: new ClickTutorBackSchema() })
|
|
111
|
+
}
|
|
112
|
+
|
|
101
113
|
return (
|
|
102
114
|
<div
|
|
103
115
|
id='tutor-ai-consumer-widget-header'
|
|
@@ -121,7 +133,7 @@ function WidgetHeader({
|
|
|
121
133
|
})}>
|
|
122
134
|
{enabledButtons.includes('arrow-left') && (
|
|
123
135
|
<div>
|
|
124
|
-
<Button aria-label='Arrow Left Icon' onClick={
|
|
136
|
+
<Button aria-label='Arrow Left Icon' onClick={handleGoBack}>
|
|
125
137
|
<Icon name='arrow-left' className='h-3.5 w-3.5' aria-hidden />
|
|
126
138
|
</Button>
|
|
127
139
|
</div>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import type { CSSProperties, MouseEventHandler } from 'react'
|
|
3
|
+
import { useTranslation } from 'react-i18next'
|
|
4
|
+
|
|
5
|
+
import { DataHubService } from '@/src/config/datahub'
|
|
6
|
+
import {
|
|
7
|
+
ClickTutorKnowMoreSchema,
|
|
8
|
+
ClickTutorTestKnowledgeSchema
|
|
9
|
+
} from '@/src/config/datahub/schemas/tutor'
|
|
10
|
+
import { Button, HorizontalDraggableScroll } from '@/src/lib/components'
|
|
11
|
+
|
|
12
|
+
export type QuickActionButtonsProps = {
|
|
13
|
+
send: (textContent?: string | null) => void
|
|
14
|
+
loading?: boolean
|
|
15
|
+
isDarkTheme?: boolean
|
|
16
|
+
className?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function QuickActionButtons({
|
|
20
|
+
send,
|
|
21
|
+
className,
|
|
22
|
+
loading = false,
|
|
23
|
+
isDarkTheme = false
|
|
24
|
+
}: QuickActionButtonsProps) {
|
|
25
|
+
const { t } = useTranslation()
|
|
26
|
+
const actionButtonStyle = useMemo(
|
|
27
|
+
() =>
|
|
28
|
+
isDarkTheme
|
|
29
|
+
? undefined
|
|
30
|
+
: ({
|
|
31
|
+
'--gradient-btn-hover-foreground': '#0d0d0d'
|
|
32
|
+
} as CSSProperties),
|
|
33
|
+
[isDarkTheme]
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const handleAskQuestion: MouseEventHandler<HTMLButtonElement> = (e) => {
|
|
37
|
+
send(e?.currentTarget?.querySelector('span[data-label=text-content]')?.textContent)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const handleAskToKnowMore: MouseEventHandler<HTMLButtonElement> = (e) => {
|
|
41
|
+
handleAskQuestion(e)
|
|
42
|
+
DataHubService.sendEvent({ schema: new ClickTutorKnowMoreSchema() })
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const handleAskToTestKnowledge: MouseEventHandler<HTMLButtonElement> = (e) => {
|
|
46
|
+
handleAskQuestion(e)
|
|
47
|
+
DataHubService.sendEvent({ schema: new ClickTutorTestKnowledgeSchema() })
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<HorizontalDraggableScroll className={className}>
|
|
52
|
+
<Button
|
|
53
|
+
variant='gradient-outline'
|
|
54
|
+
style={actionButtonStyle}
|
|
55
|
+
className='ml-5 shrink-0 text-sm'
|
|
56
|
+
onClick={handleAskToKnowMore}
|
|
57
|
+
loading={loading}>
|
|
58
|
+
<span>🤖 </span>
|
|
59
|
+
{t('starter_page.what_does_tutor_do')}
|
|
60
|
+
</Button>
|
|
61
|
+
<Button
|
|
62
|
+
variant='gradient-outline'
|
|
63
|
+
style={actionButtonStyle}
|
|
64
|
+
className='mr-5 shrink-0 text-sm'
|
|
65
|
+
onClick={handleAskToTestKnowledge}
|
|
66
|
+
loading={loading}>
|
|
67
|
+
<span>📝 </span>
|
|
68
|
+
{t('starter_page.test_me')}
|
|
69
|
+
</Button>
|
|
70
|
+
</HorizontalDraggableScroll>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default QuickActionButtons
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef } from 'react'
|
|
2
2
|
import { useQueryClient } from '@tanstack/react-query'
|
|
3
|
-
import type { CSSProperties, MouseEventHandler } from 'react'
|
|
4
3
|
import { useTranslation } from 'react-i18next'
|
|
5
4
|
|
|
6
|
-
import { Button, HorizontalDraggableScroll } from '@/src/lib/components'
|
|
7
5
|
import { useMediaQuery, useRefEventListener } from '@/src/lib/hooks'
|
|
8
6
|
import { ChatInput, useChatInputValueAtom } from '@/src/modules/messages/components'
|
|
9
7
|
import { getAllMessagesQuery, useSendTextMessage } from '@/src/modules/messages/hooks'
|
|
@@ -14,6 +12,7 @@ import { useWidgetSettingsAtom, useWidgetTabsAtom } from '../../store'
|
|
|
14
12
|
import { GreetingsCard } from '../greetings-card'
|
|
15
13
|
import { WidgetHeader } from '../header'
|
|
16
14
|
import { PageLayout } from '../page-layout'
|
|
15
|
+
import { QuickActionButtons } from '../quick-action-buttons'
|
|
17
16
|
|
|
18
17
|
function WidgetStarterPage() {
|
|
19
18
|
const { t } = useTranslation()
|
|
@@ -53,10 +52,6 @@ function WidgetStarterPage() {
|
|
|
53
52
|
})
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
const handleAskQuestion: MouseEventHandler<HTMLButtonElement> = (e) => {
|
|
57
|
-
sendText(e?.currentTarget?.querySelector('span[data-label=text-content]')?.textContent)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
55
|
const handleSend = () => {
|
|
61
56
|
sendText(chatInputRef.current?.value)
|
|
62
57
|
}
|
|
@@ -75,16 +70,6 @@ function WidgetStarterPage() {
|
|
|
75
70
|
[conversationId, limit, profileId]
|
|
76
71
|
)
|
|
77
72
|
|
|
78
|
-
const actionButtonStyle = useMemo(
|
|
79
|
-
() =>
|
|
80
|
-
isDarkTheme
|
|
81
|
-
? undefined
|
|
82
|
-
: ({
|
|
83
|
-
'--gradient-btn-hover-foreground': '#0d0d0d'
|
|
84
|
-
} as CSSProperties),
|
|
85
|
-
[isDarkTheme]
|
|
86
|
-
)
|
|
87
|
-
|
|
88
73
|
useEffect(() => {
|
|
89
74
|
if (!conversationId || !profileId) return
|
|
90
75
|
|
|
@@ -113,30 +98,16 @@ function WidgetStarterPage() {
|
|
|
113
98
|
<GreetingsCard
|
|
114
99
|
author={settings?.user?.name?.split(' ')?.[0]}
|
|
115
100
|
tutorName={name}
|
|
116
|
-
isDarkTheme={
|
|
101
|
+
isDarkTheme={isDarkTheme}
|
|
117
102
|
/>
|
|
118
103
|
</div>
|
|
119
104
|
</div>
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
loading={!isSparkieReady}>
|
|
127
|
-
<span>🤖 </span>
|
|
128
|
-
{t('starter_page.what_does_tutor_do')}
|
|
129
|
-
</Button>
|
|
130
|
-
<Button
|
|
131
|
-
variant='gradient-outline'
|
|
132
|
-
style={actionButtonStyle}
|
|
133
|
-
className='mr-5 shrink-0 text-sm'
|
|
134
|
-
onClick={handleAskQuestion}
|
|
135
|
-
loading={!isSparkieReady}>
|
|
136
|
-
<span>📝 </span>
|
|
137
|
-
{t('starter_page.test_me')}
|
|
138
|
-
</Button>
|
|
139
|
-
</HorizontalDraggableScroll>
|
|
105
|
+
<QuickActionButtons
|
|
106
|
+
className='grid-area-[b] my-4 flex flex-shrink-0 snap-x snap-mandatory gap-2 overflow-x-auto whitespace-nowrap [scrollbar-width:none] [&::-webkit-scrollbar]:hidden'
|
|
107
|
+
isDarkTheme={isDarkTheme}
|
|
108
|
+
send={sendText}
|
|
109
|
+
loading={!isSparkieReady}
|
|
110
|
+
/>
|
|
140
111
|
</div>
|
|
141
112
|
</PageLayout>
|
|
142
113
|
)
|
|
@@ -15,7 +15,11 @@ const init = async (settings: WidgetSettingProps) => {
|
|
|
15
15
|
membershipId: settings.membershipId ?? '',
|
|
16
16
|
membershipSlug: settings.membershipSlug ?? '',
|
|
17
17
|
sessionId: settings.sessionId,
|
|
18
|
-
userId: Number(settings.userId)
|
|
18
|
+
userId: Number(settings.userId),
|
|
19
|
+
product: {
|
|
20
|
+
id: Number(settings.productId) || 0,
|
|
21
|
+
category: settings.productType ?? ''
|
|
22
|
+
}
|
|
19
23
|
})
|
|
20
24
|
TutorWidgetEvents['tutor-app-widget-loaded'].dispatch()
|
|
21
25
|
} catch (error) {
|