deno.land / x / slack_web_api@1.0.0 / src / instrument.ts
123456789101112131415161718192021222324252627282930313233import { name, version } from '../config.ts'
/** * Replaces occurrences of '/' with ':' in a string, since '/' is meaningful inside User-Agent strings as a separator. */function replaceSlashes(s: string): string { return s.replace('/', ':')}
const baseUserAgent = `${replaceSlashes(name)}/${version} ` + `deno/${Deno.version.deno} ` + `${Deno.build.os}`
const appMetadata: { [key: string]: string } = {}
/** * Appends the app metadata into the User-Agent value * @param appMetadata.name - name of tool to be counted in instrumentation * @param appMetadata.version - version of tool to be counted in instrumentation */export function addAppMetadata({ name, version }: { name: string, version: string }): void { appMetadata[replaceSlashes(name)] = version}
/** * Returns the current User-Agent value for instrumentation */export function getUserAgent(): string { const appIdentifier = Object.entries(appMetadata).map(([name, version]) => `${name}/${version}`).join(' ') // only prepend the appIdentifier when its not empty return ((appIdentifier.length > 0) ? `${appIdentifier} ` : '') + baseUserAgent}
Version Info
External Dependencies