@mparticle/web-sdk
Advanced tools
Comparing version 2.23.7 to 2.23.8
{ | ||
"name": "@mparticle/web-sdk", | ||
"version": "2.23.7", | ||
"version": "2.23.8", | ||
"description": "mParticle core SDK for web applications", | ||
@@ -37,2 +37,3 @@ "license": "Apache-2.0", | ||
"build:webpack:module": "webpack --config test/integrations/module/webpack/webpack.config.js", | ||
"build:rollup:requirejs": "rollup --config test/integrations/requirejs/rollup.requirejs.config.js", | ||
"build:ts": "tsc -p .", | ||
@@ -50,3 +51,3 @@ "test": "npm run build && npm run build:test-bundle && cross-env DEBUG=false karma start test/karma.config.js", | ||
"test:integrations:module:rollup": "npm run build:rollup:module && npm run test:karma:rollup:module", | ||
"test:requirejs": "npm run build && npm run test:requirejs:before && npm run test:requirejs:after", | ||
"test:requirejs": "npm run build:iife && npm run build:rollup:requirejs && npm run test:requirejs:before && npm run test:requirejs:after", | ||
"test:requirejs:before": "cross-env FILE_ORDER=before_mp karma start test/integrations/requirejs/karma.requirejs.config.js", | ||
@@ -110,3 +111,3 @@ "test:requirejs:after": "cross-env FILE_ORDER=after_mp karma start test/integrations/requirejs/karma.requirejs.config.js", | ||
"eslint-plugin-prettier": "3.4.1", | ||
"fetch-mock": "^7.5.1", | ||
"fetch-mock": "^9.1.1", | ||
"gts": "^5.0.1", | ||
@@ -131,3 +132,3 @@ "jest": "^29.5.0", | ||
"should": "^7.1.0", | ||
"sinon": "^11.0.0", | ||
"sinon": "^16.1.3", | ||
"ts-jest": "^29.1.0", | ||
@@ -134,0 +135,0 @@ "tslib": "^2.1.0", |
import Constants from './constants'; | ||
import Types from './types'; | ||
import { BatchUploader } from './batchUploader'; | ||
import { | ||
MParticleUser, | ||
MParticleWebSDK, | ||
MPForwarder, | ||
SDKEvent, | ||
} from './sdkRuntimeModels'; | ||
import { MParticleUser, MParticleWebSDK, SDKEvent } from './sdkRuntimeModels'; | ||
import KitBlocker from './kitBlocking'; | ||
import { Dictionary, getRampNumber, isEmpty } from './utils'; | ||
import { Dictionary, isEmpty } from './utils'; | ||
import { IUploadObject } from './serverModel'; | ||
import { MPForwarder } from './forwarders.interfaces'; | ||
@@ -52,2 +48,3 @@ export type ForwardingStatsData = Dictionary<any>; | ||
// https://go.mparticle.com/work/SQDSDKS-6038 | ||
mpInstance._Persistence.update(); | ||
@@ -124,2 +121,3 @@ }; | ||
// https://go.mparticle.com/work/SQDSDKS-6038 | ||
if (options.shouldUploadEvent) { | ||
@@ -126,0 +124,0 @@ this.queueEventForBatchUpload(event); |
@@ -149,2 +149,4 @@ import { version } from '../package.json'; | ||
}, | ||
// https://go.mparticle.com/work/SQDSDKS-6039 | ||
SDKv2NonMPIDCookieKeys: { | ||
@@ -173,4 +175,10 @@ gs: 1, | ||
CCPAPurpose: 'data_sale_opt_out', | ||
IdentityMethods: { | ||
Modify: 'modify', | ||
Logout: 'logout', | ||
Login: 'login', | ||
Identify: 'identify', | ||
}, | ||
} as const; | ||
export default Constants; |
@@ -352,2 +352,4 @@ import Types from './types'; | ||
mpInstance._APIClient.sendEventToServer(commerceEvent, options); | ||
// https://go.mparticle.com/work/SQDSDKS-6038 | ||
mpInstance._Persistence.update(); | ||
@@ -354,0 +356,0 @@ } else { |
@@ -1,2 +0,7 @@ | ||
import { MParticleUser, SDKEvent, SDKEventCustomFlags, SDKUserIdentity } from './sdkRuntimeModels'; | ||
import { | ||
MParticleUser, | ||
SDKEvent, | ||
SDKEventCustomFlags, | ||
SDKUserIdentity, | ||
} from './sdkRuntimeModels'; | ||
import { Dictionary } from './utils'; | ||
@@ -7,2 +12,6 @@ import { IKitConfigs } from './configAPIClient'; | ||
// TODO: https://go.mparticle.com/work/SQDSDKS-6035 | ||
export type Kit = Dictionary; | ||
export type MPForwarder = Dictionary; | ||
// The state of the kit when accessed via window.KitName via CDN | ||
@@ -36,7 +45,20 @@ // or imported as an NPM package | ||
customFlags: SDKEventCustomFlags, | ||
clientId: string): string; | ||
onIdentifyComplete(user: MParticleUser, filteredIdentityRequest: IdentityApiData): string | KitMappedMethodFailure; | ||
onLoginComplete(user: MParticleUser, filteredIdentityRequest: IdentityApiData): string | KitMappedMethodFailure; | ||
onLogoutComplete(user: MParticleUser, filteredIdentityRequest: IdentityApiData): string | KitMappedMethodFailure; | ||
onModifyComplete(user: MParticleUser, filteredIdentityRequest: IdentityApiData): string | KitMappedMethodFailure; | ||
clientId: string | ||
): string; | ||
onIdentifyComplete( | ||
user: MParticleUser, | ||
filteredIdentityRequest: IdentityApiData | ||
): string | KitMappedMethodFailure; | ||
onLoginComplete( | ||
user: MParticleUser, | ||
filteredIdentityRequest: IdentityApiData | ||
): string | KitMappedMethodFailure; | ||
onLogoutComplete( | ||
user: MParticleUser, | ||
filteredIdentityRequest: IdentityApiData | ||
): string | KitMappedMethodFailure; | ||
onModifyComplete( | ||
user: MParticleUser, | ||
filteredIdentityRequest: IdentityApiData | ||
): string | KitMappedMethodFailure; | ||
onUserIdentified(user: MParticleUser): string | KitMappedMethodFailure; | ||
@@ -43,0 +65,0 @@ process(event: SDKEvent): string; |
@@ -5,3 +5,6 @@ import Types from './types'; | ||
import KitFilterHelper from './kitFilterHelper'; | ||
import Constants from './constants'; | ||
const { Modify, Identify, Login, Logout } = Constants.IdentityMethods; | ||
export default function Forwarders(mpInstance, kitBlocker) { | ||
@@ -444,2 +447,3 @@ var self = this; | ||
// TODO: https://go.mparticle.com/work/SQDSDKS-6036 | ||
this.setForwarderUserIdentities = function(userIdentities) { | ||
@@ -492,5 +496,11 @@ mpInstance._Store.activeForwarders.forEach(function(forwarder) { | ||
); | ||
if (identityMethod === 'identify') { | ||
const filteredUserIdentities = filteredUser.getUserIdentities(); | ||
if (identityMethod === Identify) { | ||
if (forwarder.onIdentifyComplete) { | ||
result = forwarder.onIdentifyComplete(filteredUser); | ||
result = forwarder.onIdentifyComplete( | ||
filteredUser, | ||
filteredUserIdentities | ||
); | ||
if (result) { | ||
@@ -500,5 +510,8 @@ mpInstance.Logger.verbose(result); | ||
} | ||
} else if (identityMethod === 'login') { | ||
} else if (identityMethod === Login) { | ||
if (forwarder.onLoginComplete) { | ||
result = forwarder.onLoginComplete(filteredUser); | ||
result = forwarder.onLoginComplete( | ||
filteredUser, | ||
filteredUserIdentities | ||
); | ||
if (result) { | ||
@@ -508,5 +521,8 @@ mpInstance.Logger.verbose(result); | ||
} | ||
} else if (identityMethod === 'logout') { | ||
} else if (identityMethod === Logout) { | ||
if (forwarder.onLogoutComplete) { | ||
result = forwarder.onLogoutComplete(filteredUser); | ||
result = forwarder.onLogoutComplete( | ||
filteredUser, | ||
filteredUserIdentities | ||
); | ||
if (result) { | ||
@@ -516,5 +532,8 @@ mpInstance.Logger.verbose(result); | ||
} | ||
} else if (identityMethod === 'modify') { | ||
} else if (identityMethod === Modify) { | ||
if (forwarder.onModifyComplete) { | ||
result = forwarder.onModifyComplete(filteredUser); | ||
result = forwarder.onModifyComplete( | ||
filteredUser, | ||
filteredUserIdentities | ||
); | ||
if (result) { | ||
@@ -521,0 +540,0 @@ mpInstance.Logger.verbose(result); |
@@ -102,2 +102,3 @@ import Types from './types'; | ||
// https://go.mparticle.com/work/SQDSDKS-6047 | ||
// Standalone version of jQuery.extend, from https://github.com/dansdom/extend | ||
@@ -104,0 +105,0 @@ this.extend = function() { |
@@ -6,2 +6,4 @@ import Constants from './constants'; | ||
const { Modify } = Constants.IdentityMethods; | ||
export default function IdentityAPIClient(mpInstance) { | ||
@@ -111,3 +113,3 @@ this.sendAliasRequest = function(aliasRequest, callback) { | ||
previousMPID = mpid || null; | ||
if (method === 'modify') { | ||
if (method === Modify) { | ||
xhr.open( | ||
@@ -114,0 +116,0 @@ 'post', |
@@ -1333,2 +1333,3 @@ // | ||
// https://go.mparticle.com/work/SQDSDKS-6044 | ||
if (!mpInstance._Store.webviewBridgeEnabled) { | ||
@@ -1405,2 +1406,3 @@ // Load any settings/identities/attributes from cookie or localStorage | ||
// Call mParticle._Store.SDKConfig.identityCallback when identify was not called due to a reload or a sessionId already existing | ||
// Any identity callback should always be ran regardless if an identity call is made | ||
if ( | ||
@@ -1460,2 +1462,3 @@ !mpInstance._Store.identifyCalled && | ||
// https://go.mparticle.com/work/SQDSDKS-6040 | ||
if (mpInstance._Store.isFirstRun) { | ||
@@ -1462,0 +1465,0 @@ mpInstance._Store.isFirstRun = false; |
@@ -13,2 +13,4 @@ import Constants from './constants'; | ||
var self = this; | ||
// https://go.mparticle.com/work/SQDSDKS-5022 | ||
this.useLocalStorage = function() { | ||
@@ -28,2 +30,3 @@ return ( | ||
// https://go.mparticle.com/work/SQDSDKS-6045 | ||
// Determine if there is any data in cookies or localStorage to figure out if it is the first time the browser is loading mParticle | ||
@@ -37,2 +40,3 @@ if (!localStorageData && !cookies) { | ||
// https://go.mparticle.com/work/SQDSDKS-6045 | ||
if (!mpInstance._Store.isLocalStorageAvailable) { | ||
@@ -42,2 +46,3 @@ mpInstance._Store.SDKConfig.useCookieStorage = true; | ||
// https://go.mparticle.com/work/SQDSDKS-6046 | ||
if (mpInstance._Store.isLocalStorageAvailable) { | ||
@@ -50,2 +55,3 @@ storage = window.localStorage; | ||
if (cookies) { | ||
// https://go.mparticle.com/work/SQDSDKS-6047 | ||
allData = mpInstance._Helpers.extend( | ||
@@ -69,2 +75,3 @@ false, | ||
if (localStorageData) { | ||
// https://go.mparticle.com/work/SQDSDKS-6047 | ||
allData = mpInstance._Helpers.extend( | ||
@@ -88,2 +95,3 @@ false, | ||
// https://go.mparticle.com/work/SQDSDKS-6048 | ||
try { | ||
@@ -117,2 +125,4 @@ if (mpInstance._Store.isLocalStorageAvailable) { | ||
// https://go.mparticle.com/work/SQDSDKS-6046 | ||
// Stores all non-current user MPID information into the store | ||
for (var key in allData) { | ||
@@ -128,2 +138,4 @@ if (allData.hasOwnProperty(key)) { | ||
} catch (e) { | ||
// If cookies or local storage is corrupt, we want to remove it | ||
// so that in the future, initializeStorage will work | ||
if ( | ||
@@ -166,2 +178,3 @@ self.useLocalStorage() && | ||
// https://go.mparticle.com/work/SQDSDKS-6045 | ||
this.storeDataInMemory = function(obj, currentMPID) { | ||
@@ -248,2 +261,3 @@ try { | ||
// https://go.mparticle.com/work/SQDSDKS-5022 | ||
this.determineLocalStorageAvailability = function(storage) { | ||
@@ -324,2 +338,3 @@ var result; | ||
// https://go.mparticle.com/work/SQDSDKS-6021 | ||
this.setLocalStorage = function() { | ||
@@ -507,3 +522,4 @@ if (!mpInstance._Store.isLocalStorageAvailable) { | ||
// only used in persistence | ||
// https://go.mparticle.com/work/SQDSDKS-5022 | ||
// https://go.mparticle.com/work/SQDSDKS-6021 | ||
this.setCookie = function() { | ||
@@ -1012,2 +1028,3 @@ var mpid, | ||
// https://go.mparticle.com/work/SQDSDKS-6021 | ||
this.savePersistence = function(persistence) { | ||
@@ -1185,2 +1202,3 @@ var encodedPersistence = self.encodePersistence( | ||
// https://go.mparticle.com/work/SQDSDKS-6045 | ||
// Forwarder Batching Code | ||
@@ -1187,0 +1205,0 @@ this.forwardingStatsBatches = { |
@@ -13,2 +13,3 @@ import * as EventsApi from '@mparticle/event-models'; | ||
import { ISessionManager } from './sessionManager'; | ||
import { Kit, MPForwarder } from './forwarders.interfaces'; | ||
@@ -188,6 +189,2 @@ // TODO: Resolve this with version in @mparticle/web-sdk | ||
// TODO: Create true types for Kits and Kit Configs | ||
export type Kit = Dictionary; | ||
export type MPForwarder = Dictionary; | ||
// TODO: This should eventually be moved into wherever init logic lives | ||
@@ -194,0 +191,0 @@ // TODO: Replace/Merge this with MPConfiguration in @types/mparticle__web-sdk |
@@ -16,3 +16,8 @@ // TODO: This file is no longer the server model because the web SDK payload | ||
} from './sdkRuntimeModels'; | ||
import { parseNumber, parseStringOrNumber, Dictionary } from './utils'; | ||
import { | ||
parseNumber, | ||
parseStringOrNumber, | ||
Dictionary, | ||
isValidCustomFlagProperty, | ||
} from './utils'; | ||
import { ServerSettings } from './store'; | ||
@@ -149,18 +154,8 @@ import { MPID } from '@mparticle/web-sdk'; | ||
if (Array.isArray(event.CustomFlags[prop])) { | ||
event.CustomFlags[prop].forEach(function(customFlagProperty) { | ||
// TODO: Can we use our utility functions here? | ||
if ( | ||
typeof customFlagProperty === 'number' || | ||
typeof customFlagProperty === 'string' || | ||
typeof customFlagProperty === 'boolean' | ||
) { | ||
event.CustomFlags[prop].forEach(customFlagProperty => { | ||
if (isValidCustomFlagProperty(customFlagProperty)) { | ||
valueArray.push(customFlagProperty.toString()); | ||
} | ||
}); | ||
} else if ( | ||
// TODO: Can we use our utility functions here? | ||
typeof event.CustomFlags[prop] === 'number' || | ||
typeof event.CustomFlags[prop] === 'string' || | ||
typeof event.CustomFlags[prop] === 'boolean' | ||
) { | ||
} else if (isValidCustomFlagProperty(event.CustomFlags[prop])) { | ||
valueArray.push(event.CustomFlags[prop].toString()); | ||
@@ -167,0 +162,0 @@ } |
@@ -47,2 +47,3 @@ import { MPID } from '@mparticle/web-sdk'; | ||
} else { | ||
// https://go.mparticle.com/work/SQDSDKS-6045 | ||
const persistence: IPersistenceMinified = mpInstance._Persistence.getPersistence(); | ||
@@ -49,0 +50,0 @@ if (persistence && !persistence.cu) { |
@@ -14,7 +14,5 @@ import { Batch } from '@mparticle/event-models'; | ||
DataPlanResult, | ||
Kit, | ||
KitBlockerOptions, | ||
LogLevelType, | ||
MParticleWebSDK, | ||
MPForwarder, | ||
SDKDataPlan, | ||
@@ -28,2 +26,3 @@ SDKEvent, | ||
import { SDKConsentState } from './consent'; | ||
import { Kit, MPForwarder } from './forwarders.interfaces'; | ||
@@ -30,0 +29,0 @@ // This represents the runtime configuration of the SDK AFTER |
@@ -204,3 +204,6 @@ import Constants from './constants'; | ||
const isNumber = (value: any): boolean => typeof value === 'number'; | ||
const isBoolean = (value: any): boolean => typeof value === 'boolean'; | ||
const isFunction = (fn: any): boolean => typeof fn === 'function'; | ||
const isValidCustomFlagProperty = (value: any): boolean => | ||
isNumber(value) || isString(value) || isBoolean(value); | ||
@@ -251,2 +254,3 @@ const toDataPlanSlug = (value: any): string => | ||
isEmpty, | ||
isValidCustomFlagProperty, | ||
}; |
import Types from './types'; | ||
import { isFunction, isNumber, isObject, isStringOrNumber, valueof } from './utils'; | ||
import { | ||
isFunction, | ||
isNumber, | ||
isObject, | ||
isStringOrNumber, | ||
valueof, | ||
} from './utils'; | ||
import Constants from './constants'; | ||
@@ -13,2 +19,4 @@ import { IdentityApiData } from '@mparticle/web-sdk'; | ||
const { Modify } = Constants.IdentityMethods; | ||
const Validators = { | ||
@@ -47,3 +55,3 @@ // From ./utils | ||
if (identityApiData) { | ||
if (method === 'modify') { | ||
if (method === Modify) { | ||
if ( | ||
@@ -50,0 +58,0 @@ (isObject(identityApiData.userIdentities) && |
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
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1467171
26297