-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Telemetry.ts
48 lines (44 loc) · 1.22 KB
/
Telemetry.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import type { Command } from '@prisma/internals'
import { getCLIPathHash, getProjectHash } from '@prisma/internals'
import * as checkpoint from 'checkpoint-client'
/**
* $ prisma telemetry
*/
export class Telemetry implements Command {
public static new(): Telemetry {
return new Telemetry()
}
// parse arguments
public async parse(): Promise<string | Error> {
const info = await checkpoint.getInfo()
// SHA256 identifier for the project based on the Prisma schema path
const projectPathHash = await getProjectHash()
// SHA256 of the cli path
const cliPathHash = getCLIPathHash()
const cacheItems = info.cacheItems.map((it) => {
return {
product: it.output.product,
version: it.version,
package: it.output.package,
release_tag: it.output.release_tag,
cli_path: it.cli_path,
cli_path_hash: it.output.cli_path_hash,
last_reminder: it.last_reminder,
cached_at: it.cached_at,
}
})
return JSON.stringify(
{
signature: info.signature,
cachePath: info.cachePath,
current: {
projectPathHash,
cliPathHash,
},
cacheItems,
},
undefined,
2,
)
}
}