Socket
Socket
Sign inDemoInstall

@mparticle/web-sdk

Package Overview
Dependencies
Maintainers
10
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mparticle/web-sdk - npm Package Compare versions

Comparing version 2.19.3 to 2.20.0

src/persistence.interfaces.ts

2

package.json
{
"name": "@mparticle/web-sdk",
"version": "2.19.3",
"version": "2.20.0",
"description": "mParticle core SDK for web applications",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

import Types from './types';
import filteredMparticleUser from './filteredMparticleUser';
import { isEmpty } from './utils';

@@ -62,3 +63,2 @@ export default function Forwarders(mpInstance, kitBlocker) {

);
if (!forwarder.initialized) {

@@ -528,3 +528,46 @@ forwarder.logger = mpInstance.Logger;

this.configureForwarder = function(configuration) {
// Processing forwarders is a 2 step process:
// 1. Configure the kit
// 2. Initialize the kit
// There are 2 types of kits:
// 1. UI-enabled kits
// 2. Sideloaded kits.
this.processForwarders = function(config, forwardingStatsCallback) {
if (!config) {
mpInstance.Logger.warning(
'No config was passed. Cannot process forwarders'
);
} else {
this.processUIEnabledKits(config);
this.processSideloadedKits(config);
self.initForwarders(
mpInstance._Store.SDKConfig.identifyRequest.userIdentities,
forwardingStatsCallback
);
}
};
// These are kits that are enabled via the mParticle UI.
// A kit that is UI-enabled will have a kit configuration that returns from
// the server, or in rare cases, is passed in by the developer.
// The kit configuration will be compared with the kit constructors to determine
// if there is a match before being initialized.
// Only kits that are configured properly can be active and used for kit forwarding.
this.processUIEnabledKits = function(config) {
try {
if (Array.isArray(config.kitConfigs) && config.kitConfigs.length) {
config.kitConfigs.forEach(function(kitConfig) {
self.configureUIEnabledKit(kitConfig);
});
}
} catch (e) {
mpInstance.Logger.error(
'MP Kits not configured propertly. Kits may not be initialized. ' +
e
);
}
};
this.configureUIEnabledKit = function(configuration) {
var newForwarder = null,

@@ -534,10 +577,7 @@ config = configuration,

// if there are kits inside of mpInstance._Store.SDKConfig.kits, then mParticle is self hosted
if (
mpInstance._Helpers.isObject(mpInstance._Store.SDKConfig.kits) &&
Object.keys(mpInstance._Store.SDKConfig.kits).length > 0
) {
// If there are kits inside of mpInstance._Store.SDKConfig.kits, then mParticle is self hosted
if (!isEmpty(mpInstance._Store.SDKConfig.kits)) {
forwarders = mpInstance._Store.SDKConfig.kits;
// otherwise mParticle is loaded via script tag
} else if (mpInstance._preInit.forwarderConstructors.length > 0) {
} else if (!isEmpty(mpInstance._preInit.forwarderConstructors)) {
mpInstance._preInit.forwarderConstructors.forEach(function(

@@ -558,42 +598,92 @@ forwarder

) {
newForwarder = new forwarders[name].constructor();
newForwarder = this.returnConfiguredKit(
forwarders[name],
config
);
newForwarder.id = config.moduleId;
newForwarder.isSandbox = config.isDebug || config.isSandbox;
newForwarder.hasSandbox = config.hasDebugString === 'true';
newForwarder.isVisible = config.isVisible;
newForwarder.settings = config.settings;
mpInstance._Store.configuredForwarders.push(newForwarder);
break;
}
}
}
};
newForwarder.eventNameFilters = config.eventNameFilters;
newForwarder.eventTypeFilters = config.eventTypeFilters;
newForwarder.attributeFilters = config.attributeFilters;
// Sideloaded kits are not configured in the UI and do not have kit configurations
// They are automatically added to active forwarders.
newForwarder.screenNameFilters = config.screenNameFilters;
newForwarder.screenNameFilters = config.screenNameFilters;
newForwarder.screenAttributeFilters =
config.screenAttributeFilters;
// TODO: Sideloading kits currently requires the use of a register method
// which requires an object on which to be registered.
// In the future, when all kits are moved to the config rather than
// there being a separate process for MP configured kits and
// sideloaded kits, this will need to be refactored.
this.processSideloadedKits = function(config) {
try {
if (Array.isArray(config.sideloadedKits)) {
const sideloadedKits = { kits: {} };
// First register each kit's constructor onto sideloadedKits,
// which is typed { kits: Dictionary<constructor> }.
// The constructors are keyed by the name of the kit.
config.sideloadedKits.forEach(function(sideloadedKit) {
sideloadedKit.register(sideloadedKits);
});
newForwarder.userIdentityFilters =
config.userIdentityFilters;
newForwarder.userAttributeFilters =
config.userAttributeFilters;
newForwarder.filteringEventAttributeValue =
config.filteringEventAttributeValue;
newForwarder.filteringUserAttributeValue =
config.filteringUserAttributeValue;
newForwarder.eventSubscriptionId =
config.eventSubscriptionId;
newForwarder.filteringConsentRuleValues =
config.filteringConsentRuleValues;
newForwarder.excludeAnonymousUser =
config.excludeAnonymousUser;
mpInstance._Store.configuredForwarders.push(newForwarder);
break;
// Then configure each kit
for (const registeredKitKey in sideloadedKits.kits) {
const kitConstructor =
sideloadedKits.kits[registeredKitKey];
self.configureSideloadedKit(kitConstructor);
}
}
} catch (e) {
mpInstance.Logger.error(
'Sideloaded Kits not configured propertly. Kits may not be initialized. ' +
e
);
}
};
// kits can be included via mParticle UI, or via sideloaded kit config API
this.configureSideloadedKit = function(kitConstructor) {
mpInstance._Store.configuredForwarders.push(
this.returnConfiguredKit(kitConstructor)
);
};
this.returnConfiguredKit = function(forwarder, config = {}) {
const newForwarder = new forwarder.constructor();
newForwarder.id = config.moduleId;
// TODO: isSandbox, hasSandbox is never used in any kit or in core SDK.
// isVisibleInvestigate is only used in 1 place. It is always true if
// it is sent to JS. Investigate further to determine if these can be removed.
// https://go.mparticle.com/work/SQDSDKS-5156
newForwarder.isSandbox = config.isDebug || config.isSandbox;
newForwarder.hasSandbox = config.hasDebugString === 'true';
newForwarder.isVisible = config.isVisible || true;
newForwarder.settings = config.settings || {};
newForwarder.eventNameFilters = config.eventNameFilters || [];
newForwarder.eventTypeFilters = config.eventTypeFilters || [];
newForwarder.attributeFilters = config.attributeFilters || [];
newForwarder.screenNameFilters = config.screenNameFilters || [];
newForwarder.screenAttributeFilters =
config.screenAttributeFilters || [];
newForwarder.userIdentityFilters = config.userIdentityFilters || [];
newForwarder.userAttributeFilters = config.userAttributeFilters || [];
newForwarder.filteringEventAttributeValue =
config.filteringEventAttributeValue || {};
newForwarder.filteringUserAttributeValue =
config.filteringUserAttributeValue || {};
newForwarder.eventSubscriptionId = config.eventSubscriptionId || null;
newForwarder.filteringConsentRuleValues =
config.filteringConsentRuleValues || {};
newForwarder.excludeAnonymousUser =
config.excludeAnonymousUser || false;
return newForwarder;
};
this.configurePixel = function(settings) {

@@ -610,37 +700,16 @@ if (

this.processForwarders = function(config, forwardingStatsCallback) {
if (!config) {
mpInstance.Logger.warning(
'No config was passed. Cannot process forwarders'
this.processPixelConfigs = function(config) {
try {
if (!isEmpty(config.pixelConfigs)) {
config.pixelConfigs.forEach(function(pixelConfig) {
self.configurePixel(pixelConfig);
});
}
} catch (e) {
mpInstance.Logger.error(
'Cookie Sync configs not configured propertly. Cookie Sync may not be initialized. ' +
e
);
} else {
try {
if (
Array.isArray(config.kitConfigs) &&
config.kitConfigs.length
) {
config.kitConfigs.forEach(function(kitConfig) {
self.configureForwarder(kitConfig);
});
}
if (
Array.isArray(config.pixelConfigs) &&
config.pixelConfigs.length
) {
config.pixelConfigs.forEach(function(pixelConfig) {
self.configurePixel(pixelConfig);
});
}
self.initForwarders(
mpInstance._Store.SDKConfig.identifyRequest.userIdentities,
forwardingStatsCallback
);
} catch (e) {
mpInstance.Logger.error(
'Config was not parsed propertly. Forwarders may not be initialized.'
);
}
}
};
}

@@ -43,2 +43,3 @@ // This file is used ONLY for the mParticle ESLint plugin. It should NOT be used otherwise!

sessionId: 'mockSessionId',
sideloadedKits: [],
devToken: 'test_dev_token',

@@ -45,0 +46,0 @@ isFirstRun: true,

@@ -1424,2 +1424,4 @@ //

mpInstance._Forwarders.processPixelConfigs(config);
mpInstance._SessionManager.initialize();

@@ -1426,0 +1428,0 @@ mpInstance._Events.logAST();

@@ -962,2 +962,5 @@ import Constants from './constants';

if (persistence[mpid]) {
// TODO: Investigate why setting this to UI still shows up as UA
// when running `mParticle.getInstance()._Persistence.getLocalStorage()`
// https://go.mparticle.com/work/SQDSDKS-5195
persistence[mpid].ui = userAttributes;

@@ -964,0 +967,0 @@ } else {

@@ -10,2 +10,3 @@ import * as EventsApi from '@mparticle/event-models';

import { SDKConsentApi, SDKConsentState } from './consent';
import { IPersistence } from './persistence.interfaces';

@@ -143,3 +144,3 @@ // TODO: Resolve this with version in @mparticle/web-sdk

_NativeSdkHelpers: any; // TODO: Set up API
_Persistence: any; // TODO: Set up Persistence API
_Persistence: IPersistence;
_preInit: any; // TODO: Set up API

@@ -191,2 +192,3 @@ _resetForTests(MPConfig?: SDKInitConfig): void;

kits?: Dictionary<Kit>;
sideloadedKits?: MPForwarder[];
dataPlanOptions?: KitBlockerOptions;

@@ -193,0 +195,0 @@ flags?: Dictionary;

@@ -57,3 +57,3 @@ import { Batch } from '@mparticle/event-models';

integrationDelayTimeout: number;
sideloadedKits: MPForwarder[];
aliasMaxWindow: number;

@@ -105,2 +105,4 @@ deviceId?: string;

export type ServerSettings = Dictionary;
export type SessionAttributes = Dictionary;
export type IntegrationAttributes = Dictionary<Dictionary<string>>;

@@ -117,3 +119,3 @@ type WrapperSDKTypes = 'flutter' | 'none';

isEnabled: boolean;
sessionAttributes: Dictionary;
sessionAttributes: SessionAttributes;
currentSessionMPIDs: MPID[];

@@ -146,3 +148,3 @@ consentState: SDKConsentState | null;

cookieSyncDates: Dictionary<number>;
integrationAttributes: Dictionary<Dictionary<string>>;
integrationAttributes: IntegrationAttributes;
requireDelay: boolean;

@@ -154,2 +156,3 @@ isLocalStorageAvailable: boolean | null;

kits: Dictionary<MPForwarder>;
sideloadedKits: MPForwarder[];
configuredForwarders: MPForwarder[];

@@ -205,2 +208,3 @@ pixelConfigurations: PixelConfiguration[];

kits: {},
sideloadedKits: [],
configuredForwarders: [],

@@ -268,2 +272,4 @@ pixelConfigurations: [],

this.SDKConfig.sideloadedKits = config.sideloadedKits || [];
if (config.hasOwnProperty('isIOS')) {

@@ -270,0 +276,0 @@ this.SDKConfig.isIOS = config.isIOS;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc