@brickwork-software/bw-customer-data
v0.0.2
Published
Send customer data to a Brickwork by B8ta iframe.
Downloads
1
Keywords
Readme
bw-customer-data
Post customer data into a Brickwork by B8ta appointment page iframe. Currently supports customer's email, firstName, lastName, and id. Appointment page listens for data from whitelisted origins. Contact support to edit the whitelist for your organization.
Retries until either success or limits reached. Default limits: 10 retries, with 500ms between tries. Both are optionally configurable by options parameter (see Usage).
Installation
npm install 'bw-customer-data'
or by CDN:<script async src="https://unpkg.com/bw-customer-data/dist/bw-customer-data.min.js"></script>
Configuration
Customer data can be sent to a Brickwork by B8ta iframe with an id of bw-iframe
that has loaded an appointmentpage
path.
<iframe id="bw-iframe" src="https://example.com/appointmentpage" />
Usage
const data = {
email: "[email protected]"
firstName: "Geoffrey",
id: "123",
lastName: "Jefferies",
}
const targetOrigin = "https://example.com/appointmentpage"
const options = {
maxRetries: 20,
retryDelay: 100,
}
bwCustomerData.post(data, targetOrigin, options)
.then(result => {
console.log(result)
})
.catch(result => {
console.log(result)
})
data
: objectdata.email
: stringdata.firstName
: stringdata.id
: stringdata.lastName
: string
targetOrigin
: string
options
: objectoptions.maxRetries
: numberoptions.retryDelay
: number
Examples
With valid arguments.
bwCustomerData.post(
{ firstName: "Geoffrey" },
"https://example.com/appointmentpage"
)
.then(result => {
console.log(result) // { status: "success" }
})
.catch(result => {
console.log(result)
})
With invalid arguments or misconfiguration.
bwCustomerData.post(
"Geoffrey",
"https://example.com/appointmentpage",
{ maxRetries: 20 }
)
.then(result => {
console.log(result)
})
.catch(result => {
console.log(result) // { Error: First argument must be an object, received 'string'.}
})
Data not received, such as when the iframe is not yet loaded.
bwCustomerData.post(
{ firstName: "Geoffrey" },
"https://example.com/appointmentpage",
{ maxRetries: 20 }
)
.then(result => {
console.log(result)
})
.catch(result => {
console.log(result) // { status: "error" }
})
Bugs
Include version number bwCustomerData.version()
with your issue.