From 9e60995ff0ce83aee5f91e91d81fd6168998cc62 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Sat, 13 Apr 2024 07:55:38 +0200 Subject: [PATCH] fix: run only log command in if opts.debug condition --- libs/jitsu-js/src/index.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/jitsu-js/src/index.ts b/libs/jitsu-js/src/index.ts index 4d1ab9521..8305e3276 100644 --- a/libs/jitsu-js/src/index.ts +++ b/libs/jitsu-js/src/index.ts @@ -16,7 +16,7 @@ export default function parse(input) { if (parseFloat(value) === value) { value = parseFloat(value); } - } catch (e) {} + } catch (e) { } if (value === null || value === "") { return; } @@ -24,7 +24,7 @@ export default function parse(input) { } export const emptyAnalytics: AnalyticsInterface = { - setAnonymousId: () => {}, + setAnonymousId: () => { }, track: () => Promise.resolve(), page: () => Promise.resolve(), user: () => ({}), @@ -123,15 +123,15 @@ function createUnderlyingAnalyticsInstance( setAnonymousId: (id: string) => { if (opts.debug) { console.log("[JITSU DEBUG] Setting anonymous id to " + id); - //Workaround for analytics.js bug. Underlying setAnonymousId doesn't work set the id immediately, - //so we got to it manually here. See https://github.com/jitsucom/jitsu/issues/1060 - storage.setItem("__anon_id", id); - const userState = analytics.user(); - if (userState) { - userState.anonymousId = id; - } - (analytics as any).setAnonymousId(id); } + //Workaround for analytics.js bug. Underlying setAnonymousId doesn't work set the id immediately, + //so we got to it manually here. See https://github.com/jitsucom/jitsu/issues/1060 + storage.setItem("__anon_id", id); + const userState = analytics.user(); + if (userState) { + userState.anonymousId = id; + } + (analytics as any).setAnonymousId(id); }, async group( groupId?: ID,