MCPcopy Index your code
hub / github.com/ionic-team/capacitor / getAppIdentifier

Function getAppIdentifier

cli/src/telemetry.ts:155–172  ·  view source on GitHub ↗

* Get a unique anonymous identifier for this app.

(config: Config)

Source from the content-addressed store, hash-verified

153 * Get a unique anonymous identifier for this app.
154 */
155async 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.

Callers 1

telemetryActionFunction · 0.85

Calls 1

getCommandOutputFunction · 0.90

Tested by

no test coverage detected