From 1844c948e16d0922e6655e498e3b4c662da53672 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Wed, 10 Jul 2024 15:32:10 -0400 Subject: [PATCH] Inline LaunchDarkly initiliazation --- packages/shared/src/launchDarklylient.ts | 35 +++++++++++------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/packages/shared/src/launchDarklylient.ts b/packages/shared/src/launchDarklylient.ts index 478f755e..75216ba0 100644 --- a/packages/shared/src/launchDarklylient.ts +++ b/packages/shared/src/launchDarklylient.ts @@ -11,30 +11,27 @@ import { AuthenticatedTaskQueue } from "./session/AuthenticatedTaskQueue"; class LaunchDarklyClient extends AuthenticatedTaskQueue { private client: LDClient | undefined; - async onAuthenticate(authInfo: AuthInfo | null) { - this.client = initializeLDClient( - "60ca05fb43d6f10d234bb3cf", - { - anonymous: false, - } satisfies LDUser, - { - localStoragePath: getReplayPath("launchdarkly-user-cache"), - logger: { - debug() {}, - error() {}, - info() {}, - warn() {}, - }, - } - ); - + onAuthenticate(authInfo: AuthInfo | null) { + let context: LDContext = { + anonymous: true, + }; if (authInfo) { - await this.client.identify({ + context = { anonymous: false, key: authInfo.id, kind: authInfo.type, - } satisfies LDContext); + }; } + + this.client = initializeLDClient("60ca05fb43d6f10d234bb3cf", context, { + localStoragePath: getReplayPath("launchdarkly-user-cache"), + logger: { + debug() {}, + error() {}, + info() {}, + warn() {}, + }, + }); } async onFinalize() {