deno.land / x / slack_web_api@1.0.0 / src / instrument.ts

instrument.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { 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}
slack_web_api
Slack Developer Kit for Node.js
DocumentationDocumentation
GitHub Repositoryslack-deno/web-api
GitHub Stars
3045

Version Info

Tagged at
a year ago

External Dependencies

No external dependencies 🎉