Skip to content

Commit cf0fee6

Browse files
refactor: Add Type interfaces for cookie sync manager (#940)
1 parent e15bd31 commit cf0fee6

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { MPID } from "@mparticle/web-sdk";
2+
import { Dictionary } from "./utils";
3+
import { IConsentRules } from "./consent";
4+
5+
export interface ICookieSyncManager {
6+
attemptCookieSync: (previousMPID: MPID, mpid: MPID, mpidIsNotInCookies: boolean) => void;
7+
performCookieSync: (
8+
url: string,
9+
moduleId: number,
10+
mpid: MPID,
11+
cookieSyncDates: Dictionary<number>,
12+
filteringConsentRuleValues: IConsentRules,
13+
mpidIsNotInCookies: boolean,
14+
requiresConsent: boolean
15+
) => void;
16+
replaceAmpWithAmpersand: (string: string) => string;
17+
replaceMPID: (string: string, mpid: MPID) => string;
18+
19+
/**
20+
* @deprecated replaceAmp has been deprecated, use replaceAmpersandWithAmp instead
21+
*/
22+
replaceAmp: (string: string) => string;
23+
}

src/cookieSyncManager.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,15 @@ export default function cookieSyncManager(mpInstance) {
146146
};
147147

148148
// Private
149-
// TODO: Rename function to replaceAmpWithAmpersand
149+
/**
150+
* @deprecated replaceAmp has been deprecated, use replaceAmpersandWithAmp instead
151+
*/
150152
this.replaceAmp = function(string) {
153+
return this.replaceAmpWithAmpersand(string);
154+
};
155+
156+
// Private
157+
this.replaceAmpWithAmpersand = function(string) {
151158
return string.replace(/&amp;/g, '&');
152159
};
153160

src/sdkRuntimeModels.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
} from './identity-user-interfaces';
3232
import { IIdentityType } from './types.interfaces';
3333
import IntegrationCapture from './integrationCapture';
34+
import { ICookieSyncManager } from './cookieSyncManager.interfaces';
3435

3536
// TODO: Resolve this with version in @mparticle/web-sdk
3637
export type SDKEventCustomFlags = Dictionary<any>;
@@ -158,6 +159,7 @@ export interface MParticleWebSDK {
158159
Logger: SDKLoggerApi;
159160
MPSideloadedKit: IMPSideloadedKit;
160161
_APIClient: any; // TODO: Set up API Client
162+
_CookieSyncManager: ICookieSyncManager;
161163
_Store: IStore;
162164
_Forwarders: any;
163165
_Helpers: SDKHelpersApi;

0 commit comments

Comments
 (0)