Skip to content

Commit

Permalink
feat(SDK-2265): add banner size metadata to the metadata of willShowJ…
Browse files Browse the repository at this point in the history
…ourney (#1012)

feat(SDK-2265): add banner size metadata  to the metadata of willShowJourney
  • Loading branch information
JagadeeshKaricherla-branch authored Apr 4, 2024
1 parent 5e98ad1 commit 14c72c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/branch_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ function renderHtmlBlob(parent, html, hasApp, iframeLoadedCallback) {
journeys_utils.addIframeOuterCSS(cssIframeContainer, metadata);
journeys_utils.addIframeInnerCSS(iframe, cssInsideIframe);
journeys_utils.addDynamicCtaText(iframe, ctaText);

journeys_utils.branch._publishEvent('willShowJourney', journeys_utils.journeyLinkData);
const eventData = Object.assign({}, journeys_utils.journeyLinkData);
eventData.bannerHeight = journeys_utils.bannerHeight;
eventData.isFullPageBanner = journeys_utils.isFullPage;
eventData.bannerPagePlacement = journeys_utils.position;
eventData.isBannerInline = journeys_utils.sticky === 'absolute';
eventData.isBannerSticky = journeys_utils.sticky === 'fixed';
journeys_utils.branch._publishEvent('willShowJourney', eventData);

journeys_utils.animateBannerEntrance(iframe, cssIframeContainer);
iframeLoadedCallback(iframe);
Expand Down
11 changes: 11 additions & 0 deletions test/6_branch_new.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,15 @@ describe('Branch - new', function() {
assert.equal(branch_instance.getAPIUrl(), branch_url);
});
});
describe('addListener', function() {
it('should fire listener added using addListener for an event', function() {
let listenerFired = 0;
const listener = function() {
listenerFired++;
};
branch_instance.addListener('willShowJourney', listener);
branch_instance._publishEvent('willShowJourney');
assert.equal(listenerFired, 1);
});
});
});

0 comments on commit 14c72c3

Please sign in to comment.