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

debugbear

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debugbear - npm Package Compare versions

Comparing version 2.1.4 to 2.1.5

4

callApi.ts

@@ -32,3 +32,3 @@ import axios from "axios";

// more like a browser than Node)
adapter: require("axios/lib/adapters/http"),
adapter: "http",
};

@@ -41,3 +41,3 @@ if (process.env.DEBUG) {

return (await axios(reqDetail)).data;
} catch (err) {
} catch (err: any) {
let msg = err.response?.data?.error || err.message;

@@ -44,0 +44,0 @@ if (err.response && err.response.body && err.response.body.error) {

import * as queryString from "querystring";
import { AnalysisResultObject } from "./ResponseTypes";
import { callApi } from "./callApi";
import { getNgrokTunnelPublicUrl } from "./getNgrokTunnelPublicUrl";
import { inferBuildInfo } from "./inferBuildInfo";
import { AnalysisResultObject } from "./ResponseTypes";

@@ -36,3 +36,10 @@ let pollIntervalAdjustmentFactor = 1;

async function waitForAnalysisResult(analysisId, explicitApiKeyParam) {
function arrayToQuery(arr: any[], key: string): string {
return arr.map((i) => `${key}[]=` + encodeURIComponent(i)).join("&");
}
async function waitForAnalysisResult(
analysisId: string | string[],
explicitApiKeyParam: string
) {
let hasFinished = false;

@@ -47,2 +54,7 @@ let timeWaited = 0;

const isBulkAnalysis = Array.isArray(analysisId);
const apiCallPath = isBulkAnalysis
? "/analysis/bulk/?" + arrayToQuery(analysisId, "id")
: "/analysis/" + analysisId;
let resp;

@@ -57,3 +69,3 @@ while (!hasFinished) {

method: "get",
path: "/analysis/" + analysisId,
path: apiCallPath,
explicitApiKeyParam,

@@ -69,3 +81,3 @@ });

clearInterval(waitInterval);
return resp as AnalysisResultObject;
return resp;
}

@@ -287,2 +299,25 @@

async analyzeBulk(pageIds: number[]): Promise<{
waitForResult: () => Promise<{
hasFinished: boolean;
results: AnalysisResultObject[];
}>;
}> {
const results = await callApi({
method: "post",
path: "/page/analyzeBulk",
body: { pageIds },
explicitApiKeyParam: this.apiKey,
});
return {
waitForResult: async () => {
return waitForAnalysisResult(
results.map((r) => parseFloat(r.analysis.id)),
this.apiKey
);
},
};
}
create(

@@ -289,0 +324,0 @@ projectId: string,

@@ -17,3 +17,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -46,8 +46,8 @@ if (y = 0, t) op = [op[0] & 2, t.value];

function callApi(_a) {
var _b, _c;
var method = _a.method, path = _a.path, body = _a.body, explicitApiKeyParam = _a.explicitApiKeyParam;
return __awaiter(this, void 0, void 0, function () {
return __awaiter(this, arguments, void 0, function (_b) {
var reqDetail, err_1, msg;
return __generator(this, function (_d) {
switch (_d.label) {
var _c, _d;
var method = _b.method, path = _b.path, body = _b.body, explicitApiKeyParam = _b.explicitApiKeyParam;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:

@@ -66,3 +66,3 @@ reqDetail = {

// more like a browser than Node)
adapter: require("axios/lib/adapters/http"),
adapter: "http",
};

@@ -72,14 +72,14 @@ if (process.env.DEBUG) {

}
_d.label = 1;
_e.label = 1;
case 1:
_d.trys.push([1, 3, , 4]);
return [4 /*yield*/, axios_1.default(reqDetail)];
case 2: return [2 /*return*/, (_d.sent()).data];
_e.trys.push([1, 3, , 4]);
return [4 /*yield*/, (0, axios_1.default)(reqDetail)];
case 2: return [2 /*return*/, (_e.sent()).data];
case 3:
err_1 = _d.sent();
msg = ((_c = (_b = err_1.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) || err_1.message;
err_1 = _e.sent();
msg = ((_d = (_c = err_1.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.error) || err_1.message;
if (err_1.response && err_1.response.body && err_1.response.body.error) {
msg = err_1.response.body.error;
}
throw Error("Error making request " + method.toUpperCase() + " " + path + ": " + msg);
throw Error("Error making request ".concat(method.toUpperCase(), " ").concat(path, ": ").concat(msg));
case 4: return [2 /*return*/];

@@ -86,0 +86,0 @@ }

@@ -62,3 +62,3 @@ import { AnalysisResultObject } from "./ResponseTypes";

}
declare type ServerRegion = "us-east" | "us-west" | "uk" | "australia" | "japan" | "germany" | "brazil" | "finland";
type ServerRegion = "us-east" | "us-west" | "uk" | "australia" | "japan" | "germany" | "brazil" | "finland";
declare class ProjectsApiClient extends ApiClientObject {

@@ -120,2 +120,8 @@ private apiKey;

}>;
analyzeBulk(pageIds: number[]): Promise<{
waitForResult: () => Promise<{
hasFinished: boolean;
results: AnalysisResultObject[];
}>;
}>;
create(projectId: string, { name, url, testScheduleName, deviceName, region, advancedSettings, tags, }: Pick<CreatePageOptions, "name" | "url" | "testScheduleName" | "deviceName" | "region" | "advancedSettings" | "tags">): Promise<PageObject>;

@@ -122,0 +128,0 @@ update(pageId: number, { name, url, testScheduleName, deviceName, region, advancedSettings, tags, }: Partial<CreatePageOptions>): Promise<PageObject>;

@@ -43,3 +43,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -94,5 +94,8 @@ if (y = 0, t) op = [op[0] & 2, t.value];

}());
function arrayToQuery(arr, key) {
return arr.map(function (i) { return "".concat(key, "[]=") + encodeURIComponent(i); }).join("&");
}
function waitForAnalysisResult(analysisId, explicitApiKeyParam) {
return __awaiter(this, void 0, void 0, function () {
var hasFinished, timeWaited, interval, waitInterval, resp;
var hasFinished, timeWaited, interval, waitInterval, isBulkAnalysis, apiCallPath, resp;
return __generator(this, function (_a) {

@@ -108,2 +111,6 @@ switch (_a.label) {

}, 8 * 60 * 1000);
isBulkAnalysis = Array.isArray(analysisId);
apiCallPath = isBulkAnalysis
? "/analysis/bulk/?" + arrayToQuery(analysisId, "id")
: "/analysis/" + analysisId;
_a.label = 1;

@@ -119,5 +126,5 @@ case 1:

}
return [4 /*yield*/, callApi_1.callApi({
return [4 /*yield*/, (0, callApi_1.callApi)({
method: "get",
path: "/analysis/" + analysisId,
path: apiCallPath,
explicitApiKeyParam: explicitApiKeyParam,

@@ -172,3 +179,3 @@ })];

switch (_a.label) {
case 0: return [4 /*yield*/, callApi_1.callApi({
case 0: return [4 /*yield*/, (0, callApi_1.callApi)({
method: "get",

@@ -191,3 +198,3 @@ path: "/projects/" + projectId,

switch (_a.label) {
case 0: return [4 /*yield*/, callApi_1.callApi({
case 0: return [4 /*yield*/, (0, callApi_1.callApi)({
method: "get",

@@ -207,8 +214,8 @@ path: "/projects",

ProjectsApiClient.prototype.create = function (_a) {
var name = _a.name;
return __awaiter(this, void 0, void 0, function () {
return __awaiter(this, arguments, void 0, function (_b) {
var page;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, callApi_1.callApi({
var name = _b.name;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, (0, callApi_1.callApi)({
method: "post",

@@ -222,3 +229,3 @@ path: "/projects",

case 1:
page = _b.sent();
page = _c.sent();
return [2 /*return*/, new ProjectObject(this._apiClient, page)];

@@ -232,3 +239,3 @@ }

return __generator(this, function (_a) {
return [2 /*return*/, callApi_1.callApi({
return [2 /*return*/, (0, callApi_1.callApi)({
method: "delete",

@@ -241,7 +248,7 @@ path: "/projects/" + projectId,

};
ProjectsApiClient.prototype.getPageMetrics = function (projectId, _a) {
var _b = _a === void 0 ? {} : _a, before = _b.before;
return __awaiter(this, void 0, void 0, function () {
ProjectsApiClient.prototype.getPageMetrics = function (projectId_1) {
return __awaiter(this, arguments, void 0, function (projectId, _a) {
var _b = _a === void 0 ? {} : _a, before = _b.before;
return __generator(this, function (_c) {
return [2 /*return*/, callApi_1.callApi({
return [2 /*return*/, (0, callApi_1.callApi)({
method: "get",

@@ -263,7 +270,7 @@ path: "/projects/" +

}
PagesApiClient.prototype.analyze = function (pageId, options) {
if (options === void 0) { options = {}; }
return __awaiter(this, void 0, void 0, function () {
PagesApiClient.prototype.analyze = function (pageId_1) {
return __awaiter(this, arguments, void 0, function (pageId, options) {
var inferredBuildInfo, _a, _b, analysis, resultUrl;
var _this = this;
if (options === void 0) { options = {}; }
return __generator(this, function (_c) {

@@ -273,3 +280,3 @@ switch (_c.label) {

if (!options.inferBuildInfo) return [3 /*break*/, 2];
return [4 /*yield*/, inferBuildInfo_1.inferBuildInfo({
return [4 /*yield*/, (0, inferBuildInfo_1.inferBuildInfo)({
baseBranch: options.baseBranch,

@@ -293,7 +300,7 @@ })];

_a = options;
return [4 /*yield*/, getNgrokTunnelPublicUrl_1.getNgrokTunnelPublicUrl(options.ngrokWebPort)];
return [4 /*yield*/, (0, getNgrokTunnelPublicUrl_1.getNgrokTunnelPublicUrl)(options.ngrokWebPort)];
case 3:
_a.baseUrl = _c.sent();
_c.label = 4;
case 4: return [4 /*yield*/, callApi_1.callApi({
case 4: return [4 /*yield*/, (0, callApi_1.callApi)({
method: "post",

@@ -315,7 +322,32 @@ path: "/page/" + pageId + "/analyze",

};
PagesApiClient.prototype.analyzeBulk = function (pageIds) {
return __awaiter(this, void 0, void 0, function () {
var results;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, callApi_1.callApi)({
method: "post",
path: "/page/analyzeBulk",
body: { pageIds: pageIds },
explicitApiKeyParam: this.apiKey,
})];
case 1:
results = _a.sent();
return [2 /*return*/, {
waitForResult: function () { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, waitForAnalysisResult(results.map(function (r) { return parseFloat(r.analysis.id); }), this.apiKey)];
});
}); },
}];
}
});
});
};
PagesApiClient.prototype.create = function (projectId, _a) {
var name = _a.name, url = _a.url, testScheduleName = _a.testScheduleName, deviceName = _a.deviceName, region = _a.region, advancedSettings = _a.advancedSettings, tags = _a.tags;
return callApi_1.callApi({
return (0, callApi_1.callApi)({
method: "post",
path: "/projects/" + projectId + "/pages",
path: "/projects/".concat(projectId, "/pages"),
body: {

@@ -335,5 +367,5 @@ name: name,

var name = _a.name, url = _a.url, testScheduleName = _a.testScheduleName, deviceName = _a.deviceName, region = _a.region, advancedSettings = _a.advancedSettings, tags = _a.tags;
return callApi_1.callApi({
return (0, callApi_1.callApi)({
method: "patch",
path: "/pages/" + pageId,
path: "/pages/".concat(pageId),
body: {

@@ -352,3 +384,3 @@ name: name,

PagesApiClient.prototype.delete = function (pageId) {
return callApi_1.callApi({
return (0, callApi_1.callApi)({
method: "delete",

@@ -367,5 +399,5 @@ path: "/pages/" + pageId,

}
return callApi_1.callApi({
return (0, callApi_1.callApi)({
method: "get",
path: "/page/" + pageId + "/metrics?" +
path: "/page/".concat(pageId, "/metrics?") +
queryString.stringify({

@@ -394,5 +426,5 @@ from: from.toISOString(),

switch (_a.label) {
case 0: return [4 /*yield*/, callApi_1.callApi({
case 0: return [4 /*yield*/, (0, callApi_1.callApi)({
method: "get",
path: "/project/" + projectId + "/annotations",
path: "/project/".concat(projectId, "/annotations"),
explicitApiKeyParam: this.apiKey,

@@ -409,10 +441,10 @@ })];

};
AnnotationsApiClient.prototype.create = function (projectId, _a) {
var title = _a.title, description = _a.description, pageFilter = _a.pageFilter, date = _a.date;
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, callApi_1.callApi({
AnnotationsApiClient.prototype.create = function (projectId_1, _a) {
return __awaiter(this, arguments, void 0, function (projectId, _b) {
var title = _b.title, description = _b.description, pageFilter = _b.pageFilter, date = _b.date;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, (0, callApi_1.callApi)({
method: "post",
path: "/project/" + projectId + "/annotation",
path: "/project/".concat(projectId, "/annotation"),
body: {

@@ -426,3 +458,3 @@ title: title,

})];
case 1: return [2 /*return*/, _b.sent()];
case 1: return [2 /*return*/, _c.sent()];
}

@@ -429,0 +461,0 @@ });

@@ -17,3 +17,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -47,3 +47,3 @@ if (y = 0, t) op = [op[0] & 2, t.value];

switch (_a.label) {
case 0: return [4 /*yield*/, axios_1.default({
case 0: return [4 /*yield*/, (0, axios_1.default)({
method: "get",

@@ -50,0 +50,0 @@ url: "http://localhost:" + ngrokAdminPort + "/api/tunnels",

@@ -29,3 +29,3 @@ "use strict";

try {
var output = child_process_1.execSync("git log --format=oneline -n 1 " + commitHash).toString();
var output = (0, child_process_1.execSync)("git log --format=oneline -n 1 ".concat(commitHash)).toString();
var commitHashRegex = /[0-9a-z]{20}[0-9a-z]+/;

@@ -32,0 +32,0 @@ if (commitHashRegex.test(output)) {

@@ -14,2 +14,23 @@ export interface AnalysisResultObject {

};
page?: PageObject;
}
export interface PageObject {
advancedSettings: string[];
device: {
bandwidthKbps: number;
cpuThrottling: number;
formFactor: string;
id: string;
name: string;
rtt: number;
};
id: string;
name: string;
region: string;
tags: string[];
testSchedules: {
id: string;
name: string;
}[];
url: string;
}

@@ -17,3 +17,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -107,3 +107,3 @@ if (y = 0, t) op = [op[0] & 2, t.value];

userFlowReplacements: options.userFlowReplacement,
}, lodash_1.pick(options, [
}, (0, lodash_1.pick)(options, [
"pageId",

@@ -153,4 +153,4 @@ "waitForResult",

analysis = _a.sent();
console.log("| Repo: " + analysis.repoOwner + "/" + analysis.repoName);
console.log("| Commit: " + (analysis.commitHash || "(no commit hash)") + " " + (analysis.buildTitle || "(no build title)"));
console.log("| Repo: ".concat(analysis.repoOwner, "/").concat(analysis.repoName));
console.log("| Commit: ".concat(analysis.commitHash || "(no commit hash)", " ").concat(analysis.buildTitle || "(no build title)"));
console.log("When the result is ready you can see it here: " + analysis.url);

@@ -157,0 +157,0 @@ result = null;

@@ -37,3 +37,3 @@ import * as envCi from "env-ci";

}
} catch (err) {}
} catch (err: any) {}
}

@@ -40,0 +40,0 @@

{
"name": "debugbear",
"version": "2.1.4",
"description": "Use DebugBear to test web performance as part of your Continuous Integration process.",
"version": "2.1.5",
"description": "Use DebugBear to run page speed tests and retrieve Core Web Vitals data.",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"build-watch": "tsc --watch"
},
"scripts": {},
"author": "Matt Zeunert",
"license": "MIT",
"dependencies": {
"axios": "^0.21.1",
"axios": "^1.6.0",
"commander": "^7.2.0",

@@ -20,4 +17,3 @@ "env-ci": "^5.0.2",

"devDependencies": {
"@types/node": "^10.17.28",
"typescript": "^4.3.2"
"@types/node": "^10.17.28"
},

@@ -24,0 +20,0 @@ "bin": {

@@ -14,2 +14,24 @@ export interface AnalysisResultObject {

};
page?: PageObject;
}
export interface PageObject {
advancedSettings: string[];
device: {
bandwidthKbps: number;
cpuThrottling: number;
formFactor: string;
id: string;
name: string;
rtt: number;
};
id: string;
name: string;
region: string;
tags: string[];
testSchedules: {
id: string;
name: string;
}[];
url: string;
}

@@ -0,4 +1,4 @@

import { AnalysisResultObject } from "ResponseTypes";
import * as commander from "commander";
import { pick } from "lodash";
import { AnalysisResultObject } from "ResponseTypes";
import { DebugBear } from "./DebugBear";

@@ -108,3 +108,3 @@

);
} catch (err) {
} catch (err: any) {
console.log("\nCLI command failed");

@@ -111,0 +111,0 @@ console.log(err && err.message);

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