Skip to content

Commit cc67896

Browse files
Merging Next into ---> Main (#1106)
2 parents 01e4705 + 55dfb30 commit cc67896

File tree

6 files changed

+85
-24
lines changed

6 files changed

+85
-24
lines changed

apps/api/src/app/auth/usecases/onboard-user/onboard-user.usecase.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ export class OnboardUser {
4747
'First Name': updatedUser.firstName,
4848
'Last Name': updatedUser.lastName,
4949
'Lead Email': updatedUser.email,
50-
'Lead Source': updatedUser.source,
51-
'Mentioned Role': updatedUser.role,
50+
'CRM Source': updatedUser.source,
51+
Role: updatedUser.role,
5252
'Signup Method': updatedUser.signupMethod as LEAD_SIGNUP_USING,
53-
'Company Size': updatedUser.companySize,
53+
'Est. Employees': updatedUser.companySize,
5454
});
5555
} catch (error) {
5656
captureException(error);

apps/api/src/app/shared/services/lead.service.ts

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,85 @@ interface ILeadInformation {
88
'Last Name': string;
99
'Lead Email': string;
1010
'Signup Method': LEAD_SIGNUP_USING;
11-
'Mentioned Role': string;
12-
'Lead Source': string;
13-
'Company Size': string;
11+
Role: string;
12+
'CRM Source': string;
13+
'Est. Employees': string;
1414
}
1515

1616
@Injectable()
1717
export class LeadService {
1818
private log = process.env.NODE_ENV === 'local';
19+
private maAccessTokenDate: Date;
20+
private maAccessToken: string;
21+
22+
private async getMaAccessToken(): Promise<string> {
23+
if (
24+
this.maAccessToken &&
25+
this.maAccessTokenDate &&
26+
new Date().getTime() - this.maAccessTokenDate.getTime() < 3500000
27+
) {
28+
if (this.log) console.log('Using cached ma access token');
29+
30+
// 3500000 = 58 minutes
31+
return this.maAccessToken;
32+
}
33+
if (process.env.LEAD_REFRESH_TOKEN && process.env.LEAD_CLIENT_ID && process.env.LEAD_CLIENT_SECRET) {
34+
// eslint-disable-next-line max-len
35+
const url = `https://accounts.zoho.com/oauth/v2/token?client_id=${process.env.LEAD_CLIENT_ID}&grant_type=refresh_token&client_secret=${process.env.LEAD_CLIENT_SECRET}&refresh_token=${process.env.LEAD_REFRESH_TOKEN}`;
36+
if (this.log) console.log('Lead URL', url);
37+
38+
const response = await axios.post(url);
39+
this.maAccessTokenDate = new Date();
40+
this.maAccessToken = response.data.access_token;
41+
if (this.log) console.log('New access token generated', this.maAccessToken);
42+
43+
return response.data.access_token;
44+
}
45+
46+
return undefined;
47+
}
1948

2049
public async createLead(data: ILeadInformation): Promise<void> {
50+
const maAccessToken = await this.getMaAccessToken();
51+
if (maAccessToken) {
52+
const leadData = JSON.stringify({
53+
'First Name': data['First Name'],
54+
'Last Name': data['Last Name'],
55+
'Lead Email': data['Lead Email'],
56+
Role: data.Role,
57+
'Est. Employees': data['Est. Employees'],
58+
'CRM Source': data['CRM Source'],
59+
});
60+
// Add Lead to marketing automation
61+
// eslint-disable-next-line max-len
62+
const maUrl = `https://marketingautomation.zoho.com/api/v1/json/listsubscribe?listkey=${process.env.LEAD_LIST_KEY}&leadinfo=${leadData}&topic_id=${process.env.LEAD_TOPIC_ID}`;
63+
if (this.log) console.log(maUrl);
64+
65+
try {
66+
const maResponse = await axios.post(
67+
maUrl,
68+
{},
69+
{
70+
headers: {
71+
Authorization: `Zoho-oauthtoken ${maAccessToken}`,
72+
},
73+
}
74+
);
75+
if (this.log) console.log('Lead created', maResponse.data);
76+
} catch (error) {
77+
captureException(error);
78+
}
79+
}
2180
if (process.env.LEAD_MAKE_WEBHOOK_URL) {
2281
try {
2382
await axios.post(process.env.LEAD_MAKE_WEBHOOK_URL, {
2483
firstName: data['First Name'],
2584
lastName: data['Last Name'],
2685
email: data['Lead Email'],
2786
signupMethod: data['Signup Method'],
28-
mentionedRole: data['Mentioned Role'],
29-
leadSource: data['Lead Source'],
30-
companySize: data['Company Size'],
87+
mentionedRole: data.Role,
88+
leadSource: data['CRM Source'],
89+
companySize: data['Est. Employees'],
3190
createdAt: new Date(),
3291
});
3392
if (this.log) console.log('Lead data sent to Make.com webhook');

apps/api/src/app/team/usecase/accept-invitation/accept-invitation.usecase.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ export class AcceptInvitation {
108108
'First Name': user.firstName,
109109
'Last Name': user.lastName,
110110
'Lead Email': user.email,
111-
'Lead Source': 'Invitation',
112-
'Mentioned Role': user.role,
111+
'CRM Source': 'Invitation',
112+
Role: user.role,
113113
'Signup Method': LEAD_SIGNUP_USING.EMAIL,
114-
'Company Size': user.companySize,
114+
'Est. Employees': user.companySize,
115115
});
116116
} catch (error) {
117117
captureException(error);

apps/queue-manager/src/consumers/send-bubble-data.consumer.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,17 @@ export class SendBubbleDataConsumer extends BaseConsumer {
164164
Object.keys(extra).forEach((extraObjKey) => {
165165
defaultValueObj[`extra.${extraObjKey}`] = extra[extraObjKey];
166166
});
167-
if (uploadata.customRecordFormat && uploadata.customRecordFormat.includes('{{extra.uploadId}}')) {
168-
defaultValueObj['extra.uploadId'] = _uploadId;
169-
}
170-
171-
if (uploadata.customRecordFormat && uploadata.customRecordFormat.includes('{{extra.userId}}')) {
172-
defaultValueObj['extra.userId'] = await this.uploadRepository.getUserIdFromUploadId(_uploadId);
173-
}
167+
/*
168+
* if (uploadata.customRecordFormat && uploadata.customRecordFormat.includes('{{extra.uploadId}}')) {
169+
* defaultValueObj['extra.uploadId'] = _uploadId;
170+
* }
171+
*/
172+
173+
/*
174+
* if (uploadata.customRecordFormat && uploadata.customRecordFormat.includes('{{extra.userId}}')) {
175+
* defaultValueObj['extra.userId'] = await this.uploadRepository.getUserIdFromUploadId(_uploadId);
176+
* }
177+
*/
174178
} catch (error) {}
175179
}
176180

apps/web/config/constants.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ export const HOW_HEARD_ABOUT_US = [
443443
{ value: 'Google Search', label: 'Google Search' },
444444
{ value: 'Bubble.io', label: 'Bubble.io' },
445445
{ value: 'Colleague', label: 'Colleague' },
446-
{ value: 'Linkdin', label: 'Linkdin' },
446+
{ value: 'Linkedin', label: 'Linkedin' },
447447
{ value: 'Invitation', label: 'Invitation' },
448448
{ value: 'AI (ChatGPT, Perplexity, Claude ...)', label: 'AI (ChatGPT, Perplexity, Claude ...)' },
449449
];

apps/widget/src/hooks/Phase1/usePhase1.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ export function usePhase1({ goNext, texts, onManuallyEnterData }: IUsePhase1Prop
7878
resetField('file');
7979
setError('file', {
8080
type: 'file',
81-
message: maxRecords
82-
? `${texts.PHASE3.MAX_RECORD_LIMIT_ERROR} ${maxRecords}`
83-
: texts.PHASE3.MAX_RECORD_LIMIT_ERROR ?? error.message,
81+
message: error.message,
8482
});
8583
},
8684
}
@@ -91,7 +89,7 @@ export function usePhase1({ goNext, texts, onManuallyEnterData }: IUsePhase1Prop
9189
IErrorObject,
9290
{ file: File }
9391
// eslint-disable-next-line prettier/prettier
94-
>(['getExcelSheetNames'], (excelSheetFile) => api.getExcelSheetNames(excelSheetFile), {
92+
>(['getExcelSheetNames'], (excelSheetFile) => api.getExcelSheetNames(excelSheetFile), {
9593
onSuccess(sheetNames) {
9694
if (sheetNames.length <= 1) {
9795
setValue('selectedSheetName', sheetNames[0]);

0 commit comments

Comments
 (0)