Skip to content

Commit 764e40c

Browse files
authored
Do not brick the extension when trying to get user_id for telemetry (#5251)
1 parent bb89bb4 commit 764e40c

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

extension/src/telemetry/uuid.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,31 @@ const writeMissingConfigs = (
4040
}
4141

4242
const readOrCreateConfig = (): string | undefined => {
43-
const dvcAppDir = getDVCAppDir()
44-
const iterativeAppDir = getIterativeAppDir()
43+
try {
44+
const dvcAppDir = getDVCAppDir()
45+
const iterativeAppDir = getIterativeAppDir()
4546

46-
const legacyDirectory = join(dvcAppDir, 'user_id')
47+
const legacyDirectory = join(dvcAppDir, 'user_id')
4748

48-
const legacyConfigPath = legacyDirectory
49-
const legacyConfig = loadConfig(legacyConfigPath)
49+
const legacyConfigPath = legacyDirectory
50+
const legacyConfig = loadConfig(legacyConfigPath)
5051

51-
const configPath = join(iterativeAppDir, 'telemetry')
52-
const config = loadConfig(configPath)
52+
const configPath = join(iterativeAppDir, 'telemetry')
53+
const config = loadConfig(configPath)
5354

54-
const user_id = legacyConfig.user_id || config.user_id || v4()
55+
const user_id = legacyConfig.user_id || config.user_id || v4()
5556

56-
if (legacyConfig.user_id !== user_id || config.user_id !== user_id) {
57-
writeMissingConfigs(
58-
user_id,
59-
legacyConfig,
60-
legacyConfigPath,
61-
config,
62-
configPath
63-
)
64-
}
65-
66-
return user_id
57+
if (legacyConfig.user_id !== user_id || config.user_id !== user_id) {
58+
writeMissingConfigs(
59+
user_id,
60+
legacyConfig,
61+
legacyConfigPath,
62+
config,
63+
configPath
64+
)
65+
}
66+
return user_id
67+
} catch {}
6768
}
6869

6970
export const readOrCreateUserId = () => {

0 commit comments

Comments
 (0)