Skip to content

Commit 2445dc8

Browse files
committed
Merge remote-tracking branch 'origin/development' into refactor/SDKE-283-remove-cart-related-function-from-persistence
2 parents b9179e1 + 495c955 commit 2445dc8

12 files changed

Lines changed: 525 additions & 52 deletions

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# [2.47.0](https://github.com/mParticle/mparticle-web-sdk/compare/v2.46.0...v2.47.0) (2025-10-01)
2+
3+
4+
### Bug Fixes
5+
6+
* SDKE-317 Call deferred methods on Rokt Manager instead of kit ([#1076](https://github.com/mParticle/mparticle-web-sdk/issues/1076)) ([3a0643b](https://github.com/mParticle/mparticle-web-sdk/commit/3a0643b13ce1d7ade12be85fa9d87ac5278fe158))
7+
8+
9+
### Features
10+
11+
* added DisabledVault to disable id-cache when noFunctional is set ([#1072](https://github.com/mParticle/mparticle-web-sdk/issues/1072)) ([8187d72](https://github.com/mParticle/mparticle-web-sdk/commit/8187d726aac79493a1a6c5891eaa23823ca7bf52))
12+
* added noFunctional in batchUploader to disable offline storage ([#1063](https://github.com/mParticle/mparticle-web-sdk/issues/1063)) ([97dd88a](https://github.com/mParticle/mparticle-web-sdk/commit/97dd88aa20938f2976552c86c6db774d4b6c1023))
13+
* disable session cookie/localStorage when noFunctional is set ([#1070](https://github.com/mParticle/mparticle-web-sdk/issues/1070)) ([edb2e61](https://github.com/mParticle/mparticle-web-sdk/commit/edb2e61825ffacd2ca0b444c4a9d730cd9c95590))
14+
* disable time tracking when noTargeting is set to true ([#1064](https://github.com/mParticle/mparticle-web-sdk/issues/1064)) ([71c891c](https://github.com/mParticle/mparticle-web-sdk/commit/71c891c703353451aaad712d2e7d25722cb9f641))
15+
116
# [2.46.0](https://github.com/mParticle/mparticle-web-sdk/compare/v2.45.0...v2.46.0) (2025-09-17)
217

318

dist/mparticle.common.js

Lines changed: 13 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mparticle.esm.js

Lines changed: 13 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mparticle.js

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ var mParticle = (function () {
203203
Base64: Base64$1
204204
};
205205

206-
var version = "2.46.0";
206+
var version = "2.47.0";
207207

208208
var Constants = {
209209
sdkVersion: version,
@@ -409,6 +409,13 @@ var mParticle = (function () {
409409
var HTTP_OK = 200;
410410
var HTTP_ACCEPTED = 202;
411411
var HTTP_BAD_REQUEST = 400;
412+
var StoragePrivacyMap = {
413+
SDKState: 'functional',
414+
Products: 'targeting',
415+
OfflineEvents: 'functional',
416+
IdentityCache: 'functional',
417+
TimeOnSite: 'targeting'
418+
};
412419

413420
/******************************************************************************
414421
Copyright (c) Microsoft Corporation.
@@ -2179,6 +2186,22 @@ var mParticle = (function () {
21792186
}
21802187
return SessionStorageVault;
21812188
}(BaseVault);
2189+
// DisabledVault is used when persistence is disabled by privacy flags.
2190+
var DisabledVault = /** @class */function (_super) {
2191+
__extends(DisabledVault, _super);
2192+
function DisabledVault(storageKey, options) {
2193+
var _this = _super.call(this, storageKey, window.localStorage, options) || this;
2194+
_this.contents = null;
2195+
return _this;
2196+
}
2197+
DisabledVault.prototype.store = function (_item) {
2198+
this.contents = null;
2199+
};
2200+
DisabledVault.prototype.retrieve = function () {
2201+
return this.contents;
2202+
};
2203+
return DisabledVault;
2204+
}(BaseVault);
21822205

21832206
var AsyncUploader = /** @class */function () {
21842207
function AsyncUploader(url) {
@@ -2358,7 +2381,7 @@ var mParticle = (function () {
23582381
this.batchesQueuedForProcessing = [];
23592382
// Cache Offline Storage Availability boolean
23602383
// so that we don't have to check it every time
2361-
this.offlineStorageEnabled = this.isOfflineStorageAvailable();
2384+
this.offlineStorageEnabled = this.isOfflineStorageAvailable() && !mpInstance._Store.getPrivacyFlag('OfflineEvents');
23622385
if (this.offlineStorageEnabled) {
23632386
this.eventVault = new SessionStorageVault("".concat(mpInstance._Store.storageName, "-events"), {
23642387
logger: mpInstance.Logger
@@ -4626,6 +4649,16 @@ var mParticle = (function () {
46264649
this.setNoTargeting = function (noTargeting) {
46274650
_this.noTargeting = noTargeting;
46284651
};
4652+
this.getPrivacyFlag = function (storageType) {
4653+
var privacyControl = StoragePrivacyMap[storageType];
4654+
if (privacyControl === 'functional') {
4655+
return _this.getNoFunctional();
4656+
}
4657+
if (privacyControl === 'targeting') {
4658+
return _this.getNoTargeting();
4659+
}
4660+
return false;
4661+
};
46294662
this.getDeviceId = function () {
46304663
return _this.deviceId;
46314664
};
@@ -4706,6 +4739,7 @@ var mParticle = (function () {
47064739
mpInstance._Persistence.update();
47074740
};
47084741
this.processConfig = function (config) {
4742+
var _a;
47094743
var workspaceToken = config.workspaceToken,
47104744
requiredWebviewBridgeName = config.requiredWebviewBridgeName;
47114745
// We should reprocess the flags and baseUrls in case they have changed when we request an updated config
@@ -4716,22 +4750,26 @@ var mParticle = (function () {
47164750
for (var baseUrlKeys in baseUrls) {
47174751
_this.SDKConfig[baseUrlKeys] = baseUrls[baseUrlKeys];
47184752
}
4753+
var _b = (_a = config === null || config === void 0 ? void 0 : config.launcherOptions) !== null && _a !== void 0 ? _a : {},
4754+
noFunctional = _b.noFunctional,
4755+
noTargeting = _b.noTargeting;
4756+
if (noFunctional != null) {
4757+
_this.setNoFunctional(noFunctional);
4758+
}
4759+
if (noTargeting != null) {
4760+
_this.setNoTargeting(noTargeting);
4761+
}
47194762
if (workspaceToken) {
47204763
_this.SDKConfig.workspaceToken = workspaceToken;
4721-
mpInstance._timeOnSiteTimer = new ForegroundTimeTracker(workspaceToken);
4764+
if (!_this.getPrivacyFlag('TimeOnSite')) {
4765+
mpInstance._timeOnSiteTimer = new ForegroundTimeTracker(workspaceToken);
4766+
}
47224767
} else {
47234768
mpInstance.Logger.warning('You should have a workspaceToken on your config object for security purposes.');
47244769
}
47254770
// add a new function to apply items to the store that require config to be returned
47264771
_this.storageName = createMainStorageName(workspaceToken);
47274772
_this.prodStorageName = createProductStorageName(workspaceToken);
4728-
// Extract privacy flags directly from config into Store
4729-
if (config.hasOwnProperty('noFunctional')) {
4730-
_this.setNoFunctional(config.noFunctional);
4731-
}
4732-
if (config.hasOwnProperty('noTargeting')) {
4733-
_this.setNoTargeting(config.noTargeting);
4734-
}
47354773
_this.SDKConfig.requiredWebviewBridgeName = requiredWebviewBridgeName || workspaceToken;
47364774
_this.webviewBridgeEnabled = isWebviewEnabled(_this.SDKConfig.requiredWebviewBridgeName, _this.SDKConfig.minWebviewBridgeVersion);
47374775
_this.configurationLoaded = true;
@@ -4911,6 +4949,9 @@ var mParticle = (function () {
49114949
} else {
49124950
mpInstance._Store.isFirstRun = false;
49134951
}
4952+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
4953+
return;
4954+
}
49144955

49154956
// https://go.mparticle.com/work/SQDSDKS-6045
49164957
if (!mpInstance._Store.isLocalStorageAvailable) {
@@ -4996,7 +5037,7 @@ var mParticle = (function () {
49965037
}
49975038
};
49985039
this.update = function () {
4999-
if (!mpInstance._Store.webviewBridgeEnabled) {
5040+
if (!mpInstance._Store.webviewBridgeEnabled && !mpInstance._Store.getPrivacyFlag('SDKState')) {
50005041
if (mpInstance._Store.SDKConfig.useCookieStorage) {
50015042
self.setCookie();
50025043
}
@@ -5567,6 +5608,9 @@ var mParticle = (function () {
55675608

55685609
// https://go.mparticle.com/work/SQDSDKS-6021
55695610
this.savePersistence = function (persistence) {
5611+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
5612+
return;
5613+
}
55705614
var encodedPersistence = self.encodePersistence(JSON.stringify(persistence)),
55715615
date = new Date(),
55725616
key = mpInstance._Store.storageName,
@@ -5588,6 +5632,9 @@ var mParticle = (function () {
55885632
}
55895633
};
55905634
this.getPersistence = function () {
5635+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
5636+
return null;
5637+
}
55915638
var persistence = this.useLocalStorage() ? this.getLocalStorage() : this.getCookie();
55925639
return persistence;
55935640
};
@@ -10040,20 +10087,22 @@ var mParticle = (function () {
1004010087
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.verbose("RoktManager: Processing ".concat(this.messageQueue.size, " queued messages"));
1004110088
this.messageQueue.forEach(function (message) {
1004210089
var _a, _b, _c;
10043-
if (!(message.methodName in _this.kit) || !isFunction(_this.kit[message.methodName])) {
10044-
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Method ".concat(message.methodName, " not found in kit"));
10090+
if (!(message.methodName in _this) || !isFunction(_this[message.methodName])) {
10091+
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Method ".concat(message.methodName, " not found"));
1004510092
return;
1004610093
}
1004710094
(_b = _this.logger) === null || _b === void 0 ? void 0 : _b.verbose("RoktManager: Processing queued message: ".concat(message.methodName, " with payload: ").concat(JSON.stringify(message.payload)));
1004810095
try {
10049-
var result = _this.kit[message.methodName](message.payload);
10096+
var result = _this[message.methodName](message.payload);
1005010097
_this.completePendingPromise(message.messageId, result);
1005110098
} catch (error) {
1005210099
var errorMessage = error instanceof Error ? error.message : String(error);
1005310100
(_c = _this.logger) === null || _c === void 0 ? void 0 : _c.error("RoktManager: Error processing message '".concat(message.methodName, "': ").concat(errorMessage));
1005410101
_this.completePendingPromise(message.messageId, Promise.reject(error));
1005510102
}
1005610103
});
10104+
// Clear the queue after processing all messages
10105+
this.messageQueue.clear();
1005710106
};
1005810107
RoktManager.prototype.queueMessage = function (message) {
1005910108
this.messageQueue.set(message.messageId, message);
@@ -11165,7 +11214,13 @@ var mParticle = (function () {
1116511214
return kitBlocker;
1116611215
}
1116711216
function createIdentityCache(mpInstance) {
11168-
return new LocalStorageVault("".concat(mpInstance._Store.storageName, "-id-cache"), {
11217+
var cacheKey = "".concat(mpInstance._Store.storageName, "-id-cache");
11218+
if (mpInstance._Store.getPrivacyFlag('IdentityCache')) {
11219+
return new DisabledVault(cacheKey, {
11220+
logger: mpInstance.Logger
11221+
});
11222+
}
11223+
return new LocalStorageVault(cacheKey, {
1116911224
logger: mpInstance.Logger
1117011225
});
1117111226
}

jest.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,14 @@ module.exports = {
44
// The built mParticle.js file needs to exist for integration tests
55
setupFiles: ['./dist/mparticle.js'],
66
setupFilesAfterEnv: ['jest-expect-message'],
7+
transform: {
8+
'^.+\\.(js)$': 'ts-jest',
9+
},
10+
globals: {
11+
'ts-jest': {
12+
tsconfig: {
13+
allowJs: true,
14+
},
15+
},
16+
},
717
};

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mparticle/web-sdk",
3-
"version": "2.46.0",
3+
"version": "2.47.0",
44
"description": "mParticle core SDK for web applications",
55
"license": "Apache-2.0",
66
"keywords": [

src/persistence.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export default function _Persistence(mpInstance) {
3535
mpInstance._Store.isFirstRun = false;
3636
}
3737

38+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
39+
return;
40+
}
41+
3842
// https://go.mparticle.com/work/SQDSDKS-6045
3943
if (!mpInstance._Store.isLocalStorageAvailable) {
4044
mpInstance._Store.SDKConfig.useCookieStorage = true;
@@ -113,7 +117,10 @@ export default function _Persistence(mpInstance) {
113117
};
114118

115119
this.update = function() {
116-
if (!mpInstance._Store.webviewBridgeEnabled) {
120+
if (
121+
!mpInstance._Store.webviewBridgeEnabled &&
122+
!mpInstance._Store.getPrivacyFlag('SDKState')
123+
) {
117124
if (mpInstance._Store.SDKConfig.useCookieStorage) {
118125
self.setCookie();
119126
}
@@ -803,6 +810,9 @@ export default function _Persistence(mpInstance) {
803810

804811
// https://go.mparticle.com/work/SQDSDKS-6021
805812
this.savePersistence = function(persistence) {
813+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
814+
return;
815+
}
806816
var encodedPersistence = self.encodePersistence(
807817
JSON.stringify(persistence)
808818
),
@@ -847,6 +857,9 @@ export default function _Persistence(mpInstance) {
847857
};
848858

849859
this.getPersistence = function() {
860+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
861+
return null;
862+
}
850863
var persistence = this.useLocalStorage()
851864
? this.getLocalStorage()
852865
: this.getCookie();

src/roktManager.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,22 +319,25 @@ export default class RoktManager {
319319
this.logger?.verbose(`RoktManager: Processing ${this.messageQueue.size} queued messages`);
320320

321321
this.messageQueue.forEach((message) => {
322-
if(!(message.methodName in this.kit) || !isFunction(this.kit[message.methodName])) {
323-
this.logger?.error(`RoktManager: Method ${message.methodName} not found in kit`);
322+
if(!(message.methodName in this) || !isFunction(this[message.methodName])) {
323+
this.logger?.error(`RoktManager: Method ${message.methodName} not found`);
324324
return;
325325
}
326326

327327
this.logger?.verbose(`RoktManager: Processing queued message: ${message.methodName} with payload: ${JSON.stringify(message.payload)}`);
328328

329329
try {
330-
const result = (this.kit[message.methodName] as Function)(message.payload);
330+
const result = (this[message.methodName] as Function)(message.payload);
331331
this.completePendingPromise(message.messageId, result);
332332
} catch (error) {
333333
const errorMessage = error instanceof Error ? error.message : String(error);
334334
this.logger?.error(`RoktManager: Error processing message '${message.methodName}': ${errorMessage}`);
335335
this.completePendingPromise(message.messageId, Promise.reject(error));
336336
}
337337
});
338+
339+
// Clear the queue after processing all messages
340+
this.messageQueue.clear();
338341
}
339342

340343
private queueMessage(message: IRoktMessage): void {

0 commit comments

Comments
 (0)