Lendi Lead Library
Importing
import LendiLeads from '@lendi/lendi-leads-library';
Sending data through a funnel that uses lala-customer-app
Once you have the data, it must first be set in sessionStorage:
import LendiLeads from "@lendi/lendi-lead-library";
const L3 = new LendiLeads(funnelName);
L3.set(data);
L3.setFirstName('test_first_name');
L3.setMobileNumber('test_mobile_number');
L3.setEmail('test_email');
Valid funnel names are: 'BORROWING_POWER', 'NEW_HOME_LOAN', 'REFINANCE', 'BLOG', 'PROPERTY_REPORT', 'STAMP_DUTY_CALCULATOR', 'APPOINTMENT_BOOKING', 'SIGN_UP' and 'INVITE'.
The data should be in a format that the API is expecting, there is no typescript validation on your input. However since the @lendi/lead-client is a peerDependency, the data should correspond to the funnelName using one of the following types:
- StampDutyDataV2, BorrowingPowerDataV2, FunnelDataV2 or PropertyReportDataV2.
After the data has been saved it will automatically be found and pulled from storage in lala-customer-app.
Sending data through a funnel with it's own log in page
Once data gathered, use:
const baseURL = process.env.API_URL;
LendiLeads.sendLead(data: LeadsRecord, baseURL: string);
This method expects that the data has been formatted in a way that is expected for the leads endpoint.
Note that there will be no types to validate the payload, this contract is between the consuming app and the API. The interface for a leads record is:
interface LeadsRecord {
generatedAt: string;
timeZone: string;
mobileNumber: string;
firstName: string;
origin: LeadsRecordOriginEnum;
brand: LeadsRecordBrandEnum;
accountOrigin: string;
data?: FunnelDataV1 | BorrowingPowerDataV1 | StampDutyDataV1 | PropertyReportDataV1;
email?: string;
gclId?: string;
utm?: string;
}
When constructing this object, there are several helper methods available
- gclId: (this is a google ads query string) use:
LendiLeads.retrieveGCLID();
- accountOrigin:
LendiLeads.retrieveAccountOrigin();
- generatedAt:
new Date().toISOString();
- timeZone:
Intl.DateTimeFormat().resolvedOptions().timeZone;
Using leads data on the frontend
Some leads data can be consumed statically by front end applications. They have access to firstName, mobileNumber, and email if they have been previously set. To use them do this:
import LendiLeads from '@lendi/lendi-lead-library';
const firstName: string | undefined = LendiLeads.firstName;
const mobileNumber: string | undefined = LendiLeads.mobileNumber;
const email: string | undefined = LendiLeads.email;
Use with lendi-app
In the case of Lendi-app, this library contains several transformation methods to translate the query string data into a format that is required by the core team's leads service. The main transformation method is named:
LendiLeads.transform_DEPRECATED(queryData: { [key: string]: string }, phoneNumber: string)
The queryData should be exactly what was received from the end of the funnel. phoneNumber
is a separate parameter as this is collected in a separate stage (e.g. inside lala-customer-app
).
Under the hood, this will call either a .transformFunnel_DEPRECATED()
or .transformBorrowing_DEPRECATED()
if the data came from either of the funnels (new home loan or refinance) or the borrowing power calculator.
Once this data has been returned, there is a corresponding method: LendiLeads.send_DEPRECATED(data: OldFunnel, brand: LeadsRecordBrandEnum, baseURL: string)
For the parameters:
data
can be passed through directly from the transformation
method.brand
can be passed through as a value on the enum Brand
which is exported from this library: import { Brand } from '@lendi/lendi-lead-library'
baseURL
should be the base url of the API for the current environment, the library will append /v1/leads
to the end of that URL.
NOTE: the reason these methods have been marked as _DEPRECATED is because once lendi-app is retired, the methods should never have a use again and the library should take more responsibility for the sending of leads data.
Types
The majority of the types required will be in the package @lendi/lead-client
as they are created from the generated client using the core team's openapi.yaml
swagger doc.