Skip to content

Commit

Permalink
refactor: Migrate CookieSyncManager to TypeScript (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexs-mparticle authored Nov 12, 2024
1 parent d019fe0 commit b6883b6
Show file tree
Hide file tree
Showing 13 changed files with 953 additions and 320 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ test/integrations/requirejs/test-requirejs-bundle.js
browserstack.err
local.log
test/cross-browser-testing/CBT-tests-es5.js
test/cross-browser-testing/CBT-tests.js
test/cross-browser-testing/CBT-tests.js
coverage/
14 changes: 2 additions & 12 deletions src/configAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
FetchUploader,
XHRUploader,
} from './uploaders';
import { IPixelConfiguration } from './cookieSyncManager.interfaces';

export interface IKitConfigs extends IKitFilterSettings {
name: string;
Expand Down Expand Up @@ -65,17 +66,6 @@ export interface IConsentRuleValue {
hasConsented: boolean;
}

export interface IPixelConfig {
name: string;
moduleId: number;
esId: number;
isDebug: boolean;
isProduction: boolean;
settings: Dictionary;
frequencyCap: number;
pixelUrl: string;
redirectUrl: string;
}

export interface IConfigResponse {
appName: string;
Expand All @@ -85,7 +75,7 @@ export interface IConfigResponse {
secureServiceUrl: string;
minWebviewBridgeVersion: number;
workspaceToken: string;
pixelConfigs: IPixelConfig[];
pixelConfigs: IPixelConfiguration[];
flags: SDKEventCustomFlags;
}

Expand Down
4 changes: 4 additions & 0 deletions src/consent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export interface SDKConsentApi {
createConsentState: (consentState?: ConsentState) => ConsentState;
ConsentSerialization: IConsentSerialization;
createPrivacyConsent: ICreatePrivacyConsentFunction;
isEnabledForUserConsent: (
consentRules: IConsentRules,
user: IMParticleUser
) => boolean;
}

export interface IConsentSerialization {
Expand Down
44 changes: 30 additions & 14 deletions src/cookieSyncManager.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
import { MPID } from "@mparticle/web-sdk";
import { Dictionary } from "./utils";
import { IConsentRules } from "./consent";
import { MPID } from '@mparticle/web-sdk';
import { Dictionary } from './utils';
import { IConsentRules } from './consent';

export type CookieSyncDates = Dictionary<number>;

export interface IPixelConfiguration {
name?: string;
moduleId: number;
esId?: number;
isDebug?: boolean;
isProduction?: boolean;
settings: Dictionary<string>;
frequencyCap: number;
pixelUrl: string;
redirectUrl: string;
filteringConsentRuleValues?: IConsentRules;
}
export interface ICookieSyncManager {
attemptCookieSync: (previousMPID: MPID, mpid: MPID, mpidIsNotInCookies: boolean) => void;
attemptCookieSync: (
previousMPID: MPID,
mpid: MPID,
mpidIsNotInCookies?: boolean
) => void;
performCookieSync: (
url: string,
moduleId: number,
moduleId: string,
mpid: MPID,
cookieSyncDates: Dictionary<number>,
cookieSyncDates: CookieSyncDates,
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;
}
combineUrlWithRedirect: (
mpid: MPID,
pixelUrl: string,
redirectUrl: string
) => string;
}
204 changes: 0 additions & 204 deletions src/cookieSyncManager.js

This file was deleted.

Loading

0 comments on commit b6883b6

Please sign in to comment.