Skip to content

Commit

Permalink
fix(core): fix issue with metadata value not stringified
Browse files Browse the repository at this point in the history
fix issue with metadata value not stringified
  • Loading branch information
JagadeeshKaricherla-branch committed Dec 8, 2023
1 parent dc208b3 commit 86a521f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 22 deletions.
19 changes: 0 additions & 19 deletions src/1_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1321,22 +1321,3 @@ utils.removeTrailingDotZeros = function(versionNumber) {
return versionNumber;
};

/**
* @param {Object} obj
* A utility function to deep copy objects
*/
utils.deepCopy = function(obj) {
var ret = {};
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
var val = obj[key];
if (typeof val === 'object' && val !== null) {
ret[key] = utils.deepCopy(val);
}
else {
ret[key] = val;
}
}
}
return ret;
};
2 changes: 1 addition & 1 deletion src/3_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
utils.merge(d, data);
}
if (data.hasOwnProperty("branch_requestMetadata") && data["branch_requestMetadata"] && !(resource.endpoint === '/v1/pageview' || resource.endpoint === '/v1/dismiss')) {
d['metadata'] = utils.deepcopy(data["branch_requestMetadata"]);
d['metadata'] = safejson.stringify(data["branch_requestMetadata"]);
}

if (resource.method === 'POST') {
Expand Down
2 changes: 1 addition & 1 deletion src/6_branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ Branch.prototype['setAPIResponseCallback'] = wrap(callback_params.NO_CALLBACK, f
* @function Branch.setRequestMetaData
* @param {String} key - Request metadata key
* @param {String} value - Request metadata value
* Sets request metadata
* Sets request metadata that gets passed along with all the API calls except v1/pageview
*/
Branch.prototype.setRequestMetaData = function(key, value) {
try {
Expand Down
2 changes: 1 addition & 1 deletion test/branch-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ goog.addDependency('../../../../test/1_utils.js', [], ['utils']);
goog.addDependency('../../../../test/2_storage.js', [], ['storage']);
goog.addDependency('../../../../test/3_api.js', [], ['Server', 'config', 'resources', 'safejson', 'storage', 'utils']);
goog.addDependency('../../../../test/6_branch.js', [], ['Branch', 'banner_html', 'banner_utils', 'config', 'goog.json', 'resources', 'safejson', 'session', 'storage', 'utils']);
goog.addDependency('../../../../test/6_branch_new.js', [], ['Branch', 'utils'], {'lang': 'es5'});
goog.addDependency('../../../../test/6_branch_new.js', [], ['Branch', 'utils']);
goog.addDependency('../../../../test/7_integration.js', [], ['config', 'goog.json']);
goog.addDependency('../../../../test/blob-banner.js', [], []);
goog.addDependency('../../../../test/blob-interstitial.js', [], []);
Expand Down

0 comments on commit 86a521f

Please sign in to comment.