Skip to content

Commit

Permalink
global config checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cea2aj committed May 6, 2021
1 parent 307445b commit 4d0e8fa
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions script/core.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
const IS_STAGING = HitchhikerJS.isStaging(JAMBO_INJECTED_DATA?.pages?.stagingDomains || []);
const injectedConfig = {
experienceVersion: IS_STAGING ? 'STAGING' : 'PRODUCTION',
apiKey: HitchhikerJS.getInjectedProp('{{{global_config.experienceKey}}}', ['apiKey']),
{{#unless global_config.useJWT}}
apiKey: HitchhikerJS.getInjectedProp('{{{global_config.experienceKey}}}', ['apiKey']),
{{/unless}}
{{#with env.JAMBO_INJECTED_DATA}}
{{#if businessId}}businessId: "{{businessId}}",{{/if}}
{{/with}}
Expand All @@ -29,14 +31,16 @@
{{/with}}
};
let token = null;
let iframeSearchParams = null;
if (window.frameElement) {
const iframeSrc = new URL(window.frameElement.src);
iframeSearchParams = new URLSearchParams(iframeSrc.search);
} else {
iframeSearchParams = new URLSearchParams(window.location.search);
}
token = iframeSearchParams?.get('token');
{{#if global_config.useJWT}}
let iframeSearchParams = null;
if (window.frameElement) { // to support same-origin
const iframeSrc = new URL(window.frameElement.src);
iframeSearchParams = new URLSearchParams(iframeSrc.search);
} else { // to support cross-origin
iframeSearchParams = new URLSearchParams(window.location.search);
}
token = iframeSearchParams?.get('token');
{{/if}}
ANSWERS.init({
templateBundle: TemplateBundle.default,
...injectedConfig,
Expand Down

0 comments on commit 4d0e8fa

Please sign in to comment.