MCPcopy
hub / github.com/redwoodjs/graphql / timedTelemetry

Function timedTelemetry

packages/telemetry/src/telemetry.ts:44–67  ·  view source on GitHub ↗
(
  argv: string[],
  options: Record<string, unknown>,
  func: (...args: any[]) => any,
)

Source from the content-addressed store, hash-verified

42
43// wrap a function in this call to get a telemetry hit including how long it took
44export 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
69export const errorTelemetry = async (argv: string[], error: any) => {
70 if (process.env.REDWOOD_DISABLE_TELEMETRY) {

Callers 2

handlerFunction · 0.90
handlerFunction · 0.90

Calls 1

spawnProcessFunction · 0.85

Tested by

no test coverage detected