New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

netlify-build-plugin-dareboost

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netlify-build-plugin-dareboost - npm Package Compare versions

Comparing version

to
1.1.0

97

index.js

@@ -9,6 +9,40 @@ const {

},
} = require('process');
} = require("process");
const fetch = require('node-fetch');
const fetch = require("node-fetch");
const callAPI = async function (route, postData, token) {
console.log(
`Dareboost: calling route "${route}". Data: ${JSON.stringify(
Object.assign({ token: "****************" }, postData)
)}`
);
try {
const { status, statusText } = await fetch(
`https://www.dareboost.com/api/0.6${route}`,
{
method: "POST",
headers: {
"Content-type": "application/json",
},
body: JSON.stringify(Object.assign({ token: token }, postData)),
}
);
if (status != 200) {
return failPlugin(
`Dareboost: error while calling the route "${route}". Error: ${statusText}`
);
} else {
console.log(`Dareboost: calling route "${route}" => Success`);
}
} catch (error) {
return failPlugin(
`Dareboost: error while calling the route "${route}". Error:`,
{ error }
);
}
};
module.exports = {

@@ -19,9 +53,7 @@ async onSuccess({

},
inputs: { monitoringIds, scenarioIds },
inputs: { monitoringIds, scenarioIds, configurations },
}) {
console.log('Dareboost: initiate event creation');
if (DAREBOOST_API_TOKEN && DAREBOOST_API_TOKEN.length == 0)
return failPlugin(
'Dareboost: please define your DAREBOOST_API_TOKEN as en environment variable.',
"Dareboost: please define your DAREBOOST_API_TOKEN as en environment variable.",
{

@@ -32,39 +64,30 @@ error,

try {
let postBody = {
token: DAREBOOST_API_TOKEN,
key: `build-${COMMIT_REF.slice(0, 8)}`,
text: `Netlify build from commit ${COMMIT_REF}`,
date: new Date().toISOString(),
};
let postBody = {
token: DAREBOOST_API_TOKEN,
key: `build-${COMMIT_REF.slice(0, 8)}`,
text: `Netlify build from commit ${COMMIT_REF}`,
date: new Date().toISOString(),
};
if (monitoringIds.length > 0) {
postBody.monitorings = monitoringIds
.split(',')
.map((x) => parseInt(x, 10));
}
if (scenarioIds.length > 0) {
postBody.scenarios = scenarioIds.split(',').map((x) => parseInt(x, 10));
}
if (monitoringIds.length > 0) {
postBody.monitorings = monitoringIds
.split(",")
.map((x) => parseInt(x, 10));
}
if (scenarioIds.length > 0) {
postBody.scenarios = scenarioIds.split(",").map((x) => parseInt(x, 10));
}
const { status, statusText } = await fetch(
'https://www.dareboost.com/api/0.6/event/create',
{
method: 'POST',
headers: {
'Content-type': 'application/json',
},
body: JSON.stringify(postBody),
}
);
await callAPI("/event/create", postBody, DAREBOOST_API_TOKEN);
if (status != 200) {
return failPlugin('Dareboost: event not created. Error: ' + statusText);
} else {
console.log('Dareboost: event created');
if (configurations.length) {
for (let index = 0; index < configurations.length; index++) {
await callAPI(
"/analysis/launch",
configurations[index],
DAREBOOST_API_TOKEN
);
}
} catch (error) {
return failPlugin('Dareboost: error during event creation.', { error });
}
},
};
{
"name": "netlify-build-plugin-dareboost",
"version": "1.0.2",
"version": "1.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

# Dareboost Netlify Build Plugin
When a build is successful, adds a Dareboost event on the page and/or User Journey monitors you have defined, using the [Dareboost API](https://www.dareboost.com/en/documentation-api).
**You need [a Dareboost plan](https://www.dareboost.com/en/offers) to enjoy this plugin**
## How to use?
This plugin use the [Dareboost API](https://www.dareboost.com/en/documentation-api) to react to a successful build.
**If your plan contains monitoring**: adds a Dareboost event on the page and/or User Journey monitors you have defined
**If your plan contains API credits**: launches analysis you have configured in your `netlify.toml` file.
## Minimal usage (global event)
1. Install the plugin:

@@ -22,5 +28,5 @@

### \[Optional\] Specify monitors
## \[Optional\] Create an event specific to certain monitors
If you want your Dareboost event to be specifically related to specific monitors, you can add some configuration using the Netlify Plugins inputs:
If you want your Dareboost event to be related to specific monitors, you can add some configuration using the Netlify Plugins inputs:

@@ -35,2 +41,3 @@ - `monitoringIds`: The ids of the page monitors relevant to the build, separated by a coma.

package = "netlify-build-plugin-dareboost"
[plugins.inputs]

@@ -42,1 +49,28 @@ monitoringIds = "7134"

If neither `monitoringIds` nor `scenarioIds` are defined, the event will be considered global.
## \[Optional\] Launch analyses if the build is successful
If you want the plugin to automatically launch analyses when the build is successful, you can define multiple analyses configurations.
**Beware**: the analyses will be launched simultaneously. Make sure that your subscription supports this, otherwise just define one configuration.
Example (will consume 2 API credits):
```
[[plugins]]
package = "netlify-build-plugin-dareboost"
[plugins.inputs]
[[plugins.inputs.configurations]]
url = "https://boris.schapira.dev"
lang = "en"
location = "San Jose"
isPrivate = "true"
visualMetrics = "true"
[plugins.inputs.configurations.browser]
name = "Chrome"
```
Find more information on the multiple parameters and the API quotas in the [Dareboost API documentation](https://www.dareboost.com/en/documentation-api) (route "/analysis/launch").

Sorry, the diff of this file is not supported yet