mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-04-12 02:18:18 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05eb7a326e |
@@ -13,6 +13,12 @@ import { WorklistModule } from './worklist/worklist.module';
|
|||||||
import { CallAssistModule } from './call-assist/call-assist.module';
|
import { CallAssistModule } from './call-assist/call-assist.module';
|
||||||
import { SearchModule } from './search/search.module';
|
import { SearchModule } from './search/search.module';
|
||||||
import { SupervisorModule } from './supervisor/supervisor.module';
|
import { SupervisorModule } from './supervisor/supervisor.module';
|
||||||
|
import { MaintModule } from './maint/maint.module';
|
||||||
|
import { RecordingsModule } from './recordings/recordings.module';
|
||||||
|
import { EventsModule } from './events/events.module';
|
||||||
|
import { CallerResolutionModule } from './caller/caller-resolution.module';
|
||||||
|
import { RulesEngineModule } from './rules-engine/rules-engine.module';
|
||||||
|
import { ConfigThemeModule } from './config/config-theme.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -32,6 +38,12 @@ import { SupervisorModule } from './supervisor/supervisor.module';
|
|||||||
CallAssistModule,
|
CallAssistModule,
|
||||||
SearchModule,
|
SearchModule,
|
||||||
SupervisorModule,
|
SupervisorModule,
|
||||||
|
MaintModule,
|
||||||
|
RecordingsModule,
|
||||||
|
EventsModule,
|
||||||
|
CallerResolutionModule,
|
||||||
|
RulesEngineModule,
|
||||||
|
ConfigThemeModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|||||||
@@ -32,20 +32,6 @@ export class LeadEmbedController {
|
|||||||
throw new HttpException('Either contact phone or email is required', 400);
|
throw new HttpException('Either contact phone or email is required', 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look up campaign by name and link via relation if not already set by ID
|
|
||||||
if (!leadData.campaignId) {
|
|
||||||
const campaignName = body.utm_campaign || body.utmCampaign || body.campaign;
|
|
||||||
if (campaignName) {
|
|
||||||
const campaignId = await this.lookupCampaignByName(campaignName, authHeader);
|
|
||||||
if (campaignId) {
|
|
||||||
leadData.campaignId = campaignId;
|
|
||||||
this.logger.log(`Matched campaign "${campaignName}" → ${campaignId}`);
|
|
||||||
} else {
|
|
||||||
this.logger.warn(`No campaign found matching name: "${campaignName}"`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await this.platform.queryWithAuth<any>(
|
const result = await this.platform.queryWithAuth<any>(
|
||||||
`mutation($data: LeadCreateInput!) { createLead(data: $data) { id } }`,
|
`mutation($data: LeadCreateInput!) { createLead(data: $data) { id } }`,
|
||||||
{ data: leadData },
|
{ data: leadData },
|
||||||
@@ -123,24 +109,6 @@ export class LeadEmbedController {
|
|||||||
leadData.campaignId = body.campaign_id || body.campaignId;
|
leadData.campaignId = body.campaign_id || body.campaignId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UTM tracking fields
|
|
||||||
const utmCampaign = body.utm_campaign || body.utmCampaign || body.campaign;
|
|
||||||
if (utmCampaign) {
|
|
||||||
leadData.utmCampaign = utmCampaign;
|
|
||||||
}
|
|
||||||
if (body.utm_source || body.utmSource) {
|
|
||||||
leadData.utmSource = body.utm_source || body.utmSource;
|
|
||||||
}
|
|
||||||
if (body.utm_medium || body.utmMedium) {
|
|
||||||
leadData.utmMedium = body.utm_medium || body.utmMedium;
|
|
||||||
}
|
|
||||||
if (body.utm_content || body.utmContent) {
|
|
||||||
leadData.utmContent = body.utm_content || body.utmContent;
|
|
||||||
}
|
|
||||||
if (body.utm_term || body.utmTerm) {
|
|
||||||
leadData.utmTerm = body.utm_term || body.utmTerm;
|
|
||||||
}
|
|
||||||
|
|
||||||
return leadData;
|
return leadData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,24 +131,6 @@ export class LeadEmbedController {
|
|||||||
return serviceMap[type.toLowerCase()] || type;
|
return serviceMap[type.toLowerCase()] || type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async lookupCampaignByName(name: string, authHeader: string): Promise<string | null> {
|
|
||||||
try {
|
|
||||||
const data = await this.platform.queryWithAuth<any>(
|
|
||||||
`{ campaigns(first: 50) { edges { node { id campaignName } } } }`,
|
|
||||||
undefined,
|
|
||||||
authHeader,
|
|
||||||
);
|
|
||||||
const campaigns = data?.campaigns?.edges?.map((e: any) => e.node) ?? [];
|
|
||||||
const match = campaigns.find(
|
|
||||||
(c: any) => (c.campaignName ?? '').toLowerCase() === name.toLowerCase(),
|
|
||||||
);
|
|
||||||
return match?.id ?? null;
|
|
||||||
} catch (err: any) {
|
|
||||||
this.logger.warn(`Campaign lookup failed: ${err.message}`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async createInitialActivity(
|
private async createInitialActivity(
|
||||||
leadId: string,
|
leadId: string,
|
||||||
body: Record<string, any>,
|
body: Record<string, any>,
|
||||||
|
|||||||
Reference in New Issue
Block a user