Skip to content

Commit

Permalink
tech: add platform to launchdarkly context
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioislima committed Nov 7, 2024
1 parent b03a51b commit cce33a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/backend/flags/flags.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import { logInfo, LogPrefix } from 'backend/logger/logger'
import { LDUser } from 'common/types'
import { app } from 'electron'
import * as LDElectron from 'launchdarkly-electron-client-sdk'
import { platform } from 'os'

export let ldMainClient: LDElectron.LDElectronMainClient
export const LDEnvironmentId = import.meta.env.VITE_LD_ENVIRONMENT_ID

export function initLDClient(ldUser: LDUser) {
ldMainClient = LDElectron.initializeInMain(LDEnvironmentId!, ldUser, {
streaming: true
})
ldMainClient = LDElectron.initializeInMain(
LDEnvironmentId!,
{
...ldUser,
custom: {
appVersion: app.getVersion(),
platform: platform()
}
},
{
streaming: true
}
)

ldMainClient.on('ready', () => {
logInfo('LaunchDarkly client initialized', LogPrefix.Backend)
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ const root = createRoot(container!) // createRoot(container!) if you use TypeScr
const renderApp = async () => {
const ldConfig = await window.api.getLDEnvConfig()
const appVersion = await window.api.getAppVersion()
const platform = await window.api.getPlatform()

const context = {
...ldConfig.ldUser,
appVersion,
languageCode
languageCode,
platform
}

window.api.logInfo(
Expand Down

0 comments on commit cce33a5

Please sign in to comment.