Skip to content

Commit 14c72c3

Browse files
feat(SDK-2265): add banner size metadata to the metadata of willShowJourney (#1012)
feat(SDK-2265): add banner size metadata to the metadata of willShowJourney
1 parent 5e98ad1 commit 14c72c3

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/branch_view.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ function renderHtmlBlob(parent, html, hasApp, iframeLoadedCallback) {
4545
journeys_utils.addIframeOuterCSS(cssIframeContainer, metadata);
4646
journeys_utils.addIframeInnerCSS(iframe, cssInsideIframe);
4747
journeys_utils.addDynamicCtaText(iframe, ctaText);
48-
49-
journeys_utils.branch._publishEvent('willShowJourney', journeys_utils.journeyLinkData);
48+
const eventData = Object.assign({}, journeys_utils.journeyLinkData);
49+
eventData.bannerHeight = journeys_utils.bannerHeight;
50+
eventData.isFullPageBanner = journeys_utils.isFullPage;
51+
eventData.bannerPagePlacement = journeys_utils.position;
52+
eventData.isBannerInline = journeys_utils.sticky === 'absolute';
53+
eventData.isBannerSticky = journeys_utils.sticky === 'fixed';
54+
journeys_utils.branch._publishEvent('willShowJourney', eventData);
5055

5156
journeys_utils.animateBannerEntrance(iframe, cssIframeContainer);
5257
iframeLoadedCallback(iframe);

test/6_branch_new.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,15 @@ describe('Branch - new', function() {
201201
assert.equal(branch_instance.getAPIUrl(), branch_url);
202202
});
203203
});
204+
describe('addListener', function() {
205+
it('should fire listener added using addListener for an event', function() {
206+
let listenerFired = 0;
207+
const listener = function() {
208+
listenerFired++;
209+
};
210+
branch_instance.addListener('willShowJourney', listener);
211+
branch_instance._publishEvent('willShowJourney');
212+
assert.equal(listenerFired, 1);
213+
});
214+
});
204215
});

0 commit comments

Comments
 (0)