Skip to content
Open
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
10 changes: 8 additions & 2 deletions src/consent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import KitFilterHelper from './kitFilterHelper';
import Constants from './constants';
import { IMParticleUser } from './identity-user-interfaces';
import { IMParticleWebSDKInstance } from './mp-instance';
import { logDeprecatedMethodUsage } from './reporting/deprecatedMethodLogger';

const { CCPAPurpose } = Constants;

Expand Down Expand Up @@ -505,8 +506,13 @@ export default function Consent(this: IConsent, mpInstance: IMParticleWebSDKInst

// TODO: Can we remove this? It is deprecated.
function removeCCPAState(this: ConsentState) {
mpInstance.Logger.warning(
'removeCCPAState is deprecated and will be removed in a future release; use removeCCPAConsentState instead'
logDeprecatedMethodUsage(
{
methodName: 'Consent.removeCCPAState',
warningMessage: 'removeCCPAState is deprecated and will be removed in a future release; use removeCCPAConsentState instead',
},
mpInstance.Logger,
mpInstance._LoggingDispatcher
);
// @ts-ignore
return removeCCPAConsentState();
Expand Down
110 changes: 77 additions & 33 deletions src/identity.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Constants, { HTTP_OK } from './constants';

Check failure on line 1 in src/identity.js

View workflow job for this annotation

GitHub Actions / Core Tests / Core SDK Tests

Declaration emit for this file requires using private name 'mParticleUserCart'. An explicit type annotation may unblock declaration emit.

Check failure on line 1 in src/identity.js

View workflow job for this annotation

GitHub Actions / Core Tests / Core SDK Tests

Declaration emit for this file requires using private name 'mParticleUser'. An explicit type annotation may unblock declaration emit.
import Types, { IdentityType } from './types';
import {
cacheOrClearIdCache,
Expand All @@ -20,6 +20,7 @@
} from './utils';
import { hasMPIDAndUserLoginChanged, hasMPIDChanged } from './user-utils';
import { processReadyQueue } from './pre-init-utils';
import { logDeprecatedMethodUsage } from './reporting/deprecatedMethodLogger';

export default function Identity(mpInstance) {
const { getFeatureFlag, extend } = mpInstance._Helpers;
Expand Down Expand Up @@ -1252,8 +1253,14 @@
* @return a cart object
*/
getCart: function() {
mpInstance.Logger.warning(
'Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases'
logDeprecatedMethodUsage(
{
methodName: 'Identity.getCurrentUser().getCart()',
warningMessage:
'Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases',
},
mpInstance.Logger,
mpInstance._LoggingDispatcher
);
return self.mParticleUserCart();
},
Expand Down Expand Up @@ -1334,13 +1341,18 @@
* @deprecated
*/
add: function() {
mpInstance.Logger.warning(
generateDeprecationMessage(
'Identity.getCurrentUser().getCart().add()',
true,
'eCommerce.logProductAction()',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
)
logDeprecatedMethodUsage(
{
methodName: 'Identity.getCurrentUser().getCart().add()',
warningMessage: generateDeprecationMessage(
'Identity.getCurrentUser().getCart().add()',
true,
'eCommerce.logProductAction()',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
),
},
mpInstance.Logger,
mpInstance._LoggingDispatcher
);
},
/**
Expand All @@ -1349,13 +1361,19 @@
* @deprecated
*/
remove: function() {
mpInstance.Logger.warning(
generateDeprecationMessage(
'Identity.getCurrentUser().getCart().remove()',
true,
'eCommerce.logProductAction()',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
)
logDeprecatedMethodUsage(
{
methodName:
'Identity.getCurrentUser().getCart().remove()',
warningMessage: generateDeprecationMessage(
'Identity.getCurrentUser().getCart().remove()',
true,
'eCommerce.logProductAction()',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
),
},
mpInstance.Logger,
mpInstance._LoggingDispatcher
);
},
/**
Expand All @@ -1364,13 +1382,19 @@
* @deprecated
*/
clear: function() {
mpInstance.Logger.warning(
generateDeprecationMessage(
'Identity.getCurrentUser().getCart().clear()',
true,
'',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
)
logDeprecatedMethodUsage(
{
methodName:
'Identity.getCurrentUser().getCart().clear()',
warningMessage: generateDeprecationMessage(
'Identity.getCurrentUser().getCart().clear()',
true,
'',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
),
},
mpInstance.Logger,
mpInstance._LoggingDispatcher
);
},
/**
Expand All @@ -1380,13 +1404,19 @@
* @deprecated
*/
getCartProducts: function() {
mpInstance.Logger.warning(
generateDeprecationMessage(
'Identity.getCurrentUser().getCart().getCartProducts()',
true,
'eCommerce.logProductAction()',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
)
logDeprecatedMethodUsage(
{
methodName:
'Identity.getCurrentUser().getCart().getCartProducts()',
warningMessage: generateDeprecationMessage(
'Identity.getCurrentUser().getCart().getCartProducts()',
true,
'eCommerce.logProductAction()',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
),
},
mpInstance.Logger,
mpInstance._LoggingDispatcher
);
return [];
},
Expand Down Expand Up @@ -1540,7 +1570,8 @@
prevUser,
newUser,
identityApiData,
mpInstance.Logger
mpInstance.Logger,
mpInstance._LoggingDispatcher
);

const persistence = mpInstance._Persistence.getPersistence();
Expand Down Expand Up @@ -1775,14 +1806,27 @@
}

// https://go.mparticle.com/work/SQDSDKS-6359
function tryOnUserAlias(previousUser, newUser, identityApiData, logger) {
function tryOnUserAlias(
previousUser,
newUser,
identityApiData,
logger,
loggingDispatcher
) {
if (
identityApiData &&
identityApiData.onUserAlias &&
isFunction(identityApiData.onUserAlias)
) {
try {
logger.warning(generateDeprecationMessage('onUserAlias'));
logDeprecatedMethodUsage(
{
methodName: 'onUserAlias',
warningMessage: generateDeprecationMessage('onUserAlias'),
},
logger,
loggingDispatcher
);
identityApiData.onUserAlias(previousUser, newUser);
} catch (e) {
logger.error(
Expand Down
86 changes: 58 additions & 28 deletions src/mp-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import { ErrorReportingDispatcher } from './reporting/errorReportingDispatcher';
import { LoggingDispatcher } from './reporting/loggingDispatcher';
import { IErrorReportingService, ILoggingService } from './reporting/types';
import { logDeprecatedMethodUsage } from './reporting/deprecatedMethodLogger';

export interface IErrorLogMessage {
message?: string;
Expand Down Expand Up @@ -127,11 +128,11 @@
this._NativeSdkHelpers = new NativeSdkHelpers(this);
this._SessionManager = new SessionManager(this);
this._Persistence = new Persistence(this);
this._Helpers = new Helpers(this);

Check failure on line 131 in src/mp-instance.ts

View workflow job for this annotation

GitHub Actions / Core Tests / Core SDK Tests

Type 'Helpers' is not assignable to type 'SDKHelpersApi'.
this._Events = new Events(this);
this._CookieSyncManager = new CookieSyncManager(this);
this._ServerModel = new ServerModel(this);
this._Ecommerce = new Ecommerce(this);

Check failure on line 135 in src/mp-instance.ts

View workflow job for this annotation

GitHub Actions / Core Tests / Core SDK Tests

Type 'Ecommerce' is not assignable to type 'IECommerce'.
this._ForwardingStatsUploader = new ForwardingStatsUploader(this);
this._Consent = new Consent(this);
this._IdentityAPIClient = new IdentityAPIClient(this);
Expand Down Expand Up @@ -189,7 +190,7 @@
this.ProductActionType = ProductActionType;


this._Identity = new Identity(this);

Check failure on line 193 in src/mp-instance.ts

View workflow job for this annotation

GitHub Actions / Core Tests / Core SDK Tests

Type 'Identity' is not assignable to type 'IIdentity'.
this.Identity = this._Identity.IdentityAPI;
this.generateHash = this._Helpers.generateHash;

Expand All @@ -198,9 +199,9 @@
this.getDeviceId = this._Persistence.getDeviceId;

if (typeof window !== 'undefined') {
if (window.mParticle && window.mParticle.config) {

Check failure on line 202 in src/mp-instance.ts

View workflow job for this annotation

GitHub Actions / Core Tests / Core SDK Tests

Property 'config' does not exist on type 'typeof import("/home/runner/work/mparticle-web-sdk/mparticle-web-sdk/node_modules/@types/mparticle__web-sdk/index")'.
if (window.mParticle.config.hasOwnProperty('rq')) {

Check failure on line 203 in src/mp-instance.ts

View workflow job for this annotation

GitHub Actions / Core Tests / Core SDK Tests

Property 'config' does not exist on type 'typeof import("/home/runner/work/mparticle-web-sdk/mparticle-web-sdk/node_modules/@types/mparticle__web-sdk/index")'.
this._preInit.readyQueue = window.mParticle.config.rq;

Check failure on line 204 in src/mp-instance.ts

View workflow job for this annotation

GitHub Actions / Core Tests / Core SDK Tests

Property 'config' does not exist on type 'typeof import("/home/runner/work/mparticle-web-sdk/mparticle-web-sdk/node_modules/@types/mparticle__web-sdk/index")'.
}
}
}
Expand Down Expand Up @@ -772,13 +773,18 @@
* @deprecated
*/
add: function(product, logEventBoolean) {
self.Logger.warning(
generateDeprecationMessage(
'eCommerce.Cart.add()',
true,
'eCommerce.logProductAction()',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
)
logDeprecatedMethodUsage(
{
methodName: 'mPInstance.eCommerce.Cart.add()',
warningMessage: generateDeprecationMessage(
'eCommerce.Cart.add()',
true,
'eCommerce.logProductAction()',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
),
},
self.Logger,
self._LoggingDispatcher
);
},
/**
Expand All @@ -789,13 +795,18 @@
* @deprecated
*/
remove: function(product, logEventBoolean) {
self.Logger.warning(
generateDeprecationMessage(
'eCommerce.Cart.remove()',
true,
'eCommerce.logProductAction()',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
)
logDeprecatedMethodUsage(
{
methodName: 'mPInstance.eCommerce.Cart.remove()',
warningMessage: generateDeprecationMessage(
'eCommerce.Cart.remove()',
true,
'eCommerce.logProductAction()',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
),
},
self.Logger,
self._LoggingDispatcher
);
},
/**
Expand All @@ -804,13 +815,18 @@
* @deprecated
*/
clear: function() {
self.Logger.warning(
generateDeprecationMessage(
'eCommerce.Cart.clear()',
true,
'',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
)
logDeprecatedMethodUsage(
{
methodName: 'mPInstance.eCommerce.Cart.clear()',
warningMessage: generateDeprecationMessage(
'eCommerce.Cart.clear()',
true,
'',
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
),
},
self.Logger,
self._LoggingDispatcher
);
},
},
Expand Down Expand Up @@ -940,8 +956,13 @@
* @deprecated
*/
logCheckout: function(step, option, attrs, customFlags) {
self.Logger.warning(
'mParticle.logCheckout is deprecated, please use mParticle.logProductAction instead'
logDeprecatedMethodUsage(
{
methodName: 'mParticle.logCheckout',
warningMessage: 'mParticle.logCheckout is deprecated, please use mParticle.logProductAction instead',
},
self.Logger,
self._LoggingDispatcher
);

if (!self._Store.isInitialized) {
Expand Down Expand Up @@ -1020,8 +1041,13 @@
attrs,
customFlags
) {
self.Logger.warning(
'mParticle.logPurchase is deprecated, please use mParticle.logProductAction instead'
logDeprecatedMethodUsage(
{
methodName: 'mParticle.logPurchase',
warningMessage: 'mParticle.logPurchase is deprecated, please use mParticle.logProductAction instead',
},
self.Logger,
self._LoggingDispatcher
);
if (!self._Store.isInitialized) {
self.ready(function() {
Expand Down Expand Up @@ -1132,8 +1158,13 @@
attrs,
customFlags
) {
self.Logger.warning(
'mParticle.logRefund is deprecated, please use mParticle.logProductAction instead'
logDeprecatedMethodUsage(
{
methodName: 'mParticle.logRefund',
warningMessage: 'mParticle.logRefund is deprecated, please use mParticle.logProductAction instead',
},
self.Logger,
self._LoggingDispatcher
);
if (!self._Store.isInitialized) {
self.ready(function() {
Expand Down Expand Up @@ -1659,7 +1690,7 @@
mpInstance._ErrorReportingDispatcher.logger = mpInstance.Logger;
mpInstance._LoggingDispatcher.logger = mpInstance.Logger;
mpInstance._Store = new Store(config, mpInstance, apiKey);
window.mParticle.Store = mpInstance._Store;

Check failure on line 1693 in src/mp-instance.ts

View workflow job for this annotation

GitHub Actions / Core Tests / Core SDK Tests

Property 'Store' does not exist on type 'typeof import("/home/runner/work/mparticle-web-sdk/mparticle-web-sdk/node_modules/@types/mparticle__web-sdk/index")'.
mpInstance.Logger.verbose(StartingInitialization);

// Initialize CookieConsentManager with privacy flags from launcherOptions
Expand Down Expand Up @@ -1741,4 +1772,3 @@
});
return true;
}

16 changes: 8 additions & 8 deletions src/persistence.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export interface IPersistence {
useLocalStorage(): boolean;
initializeStorage(): void;
update(): void;
storeDataInMemory(obj: IPersistenceMinified, currentMPID: MPID): void;
storeDataInMemory(obj: IPersistenceMinified, currentMPID?: MPID): void;
determineLocalStorageAvailability(storage: Storage): boolean;
setLocalStorage(): void;
getLocalStorage(): IPersistenceMinified | null;
Expand All @@ -113,17 +113,17 @@ export interface IPersistence {
maxCookieSize: number
): string;
findPrevCookiesBasedOnUI(identityApiData: IdentityApiData): void;
encodePersistence(persistence: IPersistenceMinified): string;
decodePersistence(persistenceString: string): string;
encodePersistence(persistence: string): string;
decodePersistence(persistenceString: string): string | null;
getCookieDomain(): string;
getDomain(doc: string, locationHostname: string): string;
getDomain(doc: Document, locationHostname: string): string;
saveUserCookieSyncDatesToPersistence(mpid: MPID, csd: CookieSyncDates): void;
savePersistence(persistance: IPersistenceMinified): void;
getPersistence(): IPersistenceMinified;
getFirstSeenTime(mpid: MPID): string | null;
setFirstSeenTime(mpid: MPID, time: number): void;
getPersistence(): IPersistenceMinified | null;
getFirstSeenTime(mpid: MPID): number | null;
setFirstSeenTime(mpid: MPID, time?: number): void;
getLastSeenTime(mpid: MPID): number | null;
setLastSeenTime(mpid: MPID, time: number): void;
setLastSeenTime(mpid: MPID, time?: number): void;
getDeviceId(): string;
setDeviceId(guid: string): void;
resetPersistence(): void;
Expand Down
Loading
Loading