Skip to content

Commit b6883b6

Browse files
refactor: Migrate CookieSyncManager to TypeScript (#944)
1 parent d019fe0 commit b6883b6

13 files changed

+953
-320
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ test/integrations/requirejs/test-requirejs-bundle.js
1212
browserstack.err
1313
local.log
1414
test/cross-browser-testing/CBT-tests-es5.js
15-
test/cross-browser-testing/CBT-tests.js
15+
test/cross-browser-testing/CBT-tests.js
16+
coverage/

src/configAPIClient.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
FetchUploader,
1414
XHRUploader,
1515
} from './uploaders';
16+
import { IPixelConfiguration } from './cookieSyncManager.interfaces';
1617

1718
export interface IKitConfigs extends IKitFilterSettings {
1819
name: string;
@@ -65,17 +66,6 @@ export interface IConsentRuleValue {
6566
hasConsented: boolean;
6667
}
6768

68-
export interface IPixelConfig {
69-
name: string;
70-
moduleId: number;
71-
esId: number;
72-
isDebug: boolean;
73-
isProduction: boolean;
74-
settings: Dictionary;
75-
frequencyCap: number;
76-
pixelUrl: string;
77-
redirectUrl: string;
78-
}
7969

8070
export interface IConfigResponse {
8171
appName: string;
@@ -85,7 +75,7 @@ export interface IConfigResponse {
8575
secureServiceUrl: string;
8676
minWebviewBridgeVersion: number;
8777
workspaceToken: string;
88-
pixelConfigs: IPixelConfig[];
78+
pixelConfigs: IPixelConfiguration[];
8979
flags: SDKEventCustomFlags;
9080
}
9181

src/consent.ts

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export interface SDKConsentApi {
3838
createConsentState: (consentState?: ConsentState) => ConsentState;
3939
ConsentSerialization: IConsentSerialization;
4040
createPrivacyConsent: ICreatePrivacyConsentFunction;
41+
isEnabledForUserConsent: (
42+
consentRules: IConsentRules,
43+
user: IMParticleUser
44+
) => boolean;
4145
}
4246

4347
export interface IConsentSerialization {

src/cookieSyncManager.interfaces.ts

+30-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
1-
import { MPID } from "@mparticle/web-sdk";
2-
import { Dictionary } from "./utils";
3-
import { IConsentRules } from "./consent";
1+
import { MPID } from '@mparticle/web-sdk';
2+
import { Dictionary } from './utils';
3+
import { IConsentRules } from './consent';
44

5+
export type CookieSyncDates = Dictionary<number>;
6+
7+
export interface IPixelConfiguration {
8+
name?: string;
9+
moduleId: number;
10+
esId?: number;
11+
isDebug?: boolean;
12+
isProduction?: boolean;
13+
settings: Dictionary<string>;
14+
frequencyCap: number;
15+
pixelUrl: string;
16+
redirectUrl: string;
17+
filteringConsentRuleValues?: IConsentRules;
18+
}
519
export interface ICookieSyncManager {
6-
attemptCookieSync: (previousMPID: MPID, mpid: MPID, mpidIsNotInCookies: boolean) => void;
20+
attemptCookieSync: (
21+
previousMPID: MPID,
22+
mpid: MPID,
23+
mpidIsNotInCookies?: boolean
24+
) => void;
725
performCookieSync: (
826
url: string,
9-
moduleId: number,
27+
moduleId: string,
1028
mpid: MPID,
11-
cookieSyncDates: Dictionary<number>,
29+
cookieSyncDates: CookieSyncDates,
1230
filteringConsentRuleValues: IConsentRules,
1331
mpidIsNotInCookies: boolean,
1432
requiresConsent: boolean
1533
) => 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-
}
34+
combineUrlWithRedirect: (
35+
mpid: MPID,
36+
pixelUrl: string,
37+
redirectUrl: string
38+
) => string;
39+
}

src/cookieSyncManager.js

-204
This file was deleted.

0 commit comments

Comments
 (0)