* Get a unique anonymous identifier for this app.
(config: Config)
| 153 | * Get a unique anonymous identifier for this app. |
| 154 | */ |
| 155 | async function getAppIdentifier(config: Config): Promise<string | null> { |
| 156 | const { createHash } = await import('crypto'); |
| 157 | |
| 158 | // get the first commit hash, which should be universally unique |
| 159 | const output = await getCommandOutput('git', ['rev-list', '--max-parents=0', 'HEAD'], { cwd: config.app.rootDir }); |
| 160 | |
| 161 | const firstLine = output?.split('\n')[0]; |
| 162 | |
| 163 | if (!firstLine) { |
| 164 | debug('Could not obtain unique app identifier'); |
| 165 | return null; |
| 166 | } |
| 167 | |
| 168 | // use sha1 to create a one-way hash to anonymize |
| 169 | const id = createHash('sha1').update(firstLine).digest('hex'); |
| 170 | |
| 171 | return id; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Walk through the command's parent tree and construct a space-separated name. |
no test coverage detected