Skip to content

Commit

Permalink
fix(image-fold): add bot request to store (#432)
Browse files Browse the repository at this point in the history
* add bot request to store

* refactor

* refactor

* remove optional chaning

* add optional chaning support

* remove test temporatily

* chore(release): 7.28.4-image-below-fold.0

* add back test

* use-lodash get

* Revert "add optional chaning support"

This reverts commit 0d31d8a.

* chore(release): 7.28.4-image-below-fold.1

* add below fold margin to store

* chore(release): 7.28.4-image-below-fold.2

* pr comments

* chore(release): 7.28.4-image-below-fold.3
  • Loading branch information
reddy-vishwanath authored Jul 15, 2024
1 parent 2069680 commit cd8b3f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/handlers/isomorphic-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,16 @@ exports.handleIsomorphicShell = async function handleIsomorphicShell(
};

function createStoreFromResult(url, result, opts = {}) {
const isBotRequest = _.get(url, "query.botrequest", false);
const qt = {
pageType: result.pageType || opts.defaultPageType,
subPageType: result.subPageType,
data: result.data,
currentPath: `${url.pathname}${url.search || ""}`,
currentHostUrl: result.currentHostUrl,
primaryHostUrl: result.primaryHostUrl,
isBotRequest: isBotRequest,
lazyLoadImageMargin: opts.lazyLoadImageMargin,
};
return createBasicStore(result, qt, opts);
}
Expand Down Expand Up @@ -461,6 +464,7 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
ampPageBasePath,
externalIdPattern,
enableExternalStories,
lazyLoadImageMargin,
}
) {
const url = urlLib.parse(req.url, true);
Expand All @@ -481,8 +485,10 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
}
const seoInstance = getSeoInstance(seo, config, result.pageType);
const seoTags = seoInstance && seoInstance.getMetaTags(config, result.pageType || match.pageType, result, { url });

const store = createStoreFromResult(url, result, {
disableIsomorphicComponent: statusCode != 200,
lazyLoadImageMargin,
});

if (lightPages) {
Expand Down
2 changes: 2 additions & 0 deletions server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ exports.isomorphicRoutes = function isomorphicRoutes(
webengageConfig = {},
externalIdPattern = "",
enableExternalStories = false,
lazyLoadImageMargin,
}
) {
const withConfig = withConfigPartial(getClient, logError, publisherConfig, configWrapper);
Expand Down Expand Up @@ -547,6 +548,7 @@ exports.isomorphicRoutes = function isomorphicRoutes(
ampPageBasePath,
externalIdPattern,
enableExternalStories,
lazyLoadImageMargin,
})
);

Expand Down

0 comments on commit cd8b3f5

Please sign in to comment.