Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions packages/js-sdk/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ export class Context implements ContextInterface {
this._visitorId,
experienceKey,
{
...attributes,
Comment thread
abbaseya marked this conversation as resolved.
visitorProperties, // represents audiences
locationProperties: attributes?.locationProperties, // represents site_area/locations
updateVisitorProperties: attributes?.updateVisitorProperties,
environment: attributes?.environment || this._environment
}
);
Expand Down Expand Up @@ -190,9 +189,8 @@ export class Context implements ContextInterface {
const bucketedVariations = this._experienceManager.selectVariations(
this._visitorId,
{
...attributes,
Comment thread
abbaseya marked this conversation as resolved.
visitorProperties, // represents audiences
locationProperties: attributes?.locationProperties, // represents site_area/locations
updateVisitorProperties: attributes?.updateVisitorProperties,
environment: attributes?.environment || this._environment
}
);
Expand Down
72 changes: 72 additions & 0 deletions packages/js-sdk/tests/context.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,78 @@ describe('Context tests', function () {
done
);
});
it('Should forward BucketingAttributes (enableTracking, forceVariationId, ignoreLocationProperties) through runExperience', function () {
const experienceKey = 'test-experience-ab-fullstack-2';
const originalSelectVariation =
experienceManager.selectVariation.bind(experienceManager);
let capturedAttributes;
experienceManager.selectVariation = function (
capturedVisitorId,
capturedExperienceKey,
attributes
) {
capturedAttributes = attributes;
return originalSelectVariation(
capturedVisitorId,
capturedExperienceKey,
attributes
);
};
try {
context.runExperience(experienceKey, {
locationProperties: {url: 'https://convert.com/'},
visitorProperties: {varName3: 'something'},
enableTracking: false,
Comment thread
abbaseya marked this conversation as resolved.
forceVariationId: '100299461',
ignoreLocationProperties: true,
updateVisitorProperties: true
});
expect(capturedAttributes).to.include({
enableTracking: false,
forceVariationId: '100299461',
ignoreLocationProperties: true,
updateVisitorProperties: true
});
expect(capturedAttributes.locationProperties).to.deep.equal({
url: 'https://convert.com/'
});
} finally {
experienceManager.selectVariation = originalSelectVariation;
}
});
it('Should forward BucketingAttributes (enableTracking, forceVariationId, ignoreLocationProperties) through runExperiences', function () {
const originalSelectVariations =
experienceManager.selectVariations.bind(experienceManager);
let capturedAttributes;
experienceManager.selectVariations = function (
capturedVisitorId,
attributes
) {
capturedAttributes = attributes;
return originalSelectVariations(capturedVisitorId, attributes);
};
try {
context.runExperiences({
locationProperties: {url: 'https://convert.com/'},
visitorProperties: {varName3: 'something'},
enableTracking: false,
forceVariationId: '100299461',
ignoreLocationProperties: true,
updateVisitorProperties: true
});
expect(capturedAttributes).to.include({
enableTracking: false,
forceVariationId: '100299461',
ignoreLocationProperties: true,
updateVisitorProperties: true
});
expect(capturedAttributes.locationProperties).to.deep.equal({
url: 'https://convert.com/'
});
} finally {
experienceManager.selectVariations = originalSelectVariations;
}
});
it('Shoud successfully get a single feature and its status', function (done) {
this.timeout(test_timeout);
getSingleFeatureWithStatus(
Expand Down
Loading