debugbear
Advanced tools
Comparing version 2.0.11 to 2.0.12
@@ -13,3 +13,3 @@ import * as request from "request-promise"; | ||
body, | ||
explicitApiKeyParam | ||
explicitApiKeyParam, | ||
}: { | ||
@@ -28,4 +28,4 @@ method: string; | ||
"X-Api-Key": explicitApiKeyParam, | ||
"Cli-Version": require("../package.json").version | ||
} | ||
"Cli-Version": require("../package.json").version, | ||
}, | ||
}; | ||
@@ -32,0 +32,0 @@ if (process.env.DEBUG) { |
@@ -30,3 +30,3 @@ import { callApi } from "./callApi"; | ||
...this, | ||
_apiClient: undefined | ||
_apiClient: undefined, | ||
}; | ||
@@ -43,3 +43,3 @@ } | ||
while (!hasFinished) { | ||
await new Promise(resolve => setTimeout(resolve, interval)); | ||
await new Promise((resolve) => setTimeout(resolve, interval)); | ||
timeWaited += interval; | ||
@@ -49,3 +49,3 @@ resp = await callApi({ | ||
path: "/analysis/" + analysisId, | ||
explicitApiKeyParam | ||
explicitApiKeyParam, | ||
}); | ||
@@ -92,2 +92,7 @@ ({ hasFinished } = resp); | ||
interface GetMetricsOptions { | ||
from: Date; | ||
to: Date; | ||
} | ||
interface PageObject { | ||
@@ -120,5 +125,5 @@ id: string; | ||
path: "/projects", | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
return res.map(project => { | ||
return res.map((project) => { | ||
return new ProjectObject(this._apiClient, project); | ||
@@ -133,5 +138,5 @@ }); | ||
body: { | ||
name | ||
name, | ||
}, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
@@ -145,3 +150,3 @@ return new ProjectObject(this._apiClient, page); | ||
path: "/projects/" + projectId, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
@@ -159,3 +164,3 @@ } | ||
body: { email }, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
@@ -168,3 +173,3 @@ } | ||
path: `/projects/${projectId}/collaborators`, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
@@ -209,3 +214,3 @@ } | ||
let inferredBuildInfo = await inferBuildInfo({ | ||
baseBranch: options.baseBranch | ||
baseBranch: options.baseBranch, | ||
}); | ||
@@ -234,3 +239,3 @@ | ||
body: options, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
@@ -244,3 +249,3 @@ | ||
return waitForAnalysisResult(analysis.id, this.apiKey); | ||
} | ||
}, | ||
}; | ||
@@ -261,5 +266,5 @@ } | ||
formFactor, | ||
region | ||
region, | ||
}, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
@@ -272,5 +277,17 @@ } | ||
path: "/pages/" + pageId, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
} | ||
getMetrics(pageId: string, { from, to }: GetMetricsOptions): Promise<any[]> { | ||
return callApi({ | ||
method: "GET", | ||
path: `/page/${pageId}/metrics`, | ||
body: { | ||
from, | ||
to, | ||
}, | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
} | ||
} |
"use strict"; | ||
var __awaiter = | ||
(this && this.__awaiter) || | ||
function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function rejected(value) { | ||
try { | ||
step(generator["throw"](value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function step(result) { | ||
result.done | ||
? resolve(result.value) | ||
: new P(function (resolve) { | ||
resolve(result.value); | ||
}).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = | ||
(this && this.__generator) || | ||
function (thisArg, body) { | ||
var _ = { | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [], | ||
}, | ||
f, | ||
y, | ||
t, | ||
g; | ||
return ( | ||
(g = { next: verb(0), throw: verb(1), return: verb(2) }), | ||
typeof Symbol === "function" && | ||
(g[Symbol.iterator] = function () { | ||
return this; | ||
}), | ||
g | ||
); | ||
function verb(n) { | ||
return function (v) { | ||
return step([n, v]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) | ||
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; | ||
if (((y = 0), t)) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { value: op[1], done: false }; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [0]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if ( | ||
!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && | ||
(op[0] === 6 || op[0] === 2) | ||
) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [6, e]; | ||
y = 0; | ||
} finally { | ||
f = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var DebugBear_1 = require("./DebugBear"); | ||
function analyzePage(options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var dbbClient, analysis; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!process.env.DEBUGBEAR_API_KEY) { | ||
throw Error( | ||
"Need to provide API key via DEBUGBEAR_API_KEY environment variable" | ||
); | ||
} | ||
dbbClient = new DebugBear_1.DebugBear(process.env.DEBUGBEAR_API_KEY); | ||
if (!options) { | ||
console.log( | ||
"The pageId option is required. You can find the page ID in the top right corner on the results page." | ||
); | ||
} | ||
return [ | ||
4 /*yield*/, | ||
dbbClient.pages.analyze(options.pageId, options), | ||
]; | ||
case 1: | ||
analysis = _a.sent(); | ||
if (options.isCli) { | ||
console.log( | ||
"When the result is ready you can see it here: " + analysis.url | ||
); | ||
} | ||
if (!options.waitForResult) return [3 /*break*/, 3]; | ||
if (options.isCli) { | ||
console.log("Waiting for result"); | ||
} | ||
return [4 /*yield*/, analysis.waitForResult()]; | ||
case 2: | ||
_a.sent(); | ||
if (options.isCli) { | ||
console.log("Analysis complete"); | ||
} | ||
_a.label = 3; | ||
case 3: | ||
return [ | ||
2 /*return*/, | ||
{ | ||
resultUrl: analysis.url, | ||
}, | ||
]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.analyzePage = analyzePage; |
export declare class ApiClient { | ||
pages: PagesApiClient; | ||
projects: ProjectsApiClient; | ||
collaborators: CollaboratorsApiClient; | ||
constructor(apiKey: string); | ||
pages: PagesApiClient; | ||
projects: ProjectsApiClient; | ||
collaborators: CollaboratorsApiClient; | ||
constructor(apiKey: string); | ||
} | ||
declare class ProjectsApiClient { | ||
private apiKey; | ||
constructor(apiKey: string); | ||
get(): Promise<any>; | ||
create({ name }: { | ||
name: any; | ||
}): Promise<any>; | ||
private apiKey; | ||
constructor(apiKey: string); | ||
get(): Promise<any>; | ||
create({ name }: { name: any }): Promise<any>; | ||
} | ||
declare class CollaboratorsApiClient { | ||
private apiKey; | ||
constructor(apiKey: string); | ||
create(projectId: any, { email }: { | ||
email: string; | ||
}): Promise<any>; | ||
get(projectId: any): Promise<any>; | ||
private apiKey; | ||
constructor(apiKey: string); | ||
create( | ||
projectId: any, | ||
{ | ||
email, | ||
}: { | ||
email: string; | ||
} | ||
): Promise<any>; | ||
get(projectId: any): Promise<any>; | ||
} | ||
declare class PagesApiClient { | ||
private apiKey; | ||
constructor(apiKey: string); | ||
analyze(pageId: number): Promise<{ | ||
resultUrl: any; | ||
}>; | ||
create(projectId: number, { name, url, everyNHours, formFactor, region }: { | ||
name: string; | ||
url: string; | ||
everyNHours?: number; | ||
formFactor?: "mobile" | "desktop"; | ||
region?: string; | ||
}): Promise<any>; | ||
private apiKey; | ||
constructor(apiKey: string); | ||
analyze( | ||
pageId: number | ||
): Promise<{ | ||
resultUrl: any; | ||
}>; | ||
create( | ||
projectId: number, | ||
{ | ||
name, | ||
url, | ||
everyNHours, | ||
formFactor, | ||
region, | ||
}: { | ||
name: string; | ||
url: string; | ||
everyNHours?: number; | ||
formFactor?: "mobile" | "desktop"; | ||
region?: string; | ||
} | ||
): Promise<any>; | ||
} | ||
export {}; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var __awaiter = | ||
(this && this.__awaiter) || | ||
function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
function fulfilled(value) { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function rejected(value) { | ||
try { | ||
step(generator["throw"](value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function step(result) { | ||
result.done | ||
? resolve(result.value) | ||
: new P(function (resolve) { | ||
resolve(result.value); | ||
}).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
}; | ||
var __generator = | ||
(this && this.__generator) || | ||
function (thisArg, body) { | ||
var _ = { | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [], | ||
}, | ||
f, | ||
y, | ||
t, | ||
g; | ||
return ( | ||
(g = { next: verb(0), throw: verb(1), return: verb(2) }), | ||
typeof Symbol === "function" && | ||
(g[Symbol.iterator] = function () { | ||
return this; | ||
}), | ||
g | ||
); | ||
function verb(n) { | ||
return function (v) { | ||
return step([n, v]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) 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; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) | ||
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; | ||
if (((y = 0), t)) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { value: op[1], done: false }; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [0]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if ( | ||
!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && | ||
(op[0] === 6 || op[0] === 2) | ||
) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [6, e]; | ||
y = 0; | ||
} finally { | ||
f = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -41,100 +134,115 @@ var analyzePage_1 = require("./analyzePage"); | ||
var ApiClient = /** @class */ (function () { | ||
function ApiClient(apiKey) { | ||
this.pages = new PagesApiClient(apiKey); | ||
this.projects = new ProjectsApiClient(apiKey); | ||
this.collaborators = new CollaboratorsApiClient(apiKey); | ||
} | ||
return ApiClient; | ||
}()); | ||
function ApiClient(apiKey) { | ||
this.pages = new PagesApiClient(apiKey); | ||
this.projects = new ProjectsApiClient(apiKey); | ||
this.collaborators = new CollaboratorsApiClient(apiKey); | ||
} | ||
return ApiClient; | ||
})(); | ||
exports.ApiClient = ApiClient; | ||
var ProjectsApiClient = /** @class */ (function () { | ||
function ProjectsApiClient(apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
ProjectsApiClient.prototype.get = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, callApi_1.callApi({ | ||
method: "GET", | ||
path: "/projects", | ||
explicitApiKeyParam: this.apiKey | ||
})]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2 /*return*/, res]; | ||
} | ||
}); | ||
}); | ||
}; | ||
ProjectsApiClient.prototype.create = function (_a) { | ||
var name = _a.name; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var res; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, callApi_1.callApi({ | ||
method: "POST", | ||
path: "/projects", | ||
body: { | ||
name: name | ||
}, | ||
explicitApiKeyParam: this.apiKey | ||
})]; | ||
case 1: | ||
res = _b.sent(); | ||
return [2 /*return*/, res]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return ProjectsApiClient; | ||
}()); | ||
function ProjectsApiClient(apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
ProjectsApiClient.prototype.get = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
return [ | ||
4 /*yield*/, | ||
callApi_1.callApi({ | ||
method: "GET", | ||
path: "/projects", | ||
explicitApiKeyParam: this.apiKey, | ||
}), | ||
]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2 /*return*/, res]; | ||
} | ||
}); | ||
}); | ||
}; | ||
ProjectsApiClient.prototype.create = function (_a) { | ||
var name = _a.name; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var res; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
return [ | ||
4 /*yield*/, | ||
callApi_1.callApi({ | ||
method: "POST", | ||
path: "/projects", | ||
body: { | ||
name: name, | ||
}, | ||
explicitApiKeyParam: this.apiKey, | ||
}), | ||
]; | ||
case 1: | ||
res = _b.sent(); | ||
return [2 /*return*/, res]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return ProjectsApiClient; | ||
})(); | ||
var CollaboratorsApiClient = /** @class */ (function () { | ||
function CollaboratorsApiClient(apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
CollaboratorsApiClient.prototype.create = function (projectId, _a) { | ||
var email = _a.email; | ||
return callApi_1.callApi({ | ||
method: "POST", | ||
path: "/projects/" + projectId + "/collaborators", | ||
body: { email: email }, | ||
explicitApiKeyParam: this.apiKey | ||
}); | ||
}; | ||
CollaboratorsApiClient.prototype.get = function (projectId) { | ||
return callApi_1.callApi({ | ||
method: "GET", | ||
path: "/projects/" + projectId + "/collaborators", | ||
explicitApiKeyParam: this.apiKey | ||
}); | ||
}; | ||
return CollaboratorsApiClient; | ||
}()); | ||
function CollaboratorsApiClient(apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
CollaboratorsApiClient.prototype.create = function (projectId, _a) { | ||
var email = _a.email; | ||
return callApi_1.callApi({ | ||
method: "POST", | ||
path: "/projects/" + projectId + "/collaborators", | ||
body: { email: email }, | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
}; | ||
CollaboratorsApiClient.prototype.get = function (projectId) { | ||
return callApi_1.callApi({ | ||
method: "GET", | ||
path: "/projects/" + projectId + "/collaborators", | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
}; | ||
return CollaboratorsApiClient; | ||
})(); | ||
var PagesApiClient = /** @class */ (function () { | ||
function PagesApiClient(apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
PagesApiClient.prototype.analyze = function (pageId) { | ||
// todo: should be the other way round, the analyzePage function should call the pages api | ||
return analyzePage_1.analyzePage({ pageId: pageId, explicitApiKeyParam: this.apiKey }); | ||
}; | ||
PagesApiClient.prototype.create = function (projectId, _a) { | ||
var name = _a.name, url = _a.url, everyNHours = _a.everyNHours, formFactor = _a.formFactor, region = _a.region; | ||
return callApi_1.callApi({ | ||
method: "POST", | ||
path: "/projects/" + projectId + "/pages", | ||
body: { | ||
name: name, | ||
url: url, | ||
everyNHours: everyNHours, | ||
formFactor: formFactor, | ||
region: region | ||
}, | ||
explicitApiKeyParam: this.apiKey | ||
}); | ||
}; | ||
return PagesApiClient; | ||
}()); | ||
function PagesApiClient(apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
PagesApiClient.prototype.analyze = function (pageId) { | ||
// todo: should be the other way round, the analyzePage function should call the pages api | ||
return analyzePage_1.analyzePage({ | ||
pageId: pageId, | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
}; | ||
PagesApiClient.prototype.create = function (projectId, _a) { | ||
var name = _a.name, | ||
url = _a.url, | ||
everyNHours = _a.everyNHours, | ||
formFactor = _a.formFactor, | ||
region = _a.region; | ||
return callApi_1.callApi({ | ||
method: "POST", | ||
path: "/projects/" + projectId + "/pages", | ||
body: { | ||
name: name, | ||
url: url, | ||
everyNHours: everyNHours, | ||
formFactor: formFactor, | ||
region: region, | ||
}, | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
}; | ||
return PagesApiClient; | ||
})(); |
@@ -1,2 +0,2 @@ | ||
export declare function callApi({ method, path, body, explicitApiKeyParam }: { | ||
export declare function callApi({ method, path, body, explicitApiKeyParam, }: { | ||
method: string; | ||
@@ -3,0 +3,0 @@ path: string; |
@@ -56,4 +56,4 @@ "use strict"; | ||
"X-Api-Key": explicitApiKeyParam, | ||
"Cli-Version": require("../package.json").version | ||
} | ||
"Cli-Version": require("../package.json").version, | ||
}, | ||
}; | ||
@@ -60,0 +60,0 @@ if (process.env.DEBUG) { |
@@ -30,2 +30,6 @@ import { AnalysisResultObject } from "./ResponseTypes"; | ||
} | ||
interface GetMetricsOptions { | ||
from: Date; | ||
to: Date; | ||
} | ||
interface PageObject { | ||
@@ -93,3 +97,4 @@ id: string; | ||
delete(pageId: string): Promise<any>; | ||
getMetrics(pageId: string, { from, to }: GetMetricsOptions): Promise<any[]>; | ||
} | ||
export {}; |
@@ -107,3 +107,3 @@ "use strict"; | ||
path: "/analysis/" + analysisId, | ||
explicitApiKeyParam: explicitApiKeyParam | ||
explicitApiKeyParam: explicitApiKeyParam, | ||
})]; | ||
@@ -158,3 +158,3 @@ case 3: | ||
path: "/projects", | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
})]; | ||
@@ -180,5 +180,5 @@ case 1: | ||
body: { | ||
name: name | ||
name: name, | ||
}, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
})]; | ||
@@ -198,3 +198,3 @@ case 1: | ||
path: "/projects/" + projectId, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
})]; | ||
@@ -216,3 +216,3 @@ }); | ||
body: { email: email }, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
@@ -224,3 +224,3 @@ }; | ||
path: "/projects/" + projectId + "/collaborators", | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
@@ -244,3 +244,3 @@ }; | ||
return [4 /*yield*/, inferBuildInfo_1.inferBuildInfo({ | ||
baseBranch: options.baseBranch | ||
baseBranch: options.baseBranch, | ||
})]; | ||
@@ -271,3 +271,3 @@ case 1: | ||
body: options, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
})]; | ||
@@ -295,5 +295,5 @@ case 5: | ||
formFactor: formFactor, | ||
region: region | ||
region: region, | ||
}, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
@@ -305,6 +305,18 @@ }; | ||
path: "/pages/" + pageId, | ||
explicitApiKeyParam: this.apiKey | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
}; | ||
PagesApiClient.prototype.getMetrics = function (pageId, _a) { | ||
var from = _a.from, to = _a.to; | ||
return callApi_1.callApi({ | ||
method: "GET", | ||
path: "/page/" + pageId + "/metrics", | ||
body: { | ||
from: from, | ||
to: to, | ||
}, | ||
explicitApiKeyParam: this.apiKey, | ||
}); | ||
}; | ||
return PagesApiClient; | ||
}()); |
@@ -47,3 +47,3 @@ "use strict"; | ||
json: true, | ||
url: "http://localhost:" + ngrokAdminPort + "/api/tunnels" | ||
url: "http://localhost:" + ngrokAdminPort + "/api/tunnels", | ||
})]; | ||
@@ -50,0 +50,0 @@ case 1: |
@@ -42,5 +42,5 @@ "use strict"; | ||
commitBranch: commitBranch, | ||
buildTitle: buildTitle | ||
buildTitle: buildTitle, | ||
}; | ||
} | ||
exports.inferBuildInfo = inferBuildInfo; |
@@ -5,4 +5,4 @@ "use strict"; | ||
function makeApiClient(apiKey) { | ||
return new DebugBear_1.DebugBear(apiKey); | ||
return new DebugBear_1.DebugBear(apiKey); | ||
} | ||
exports.makeApiClient = makeApiClient; |
@@ -94,6 +94,6 @@ "use strict"; | ||
baseUrl: baseUrl, | ||
isCli: true | ||
isCli: true, | ||
}, { | ||
customHeaders: program.customHeader, | ||
userFlowReplacements: program.userFlowReplacement | ||
userFlowReplacements: program.userFlowReplacement, | ||
}, lodash_1.pick(program, [ | ||
@@ -111,3 +111,3 @@ "pageId", | ||
"inferBuildInfo", | ||
"ngrokWebPort" | ||
"ngrokWebPort", | ||
])))]; | ||
@@ -146,4 +146,3 @@ case 2: | ||
console.log("| Repo: " + analysis.repoOwner + "/" + analysis.repoName); | ||
console.log("| Commit: " + (analysis.commitHash || | ||
"(no commit hash)") + " " + (analysis.buildTitle || "(no build title)")); | ||
console.log("| Commit: " + (analysis.commitHash || "(no commit hash)") + " " + (analysis.buildTitle || "(no build title)")); | ||
if (options.isCli) { | ||
@@ -164,3 +163,3 @@ console.log("When the result is ready you can see it here: " + analysis.url); | ||
case 3: return [2 /*return*/, { | ||
resultUrl: analysis.url | ||
resultUrl: analysis.url, | ||
}]; | ||
@@ -167,0 +166,0 @@ } |
"use strict"; | ||
var analyzePage = require("./dist/index").analyzePage; | ||
analyzePage({ | ||
pageId: 185 | ||
pageId: 185, | ||
}); |
@@ -7,6 +7,6 @@ import * as request from "request-promise"; | ||
json: true, | ||
url: "http://localhost:" + ngrokAdminPort + "/api/tunnels" | ||
url: "http://localhost:" + ngrokAdminPort + "/api/tunnels", | ||
}); | ||
const tunnel = tunnelsResponse.tunnels.filter(t => t.proto === "https")[0]; | ||
const tunnel = tunnelsResponse.tunnels.filter((t) => t.proto === "https")[0]; | ||
return tunnel.public_url; | ||
} |
@@ -45,4 +45,4 @@ import * as envCi from "env-ci"; | ||
commitBranch, | ||
buildTitle | ||
buildTitle, | ||
}; | ||
} |
{ | ||
"name": "debugbear", | ||
"version": "2.0.11", | ||
"version": "2.0.12", | ||
"description": "API/CLI for DebugBearAnalyze pages with DebugBear. Analyze pages on demand on demand or as part of your Continuous Integration process.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -55,3 +55,3 @@ import * as commander from "commander"; | ||
) | ||
.action(function(url) { | ||
.action(function (url) { | ||
urlValue = url; | ||
@@ -75,7 +75,7 @@ }) | ||
baseUrl, | ||
isCli: true | ||
isCli: true, | ||
}, | ||
{ | ||
customHeaders: program.customHeader, | ||
userFlowReplacements: program.userFlowReplacement | ||
userFlowReplacements: program.userFlowReplacement, | ||
}, | ||
@@ -94,3 +94,3 @@ pick(program, [ | ||
"inferBuildInfo", | ||
"ngrokWebPort" | ||
"ngrokWebPort", | ||
]) | ||
@@ -123,4 +123,5 @@ ) | ||
console.log( | ||
`| Commit: ${analysis.commitHash || | ||
"(no commit hash)"} ${analysis.buildTitle || "(no build title)"}` | ||
`| Commit: ${analysis.commitHash || "(no commit hash)"} ${ | ||
analysis.buildTitle || "(no build title)" | ||
}` | ||
); | ||
@@ -145,4 +146,4 @@ | ||
return { | ||
resultUrl: analysis.url | ||
resultUrl: analysis.url, | ||
}; | ||
} |
const { analyzePage } = require("./dist/index"); | ||
analyzePage({ | ||
pageId: 185 | ||
pageId: 185, | ||
}); |
64285
1801
7