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: run only log command in if opts.debug condition for setAnonymousId #1099

Merged
merged 1 commit into from
Apr 15, 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
20 changes: 10 additions & 10 deletions libs/jitsu-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export default function parse(input) {
if (parseFloat(value) === value) {
value = parseFloat(value);
}
} catch (e) {}
} catch (e) { }
if (value === null || value === "") {
return;
}
return value;
}

export const emptyAnalytics: AnalyticsInterface = {
setAnonymousId: () => {},
setAnonymousId: () => { },
track: () => Promise.resolve(),
page: () => Promise.resolve(),
user: () => ({}),
Expand Down Expand Up @@ -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,
Expand Down