Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FF-1749: JS SDK Common UFC update #45

Merged
merged 42 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f69cdc6
wip
schmit Mar 25, 2024
07b9cde
making progress
schmit Mar 27, 2024
fd04b4b
make more tests pass
schmit Mar 27, 2024
ca7ea07
wip
schmit Mar 28, 2024
2a7b3ec
fix more tests
schmit Mar 28, 2024
d676f4c
update event cache test
schmit Mar 28, 2024
12eb7d1
.bind(this)
schmit Mar 28, 2024
e9bb4b3
pass all the tests
schmit Mar 28, 2024
684da8a
Update script to create obfuscated UFC
schmit Mar 28, 2024
aa64366
add obfuscation and make all tests pass
schmit Mar 29, 2024
4d6264e
cleanup
schmit Mar 29, 2024
1e9e10e
Address PR comments
schmit Apr 3, 2024
cab5b1f
Address PR comments
schmit Apr 3, 2024
e5d4be1
Hardcoded obfuscation tests and other fixes
schmit Apr 3, 2024
7400ed0
test for overwriting id for matching rules
schmit Apr 3, 2024
4d9a3a0
remove unused import
schmit Apr 3, 2024
67f7cbc
remove unneeded lint comment
schmit Apr 3, 2024
c6b0960
Add comment on getAssignmentDetail
schmit Apr 3, 2024
d71727e
addressing PR comments
schmit Apr 4, 2024
c650af5
update e2e test for more clarity
schmit Apr 4, 2024
bfd47f6
move obfuscated to client attribute, valueOf eppoValue
schmit Apr 4, 2024
bfc201e
add version metadata, add isInitialized
schmit Apr 4, 2024
8e5dbeb
Add uninitialized test back in
schmit Apr 4, 2024
7a3f392
add version update to pre-commit
schmit Apr 4, 2024
25d8ebf
add version in pre-commit
schmit Apr 4, 2024
834606e
test
schmit Apr 4, 2024
370d80a
update version
schmit Apr 4, 2024
d058c46
bump version
schmit Apr 4, 2024
9ce18fb
Merge branch 'main' into ufc-revamp
schmit Apr 4, 2024
cf991bc
dont be fancy
schmit Apr 4, 2024
6d063c4
remove evaluator as arg to eppo client constructor
schmit Apr 10, 2024
a5cfe95
Replace lru-cache package with simple local implementation (FF-1876) …
leoromanovsky Apr 5, 2024
bafd881
Merge branch 'main' into ufc-revamp
schmit Apr 10, 2024
5958d19
update endpoint to match backend
schmit Apr 12, 2024
ee3d43a
[ufc] add null operator and more fixes (#50)
schmit Apr 15, 2024
9915183
export test helpers
schmit Apr 15, 2024
fd6e357
export flag and variationtype
schmit Apr 15, 2024
a28e473
export attribute type
schmit Apr 15, 2024
08e36c8
export more types
schmit Apr 15, 2024
7735cc6
Update function signatures
schmit Apr 18, 2024
7b25f18
[UFC] Update obfuscation decoding (#52)
schmit Apr 19, 2024
555dece
Merge branch 'main' into ufc-revamp
schmit Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ test-data:
rm -rf $(testDataDir)
mkdir -p $(tempDir)
git clone -b ${branchName} --depth 1 --single-branch ${githubRepoLink} ${gitDataDir}
cp ${gitDataDir}rac-experiments-v3.json ${testDataDir}
cp ${gitDataDir}rac-experiments-v3-obfuscated.json ${testDataDir}
cp -r ${gitDataDir}assignment-v2 ${testDataDir}
cp -r ${gitDataDir}assignment-v2-holdouts/. ${testDataDir}assignment-v2
cp -r ${gitDataDir}ufc ${testDataDir}
rm -rf ${tempDir}

## prepare
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"typecheck": "tsc",
"test": "yarn test:unit",
"test:unit": "NODE_ENV=test jest '.*\\.spec\\.ts'",
"obfuscate-mock-rac": "ts-node test/writeObfuscatedMockRac"
"obfuscate-mock-ufc": "ts-node test/writeObfuscatedMockUFC"
},
"jsdelivr": "dist/eppo-sdk.js",
"repository": {
Expand Down
7 changes: 4 additions & 3 deletions src/assignment-cache.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { LRUCache } from 'lru-cache';

import { EppoValue } from './eppo_value';

Check warning on line 3 in src/assignment-cache.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

'EppoValue' is defined but never used
import { getMD5Hash } from './obfuscation';

export interface AssignmentCacheKey {
subjectKey: string;
flagKey: string;
allocationKey: string;
variationValue: EppoValue;
variationKey: string;
}

export interface Cacheable {
Expand All @@ -32,15 +33,15 @@
// the subject has been assigned to a different variation
// than was previously logged.
// in this case we need to log the assignment again.
if (this.cache.get(this.getCacheKey(key)) !== key.variationValue.toHashedString()) {
if (this.cache.get(this.getCacheKey(key)) !== getMD5Hash(key.variationKey)) {
return false;
}

return true;
}

setLastLoggedAssignment(key: AssignmentCacheKey): void {
this.cache.set(this.getCacheKey(key), key.variationValue.toHashedString());
this.cache.set(this.getCacheKey(key), getMD5Hash(key.variationKey));
}

protected getCacheKey({ subjectKey, flagKey, allocationKey }: AssignmentCacheKey): string {
Expand Down
18 changes: 5 additions & 13 deletions src/assignment-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ export type NullableHoldoutVariationType = HoldoutVariationEnum | null;
* Holds data about the variation a subject was assigned to.
* @public
*/

export interface IAssignmentEvent {
/**
* An Eppo allocation key
*/
allocation: string;
allocation: string | null;

/**
* An Eppo experiment key
*/
experiment: string;
experiment: string | null;

/**
* An Eppo feature flag key
Expand All @@ -28,7 +29,7 @@ export interface IAssignmentEvent {
/**
* The assigned variation
*/
variation: string;
variation: string | null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would a (logged) assigned variation be null?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When no allocation matches (or when the flag is disabled) and we return noneResult. Is the question that you don't expect such occurrenced to be logged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is to enable logging the lack of assignment, which seems valuable especially because you probably want to figure out why assignments are not working

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense if its a change we want. Note that currently, when no assignment is given, we do not log the null assignment.


/**
* The entity or user that was assigned to a variation
Expand All @@ -40,18 +41,9 @@ export interface IAssignmentEvent {
*/
timestamp: string;

/**
* An Eppo holdout key
*/
holdout: string | null;

/**
* The Eppo holdout variation for the assigned variation
*/
holdoutVariation: NullableHoldoutVariationType;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
subjectAttributes: Record<string, any>;
[propName: string]: unknown;
schmit marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Loading
Loading