-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Assignment Logic #1
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
Conversation
d753982
to
dd980d1
Compare
@@ -0,0 +1,76 @@ | |||
import { createHash } from 'crypto'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from @eppo/node-server-sdk.
@@ -0,0 +1,12 @@ | |||
import { Rule } from './rule'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from @eppo/node-server-sdk
src/experiment/rule.ts
Outdated
@@ -0,0 +1,19 @@ | |||
export type AttributeValueType = string | number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from @eppo/node-server-sdk
@@ -0,0 +1,9 @@ | |||
export interface IShardRange { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from @eppo/node-server-sdk
src/rule.ts
Outdated
@@ -0,0 +1,19 @@ | |||
export type AttributeValueType = string | number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from @eppo/node-server-sdk
src/rule_evaluator.ts
Outdated
@@ -0,0 +1,59 @@ | |||
import { Condition, OperatorType, Rule, AttributeValueType } from './rule'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from @eppo/node-server-sdk
@@ -0,0 +1,15 @@ | |||
import { createHash } from 'crypto'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from @eppo/node-server-sdk
src/constants.ts
Outdated
@@ -0,0 +1,2 @@ | |||
export const REQUEST_TIMEOUT_MILLIS = 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this will run on end-users devices, I think we should increase this to 5 or 10 seconds (since the user's internet connection could be really slow).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increased it to 5 seconds
src/eppo-client.ts
Outdated
|
||
export default class EppoClient implements IEppoClient { | ||
constructor( | ||
private subjectKey: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should still pass this into the getAssignment
function. A customer way want to experiment on an anonymous/logged out user until they log in, at which point they'd want to use a different type of subject ID. If we require subjectKey
to be passed in to the constructor here, they'd have to recreate and initialize the client after login.
@@ -0,0 +1,66 @@ | |||
/* eslint-disable @typescript-eslint/no-explicit-any */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from @eppo/node-server-sdk
This PR copies over the assignment logic from the node-server-sdk. The only notable difference is how the SDK is initialized. The client-side SDK operates in a single-subject environment. Therefore, the
subjectKey
andsubjectAttributes
are provided during initialization:With the subject attributes provided during initialization, the
getAssignment
function only needs one argument for experiment key:This PR also utilizes browser session storage for storing the assignment configuration.