@mparticle/web-sdk
Advanced tools
Comparing version 2.26.3 to 2.26.4
{ | ||
"name": "@mparticle/web-sdk", | ||
"version": "2.26.3", | ||
"version": "2.26.4", | ||
"description": "mParticle core SDK for web applications", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
import Constants from './constants'; | ||
import Types from './types'; | ||
import { BatchUploader } from './batchUploader'; | ||
import { MParticleUser, MParticleWebSDK, SDKEvent } from './sdkRuntimeModels'; | ||
import { MParticleWebSDK, SDKEvent } from './sdkRuntimeModels'; | ||
import KitBlocker from './kitBlocking'; | ||
@@ -9,2 +9,3 @@ import { Dictionary, getRampNumber, isEmpty, parseNumber } from './utils'; | ||
import { MPForwarder } from './forwarders.interfaces'; | ||
import { IMParticleUser } from './identity-user-interfaces'; | ||
@@ -17,3 +18,3 @@ export type ForwardingStatsData = Dictionary<any>; | ||
processQueuedEvents: () => void; | ||
appendUserInfoToEvents: (user: MParticleUser, events: SDKEvent[]) => void; | ||
appendUserInfoToEvents: (user: IMParticleUser, events: SDKEvent[]) => void; | ||
sendEventToServer: (event: SDKEvent, _options?: Dictionary<any>) => void; | ||
@@ -20,0 +21,0 @@ sendSingleEventToServer: (event: SDKEvent) => void; |
import { Batch } from '@mparticle/event-models'; | ||
import Constants from './constants'; | ||
import { | ||
SDKEvent, | ||
MParticleUser, | ||
MParticleWebSDK, | ||
SDKLoggerApi, | ||
} from './sdkRuntimeModels'; | ||
import { SDKEvent, MParticleWebSDK, SDKLoggerApi } from './sdkRuntimeModels'; | ||
import { convertEvents } from './sdkToEventsApiConverter'; | ||
@@ -13,8 +8,9 @@ import Types from './types'; | ||
import { SessionStorageVault, LocalStorageVault } from './vault'; | ||
import { | ||
import { | ||
AsyncUploader, | ||
FetchUploader, | ||
XHRUploader, | ||
fetchPayload | ||
fetchPayload, | ||
} from './uploaders'; | ||
import { IMParticleUser } from './identity-user-interfaces'; | ||
@@ -209,3 +205,3 @@ /** | ||
sdkEvents: SDKEvent[], | ||
defaultUser: MParticleUser, | ||
defaultUser: IMParticleUser, | ||
mpInstance: MParticleWebSDK | ||
@@ -212,0 +208,0 @@ ): Batch[] | null { |
@@ -7,6 +7,7 @@ import { | ||
} from '@mparticle/web-sdk'; | ||
import { MParticleUser, MParticleWebSDK } from './sdkRuntimeModels'; | ||
import { MParticleWebSDK } from './sdkRuntimeModels'; | ||
import { Dictionary, isObject } from './utils'; | ||
import KitFilterHelper from './kitFilterHelper'; | ||
import Constants from './constants'; | ||
import { IMParticleUser } from './identity-user-interfaces'; | ||
@@ -112,3 +113,3 @@ const { CCPAPurpose } = Constants; | ||
consentRules: IConsentRules, | ||
user: MParticleUser | ||
user: IMParticleUser | ||
) => boolean; | ||
@@ -128,3 +129,3 @@ createPrivacyConsent: ICreatePrivacyConsentFunction; | ||
consentRules: IConsentRules, | ||
user: MParticleUser | ||
user: IMParticleUser | ||
): boolean { | ||
@@ -131,0 +132,0 @@ if ( |
@@ -1,11 +0,10 @@ | ||
import { | ||
MParticleUser, | ||
SDKEvent, | ||
SDKEventCustomFlags, | ||
SDKUserIdentity, | ||
} from './sdkRuntimeModels'; | ||
import { SDKEvent, SDKEventCustomFlags } from './sdkRuntimeModels'; | ||
import { Dictionary } from './utils'; | ||
import { IKitConfigs } from './configAPIClient'; | ||
import { UserAttributes } from './persistence.interfaces'; | ||
import { IdentityApiData } from '@mparticle/web-sdk'; | ||
import { | ||
IMParticleUser, | ||
ISDKUserIdentity, | ||
UserAttributes, | ||
} from './identity-user-interfaces'; | ||
@@ -22,3 +21,3 @@ // TODO: https://go.mparticle.com/work/SQDSDKS-6035 | ||
// The state of the kit after being added to forwarderConstructors in the CDN | ||
// The state of the kit after being added to forwarderConstructors in the CDN | ||
// or after registered to SDKConfig.kits via NPM | ||
@@ -41,3 +40,3 @@ export interface RegisteredKit { | ||
userAttributes: UserAttributes, | ||
userIdentities: SDKUserIdentity, | ||
userIdentities: ISDKUserIdentity, | ||
appVersion: string, | ||
@@ -49,22 +48,22 @@ appName: string, | ||
onIdentifyComplete( | ||
user: MParticleUser, | ||
user: IMParticleUser, | ||
filteredIdentityRequest: IdentityApiData | ||
): string | KitMappedMethodFailure; | ||
onLoginComplete( | ||
user: MParticleUser, | ||
user: IMParticleUser, | ||
filteredIdentityRequest: IdentityApiData | ||
): string | KitMappedMethodFailure; | ||
onLogoutComplete( | ||
user: MParticleUser, | ||
user: IMParticleUser, | ||
filteredIdentityRequest: IdentityApiData | ||
): string | KitMappedMethodFailure; | ||
onModifyComplete( | ||
user: MParticleUser, | ||
user: IMParticleUser, | ||
filteredIdentityRequest: IdentityApiData | ||
): string | KitMappedMethodFailure; | ||
onUserIdentified(user: MParticleUser): string | KitMappedMethodFailure; | ||
onUserIdentified(user: IMParticleUser): string | KitMappedMethodFailure; | ||
process(event: SDKEvent): string; | ||
setOptOut(isOptingOut: boolean): string | KitMappedMethodFailure; | ||
removeUserAttribute(key: string): string; | ||
setUserAttribute(key: string, value:string): string; | ||
setUserAttribute(key: string, value: string): string; | ||
@@ -76,7 +75,7 @@ // TODO: Convert type to enum during Identity migration | ||
// TODO: https://go.mparticle.com/work/SQDSDKS-5156 | ||
isSandbox: boolean; | ||
isSandbox: boolean; | ||
hasSandbox: boolean; | ||
} | ||
export interface KitMappedMethodFailure { | ||
error: string | ||
error: string; | ||
} | ||
@@ -87,2 +86,5 @@ | ||
export type forwardingStatsCallback = (forwarder: ConfiguredKit, event: SDKEvent) => void; | ||
export type forwardingStatsCallback = ( | ||
forwarder: ConfiguredKit, | ||
event: SDKEvent | ||
) => void; |
@@ -6,3 +6,3 @@ import Constants, { ONE_DAY_IN_SECONDS, MILLIS_IN_ONE_SEC } from './constants'; | ||
import { IdentityApiData, UserIdentities, IdentityCallback } from '@mparticle/web-sdk'; | ||
import { IdentityAPIMethod, MParticleWebSDK } from './sdkRuntimeModels'; | ||
import { IdentityAPIMethod } from './identity.interfaces'; | ||
@@ -9,0 +9,0 @@ const { Identify, Modify, Login, Logout } = Constants.IdentityMethods; |
@@ -17,2 +17,3 @@ import { Context } from '@mparticle/event-models'; | ||
import { Dictionary } from './utils'; | ||
import { UserAttributes } from './identity-user-interfaces'; | ||
@@ -26,6 +27,2 @@ export type CookieSyncDate = Dictionary<string>; | ||
// TODO: Migrate this to @types/mparticle__web-sdk | ||
// https://go.mparticle.com/work/SQDSDKS-5196 | ||
export type UserAttributes = AllUserAttributes; | ||
export interface IGlobalStoreV2MinifiedKeys { | ||
@@ -32,0 +29,0 @@ sid: string; // Session ID |
import * as EventsApi from '@mparticle/event-models'; | ||
import { DataPlanVersion } from '@mparticle/data-planning-models'; | ||
import { | ||
MPConfiguration, | ||
IdentityApiData, | ||
MPID, | ||
Callback, | ||
} from '@mparticle/web-sdk'; | ||
import { MPConfiguration, MPID, Callback } from '@mparticle/web-sdk'; | ||
import { IStore } from './store'; | ||
import Validators from './validators'; | ||
import { Dictionary, valueof } from './utils'; | ||
import { Dictionary } from './utils'; | ||
import { IServerModel } from './serverModel'; | ||
@@ -19,3 +14,9 @@ import { IKitConfigs } from './configAPIClient'; | ||
import { Kit, MPForwarder } from './forwarders.interfaces'; | ||
import Constants from './constants'; | ||
import { SDKIdentityApi } from './identity.interfaces'; | ||
import { | ||
ISDKUserAttributeChangeData, | ||
ISDKUserIdentityChanges, | ||
IMParticleUser, | ||
ISDKUserIdentity, | ||
} from './identity-user-interfaces'; | ||
@@ -31,3 +32,3 @@ // TODO: Resolve this with version in @mparticle/web-sdk | ||
UserAttributes?: { [key: string]: string | string[] | null }; | ||
UserIdentities?: SDKUserIdentity[]; | ||
UserIdentities?: ISDKUserIdentity[]; | ||
SourceMessageId: string; | ||
@@ -56,4 +57,4 @@ MPID: string; | ||
ShoppingCart?: SDKShoppingCart; | ||
UserIdentityChanges?: SDKUserIdentityChangeData; | ||
UserAttributeChanges?: SDKUserAttributeChangeData; | ||
UserIdentityChanges?: ISDKUserIdentityChanges; | ||
UserAttributeChanges?: ISDKUserAttributeChangeData; | ||
CurrencyCode: string; | ||
@@ -63,5 +64,2 @@ DataPlan?: SDKDataPlan; | ||
} | ||
export type IdentityAPIMethod = valueof<typeof Constants.IdentityMethods>; | ||
export interface SDKGeoLocation { | ||
@@ -77,7 +75,2 @@ lat: number | string; | ||
export interface SDKUserIdentity { | ||
Identity?: string; | ||
Type: number; | ||
} | ||
export interface SDKShoppingCart { | ||
@@ -247,12 +240,2 @@ ProductList?: SDKProduct[]; | ||
export interface SDKIdentityApi { | ||
getCurrentUser(); | ||
IdentityAPI; | ||
identify; | ||
login; | ||
logout; | ||
modify; | ||
getUser(mpid: string): MParticleUser; | ||
} | ||
export interface SDKHelpersApi { | ||
@@ -280,3 +263,3 @@ canLog?(): boolean; | ||
body: string, | ||
mParticleUser?: MParticleUser, | ||
mParticleUser?: IMParticleUser, | ||
previousMpid?: MPID | ||
@@ -314,31 +297,2 @@ ): void; | ||
// FIXME: Resolve with User in @types/mparticle-web-sdk | ||
// https://go.mparticle.com/work/SQDSDKS-5033 | ||
export interface MParticleUser { | ||
getMPID(): string; | ||
getConsentState(): SDKConsentState; | ||
getAllUserAttributes(): any; // FIXME; | ||
getUserIdentities(): IdentityApiData; // FIXME: Is this correct? | ||
} | ||
export interface SDKUserIdentityChangeData { | ||
New: Identity; | ||
Old: Identity; | ||
} | ||
export interface Identity { | ||
IdentityType: SDKIdentityTypeEnum; | ||
Identity: string; | ||
Timestamp: number; | ||
CreatedThisBatch: boolean; | ||
} | ||
export interface SDKUserAttributeChangeData { | ||
UserAttributeName: string; | ||
New: string; | ||
Old: string; | ||
Deleted: boolean; | ||
IsNewAttribute: boolean; | ||
} | ||
export interface BaseEvent { | ||
@@ -352,4 +306,4 @@ messageType: number; | ||
sourceMessageId?: string; | ||
userAttributeChanges?: SDKUserAttributeChangeData; | ||
userIdentityChanges?: SDKUserIdentityChangeData; | ||
userAttributeChanges?: ISDKUserAttributeChangeData; | ||
userIdentityChanges?: ISDKUserIdentityChanges; | ||
} | ||
@@ -381,26 +335,1 @@ | ||
} | ||
export enum SDKIdentityTypeEnum { | ||
other = 'other', | ||
customerId = 'customerid', | ||
facebook = 'facebook', | ||
twitter = 'twitter', | ||
google = 'google', | ||
microsoft = 'microsoft', | ||
yahoo = 'yahoo', | ||
email = 'email', | ||
alias = 'alias', | ||
facebookCustomAudienceId = 'facebookcustomaudienceid', | ||
otherId2 = 'other2', | ||
otherId3 = 'other3', | ||
otherId4 = 'other4', | ||
otherId5 = 'other5', | ||
otherId6 = 'other6', | ||
otherId7 = 'other7', | ||
otherId8 = 'other8', | ||
otherId9 = 'other9', | ||
otherId10 = 'other10', | ||
mobileNumber = 'mobile_number', | ||
phoneNumber2 = 'phone_number_2', | ||
phoneNumber3 = 'phone_number_3', | ||
} |
@@ -6,6 +6,4 @@ import { | ||
SDKPromotion, | ||
SDKUserIdentity, | ||
SDKProductActionType, | ||
MParticleWebSDK, | ||
SDKIdentityTypeEnum, | ||
} from './sdkRuntimeModels'; | ||
@@ -20,2 +18,4 @@ import * as EventsApi from '@mparticle/event-models'; | ||
import { isEmpty } from './utils'; | ||
import { ISDKUserIdentity } from './identity-user-interfaces'; | ||
import { SDKIdentityTypeEnum } from './identity.interfaces'; | ||
@@ -156,3 +156,3 @@ export function convertEvents( | ||
export function convertUserIdentities( | ||
sdkUserIdentities?: SDKUserIdentity[] | ||
sdkUserIdentities?: ISDKUserIdentity[] | ||
): EventsApi.BatchUserIdentities | null { | ||
@@ -413,4 +413,5 @@ if (!sdkUserIdentities || !sdkUserIdentities.length) { | ||
): EventsApi.CommerceEvent { | ||
const commonEventData: EventsApi.CommonEventData = | ||
convertBaseEventData(sdkEvent); | ||
const commonEventData: EventsApi.CommonEventData = convertBaseEventData( | ||
sdkEvent | ||
); | ||
let commerceEventData: EventsApi.CommerceEventData = { | ||
@@ -434,4 +435,5 @@ custom_flags: sdkEvent.CustomFlags, | ||
): EventsApi.CrashReportEvent { | ||
const commonEventData: EventsApi.CommonEventData = | ||
convertBaseEventData(sdkEvent); | ||
const commonEventData: EventsApi.CommonEventData = convertBaseEventData( | ||
sdkEvent | ||
); | ||
let crashReportEventData: EventsApi.CrashReportEventData = { | ||
@@ -450,4 +452,5 @@ message: sdkEvent.EventName, | ||
): EventsApi.ApplicationStateTransitionEvent { | ||
const commonEventData: EventsApi.CommonEventData = | ||
convertBaseEventData(sdkEvent); | ||
const commonEventData: EventsApi.CommonEventData = convertBaseEventData( | ||
sdkEvent | ||
); | ||
let astEventData: EventsApi.ApplicationStateTransitionEventData = { | ||
@@ -472,4 +475,5 @@ application_transition_type: | ||
): EventsApi.SessionEndEvent { | ||
const commonEventData: EventsApi.CommonEventData = | ||
convertBaseEventData(sdkEvent); | ||
const commonEventData: EventsApi.CommonEventData = convertBaseEventData( | ||
sdkEvent | ||
); | ||
let sessionEndEventData: EventsApi.SessionEndEventData = { | ||
@@ -490,4 +494,5 @@ session_duration_ms: sdkEvent.SessionLength, | ||
): EventsApi.SessionStartEvent { | ||
const commonEventData: EventsApi.CommonEventData = | ||
convertBaseEventData(sdkEvent); | ||
const commonEventData: EventsApi.CommonEventData = convertBaseEventData( | ||
sdkEvent | ||
); | ||
let sessionStartEventData: EventsApi.SessionStartEventData = {}; | ||
@@ -507,4 +512,5 @@ sessionStartEventData = Object.assign( | ||
): EventsApi.ScreenViewEvent { | ||
const commonEventData: EventsApi.CommonEventData = | ||
convertBaseEventData(sdkEvent); | ||
const commonEventData: EventsApi.CommonEventData = convertBaseEventData( | ||
sdkEvent | ||
); | ||
let screenViewEventData: EventsApi.ScreenViewEventData = { | ||
@@ -522,4 +528,5 @@ custom_flags: sdkEvent.CustomFlags, | ||
export function convertOptOutEvent(sdkEvent: SDKEvent): EventsApi.OptOutEvent { | ||
const commonEventData: EventsApi.CommonEventData = | ||
convertBaseEventData(sdkEvent); | ||
const commonEventData: EventsApi.CommonEventData = convertBaseEventData( | ||
sdkEvent | ||
); | ||
let optOutEventData: EventsApi.OptOutEventData = { | ||
@@ -536,4 +543,5 @@ is_opted_out: sdkEvent.OptOut, | ||
export function convertCustomEvent(sdkEvent: SDKEvent): EventsApi.CustomEvent { | ||
const commonEventData: EventsApi.CommonEventData = | ||
convertBaseEventData(sdkEvent); | ||
const commonEventData: EventsApi.CommonEventData = convertBaseEventData( | ||
sdkEvent | ||
); | ||
let customEventData: EventsApi.CustomEventData = { | ||
@@ -642,4 +650,5 @@ custom_event_type: convertSdkEventType( | ||
): EventsApi.UserAttributeChangeEvent | null { | ||
const commonEventData: EventsApi.CommonEventData = | ||
convertBaseEventData(sdkEvent); | ||
const commonEventData: EventsApi.CommonEventData = convertBaseEventData( | ||
sdkEvent | ||
); | ||
let userAttributeChangeEvent: EventsApi.UserAttributeChangeEventData = { | ||
@@ -667,4 +676,5 @@ user_attribute_name: sdkEvent.UserAttributeChanges.UserAttributeName, | ||
): EventsApi.UserIdentityChangeEvent | null { | ||
const commonEventData: EventsApi.CommonEventData = | ||
convertBaseEventData(sdkEvent); | ||
const commonEventData: EventsApi.CommonEventData = convertBaseEventData( | ||
sdkEvent | ||
); | ||
@@ -671,0 +681,0 @@ let userIdentityChangeEvent: EventsApi.UserIdentityChangeEventData = { |
@@ -9,3 +9,2 @@ // TODO: This file is no longer the server model because the web SDK payload | ||
BaseEvent, | ||
MParticleUser, | ||
MParticleWebSDK, | ||
@@ -15,3 +14,2 @@ SDKEvent, | ||
SDKProduct, | ||
SDKUserIdentity, | ||
} from './sdkRuntimeModels'; | ||
@@ -32,2 +30,3 @@ import { | ||
} from './consent'; | ||
import { IMParticleUser, ISDKUserIdentity } from './identity-user-interfaces'; | ||
@@ -54,3 +53,3 @@ const MessageType = Types.MessageType; | ||
ua?: Dictionary<string | string[]>; | ||
ui?: SDKUserIdentity[]; | ||
ui?: ISDKUserIdentity[]; | ||
ia?: Dictionary<Dictionary<string>>; | ||
@@ -142,5 +141,5 @@ str?: ServerSettings; | ||
convertEventToV2DTO: (event: IUploadObject) => IServerV2DTO; | ||
createEventObject: (event: BaseEvent, user?: MParticleUser) => SDKEvent; | ||
createEventObject: (event: BaseEvent, user?: IMParticleUser) => SDKEvent; | ||
convertToConsentStateV2DTO: (state: SDKConsentState) => IConsentStateV2DTO; | ||
appendUserInfo: (user: MParticleUser, event: SDKEvent) => void; | ||
appendUserInfo: (user: IMParticleUser, event: SDKEvent) => void; | ||
} | ||
@@ -207,3 +206,6 @@ | ||
// TODO: Can we refactor this to not mutate the event? | ||
this.appendUserInfo = function(user: MParticleUser, event: SDKEvent): void { | ||
this.appendUserInfo = function( | ||
user: IMParticleUser, | ||
event: SDKEvent | ||
): void { | ||
if (!event) { | ||
@@ -239,3 +241,3 @@ return; | ||
for (var key in dtoUserIdentities) { | ||
var userIdentity: Partial<SDKUserIdentity> = {}; | ||
var userIdentity: Partial<ISDKUserIdentity> = {}; | ||
userIdentity.Identity = dtoUserIdentities[key]; | ||
@@ -302,3 +304,3 @@ userIdentity.Type = mpInstance._Helpers.parseNumber(key); | ||
event: BaseEvent, | ||
user?: MParticleUser | ||
user?: IMParticleUser | ||
): SDKEvent | IUploadObject { | ||
@@ -305,0 +307,0 @@ var uploadObject: Partial<IUploadObject> = {}; |
import { MPID } from '@mparticle/web-sdk'; | ||
import Constants from './constants'; | ||
import { IPersistenceMinified } from './persistence.interfaces'; | ||
import { MParticleUser, MParticleWebSDK } from './sdkRuntimeModels'; | ||
import { MParticleWebSDK } from './sdkRuntimeModels'; | ||
import Types from './types'; | ||
import { generateDeprecationMessage } from './utils'; | ||
import { IMParticleUser } from './identity-user-interfaces'; | ||
@@ -89,3 +90,3 @@ const { Messages } = Constants; | ||
const currentUser: MParticleUser = mpInstance.Identity.getCurrentUser(); | ||
const currentUser: IMParticleUser = mpInstance.Identity.getCurrentUser(); | ||
const mpid: MPID = currentUser ? currentUser.getMPID() : null; | ||
@@ -92,0 +93,0 @@ |
@@ -10,2 +10,4 @@ import Constants from './constants'; | ||
export type Environment = 'development' | 'production'; | ||
const createCookieString = (value: string): string => | ||
@@ -12,0 +14,0 @@ replaceCommasWithPipes(replaceQuotesWithApostrophes(value)); |
@@ -11,3 +11,3 @@ import Types from './types'; | ||
import { IdentityApiData } from '@mparticle/web-sdk'; | ||
import { IdentityAPIMethod } from './sdkRuntimeModels'; | ||
import { IdentityAPIMethod } from './identity.interfaces'; | ||
@@ -14,0 +14,0 @@ type ValidationIdentitiesReturn = { |
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
1536795
49
27688