-
Notifications
You must be signed in to change notification settings - Fork 142
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
💥 [RUM-7704] Remove anonymous user feature flag for v6 #3216
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,7 @@ | ||||||
import type { Clock } from '../../../test' | ||||||
import { expireCookie, mockClock } from '../../../test' | ||||||
import { getCookie, setCookie } from '../../browser/cookie' | ||||||
import type { Configuration } from '../configuration' | ||||||
import type { SessionStore } from './sessionStore' | ||||||
import { STORAGE_POLL_DELAY, startSessionStore, selectSessionStoreStrategyType } from './sessionStore' | ||||||
import { SESSION_EXPIRATION_DELAY, SESSION_TIME_OUT_DELAY } from './sessionConstants' | ||||||
|
@@ -16,8 +17,8 @@ const DURATION = 123456 | |||||
const PRODUCT_KEY = 'product' | ||||||
const FIRST_ID = 'first' | ||||||
const SECOND_ID = 'second' | ||||||
|
||||||
const EXPIRED_SESSION: SessionState = { isExpired: '1' } | ||||||
const EXPIRED_SESSION: SessionState = { isExpired: '1', anonymousId: '0' } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 suggestion:
Suggested change
|
||||||
const DEFAULT_INIT_CONFIGURATION = { trackAnonymousUser: true } as Configuration | ||||||
|
||||||
function setSessionInStore(trackingType: FakeTrackingType = FakeTrackingType.TRACKED, id?: string, expire?: number) { | ||||||
setCookie( | ||||||
|
@@ -36,14 +37,14 @@ function expectTrackedSessionToBeInStore(id?: string) { | |||||
} | ||||||
|
||||||
function expectNotTrackedSessionToBeInStore() { | ||||||
expect(getCookie(SESSION_STORE_KEY)).not.toContain('id=') | ||||||
expect(getCookie(SESSION_STORE_KEY)).not.toContain('&id=') | ||||||
expect(getCookie(SESSION_STORE_KEY)).not.toContain('isExpired=1') | ||||||
expect(getCookie(SESSION_STORE_KEY)).toContain(`${PRODUCT_KEY}=${FakeTrackingType.NOT_TRACKED}`) | ||||||
} | ||||||
|
||||||
function expectSessionToBeExpiredInStore() { | ||||||
expect(getCookie(SESSION_STORE_KEY)).toContain('isExpired=1') | ||||||
expect(getCookie(SESSION_STORE_KEY)).not.toContain('id=') | ||||||
expect(getCookie(SESSION_STORE_KEY)).not.toContain('&id=') | ||||||
expect(getCookie(SESSION_STORE_KEY)).not.toContain(`${PRODUCT_KEY}=`) | ||||||
} | ||||||
|
||||||
|
@@ -117,7 +118,12 @@ describe('session store', () => { | |||||
fail('Unable to initialize cookie storage') | ||||||
return | ||||||
} | ||||||
sessionStoreManager = startSessionStore(sessionStoreStrategyType, PRODUCT_KEY, computeSessionState) | ||||||
sessionStoreManager = startSessionStore( | ||||||
sessionStoreStrategyType, | ||||||
DEFAULT_INIT_CONFIGURATION, | ||||||
PRODUCT_KEY, | ||||||
computeSessionState | ||||||
) | ||||||
sessionStoreManager.expireObservable.subscribe(expireSpy) | ||||||
sessionStoreManager.renewObservable.subscribe(renewSpy) | ||||||
} | ||||||
|
@@ -136,6 +142,7 @@ describe('session store', () => { | |||||
|
||||||
describe('initialize session', () => { | ||||||
it('when session not in store, should initialize a new session', () => { | ||||||
spyOn(Math, 'random').and.callFake(() => 0) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 suggestion: remove this line, use |
||||||
setupSessionStore() | ||||||
|
||||||
expect(sessionStoreManager.getSession()).toEqual(EXPIRED_SESSION) | ||||||
|
@@ -454,6 +461,7 @@ describe('session store', () => { | |||||
|
||||||
describe('reinitialize session', () => { | ||||||
it('when session not in store, should reinitialize the store', () => { | ||||||
spyOn(Math, 'random').and.callFake(() => 0) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 suggestion: remove this line, use |
||||||
setupSessionStore() | ||||||
|
||||||
sessionStoreManager.restartSession() | ||||||
|
@@ -491,7 +499,12 @@ describe('session store', () => { | |||||
allowFallbackToLocalStorage: false, | ||||||
}) | ||||||
|
||||||
const sessionStoreManager = startSessionStore(sessionStoreStrategyType!, PRODUCT_KEY, computeSessionState) | ||||||
const sessionStoreManager = startSessionStore( | ||||||
sessionStoreStrategyType!, | ||||||
DEFAULT_INIT_CONFIGURATION, | ||||||
PRODUCT_KEY, | ||||||
computeSessionState | ||||||
) | ||||||
sessionStoreManager.sessionStateUpdateObservable.subscribe(updateSpy) | ||||||
|
||||||
return sessionStoreManager | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 suggestion: I don't think the anonymous id value is tested in this test. Maybe remove this line?