Skip to content

Commit

Permalink
fix(VWO.js) fix APIs return values in case of eturnPromiseFor
Browse files Browse the repository at this point in the history
  • Loading branch information
softvar committed Nov 13, 2023
1 parent 96feed9 commit b4c080c
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.63.0] - 2023-11-13

### Fixed

- Fixed logic which was not affecting VWO Data360-enabled accounts where promise for different APIs was not getting resolved when `returnPromiseFor` is used while launching the SDK.
- Fixed issue where promise was not getting resolved in case of pushing an object in `push` API instead of individual custom dimension / visitor property. Only affecting if `returnPromiseFor` was used at the time of launching the SDK.
- Fixed issue where promise was not getting resolved in case of passing `null/undefined/Array` as campaign-key while invoking track API to track more than one same goal at a time across the campaigns. Only affecting if `returnPromiseFor` was used at the time of launching the SDK.

## [1.62.2] - 2023-11-03

### Fixed
Expand Down
21 changes: 15 additions & 6 deletions dist/vwo-javascript-sdk.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/vwo-javascript-sdk.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/vwo-javascript-sdk.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vwo-javascript-sdk.min.js.map

Large diffs are not rendered by default.

25 changes: 22 additions & 3 deletions lib/VWO.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,18 @@ class VWO {
let counter = 0;
options.responseCallback = (_error, _response) => {
counter += 1;
// In case of global goals, when all campaigns are tracked, then only resolve
if (counter === FunctionUtil.objectValues(trackResponse).filter(Boolean).length) {
// For Data360, one single call is there to track multiple metrices
// For global goals, we are now sending one single batch-events call
if (
self.isEventArchEnabled ||
(DataTypeUtil.isArray(campaignSpecifier) ||
((DataTypeUtil.isUndefined(campaignSpecifier) || DataTypeUtil.isNull(campaignSpecifier)) &&
FunctionUtil.objectValues(trackResponse).filter(Boolean).length))
) {
resolve(trackResponse);
} else if (counter === FunctionUtil.objectValues(trackResponse).filter(Boolean).length) {
// In case of global goals, when all campaigns are tracked, then only resolve
// TODO: verify if this can be removed as we are sending batch events call always for non-Data360 accounts
resolve(trackResponse);
}
};
Expand Down Expand Up @@ -542,7 +552,16 @@ class VWO {
responseCallback: (_error, _response) => {
counter += 1;
// In case of multiple custom dimensions, when all are tracked, then only resolve
if (counter === FunctionUtil.objectValues(apiResponse).filter(Boolean).length) {
// if customDimensionMap is used
if (
customDimensionMap &&
DataTypeUtil.isObject(customDimensionMap) &&
FunctionUtil.objectValues(customDimensionMap).filter(Boolean).length > 1
) {
resolve(apiResponse);
}
// else if custom dimensions are sent with tag key and value instead of a map
else if (counter === FunctionUtil.objectValues(apiResponse).filter(Boolean).length) {
resolve(apiResponse);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/api/activate.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function activate(vwoInstance, campaignKey, userId, options = {}) {
userAgent,
userIpAddress
} = options;

var visitorUserAgent = userAgent;

// Check if arguments have valid data-type
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/EventDispatcherUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ let EventDispatcher = {
null,
error => {
const result = this.handlePostResponse(properties, payload, error);
if (responseCallback) {
responseCallback(error, { status: 'success' });
}
resolve(result);
},
customHeaders
Expand Down

0 comments on commit b4c080c

Please sign in to comment.