fleet/website/api/controllers/deliver-mdm-beta-signup.js
Eric 9ddd5f2ede
Website: Add MDM page (#9264)
Changes:
- Added a new page: `/device-management`
- Added a new action: `deliver-mdm-beta-signup.js` - This action sends a
post request to a Zapier webhook when a user submits a form on the
`/device-managment` page.
- Added a new component: `<scrollable-tweets>`
- Updated routes, importer, policies, cloud-sdk, and
`download-sitemap.js`
- Updated the route for our success story articles to live at
`fleetdm.com/success-stories/*` (Previously at
`fleetdm.com/device-management/*`) and updated `config/routes.js` to
have redirects for each article in that category
- Updated the "Use cases" navigation item to "Platform" and changed the
platform link to "How it works"

Co-authored-by: Mike Thomas <[email protected]>
Co-authored-by: Mike McNeil <[email protected]>
2023-01-11 11:29:38 -06:00

67 lines
1.9 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'Deliver MDM beta signup',
description: 'Delivers a message to an internal slack channel to notify us when someone signs up for our live Q&A',
inputs: {
emailAddress: {
required: true,
type: 'string',
description: 'The email address provided when a user submitted the mdm beta signup form.',
example: '[email protected]'
},
fullName: {
required: true,
type: 'string',
description: 'The name provided when a user submitted the mdm beta signup form',
},
jobTitle: {
required: true,
type: 'string',
description: 'The job title provided when a user submitted the mdm beta signup form',
},
},
exits: {
success: {
description: 'The message was sent successfully.'
}
},
fn: async function({emailAddress, fullName, jobTitle}) {
if(!sails.config.custom.zapierSandboxWebhookSecret) {
throw new Error('Message not delivered: zapierSandboxWebhookSecret needs to be configured in sails.config.custom.');
}
// Send a POST request to Zapier
await sails.helpers.http.post(
'https://hooks.zapier.com/hooks/catch/3627242/bj5nh8y/',
{
'emailAddress': emailAddress,
'fullName': fullName,
'jobTitle': jobTitle,
'webhookSecret': sails.config.custom.zapierSandboxWebhookSecret
}
)
.timeout(5000)
.tolerate(['non200Response', 'requestFailed', {name: 'TimeoutError'}], (err)=>{
// Note that Zapier responds with a 2xx status code even if something goes wrong, so just because this message is not logged doesn't mean everything is hunky dory. More info: https://github.com/fleetdm/fleet/pull/6380#issuecomment-1204395762
sails.log.warn(`When a user submitted the MDM beta signup form, an error occurred while sending a request to Zapier. Raw error: ${require('util').inspect(err)}`);
return;
});
}
};