Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lendi/lendi-lead-library

Package Overview
Dependencies
Maintainers
74
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lendi/lendi-lead-library

Support green call files through funnels

  • 1.10.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
31
increased by933.33%
Maintainers
74
Weekly downloads
 
Created
Source

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:

// See below for valid funnel names.
import LendiLeads from "@lendi/lendi-lead-library";
const L3 = new LendiLeads(funnelName);

// Put your funnel data in here as a valid funnel object for leads service to consume
L3.set(data);

// We have some special optional keys that make it easier for other frontends to read the L3 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:


// This should be a reference to the environment
// base URL as L3 will remain unaware.
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.

Keywords

FAQs

Package last updated on 04 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc