Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(promo-managed): allow to enable debug in config #134

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/promo-manager/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import {Controller} from './controller';
import {getHooks} from './getHooks';
import type {PromoOptions} from './types';

const getDebug = () => {
const getDebug = (options: PromoOptions) => {
if (typeof window === 'undefined') {
return false;
}

const isDebugModeEnabled = Boolean(window.localStorage.getItem('debugPromoManager'));
const isDebugEnabledInLs = Boolean(window.localStorage.getItem('debugPromoManager'));
const isDebugEnabledInConfig = Boolean(options.debugMode);

return isDebugModeEnabled;
return isDebugEnabledInConfig || isDebugEnabledInLs;
};

export function createPromoManager(options: PromoOptions) {
const controller = new Controller({...options, debugMode: getDebug()});
const controller = new Controller({...options, debugMode: getDebug(options)});

const {usePromoManager, useActivePromo, usePromo} = getHooks(controller);

Expand Down
Loading