Skip to content

Commit

Permalink
refactor: Add Type interfaces for cookie sync manager (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexs-mparticle committed Nov 6, 2024
1 parent b8a1a8f commit 6b15343
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/cookieSyncManager.interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { MPID } from "@mparticle/web-sdk";
import { Dictionary } from "./utils";
import { IConsentRules } from "./consent";

export interface ICookieSyncManager {
attemptCookieSync: (previousMPID: MPID, mpid: MPID, mpidIsNotInCookies: boolean) => void;
performCookieSync: (
url: string,
moduleId: number,
mpid: MPID,
cookieSyncDates: Dictionary<number>,
filteringConsentRuleValues: IConsentRules,
mpidIsNotInCookies: boolean,
requiresConsent: boolean
) => void;
replaceAmpWithAmpersand: (string: string) => string;
replaceMPID: (string: string, mpid: MPID) => string;

/**
* @deprecated replaceAmp has been deprecated, use replaceAmpersandWithAmp instead
*/
replaceAmp: (string: string) => string;
}
9 changes: 8 additions & 1 deletion src/cookieSyncManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,15 @@ export default function cookieSyncManager(mpInstance) {
};

// Private
// TODO: Rename function to replaceAmpWithAmpersand
/**
* @deprecated replaceAmp has been deprecated, use replaceAmpersandWithAmp instead
*/
this.replaceAmp = function(string) {
return this.replaceAmpWithAmpersand(string);
};

// Private
this.replaceAmpWithAmpersand = function(string) {
return string.replace(/&amp;/g, '&');
};

Expand Down
2 changes: 2 additions & 0 deletions src/sdkRuntimeModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from './identity-user-interfaces';
import { IIdentityType } from './types.interfaces';
import IntegrationCapture from './integrationCapture';
import { ICookieSyncManager } from './cookieSyncManager.interfaces';

// TODO: Resolve this with version in @mparticle/web-sdk
export type SDKEventCustomFlags = Dictionary<any>;
Expand Down Expand Up @@ -158,6 +159,7 @@ export interface MParticleWebSDK {
Logger: SDKLoggerApi;
MPSideloadedKit: IMPSideloadedKit;
_APIClient: any; // TODO: Set up API Client
_CookieSyncManager: ICookieSyncManager;
_Store: IStore;
_Forwarders: any;
_Helpers: SDKHelpersApi;
Expand Down

0 comments on commit 6b15343

Please sign in to comment.