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 {Logger} from '../fb-interfaces/Logger.js';
|
||||
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 PropTypes from 'prop-types';
|
||||
import {clipboard} from 'electron';
|
||||
@@ -139,8 +139,8 @@ export default class ShareSheet extends Component<Props, State> {
|
||||
);
|
||||
|
||||
this.setState({errorArray, result});
|
||||
if (result.flipperUrl) {
|
||||
clipboard.writeText(String(result.flipperUrl));
|
||||
if ((result as DataExportResult).flipperUrl) {
|
||||
clipboard.writeText(String((result as DataExportResult).flipperUrl));
|
||||
new Notification('Sharable Flipper trace created', {
|
||||
body: 'URL copied to clipboard',
|
||||
requireInteraction: true,
|
||||
|
||||
@@ -17,23 +17,24 @@ export function logoutUser(): Promise<void> {
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
export async function shareFlipperData(
|
||||
trace: string,
|
||||
): Promise<
|
||||
| {
|
||||
export type DataExportResult = {
|
||||
id: string;
|
||||
os: 'string';
|
||||
deviceType: string;
|
||||
plugins: string[];
|
||||
fileUrl: string;
|
||||
flipperUrl: string;
|
||||
}
|
||||
| {
|
||||
};
|
||||
|
||||
export type DataExportError = {
|
||||
error: string;
|
||||
error_class: string;
|
||||
stacktrace: string;
|
||||
}
|
||||
> {
|
||||
};
|
||||
|
||||
export async function shareFlipperData(
|
||||
trace: string,
|
||||
): Promise<DataExportError | DataExportResult> {
|
||||
new Notification('Feature not implemented');
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
@@ -5,8 +5,13 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {getInstance} from '../fb-stubs/Logger.tsx';
|
||||
import {CancelledPromiseError} from './errors.tsx';
|
||||
import {getInstance} from '../fb-stubs/Logger';
|
||||
import {CancelledPromiseError} from './errors';
|
||||
|
||||
type Result =
|
||||
| {kind: 'success'}
|
||||
| {kind: 'cancelled'}
|
||||
| {kind: 'failure'; supportedOperation: boolean; error: any};
|
||||
|
||||
export class UnsupportedError extends Error {
|
||||
constructor(message: string) {
|
||||
@@ -27,17 +32,17 @@ export function reportPlatformFailures<T>(
|
||||
): Promise<T> {
|
||||
return promise.then(
|
||||
fulfilledValue => {
|
||||
logPlatformSuccessRate(name, {isSuccess: true});
|
||||
logPlatformSuccessRate(name, {kind: 'success'});
|
||||
return fulfilledValue;
|
||||
},
|
||||
rejectionReason => {
|
||||
if (rejectionReason instanceof CancelledPromiseError) {
|
||||
logPlatformSuccessRate(name, {
|
||||
isCancelled: true,
|
||||
kind: 'cancelled',
|
||||
});
|
||||
} else {
|
||||
logPlatformSuccessRate(name, {
|
||||
isSuccess: false,
|
||||
kind: 'failure',
|
||||
supportedOperation: !(rejectionReason instanceof UnsupportedError),
|
||||
error: rejectionReason,
|
||||
});
|
||||
@@ -61,17 +66,17 @@ export function reportPluginFailures<T>(
|
||||
): Promise<T> {
|
||||
return promise.then(
|
||||
fulfilledValue => {
|
||||
logPluginSuccessRate(name, plugin, {isSuccess: true});
|
||||
logPluginSuccessRate(name, plugin, {kind: 'success'});
|
||||
return fulfilledValue;
|
||||
},
|
||||
rejectionReason => {
|
||||
if (rejectionReason instanceof CancelledPromiseError) {
|
||||
logPluginSuccessRate(name, plugin, {
|
||||
isCancelled: true,
|
||||
logPlatformSuccessRate(name, {
|
||||
kind: 'cancelled',
|
||||
});
|
||||
} else {
|
||||
logPluginSuccessRate(name, plugin, {
|
||||
isSuccess: false,
|
||||
logPlatformSuccessRate(name, {
|
||||
kind: 'failure',
|
||||
supportedOperation: !(rejectionReason instanceof UnsupportedError),
|
||||
error: rejectionReason,
|
||||
});
|
||||
@@ -91,11 +96,11 @@ export function tryCatchReportPlatformFailures<T>(
|
||||
): T {
|
||||
try {
|
||||
const result = closure();
|
||||
logPlatformSuccessRate(name, {isSuccess: true});
|
||||
logPlatformSuccessRate(name, {kind: 'success'});
|
||||
return result;
|
||||
} catch (e) {
|
||||
logPlatformSuccessRate(name, {
|
||||
isSuccess: false,
|
||||
kind: 'failure',
|
||||
supportedOperation: !(e instanceof UnsupportedError),
|
||||
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) {
|
||||
if (result.isSuccess) {
|
||||
if (result.kind === 'success') {
|
||||
getInstance().track('success-rate', name, {value: 1});
|
||||
} else if (result.isCancelled) {
|
||||
} else if (result.kind === 'cancelled') {
|
||||
getInstance().track('operation-cancelled', name);
|
||||
} else {
|
||||
getInstance().track('success-rate', name, {
|
||||
@@ -123,9 +123,9 @@ function logPlatformSuccessRate(name: 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);
|
||||
} else if (result.isCancelled) {
|
||||
} else if (result.kind === 'cancelled') {
|
||||
getInstance().track('operation-cancelled', name, undefined, plugin);
|
||||
} else {
|
||||
getInstance().track(
|
||||
Reference in New Issue
Block a user