Add FBOS version to rollbar errors

pull/736/head
Rick Carlino 2018-03-19 10:25:42 -05:00
parent 291b2a3ccb
commit bcbbda2245
7 changed files with 1631 additions and 47 deletions

View File

@ -90,6 +90,7 @@
"typescript": "2.7.2",
"url-loader": "^0.6.2",
"webpack": "^3.8.1",
"webpack-cli": "^2.0.12",
"webpack-uglify-js-plugin": "^1.1.9",
"weinre": "^2.0.0-pre-I0Z7U9OV",
"which": "^1.3.0",

7
typings/index.d.ts vendored
View File

@ -5,10 +5,13 @@
declare var globalConfig: { [k: string]: string };
interface Rollbar {
error?(msg: string): void;
error?(msg: string | object): void;
global(config: object): void;
}
declare var Rollbar: Rollbar | undefined;
interface Window {
Rollbar: Rollbar | undefined;
}
declare namespace jest {
export interface Matchers<R> {

View File

@ -1,5 +1,5 @@
import * as React from "react";
import { get, noop } from "lodash";
import { get } from "lodash";
import { Page } from "./ui/index";
import { Session } from "./session";
@ -9,8 +9,9 @@ export function crashPage(error: object) {
render() {
const stack = get(error, "stack", "No stack.");
const message = get(error, "message", "No message available.");
const Rollbar = get(window, "Rollbar", { error: noop });
Rollbar.error(error);
window.Rollbar &&
window.Rollbar.error &&
window.Rollbar.error(error);
const msg = JSON.stringify({ message, stack });
return <Page>

View File

@ -24,7 +24,7 @@ import { FirmwareConfig } from "../config_storage/firmware_configs";
const ON = 1, OFF = 0;
export type ConfigKey = keyof McuParams;
export const EXPECTED_MAJOR = 5;
export const EXPECTED_MAJOR = 6;
export const EXPECTED_MINOR = 0;
export const FEATURE_MIN_VERSIONS_URL =
"https://raw.githubusercontent.com/FarmBot/farmbot_os/staging/" +

View File

@ -35,9 +35,8 @@ export function bail(message: string): never {
}
export const catchErrors = (error: Error) => {
if (_.get(window, "Rollbar.error")) {
// tslint:disable-next-line:no-any
Rollbar && Rollbar.error && Rollbar.error(error as any);
if (window.Rollbar && window.Rollbar.error) {
window.Rollbar.error(error);
} else {
throw error;
}

View File

@ -107,6 +107,10 @@ export function shouldDisplay(
const target = override || current;
if (isString(target)) {
const min = (lookupData || {})[feature] || MinVersionOverride.NEVER;
console.log("CHANGING ROLLBAR FBOS VERSION TO " + (target || "NONE"));
window.Rollbar && window
.Rollbar
.global({ payload: { client: { javascript: { fbos_version: target } } } });
switch (semverCompare(target, min)) {
case SemverResult.LEFT_IS_GREATER:
case SemverResult.EQUAL:
@ -121,8 +125,7 @@ export function shouldDisplay(
/**
* Compare the current FBOS version in the bot's
* state with the API's fbos_version string and return the greatest version.
*/
* state with the API's fbos_version string and return the greatest version. */
export function determineInstalledOsVersion(
bot: BotState, device: TaggedDevice | undefined): string | undefined {
const fromBotState = bot.hardware.informational_settings.controller_version;

1649
yarn.lock

File diff suppressed because it is too large Load Diff