Skip to content

Commit

Permalink
fix(core): fix issue with minification not exposing methods that are …
Browse files Browse the repository at this point in the history
…added to branch prototype using dot (#970)


- fix( ) :  fix issue with minification not exposing methods that are added to branch prototype using dot notation
- fix( ) - fix issue with branch_requestMetadata sent as part of pageview request
- chore( ) - fix linting error with banner warning message
- chore( ) - clean-up commented test code
  • Loading branch information
JagadeeshKaricherla-branch authored Jan 3, 2024
1 parent 78dcb08 commit 8c076cd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/3_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@
}
}
else if (resource.endpoint === '/v1/pageview' || resource.endpoint === '/v1/dismiss') {
// /v1/pageview and v1/dismiss require custom keys to be available in the post body due
// to .setBranchViewData() call so the logic above won't work
utils.merge(d, data);
if (d['branch_requestMetadata']) {
delete d['branch_requestMetadata'];
}
}
if (data.hasOwnProperty("branch_requestMetadata") && data["branch_requestMetadata"] && !(resource.endpoint === '/v1/pageview' || resource.endpoint === '/v1/dismiss')) {
d['metadata'] = safejson.stringify(data["branch_requestMetadata"]);
Expand Down
7 changes: 4 additions & 3 deletions src/6_branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,8 @@ Branch.prototype['closeJourney'] = wrap(callback_params.CALLBACK_ERR, function(d
});

Branch.prototype['banner'] = wrap(callback_params.CALLBACK_ERR, function(done, options, data) {
console.warn('The "banner" method is deprecated and will be removed in future versions. Please use Branch Journeys instead. For more information and migration steps, visit: https://help.branch.io/using-branch/docs/journeys-overview');
var banner_deprecation_msg = 'The "banner" method is deprecated and will be removed in future versions. Please use Branch Journeys instead. For more information and migration steps, visit: https://help.branch.io/using-branch/docs/journeys-overview';
console.warn(banner_deprecation_msg);
var platform = utils.getPlatformByUserAgent();
if ([ "other", "desktop" ].includes(platform)) {
console.info("banner functionality is not supported on this platform");
Expand Down Expand Up @@ -1936,7 +1937,7 @@ Branch.prototype['setAPIResponseCallback'] = wrap(callback_params.NO_CALLBACK, f
* @param {Boolean} withExtendedJourneysAssist - Boolean indicating whether or not to get ReferringLink for extended Journeys Assist scenario.defaults to false.
* Gets the referring link from storage (session, local) wih link expiry applied if provided.
*/
Branch.prototype.referringLink = function(withExtendedJourneysAssist) {
Branch.prototype['referringLink'] = function(withExtendedJourneysAssist) {
return this._referringLink(withExtendedJourneysAssist);
};

Expand All @@ -1946,7 +1947,7 @@ Branch.prototype['setAPIResponseCallback'] = wrap(callback_params.NO_CALLBACK, f
* @param {String} value - Request metadata value
* Sets request metadata that gets passed along with all the API calls except v1/pageview
*/
Branch.prototype.setRequestMetaData = function(key, value) {
Branch.prototype['setRequestMetaData'] = function(key, value) {
try {
if ((typeof(key) === 'undefined' || key === null || key.length === 0) || (typeof value === "undefined")) {
return;
Expand Down
3 changes: 2 additions & 1 deletion src/onpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
'crossPlatformIds',
'lastAttributedTouchData',
'setAPIResponseCallback',
'qrCode'
'qrCode',
'setRequestMetaData'
],
0
);
11 changes: 0 additions & 11 deletions test/6_branch_new.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,4 @@ describe('Branch - new', function() {
assert.deepEqual(requestMetadata, { "key": "value" });
});
});
/*
describe('setRequestMetaData - exceptions', function() {
it('should throw exception', function() {
var logSpy = sinon.spy(console, 'log');
sinon.stub(utils, 'addPropertyIfNotNull').throws(new Error("fake error"));
branch_instance.setRequestMetaData.call({ requestMetadata: {} }, "validKey", 'validValue');
assert(logSpy.calledWith("An error occured while setting request metadata"));
});
});
*/
});

0 comments on commit 8c076cd

Please sign in to comment.