Skip to content

Commit

Permalink
Add debug cookie to white list
Browse files Browse the repository at this point in the history
Add debug cookie to white list

Update qw_tag.js stackProxy data layer name, add a test of qw_tag.js
  • Loading branch information
sabio committed Sep 14, 2023
1 parent 44d312b commit 3ec3857
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/providers/debugConsole/const.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const DEBUG_STORAGE_FLAG = 'debug';
export const DEBUG_CTX_FLAG = '_ym_debug';
export const DEBUG_URL_PARAM = '_ym_debug';
export const DEBUG_STORAGE_FLAG = 'debug' as const;
export const DEBUG_CTX_FLAG = `_ym_${DEBUG_STORAGE_FLAG}` as const;
export const DEBUG_URL_PARAM = DEBUG_CTX_FLAG;
export const DEBUG_COOKIE = DEBUG_CTX_FLAG;
2 changes: 1 addition & 1 deletion src/providers/debugConsole/debugEnabled.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { globalCookieStorage } from 'src/storage/cookie';
import { memo } from 'src/utils/function';
import { getLocation } from 'src/utils/location';
import { DEBUG_STORAGE_FLAG, DEBUG_CTX_FLAG, DEBUG_URL_PARAM } from './const';
import { DEBUG_CTX_FLAG, DEBUG_STORAGE_FLAG, DEBUG_URL_PARAM } from './const';

export const isDebugUrlWithValue = (ctx: Window, value: string) =>
getLocation(ctx).href.indexOf(`${DEBUG_URL_PARAM}=${value}`) > -1;
Expand Down
13 changes: 11 additions & 2 deletions src/providers/debugConsole/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { flags } from '@inject';
import { DEBUG_CONSOLE_FEATURE } from 'generated/features';
import {
DEBUG_CONSOLE_FEATURE,
DEBUG_EVENTS_FEATURE,
} from 'generated/features';
import {
prioritizedProviders,
windowProviderInitializers,
} from 'src/providersEntrypoint';
import { COOKIES_WHITELIST } from 'src/storage/cookie/isAllowed';
import { useReportNonNativeFunctionProvider } from '../reportNonNativeFunctions';
import { DEBUG_CTX_FLAG } from './const';
import { DEBUG_COOKIE, DEBUG_CTX_FLAG } from './const';
import { useDebugConsoleProvider } from './debugConsole';

declare global {
Expand All @@ -16,7 +20,12 @@ declare global {

export const initProvider = () => {
prioritizedProviders.push(useDebugConsoleProvider);

if (flags[DEBUG_CONSOLE_FEATURE]) {
windowProviderInitializers.unshift(useReportNonNativeFunctionProvider);
}

if (flags[DEBUG_CONSOLE_FEATURE] || flags[DEBUG_EVENTS_FEATURE]) {
COOKIES_WHITELIST.push(DEBUG_COOKIE);
}
};

0 comments on commit 3ec3857

Please sign in to comment.