Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## [2.50.1](https://github.com/mParticle/mparticle-web-sdk/compare/v2.50.0...v2.50.1) (2025-11-20)

# [2.50.0](https://github.com/mParticle/mparticle-web-sdk/compare/v2.49.0...v2.50.0) (2025-11-13)


Expand Down
24 changes: 13 additions & 11 deletions dist/mparticle.common.js

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions dist/mparticle.esm.js

Large diffs are not rendered by default.

83 changes: 5 additions & 78 deletions dist/mparticle.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ var mParticle = (function () {
Base64: Base64$1
};

var version = "2.50.0";
var version = "2.50.1";

var Constants = {
sdkVersion: version,
Expand Down Expand Up @@ -413,12 +413,6 @@ var mParticle = (function () {
var HTTP_OK = 200;
var HTTP_ACCEPTED = 202;
var HTTP_BAD_REQUEST = 400;
var StoragePrivacyMap = {
SDKState: 'functional',
OfflineEvents: 'functional',
IdentityCache: 'functional',
TimeOnSite: 'targeting'
};

/******************************************************************************
Copyright (c) Microsoft Corporation.
Expand Down Expand Up @@ -2200,22 +2194,6 @@ var mParticle = (function () {
}
return SessionStorageVault;
}(BaseVault);
// DisabledVault is used when persistence is disabled by privacy flags.
var DisabledVault = /** @class */function (_super) {
__extends(DisabledVault, _super);
function DisabledVault(storageKey, options) {
var _this = _super.call(this, storageKey, window.localStorage, options) || this;
_this.contents = null;
return _this;
}
DisabledVault.prototype.store = function (_item) {
this.contents = null;
};
DisabledVault.prototype.retrieve = function () {
return this.contents;
};
return DisabledVault;
}(BaseVault);

var AsyncUploader = /** @class */function () {
function AsyncUploader(url) {
Expand Down Expand Up @@ -2395,7 +2373,7 @@ var mParticle = (function () {
this.batchesQueuedForProcessing = [];
// Cache Offline Storage Availability boolean
// so that we don't have to check it every time
this.offlineStorageEnabled = this.isOfflineStorageAvailable() && !mpInstance._Store.getPrivacyFlag('OfflineEvents');
this.offlineStorageEnabled = this.isOfflineStorageAvailable();
if (this.offlineStorageEnabled) {
this.eventVault = new SessionStorageVault("".concat(mpInstance._Store.storageName, "-events"), {
logger: mpInstance.Logger
Expand Down Expand Up @@ -4402,8 +4380,6 @@ var mParticle = (function () {
var isWebviewEnabled = mpInstance._NativeSdkHelpers.isWebviewEnabled;
var defaultStore = {
isEnabled: true,
noFunctional: false,
noTargeting: false,
sessionAttributes: {},
localSessionAttributes: {},
currentSessionMPIDs: [],
Expand Down Expand Up @@ -4641,28 +4617,6 @@ var mParticle = (function () {
_this._setPersistence(mpid, 'con', toMinifiedJsonObject(consentState));
}
};
this.getNoFunctional = function () {
return _this.noFunctional;
};
this.setNoFunctional = function (noFunctional) {
_this.noFunctional = noFunctional;
};
this.getNoTargeting = function () {
return _this.noTargeting;
};
this.setNoTargeting = function (noTargeting) {
_this.noTargeting = noTargeting;
};
this.getPrivacyFlag = function (storageType) {
var privacyControl = StoragePrivacyMap[storageType];
if (privacyControl === 'functional') {
return _this.getNoFunctional();
}
if (privacyControl === 'targeting') {
return _this.getNoTargeting();
}
return false;
};
this.getDeviceId = function () {
return _this.deviceId;
};
Expand Down Expand Up @@ -4743,7 +4697,6 @@ var mParticle = (function () {
mpInstance._Persistence.update();
};
this.processConfig = function (config) {
var _a;
var workspaceToken = config.workspaceToken,
requiredWebviewBridgeName = config.requiredWebviewBridgeName;
// We should reprocess the flags and baseUrls in case they have changed when we request an updated config
Expand All @@ -4754,20 +4707,9 @@ var mParticle = (function () {
for (var baseUrlKeys in baseUrls) {
_this.SDKConfig[baseUrlKeys] = baseUrls[baseUrlKeys];
}
var _b = (_a = config === null || config === void 0 ? void 0 : config.launcherOptions) !== null && _a !== void 0 ? _a : {},
noFunctional = _b.noFunctional,
noTargeting = _b.noTargeting;
if (noFunctional != null) {
_this.setNoFunctional(noFunctional);
}
if (noTargeting != null) {
_this.setNoTargeting(noTargeting);
}
if (workspaceToken) {
_this.SDKConfig.workspaceToken = workspaceToken;
if (!_this.getPrivacyFlag('TimeOnSite')) {
mpInstance._timeOnSiteTimer = new ForegroundTimeTracker(workspaceToken);
}
mpInstance._timeOnSiteTimer = new ForegroundTimeTracker(workspaceToken);
} else {
mpInstance.Logger.warning('You should have a workspaceToken on your config object for security purposes.');
}
Expand Down Expand Up @@ -4952,9 +4894,6 @@ var mParticle = (function () {
} else {
mpInstance._Store.isFirstRun = false;
}
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
return;
}

// https://go.mparticle.com/work/SQDSDKS-6045
if (!mpInstance._Store.isLocalStorageAvailable) {
Expand Down Expand Up @@ -5021,7 +4960,7 @@ var mParticle = (function () {
}
};
this.update = function () {
if (!mpInstance._Store.webviewBridgeEnabled && !mpInstance._Store.getPrivacyFlag('SDKState')) {
if (!mpInstance._Store.webviewBridgeEnabled) {
if (mpInstance._Store.SDKConfig.useCookieStorage) {
self.setCookie();
}
Expand Down Expand Up @@ -5504,9 +5443,6 @@ var mParticle = (function () {

// https://go.mparticle.com/work/SQDSDKS-6021
this.savePersistence = function (persistence) {
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
return;
}
var encodedPersistence = self.encodePersistence(JSON.stringify(persistence)),
date = new Date(),
key = mpInstance._Store.storageName,
Expand All @@ -5528,9 +5464,6 @@ var mParticle = (function () {
}
};
this.getPersistence = function () {
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
return null;
}
var persistence = this.useLocalStorage() ? this.getLocalStorage() : this.getCookie();
return persistence;
};
Expand Down Expand Up @@ -11065,13 +10998,7 @@ var mParticle = (function () {
return kitBlocker;
}
function createIdentityCache(mpInstance) {
var cacheKey = "".concat(mpInstance._Store.storageName, "-id-cache");
if (mpInstance._Store.getPrivacyFlag('IdentityCache')) {
return new DisabledVault(cacheKey, {
logger: mpInstance.Logger
});
}
return new LocalStorageVault(cacheKey, {
return new LocalStorageVault("".concat(mpInstance._Store.storageName, "-id-cache"), {
logger: mpInstance.Logger
});
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mparticle/web-sdk",
"version": "2.50.0",
"version": "2.50.1",
"description": "mParticle core SDK for web applications",
"license": "Apache-2.0",
"keywords": [
Expand Down
24 changes: 24 additions & 0 deletions src/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { AsyncUploader, FetchUploader, XHRUploader } from './uploaders';
import { IMParticleWebSDKInstance } from './mp-instance';
import { appendUserInfo } from './user-utils';
import { LogRequest } from './logging/logRequest';

export interface IAPIClient {
uploader: BatchUploader | null;
Expand All @@ -27,6 +28,7 @@
forwarder: MPForwarder,
event: IUploadObject
) => void;
sendLogToServer: (log: LogRequest) => void;
}

export interface IForwardingStatsData {
Expand Down Expand Up @@ -231,4 +233,26 @@
}
}
};

this.sendLogToServer = function(logRequest: LogRequest) {
const baseUrl = mpInstance._Helpers.createServiceUrl(

Check warning on line 238 in src/apiClient.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this useless assignment to variable "baseUrl".

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-web-sdk&issues=AZq7z7yxzKrzhH-ms5s5&open=AZq7z7yxzKrzhH-ms5s5&pullRequest=1122
mpInstance._Store.SDKConfig.v2SecureServiceUrl,
mpInstance._Store.devToken
);
const uploadUrl = `apps.stage.rokt.com/v1/log/v1/log`;
// const uploadUrl = `${baseUrl}/v1/log`;

Check warning on line 243 in src/apiClient.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this commented out code.

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-web-sdk&issues=AZq7z7yxzKrzhH-ms5s6&open=AZq7z7yxzKrzhH-ms5s6&pullRequest=1122

const uploader = window.fetch

Check warning on line 245 in src/apiClient.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-web-sdk&issues=AZq7z7yxzKrzhH-ms5s7&open=AZq7z7yxzKrzhH-ms5s7&pullRequest=1122
? new FetchUploader(uploadUrl)
: new XHRUploader(uploadUrl);

uploader.upload({
method: 'POST',
headers: {
Accept: 'text/plain;charset=UTF-8',
'Content-Type': 'text/plain;charset=UTF-8',
},
body: JSON.stringify(logRequest),
});
};
}
4 changes: 1 addition & 3 deletions src/batchUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ export class BatchUploader {

// Cache Offline Storage Availability boolean
// so that we don't have to check it every time
this.offlineStorageEnabled =
this.isOfflineStorageAvailable() &&
!mpInstance._Store.getPrivacyFlag('OfflineEvents');
this.offlineStorageEnabled = this.isOfflineStorageAvailable();

if (this.offlineStorageEnabled) {
this.eventVault = new SessionStorageVault<SDKEvent[]>(
Expand Down
11 changes: 0 additions & 11 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,3 @@ export const HTTP_UNAUTHORIZED = 401 as const;
export const HTTP_FORBIDDEN = 403 as const;
export const HTTP_NOT_FOUND = 404 as const;
export const HTTP_SERVER_ERROR = 500 as const;

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

export type StorageTypes = 'SDKState' | 'OfflineEvents' | 'IdentityCache' | 'TimeOnSite';

export const StoragePrivacyMap: Record<StorageTypes, PrivacyControl> = {
SDKState: 'functional',
OfflineEvents: 'functional',
IdentityCache: 'functional',
TimeOnSite: 'targeting',
};
5 changes: 5 additions & 0 deletions src/logging/errorCodes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type ErrorCodes = (typeof ErrorCodes)[keyof typeof ErrorCodes];

export const ErrorCodes = {
UNHANDLED_EXCEPTION: 'UNHANDLED_EXCEPTION',
} as const;
Empty file added src/logging/logMessage.ts
Empty file.
21 changes: 21 additions & 0 deletions src/logging/logRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ErrorCodes } from "./errorCodes";

export enum LogRequestSeverity {
Error = 'error',
Warning = 'warning',
Info = 'info',
}

export interface LogRequest {
additionalInformation: {
message: string;
version: string;
};
severity: LogRequestSeverity;
code: ErrorCodes;
url: string;
deviceInfo: string;
stackTrace: string;
reporter: string;
integration: string;
}
Loading
Loading