Download mobile/modules/bluetooth-sdk/plugin/src/analyticsProps.ts from Anirudh1950/MentraOS: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/modules/bluetooth-sdk/plugin/src/analyticsProps.ts
- Command line
-
hf download hf://Anirudh1950/MentraOS/mobile/modules/bluetooth-sdk/plugin/src/analyticsProps.ts
-
curl -L -o analyticsProps.ts https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/modules/bluetooth-sdk/plugin/src/analyticsProps.ts
1.52 kB
| import {type BluetoothSdkPluginProps} from "./index" | |
| export interface ResolvedAnalyticsProps { | |
| /** `undefined` leaves the native default (enabled) untouched. */ | |
| disabled?: boolean | |
| /** Normalized host lane such as `dev`, `staging`, or `prod`. */ | |
| environment?: string | |
| } | |
| const ENVIRONMENT_PATTERN = /^[a-z0-9][a-z0-9_-]{0,31}$/ | |
| export function normalizeAnalyticsEnvironment(raw: unknown): string | undefined { | |
| if (raw === undefined || raw === null || raw === "") return undefined | |
| if (typeof raw !== "string") { | |
| throw new Error(`@mentra/bluetooth-sdk: analytics.environment must be a string, received ${typeof raw}`) | |
| } | |
| const value = raw.trim().toLowerCase() | |
| if (!ENVIRONMENT_PATTERN.test(value)) { | |
| throw new Error( | |
| `@mentra/bluetooth-sdk: analytics.environment "${raw}" must match ${ENVIRONMENT_PATTERN} (for example "dev", "staging", "prod")`, | |
| ) | |
| } | |
| return value | |
| } | |
| export function resolveAnalyticsProps(props: BluetoothSdkPluginProps | undefined): ResolvedAnalyticsProps { | |
| const analytics = props?.analytics | |
| let disabled: boolean | undefined | |
| let environment: string | undefined | |
| if (analytics === false) { | |
| disabled = true | |
| } else if (analytics === true) { | |
| disabled = false | |
| } else if (typeof analytics === "object" && analytics !== null) { | |
| if (analytics.enabled !== undefined) disabled = !analytics.enabled | |
| environment = normalizeAnalyticsEnvironment(analytics.environment) | |
| } | |
| return {disabled, environment} | |
| } | |