Skip to content

Commit

Permalink
refactor: improve validation
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs committed Nov 21, 2024
1 parent 15dc64c commit 4405c77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion packages/analytics-js/src/components/core/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import type {
LoadOptions,
} from '@rudderstack/analytics-js-common/types/LoadOptions';
import type { ApiCallback } from '@rudderstack/analytics-js-common/types/EventApi';
import { isObjectAndNotNull } from '@rudderstack/analytics-js-common/utilities/object';
import {
ANALYTICS_CORE,
READY_API,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,11 @@ class UserSessionManager implements IUserSessionManager {
* 3. generateUUID: A new unique id is generated and assigned.
*/
setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string) {
let finalAnonymousId: string | undefined | null = anonymousId;
let finalAnonymousId: string | undefined = anonymousId;
if (!isString(anonymousId) || !finalAnonymousId) {
finalAnonymousId = undefined;
}

if (this.isPersistenceEnabledForStorageEntry('anonymousId')) {
if (!finalAnonymousId && rudderAmpLinkerParam) {
const linkerPluginsResult = this.pluginsManager?.invokeSingle(
Expand Down Expand Up @@ -668,7 +672,7 @@ class UserSessionManager implements IUserSessionManager {
session.groupTraits.value = DEFAULT_USER_SESSION_VALUES.groupTraits;
session.authToken.value = DEFAULT_USER_SESSION_VALUES.authToken;

if (resetAnonymousId) {
if (resetAnonymousId === true) {
// This will generate a new anonymous ID
this.setAnonymousId();
}
Expand Down

0 comments on commit 4405c77

Please sign in to comment.