@@ -6,6 +6,7 @@ import { IServiceOptions } from './IServiceOptions'
6
6
import isFeatureEnabled from '../feature-flags/isFeatureEnabled'
7
7
import {
8
8
DEFAULT_GUIDES ,
9
+ DEFAULT_GUIDES_V2 ,
9
10
QuickstartGuideMap ,
10
11
QuickstartGuideSettings ,
11
12
QuickstartGuideType ,
@@ -14,6 +15,8 @@ import IntegrationRepository from '../database/repositories/integrationRepositor
14
15
import MemberService from './memberService'
15
16
import TenantUserRepository from '../database/repositories/tenantUserRepository'
16
17
import ReportRepository from '../database/repositories/reportRepository'
18
+ import AutomationRepository from '../database/repositories/automationRepository'
19
+ import SettingsRepository from '@/database/repositories/settingsRepository'
17
20
18
21
export default class QuickstartGuideService extends LoggerBase {
19
22
options : IServiceOptions
@@ -39,7 +42,10 @@ export default class QuickstartGuideService extends LoggerBase {
39
42
}
40
43
41
44
async find ( ) : Promise < QuickstartGuideMap > {
42
- const guides : QuickstartGuideMap = JSON . parse ( JSON . stringify ( DEFAULT_GUIDES ) )
45
+ const isGuidesV2Enabled = await isFeatureEnabled ( FeatureFlag . QUICKSTART_V2 , this . options )
46
+ const guides : QuickstartGuideMap = JSON . parse (
47
+ JSON . stringify ( isGuidesV2Enabled ? DEFAULT_GUIDES_V2 : DEFAULT_GUIDES ) ,
48
+ )
43
49
44
50
const integrationCount : number = await IntegrationRepository . count ( { } , this . options )
45
51
@@ -66,21 +72,58 @@ export default class QuickstartGuideService extends LoggerBase {
66
72
this . options ,
67
73
)
68
74
69
- guides [ QuickstartGuideType . CONNECT_INTEGRATION ] . completed = integrationCount > 1
70
- guides [ QuickstartGuideType . ENRICH_MEMBER ] . completed = enrichedMembers . count > 0
71
- guides [ QuickstartGuideType . VIEW_REPORT ] . completed = viewedReports . count > 0
72
- guides [ QuickstartGuideType . INVITE_COLLEAGUES ] . completed = allTenantUsers . some (
73
- ( tu ) => tu . invitedById === this . options . currentUser . id ,
75
+ const automations = await new AutomationRepository ( this . options ) . findAndCountAll ( { } )
76
+ const tenantSettings = await SettingsRepository . getTenantSettings (
77
+ this . options . currentTenant . id ,
78
+ this . options ,
74
79
)
75
80
76
- if ( await isFeatureEnabled ( FeatureFlag . EAGLE_EYE , this . options ) ) {
81
+ if ( QuickstartGuideType . CONNECT_INTEGRATION in guides ) {
82
+ guides [ QuickstartGuideType . CONNECT_INTEGRATION ] . completed = integrationCount > 1
83
+ }
84
+ if ( QuickstartGuideType . ENRICH_MEMBER in guides ) {
85
+ guides [ QuickstartGuideType . ENRICH_MEMBER ] . completed = enrichedMembers . count > 0
86
+ }
87
+ if ( QuickstartGuideType . VIEW_REPORT in guides ) {
88
+ guides [ QuickstartGuideType . VIEW_REPORT ] . completed = viewedReports . count > 0
89
+ }
90
+ if ( QuickstartGuideType . INVITE_COLLEAGUES in guides ) {
91
+ guides [ QuickstartGuideType . INVITE_COLLEAGUES ] . completed = allTenantUsers . some (
92
+ ( tu ) => tu . invitedById === this . options . currentUser . id ,
93
+ )
94
+ }
95
+
96
+ if ( QuickstartGuideType . CONNECT_FIRST_INTEGRATION in guides ) {
97
+ guides [ QuickstartGuideType . CONNECT_FIRST_INTEGRATION ] . completed = integrationCount > 0
98
+ }
99
+
100
+ if ( QuickstartGuideType . CREATE_AUTOMATIONS in guides ) {
101
+ guides [ QuickstartGuideType . CREATE_AUTOMATIONS ] . completed = automations . count > 0
102
+ }
103
+
104
+ if ( QuickstartGuideType . EXPLORE_ORGANIZATIONS in guides ) {
105
+ guides [ QuickstartGuideType . EXPLORE_ORGANIZATIONS ] . completed =
106
+ tenantSettings . organizationsViewed
107
+ }
108
+
109
+ if ( QuickstartGuideType . EXPLORE_CONTACTS in guides ) {
110
+ guides [ QuickstartGuideType . EXPLORE_CONTACTS ] . completed = tenantSettings . contactsViewed
111
+ }
112
+
113
+ if (
114
+ QuickstartGuideType . SET_EAGLE_EYE in guides &&
115
+ ( await isFeatureEnabled ( FeatureFlag . EAGLE_EYE , this . options ) )
116
+ ) {
77
117
guides [ QuickstartGuideType . SET_EAGLE_EYE ] . completed = tenantUser . settings . eagleEye . onboarded
78
118
} else {
79
119
delete guides [ QuickstartGuideType . SET_EAGLE_EYE ]
80
120
}
81
121
82
122
// try to find an enrichable member for button CTA of enrich member guide
83
- if ( ! guides [ QuickstartGuideType . ENRICH_MEMBER ] . completed ) {
123
+ if (
124
+ QuickstartGuideType . ENRICH_MEMBER in guides &&
125
+ ! guides [ QuickstartGuideType . ENRICH_MEMBER ] . completed
126
+ ) {
84
127
const enrichableMembers = await ms . findAndCountAll ( {
85
128
advancedFilter : {
86
129
and : [
0 commit comments