Migrate metrics
Summary: Had to mess with the tagged union we had, to distinguish based on a string rather a bool which is a bit rubbish. Reviewed By: danielbuechele Differential Revision: D16764797 fbshipit-source-id: c33536f17b0705ca40abef8448802f9961c4c114
This commit is contained in:
committed by
Facebook Github Bot
parent
46e0abecdf
commit
2a34125413
@@ -20,7 +20,7 @@ import React, {Component} from 'react';
|
|||||||
import {setExportStatusComponent, unsetShare} from '../reducers/application';
|
import {setExportStatusComponent, unsetShare} from '../reducers/application';
|
||||||
import {Logger} from '../fb-interfaces/Logger.js';
|
import {Logger} from '../fb-interfaces/Logger.js';
|
||||||
import {Idler} from '../utils/Idler';
|
import {Idler} from '../utils/Idler';
|
||||||
import {shareFlipperData} from '../fb-stubs/user';
|
import {shareFlipperData, DataExportResult} from '../fb-stubs/user';
|
||||||
import {exportStore, EXPORT_FLIPPER_TRACE_EVENT} from '../utils/exportData';
|
import {exportStore, EXPORT_FLIPPER_TRACE_EVENT} from '../utils/exportData';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {clipboard} from 'electron';
|
import {clipboard} from 'electron';
|
||||||
@@ -139,8 +139,8 @@ export default class ShareSheet extends Component<Props, State> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.setState({errorArray, result});
|
this.setState({errorArray, result});
|
||||||
if (result.flipperUrl) {
|
if ((result as DataExportResult).flipperUrl) {
|
||||||
clipboard.writeText(String(result.flipperUrl));
|
clipboard.writeText(String((result as DataExportResult).flipperUrl));
|
||||||
new Notification('Sharable Flipper trace created', {
|
new Notification('Sharable Flipper trace created', {
|
||||||
body: 'URL copied to clipboard',
|
body: 'URL copied to clipboard',
|
||||||
requireInteraction: true,
|
requireInteraction: true,
|
||||||
|
|||||||
@@ -17,23 +17,24 @@ export function logoutUser(): Promise<void> {
|
|||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function shareFlipperData(
|
export type DataExportResult = {
|
||||||
trace: string,
|
|
||||||
): Promise<
|
|
||||||
| {
|
|
||||||
id: string;
|
id: string;
|
||||||
os: 'string';
|
os: 'string';
|
||||||
deviceType: string;
|
deviceType: string;
|
||||||
plugins: string[];
|
plugins: string[];
|
||||||
fileUrl: string;
|
fileUrl: string;
|
||||||
flipperUrl: string;
|
flipperUrl: string;
|
||||||
}
|
};
|
||||||
| {
|
|
||||||
|
export type DataExportError = {
|
||||||
error: string;
|
error: string;
|
||||||
error_class: string;
|
error_class: string;
|
||||||
stacktrace: string;
|
stacktrace: string;
|
||||||
}
|
};
|
||||||
> {
|
|
||||||
|
export async function shareFlipperData(
|
||||||
|
trace: string,
|
||||||
|
): Promise<DataExportError | DataExportResult> {
|
||||||
new Notification('Feature not implemented');
|
new Notification('Feature not implemented');
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,13 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {getInstance} from '../fb-stubs/Logger.tsx';
|
import {getInstance} from '../fb-stubs/Logger';
|
||||||
import {CancelledPromiseError} from './errors.tsx';
|
import {CancelledPromiseError} from './errors';
|
||||||
|
|
||||||
|
type Result =
|
||||||
|
| {kind: 'success'}
|
||||||
|
| {kind: 'cancelled'}
|
||||||
|
| {kind: 'failure'; supportedOperation: boolean; error: any};
|
||||||
|
|
||||||
export class UnsupportedError extends Error {
|
export class UnsupportedError extends Error {
|
||||||
constructor(message: string) {
|
constructor(message: string) {
|
||||||
@@ -27,17 +32,17 @@ export function reportPlatformFailures<T>(
|
|||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
return promise.then(
|
return promise.then(
|
||||||
fulfilledValue => {
|
fulfilledValue => {
|
||||||
logPlatformSuccessRate(name, {isSuccess: true});
|
logPlatformSuccessRate(name, {kind: 'success'});
|
||||||
return fulfilledValue;
|
return fulfilledValue;
|
||||||
},
|
},
|
||||||
rejectionReason => {
|
rejectionReason => {
|
||||||
if (rejectionReason instanceof CancelledPromiseError) {
|
if (rejectionReason instanceof CancelledPromiseError) {
|
||||||
logPlatformSuccessRate(name, {
|
logPlatformSuccessRate(name, {
|
||||||
isCancelled: true,
|
kind: 'cancelled',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
logPlatformSuccessRate(name, {
|
logPlatformSuccessRate(name, {
|
||||||
isSuccess: false,
|
kind: 'failure',
|
||||||
supportedOperation: !(rejectionReason instanceof UnsupportedError),
|
supportedOperation: !(rejectionReason instanceof UnsupportedError),
|
||||||
error: rejectionReason,
|
error: rejectionReason,
|
||||||
});
|
});
|
||||||
@@ -61,17 +66,17 @@ export function reportPluginFailures<T>(
|
|||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
return promise.then(
|
return promise.then(
|
||||||
fulfilledValue => {
|
fulfilledValue => {
|
||||||
logPluginSuccessRate(name, plugin, {isSuccess: true});
|
logPluginSuccessRate(name, plugin, {kind: 'success'});
|
||||||
return fulfilledValue;
|
return fulfilledValue;
|
||||||
},
|
},
|
||||||
rejectionReason => {
|
rejectionReason => {
|
||||||
if (rejectionReason instanceof CancelledPromiseError) {
|
if (rejectionReason instanceof CancelledPromiseError) {
|
||||||
logPluginSuccessRate(name, plugin, {
|
logPlatformSuccessRate(name, {
|
||||||
isCancelled: true,
|
kind: 'cancelled',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
logPluginSuccessRate(name, plugin, {
|
logPlatformSuccessRate(name, {
|
||||||
isSuccess: false,
|
kind: 'failure',
|
||||||
supportedOperation: !(rejectionReason instanceof UnsupportedError),
|
supportedOperation: !(rejectionReason instanceof UnsupportedError),
|
||||||
error: rejectionReason,
|
error: rejectionReason,
|
||||||
});
|
});
|
||||||
@@ -91,11 +96,11 @@ export function tryCatchReportPlatformFailures<T>(
|
|||||||
): T {
|
): T {
|
||||||
try {
|
try {
|
||||||
const result = closure();
|
const result = closure();
|
||||||
logPlatformSuccessRate(name, {isSuccess: true});
|
logPlatformSuccessRate(name, {kind: 'success'});
|
||||||
return result;
|
return result;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logPlatformSuccessRate(name, {
|
logPlatformSuccessRate(name, {
|
||||||
isSuccess: false,
|
kind: 'failure',
|
||||||
supportedOperation: !(e instanceof UnsupportedError),
|
supportedOperation: !(e instanceof UnsupportedError),
|
||||||
error: e,
|
error: e,
|
||||||
});
|
});
|
||||||
@@ -103,15 +108,10 @@ export function tryCatchReportPlatformFailures<T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Result =
|
|
||||||
| {isSuccess: true}
|
|
||||||
| {isCancelled: true}
|
|
||||||
| {isSuccess: false, supportedOperation: boolean, error: any};
|
|
||||||
|
|
||||||
function logPlatformSuccessRate(name: string, result: Result) {
|
function logPlatformSuccessRate(name: string, result: Result) {
|
||||||
if (result.isSuccess) {
|
if (result.kind === 'success') {
|
||||||
getInstance().track('success-rate', name, {value: 1});
|
getInstance().track('success-rate', name, {value: 1});
|
||||||
} else if (result.isCancelled) {
|
} else if (result.kind === 'cancelled') {
|
||||||
getInstance().track('operation-cancelled', name);
|
getInstance().track('operation-cancelled', name);
|
||||||
} else {
|
} else {
|
||||||
getInstance().track('success-rate', name, {
|
getInstance().track('success-rate', name, {
|
||||||
@@ -123,9 +123,9 @@ function logPlatformSuccessRate(name: string, result: Result) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function logPluginSuccessRate(name: string, plugin: string, result: Result) {
|
function logPluginSuccessRate(name: string, plugin: string, result: Result) {
|
||||||
if (result.isSuccess) {
|
if (result.kind === 'success') {
|
||||||
getInstance().track('success-rate', name, {value: 1}, plugin);
|
getInstance().track('success-rate', name, {value: 1}, plugin);
|
||||||
} else if (result.isCancelled) {
|
} else if (result.kind === 'cancelled') {
|
||||||
getInstance().track('operation-cancelled', name, undefined, plugin);
|
getInstance().track('operation-cancelled', name, undefined, plugin);
|
||||||
} else {
|
} else {
|
||||||
getInstance().track(
|
getInstance().track(
|
||||||
Reference in New Issue
Block a user