Path: blob/main/src/vs/workbench/contrib/editTelemetry/browser/randomService.ts
4782 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { generateUuid } from '../../../../base/common/uuid.js';6import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';78export const IRandomService = createDecorator<IRandomService>('randomService');910export interface IRandomService {11readonly _serviceBrand: undefined;1213generateUuid(): string;14generatePrefixedUuid(prefix: string): string;15}1617export class RandomService implements IRandomService {18readonly _serviceBrand: undefined;1920generateUuid(): string {21return generateUuid();22}2324/** Namespace should be 3 letter. */25generatePrefixedUuid(namespace: string): string {26return `${namespace}-${this.generateUuid()}`;27}28}293031