Skip to content

Commit

Permalink
[sc-177790] Replaced getUser with getContext (#279)
Browse files Browse the repository at this point in the history
* Replaced getUser with getContext

* Remove contextKind

* Update GoalManager.js

Co-authored-by: Yusinto Ngadiman <[email protected]>
  • Loading branch information
yusinto and yusinto authored Nov 29, 2022
1 parent 2264fad commit ef850cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $('<div></div>');
$content.append('These are the feature flag values from the current environment for the user:');
$content.append($('<code></code>').text(' ' + userJson)).append('<br><br>');
$content.append($('<code></code>').text(' ' + contextJson)).append('<br><br>');

var $table = $('<table></table>').addClass('table').addClass('table-sm');
var $thead = $('<thead></thead>');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 2 additions & 6 deletions src/GoalManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ef850cb

Please sign in to comment.