Skip to content

Commit 8c076cd

Browse files
fix(core): fix issue with minification not exposing methods that are 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
1 parent 78dcb08 commit 8c076cd

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

src/3_api.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@
127127
}
128128
}
129129
else if (resource.endpoint === '/v1/pageview' || resource.endpoint === '/v1/dismiss') {
130-
// /v1/pageview and v1/dismiss require custom keys to be available in the post body due
131-
// to .setBranchViewData() call so the logic above won't work
132130
utils.merge(d, data);
131+
if (d['branch_requestMetadata']) {
132+
delete d['branch_requestMetadata'];
133+
}
133134
}
134135
if (data.hasOwnProperty("branch_requestMetadata") && data["branch_requestMetadata"] && !(resource.endpoint === '/v1/pageview' || resource.endpoint === '/v1/dismiss')) {
135136
d['metadata'] = safejson.stringify(data["branch_requestMetadata"]);

src/6_branch.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,8 @@ Branch.prototype['closeJourney'] = wrap(callback_params.CALLBACK_ERR, function(d
16941694
});
16951695

16961696
Branch.prototype['banner'] = wrap(callback_params.CALLBACK_ERR, function(done, options, data) {
1697-
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');
1697+
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';
1698+
console.warn(banner_deprecation_msg);
16981699
var platform = utils.getPlatformByUserAgent();
16991700
if ([ "other", "desktop" ].includes(platform)) {
17001701
console.info("banner functionality is not supported on this platform");
@@ -1936,7 +1937,7 @@ Branch.prototype['setAPIResponseCallback'] = wrap(callback_params.NO_CALLBACK, f
19361937
* @param {Boolean} withExtendedJourneysAssist - Boolean indicating whether or not to get ReferringLink for extended Journeys Assist scenario.defaults to false.
19371938
* Gets the referring link from storage (session, local) wih link expiry applied if provided.
19381939
*/
1939-
Branch.prototype.referringLink = function(withExtendedJourneysAssist) {
1940+
Branch.prototype['referringLink'] = function(withExtendedJourneysAssist) {
19401941
return this._referringLink(withExtendedJourneysAssist);
19411942
};
19421943

@@ -1946,7 +1947,7 @@ Branch.prototype['setAPIResponseCallback'] = wrap(callback_params.NO_CALLBACK, f
19461947
* @param {String} value - Request metadata value
19471948
* Sets request metadata that gets passed along with all the API calls except v1/pageview
19481949
*/
1949-
Branch.prototype.setRequestMetaData = function(key, value) {
1950+
Branch.prototype['setRequestMetaData'] = function(key, value) {
19501951
try {
19511952
if ((typeof(key) === 'undefined' || key === null || key.length === 0) || (typeof value === "undefined")) {
19521953
return;

src/onpage.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
'crossPlatformIds',
5656
'lastAttributedTouchData',
5757
'setAPIResponseCallback',
58-
'qrCode'
58+
'qrCode',
59+
'setRequestMetaData'
5960
],
6061
0
6162
);

test/6_branch_new.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,4 @@ describe('Branch - new', function() {
5454
assert.deepEqual(requestMetadata, { "key": "value" });
5555
});
5656
});
57-
/*
58-
describe('setRequestMetaData - exceptions', function() {
59-
it('should throw exception', function() {
60-
var logSpy = sinon.spy(console, 'log');
61-
sinon.stub(utils, 'addPropertyIfNotNull').throws(new Error("fake error"));
62-
branch_instance.setRequestMetaData.call({ requestMetadata: {} }, "validKey", 'validValue');
63-
assert(logSpy.calledWith("An error occured while setting request metadata"));
64-
});
65-
66-
});
67-
*/
6857
});

0 commit comments

Comments
 (0)