Skip to content

Commit fa714f3

Browse files
authored
Quickstart v2 (#1832)
1 parent 92818ee commit fa714f3

File tree

63 files changed

+887
-64
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+887
-64
lines changed

backend/src/api/tenant/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ export default (app) => {
2222
)
2323
app.post(`/tenant/:tenantId/sampleData`, safeWrap(require('./tenantGenerateSampleData').default))
2424
app.delete(`/tenant/:tenantId/sampleData`, safeWrap(require('./tenantDeleteSampleData').default))
25+
app.post(
26+
`/tenant/:tenantId/viewOrganizations`,
27+
safeWrap(require('./tenantViewOrganizations').default),
28+
)
29+
app.post(`/tenant/:tenantId/viewContacts`, safeWrap(require('./tenantViewContacts').default))
2530
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import TenantService from '../../services/tenantService'
2+
3+
export default async (req, res) => {
4+
const payload = await new TenantService(req).viewContacts()
5+
6+
await req.responseHandler.success(req, res, payload)
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import TenantService from '../../services/tenantService'
2+
3+
export default async (req, res) => {
4+
const payload = await new TenantService(req).viewOrganizations()
5+
6+
await req.responseHandler.success(req, res, payload)
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE public."settings" DROP COLUMN "organizationsViewed";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE public."settings" DROP COLUMN "contactsViewed";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE public."settings" ADD COLUMN "organizationsViewed" bool;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE public."settings" ADD COLUMN "contactsViewed" bool;

backend/src/database/models/settings.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export default (sequelize, DataTypes) => {
2121
slackWebHook: {
2222
type: DataTypes.STRING(1024),
2323
},
24+
organizationsViewed: {
25+
type: DataTypes.BOOLEAN(),
26+
},
27+
contactsViewed: {
28+
type: DataTypes.BOOLEAN(),
29+
},
2430
attributeSettings: {
2531
type: DataTypes.JSONB,
2632
allowNull: false,

backend/src/services/quickstartGuideService.ts

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { IServiceOptions } from './IServiceOptions'
66
import isFeatureEnabled from '../feature-flags/isFeatureEnabled'
77
import {
88
DEFAULT_GUIDES,
9+
DEFAULT_GUIDES_V2,
910
QuickstartGuideMap,
1011
QuickstartGuideSettings,
1112
QuickstartGuideType,
@@ -14,6 +15,8 @@ import IntegrationRepository from '../database/repositories/integrationRepositor
1415
import MemberService from './memberService'
1516
import TenantUserRepository from '../database/repositories/tenantUserRepository'
1617
import ReportRepository from '../database/repositories/reportRepository'
18+
import AutomationRepository from '../database/repositories/automationRepository'
19+
import SettingsRepository from '@/database/repositories/settingsRepository'
1720

1821
export default class QuickstartGuideService extends LoggerBase {
1922
options: IServiceOptions
@@ -39,7 +42,10 @@ export default class QuickstartGuideService extends LoggerBase {
3942
}
4043

4144
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+
)
4349

4450
const integrationCount: number = await IntegrationRepository.count({}, this.options)
4551

@@ -66,21 +72,58 @@ export default class QuickstartGuideService extends LoggerBase {
6672
this.options,
6773
)
6874

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,
7479
)
7580

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+
) {
77117
guides[QuickstartGuideType.SET_EAGLE_EYE].completed = tenantUser.settings.eagleEye.onboarded
78118
} else {
79119
delete guides[QuickstartGuideType.SET_EAGLE_EYE]
80120
}
81121

82122
// 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+
) {
84127
const enrichableMembers = await ms.findAndCountAll({
85128
advancedFilter: {
86129
and: [

backend/src/services/tenantService.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,14 @@ export default class TenantService {
362362
}
363363
}
364364

365+
async viewOrganizations() {
366+
return SettingsService.save({ organizationsViewed: true }, this.options)
367+
}
368+
369+
async viewContacts() {
370+
return SettingsService.save({ contactsViewed: true }, this.options)
371+
}
372+
365373
async updatePlanUser(id, planStripeCustomerId, planUserId) {
366374
const transaction = await SequelizeRepository.createTransaction(this.options)
367375

0 commit comments

Comments
 (0)