Skip to content

[FSSDK-11127] implement cmab service #1011

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

Merged
merged 2 commits into from
Mar 6, 2025
Merged

[FSSDK-11127] implement cmab service #1011

merged 2 commits into from
Mar 6, 2025

Conversation

raju-opti
Copy link
Contributor

Summary

Test plan

  • added tests for cmab service implementation

Issues

  • FSSDK-11127

@coveralls
Copy link

Coverage Status

coverage: 82.059% (+0.004%) from 82.055%
when pulling cf3c7da on raju/cmabservice
into a4c27a2 on master.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

Looks good! A few suggestions to consider.

/**
* Get variation id for the user
* @param {OptimizelyUserContext} userContext
* @param {string} experimentId
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param {string} experimentId
* @param {string} ruleId

getDecision(
projectConfig: ProjectConfig,
userContext: OptimizelyUserContext,
experimentId: string,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
experimentId: string,
ruleId: string,

}
}

const variation = await this.fetchVariation(ruleId, userContext.getUserId(), filteredAttributes);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const variation = await this.fetchVariation(ruleId, userContext.getUserId(), filteredAttributes);
const variation = await this.fetchDecision(ruleId, userContext.getUserId(), filteredAttributes);

const cmabAttributeIds = experiment.cmab.attributeIds;

Object.keys(attributes).forEach((key) => {
const attributeId = projectConfig.attributeKeyMap[key].id;
Copy link
Contributor

Choose a reason for hiding this comment

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

What about user attributes not in projectConfig.attributes?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can start with cmab.attributes? We can avoid walk-through all the user attributes.
In this way, we can also create the fixed order of filtered attributes -

for aId in cmab.attributes {
aKey = project.atrributes[aId]
if aKey in UserContext {
filteredAttribute.add()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

also added test for attribute order insensitivity.

}

const cachedValue = await this.cmabCache.get(cacheKey);
const attributesHash = String(murmurhash.v3(JSON.stringify(filteredAttributes)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we sort by keys? Same set of attributes can be passed in different orders in UserContext?

@raju-opti raju-opti requested a review from jaeopt March 6, 2025 10:24
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

LGTM

@raju-opti raju-opti merged commit 69e3f6f into master Mar 6, 2025
9 of 15 checks passed
@raju-opti raju-opti deleted the raju/cmabservice branch March 6, 2025 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants