Skip to content

Commit

Permalink
Inline LaunchDarkly initiliazation
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Jul 10, 2024
1 parent 1d79fbf commit 1844c94
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions packages/shared/src/launchDarklylient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 1844c94

Please sign in to comment.