Skip to content

Commit fe183fa

Browse files
committed
Remove SdkState
1 parent 553545c commit fe183fa

File tree

4 files changed

+8
-123
lines changed

4 files changed

+8
-123
lines changed

src/constants.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,9 @@ export const HTTP_SERVER_ERROR = 500 as const;
236236

237237
export type PrivacyControl = 'functional' | 'targeting';
238238

239-
export type StorageTypes = 'SDKState' | 'OfflineEvents' | 'IdentityCache' | 'TimeOnSite';
239+
export type StorageTypes = 'OfflineEvents' | 'IdentityCache' | 'TimeOnSite';
240240

241241
export const StoragePrivacyMap: Record<StorageTypes, PrivacyControl> = {
242-
SDKState: 'functional',
243242
OfflineEvents: 'functional',
244243
IdentityCache: 'functional',
245244
TimeOnSite: 'targeting',

src/persistence.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ export default function _Persistence(mpInstance) {
3434
mpInstance._Store.isFirstRun = false;
3535
}
3636

37-
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
38-
// Calling storeDataInMemory without parameters will create a new DAS if it doesn't exist
39-
self.storeDataInMemory();
40-
return;
41-
}
42-
4337
// https://go.mparticle.com/work/SQDSDKS-6045
4438
if (!mpInstance._Store.isLocalStorageAvailable) {
4539
mpInstance._Store.SDKConfig.useCookieStorage = true;
@@ -118,10 +112,7 @@ export default function _Persistence(mpInstance) {
118112
};
119113

120114
this.update = function() {
121-
if (
122-
!mpInstance._Store.webviewBridgeEnabled &&
123-
!mpInstance._Store.getPrivacyFlag('SDKState')
124-
) {
115+
if (!mpInstance._Store.webviewBridgeEnabled) {
125116
if (mpInstance._Store.SDKConfig.useCookieStorage) {
126117
self.setCookie();
127118
}
@@ -811,9 +802,6 @@ export default function _Persistence(mpInstance) {
811802

812803
// https://go.mparticle.com/work/SQDSDKS-6021
813804
this.savePersistence = function(persistence) {
814-
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
815-
return;
816-
}
817805
var encodedPersistence = self.encodePersistence(
818806
JSON.stringify(persistence)
819807
),
@@ -858,9 +846,6 @@ export default function _Persistence(mpInstance) {
858846
};
859847

860848
this.getPersistence = function() {
861-
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
862-
return null;
863-
}
864849
var persistence = this.useLocalStorage()
865850
? this.getLocalStorage()
866851
: this.getCookie();

test/jest/persistence.spec.ts

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,12 @@ describe('Persistence', () => {
3939
});
4040

4141
describe('#update', () => {
42-
describe('noFunctional privacy flag set to true', () => {
43-
beforeEach(() => {
44-
store.setNoFunctional(true);
45-
store.webviewBridgeEnabled = false;
46-
});
47-
48-
it('should NOT write to cookie and localStorage when useCookieStorage is true', () => {
49-
store.SDKConfig.useCookieStorage = true;
50-
51-
const setCookieSpy = jest.spyOn(persistence, 'setCookie');
52-
const setLocalStorageSpy = jest.spyOn(persistence, 'setLocalStorage');
53-
54-
persistence.update();
55-
56-
expect(setCookieSpy).not.toHaveBeenCalled();
57-
expect(setLocalStorageSpy).not.toHaveBeenCalled();
58-
});
59-
60-
it('should NOT write to localStorage when useCookieStorage is false', () => {
61-
store.SDKConfig.useCookieStorage = false;
62-
63-
const setCookieSpy = jest.spyOn(persistence, 'setCookie');
64-
const setLocalStorageSpy = jest.spyOn(persistence, 'setLocalStorage');
65-
66-
persistence.update();
67-
68-
expect(setCookieSpy).not.toHaveBeenCalled();
69-
expect(setLocalStorageSpy).not.toHaveBeenCalled();
70-
});
71-
});
42+
// describe('noFunctional privacy flag set to true', () => {
43+
// beforeEach(() => {
44+
// store.setNoFunctional(true);
45+
// store.webviewBridgeEnabled = false;
46+
// });
47+
// });
7248

7349
describe('noFunctional privacy flag set to false', () => {
7450
beforeEach(() => {

test/src/tests-persistence.ts

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,81 +1882,6 @@ describe('persistence', () => {
18821882
beforeEach(() => {
18831883
mParticle.config.launcherOptions = { noFunctional: true };
18841884
});
1885-
1886-
it('should NOT store cookie when useCookieStorage = true', async () => {
1887-
mParticle.config.useCookieStorage = true;
1888-
1889-
mParticle.init(apiKey, mParticle.config);
1890-
await waitForCondition(hasIdentifyReturned);
1891-
1892-
mParticle.getInstance()._Persistence.update();
1893-
1894-
expect(findCookie()).to.not.be.ok;
1895-
});
1896-
1897-
it('should NOT write localStorage when useCookieStorage = false', async () => {
1898-
mParticle.config.useCookieStorage = false;
1899-
1900-
mParticle.init(apiKey, mParticle.config);
1901-
await waitForCondition(hasIdentifyReturned);
1902-
1903-
mParticle.getInstance()._Persistence.update();
1904-
1905-
expect(getLocalStorage()).to.not.be.ok;
1906-
});
1907-
1908-
it('should allow identity calls and event sending without any persistence data', async () => {
1909-
mParticle.config.useCookieStorage = false;
1910-
mParticle.init(apiKey, mParticle.config);
1911-
1912-
await waitForCondition(hasIdentifyReturned);
1913-
1914-
// Verify identity call was made
1915-
const identityCalls = fetchMock.calls().filter(call =>
1916-
call[0].includes('/identify')
1917-
);
1918-
expect(identityCalls.length).to.equal(1);
1919-
1920-
const identityData = JSON.parse(identityCalls[0][1].body as string);
1921-
expect(identityData).to.have.property('known_identities');
1922-
1923-
// Should have a device_application_stamp generated by SDK
1924-
expect(identityData.known_identities).to.have.property('device_application_stamp');
1925-
expect(identityData.known_identities.device_application_stamp).to.be.a('string');
1926-
1927-
// Reset for event test
1928-
fetchMock.resetHistory();
1929-
1930-
// Test 2: Event sending should work without persistence data
1931-
mParticle.logEvent('No Persistence Test Event');
1932-
1933-
// Verify event was sent
1934-
const eventCalls = fetchMock.calls().filter(call =>
1935-
call[0].includes('/events')
1936-
);
1937-
1938-
expect(eventCalls.length).to.be.greaterThan(0);
1939-
1940-
const eventCall = eventCalls.find(call =>
1941-
(call[1].body as string).includes('No Persistence Test Event')
1942-
);
1943-
expect(eventCall).to.be.ok;
1944-
1945-
const eventBatch = JSON.parse(eventCall[1].body as string);
1946-
expect(eventBatch).to.have.property('events');
1947-
expect(eventBatch.events.length).to.be.greaterThan(0);
1948-
1949-
const testEvent = eventBatch.events.find(event =>
1950-
event.data && event.data.event_name === 'No Persistence Test Event'
1951-
);
1952-
expect(testEvent).to.be.ok;
1953-
1954-
expect(findCookie()).to.not.be.ok;
1955-
expect(getLocalStorage()).to.not.be.ok;
1956-
1957-
const store = mParticle.getInstance()._Store;
1958-
expect(identityData.known_identities.device_application_stamp).to.equal(store.deviceId);
1959-
});
19601885
});
19611886

19621887
describe('set to false', () => {

0 commit comments

Comments
 (0)