Skip to content

Commit 1371d26

Browse files
author
Prashant.patil
committed
SCAL-244420: check mixpanel sanity
1 parent 136fd42 commit 1371d26

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/embed/base.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ function backwardCompat(embedConfig: EmbedConfig): EmbedConfig {
173173
}
174174

175175
type InitFlagStore = {
176-
initPromise: Promise<ReturnType<typeof init>>;
177-
isInitCalled: boolean;
178-
initPromiseResolve: (value: ReturnType<typeof init>) => void;
176+
initPromise: Promise<ReturnType<typeof init>>;
177+
isInitCalled: boolean;
178+
initPromiseResolve: (value: ReturnType<typeof init>) => void;
179179
}
180180
const initFlagKey = 'initFlagKey';
181181

@@ -201,7 +201,7 @@ createAndSetInitPromise();
201201

202202
export const getInitPromise = ():
203203
Promise<
204-
ReturnType<typeof init>
204+
ReturnType<typeof init>
205205
> => getValueFromWindow<InitFlagStore>(initFlagKey)?.initPromise;
206206

207207
export const getIsInitCalled = (): boolean => !!getValueFromWindow(initFlagKey)?.isInitCalled;
@@ -228,8 +228,8 @@ export const getIsInitCalled = (): boolean => !!getValueFromWindow(initFlagKey)?
228228
*/
229229
export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
230230
sanity(embedConfig);
231-
resetAllCachedServices();
232-
embedConfig = setEmbedConfig(
231+
//resetAllCachedServices();
232+
/*embedConfig = setEmbedConfig(
233233
backwardCompat({
234234
...CONFIG_DEFAULTS,
235235
...embedConfig,
@@ -239,29 +239,29 @@ export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
239239
240240
setGlobalLogLevelOverride(embedConfig.logLevel);
241241
registerReportingObserver();
242-
242+
*/
243243
const authEE = new EventEmitter<AuthStatus | AuthEvent>();
244244
setAuthEE(authEE);
245245
handleAuth();
246246

247247
const { password, ...configToTrack } = getEmbedConfig();
248-
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
248+
/* uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
249249
...configToTrack,
250250
usedCustomizationSheet: embedConfig.customizations?.style?.customCSSUrl != null,
251251
usedCustomizationVariables: embedConfig.customizations?.style?.customCSS?.variables != null,
252252
usedCustomizationRules:
253253
embedConfig.customizations?.style?.customCSS?.rules_UNSTABLE != null,
254254
usedCustomizationStrings: !!embedConfig.customizations?.content?.strings,
255255
usedCustomizationIconSprite: !!embedConfig.customizations?.iconSpriteUrl,
256-
});
256+
}); */
257257

258258
if (getEmbedConfig().callPrefetch) {
259259
prefetch(getEmbedConfig().thoughtSpotHost);
260260
}
261261

262262
// Resolves the promise created in the initPromiseKey
263-
getValueFromWindow<InitFlagStore>(initFlagKey).initPromiseResolve(authEE);
264-
getValueFromWindow<InitFlagStore>(initFlagKey).isInitCalled = true;
263+
/*getValueFromWindow<InitFlagStore>(initFlagKey).initPromiseResolve(authEE);
264+
getValueFromWindow<InitFlagStore>(initFlagKey).isInitCalled = true; */
265265

266266
return authEE as AuthEventEmitter;
267267
};
@@ -308,7 +308,7 @@ export const renderInQueue = (fn: (next?: (val?: any) => void) => Promise<any>):
308308
return renderQueue;
309309
}
310310
// Sending an empty function to keep it consistent with the above usage.
311-
return fn(() => {}); // eslint-disable-line @typescript-eslint/no-empty-function
311+
return fn(() => { }); // eslint-disable-line @typescript-eslint/no-empty-function
312312
};
313313

314314
/**

src/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ export function storeValueInWindow<T>(
354354
value: T,
355355
options: { ignoreIfAlreadyExists?: boolean } = {},
356356
): T {
357+
358+
if (typeof window !== undefined) {
359+
return null;
360+
}
361+
357362
if (!window[sdkWindowKey]) {
358363
(window as any)[sdkWindowKey] = {};
359364
}

0 commit comments

Comments
 (0)