Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091export type BaseMetadata = { deviceId: string platform: string appVersion: string bundleIdentifier: string bundleDate: number referrerSrc: string referrerUrl: string isBetaUser?: boolean}
export type GeolocationMetadata = { countryCode: string regionCode: string}
export type SessionMetadata = { did: string isBlackskyPds: boolean}
export type PreferencesMetadata = { appLanguage: string contentLanguages: string[]}
export type PostQuotesMetadata = { uri: string quoteSort: 'top' | 'latest'}
export type MergeableMetadata = { session?: SessionMetadata preferences?: PreferencesMetadata postQuotes?: PostQuotesMetadata /** * Navigation metadata is not actually available on this object, instead it's * merged in at time-of-log/metric. See `#/analytics/metadata.ts` for details. */ navigation?: NavigationMetadata}
export type Metadata = { base: BaseMetadata geolocation: GeolocationMetadata} & MergeableMetadata
/** Session IDs are only added when a metric is queued, never held in context. */export type MetricMetadata = Omit<Partial<Metadata>, 'base'> & { base: Partial<BaseMetadata> & {deviceId: string; sessionId: string}}
/* * Navigation metadata is handle out-of-band from React, since we don't want to * slow down screen transitions in any way, and there doesn't seem to be a nice * way to get current navigation state without an additional re-render between * navigations. * * So instead of this data being available on the Metadata object, it's stored * here and merged in at time-of-log/metric. */export type NavigationMetadata = { previousScreen?: string currentScreen?: string}let navigationMetadata: NavigationMetadata | undefinedexport function getNavigationMetadata() { return navigationMetadata}export function setNavigationMetadata(meta: NavigationMetadata | undefined) { navigationMetadata = meta}
/** * We don't want or need to send all data to the logger */export function getMetadataForLogger({ base, geolocation, session,}: Metadata): Record<string, unknown> { return { deviceId: base.deviceId, platform: base.platform, appVersion: base.appVersion, countryCode: geolocation.countryCode, regionCode: geolocation.regionCode, isBlackskyPds: session?.isBlackskyPds || 'anonymous', }}