( argv: string[], options: Record<string, unknown>, func: (...args: any[]) => any, )
| 42 | |
| 43 | // wrap a function in this call to get a telemetry hit including how long it took |
| 44 | export const timedTelemetry = async ( |
| 45 | argv: string[], |
| 46 | options: Record<string, unknown>, |
| 47 | func: (...args: any[]) => any, |
| 48 | ) => { |
| 49 | if (process.env.REDWOOD_DISABLE_TELEMETRY) { |
| 50 | return func.call(this) |
| 51 | } |
| 52 | |
| 53 | const start = new Date() |
| 54 | const result = await func.call(this) |
| 55 | const duration = new Date().getTime() - start.getTime() |
| 56 | |
| 57 | spawnProcess( |
| 58 | '--argv', |
| 59 | JSON.stringify(argv), |
| 60 | '--duration', |
| 61 | duration.toString(), |
| 62 | '--type', |
| 63 | JSON.stringify(options.type), |
| 64 | ) |
| 65 | |
| 66 | return result |
| 67 | } |
| 68 | |
| 69 | export const errorTelemetry = async (argv: string[], error: any) => { |
| 70 | if (process.env.REDWOOD_DISABLE_TELEMETRY) { |
no test coverage detected