From ef850cb0d95b7d21f4b4b1bb95913e9a98daa4a2 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Mon, 28 Nov 2022 16:24:39 -0800 Subject: [PATCH] [sc-177790] Replaced getUser with getContext (#279) * Replaced getUser with getContext * Remove contextKind * Update GoalManager.js Co-authored-by: Yusinto Ngadiman --- example/example.js | 4 ++-- package.json | 2 +- src/GoalManager.js | 8 ++------ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/example/example.js b/example/example.js index d181cab8..6c68552d 100644 --- a/example/example.js +++ b/example/example.js @@ -139,13 +139,13 @@ $(function() { // client.variation() to get individual values by flag key, but here we are iterating through them all. function showAllFlags(changes) { - var userJson = JSON.stringify(client.getUser(), null, ' '); + var contextJson = JSON.stringify(client.getContext(), null, ' '); var allFlags = client.allFlags(); var keys = Object.keys(allFlags).sort(); $content = $('
'); $content.append('These are the feature flag values from the current environment for the user:'); - $content.append($('').text(' ' + userJson)).append('

'); + $content.append($('').text(' ' + contextJson)).append('

'); var $table = $('
').addClass('table').addClass('table-sm'); var $thead = $(''); diff --git a/package.json b/package.json index e1636699..982ffc50 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ }, "dependencies": { "escape-string-regexp": "^4.0.0", - "launchdarkly-js-sdk-common": "5.0.0-alpha.3" + "launchdarkly-js-sdk-common": "5.0.0-alpha.5" }, "repository": { "type": "git", diff --git a/src/GoalManager.js b/src/GoalManager.js index 87b57d04..6d742a65 100644 --- a/src/GoalManager.js +++ b/src/GoalManager.js @@ -23,20 +23,16 @@ export default function GoalManager(clientVars, readyCallback) { } function sendGoalEvent(kind, goal) { - const user = clientVars.ident.getUser(); + const context = clientVars.ident.getContext(); const event = { kind: kind, key: goal.key, data: null, url: window.location.href, - user: user, creationDate: new Date().getTime(), + contextKeys: common.getContextKeys(context), }; - if (user && user.anonymous) { - event.contextKind = 'anonymousUser'; - } - if (kind === 'click') { event.selector = goal.selector; }