Skip to content

Commit ab0b2c6

Browse files
authored
🤖 Merge PR DefinitelyTyped#74401 Sync types with mparticle-web-sdk by @jaissica12
1 parent 5734314 commit ab0b2c6

File tree

3 files changed

+253
-115
lines changed

3 files changed

+253
-115
lines changed

types/mparticle__web-sdk/index.d.ts

Lines changed: 107 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import { Batch } from "@mparticle/event-models";
44
export type Dictionary<V = any> = Record<string, V>;
55

66
// Rokt Manager Types
7-
export type RoktAttributeValueArray = Array<string | number | boolean | Dictionary>;
7+
export type RoktAttributeValueArray = Array<string | number | boolean>;
88
export type RoktAttributeValueType = string | number | boolean | undefined | null;
99
export type RoktAttributeValue = RoktAttributeValueType | RoktAttributeValueArray;
10-
export type RoktPartnerAttributes = Record<string, RoktAttributeValue>;
10+
export type RoktAttributes = Record<string, RoktAttributeValue>;
1111

1212
export interface RoktPartnerExtensionData<T> {
1313
[extensionName: string]: T;
1414
}
1515

1616
export interface RoktSelectPlacementsOptions {
17-
attributes: RoktPartnerAttributes;
17+
attributes: RoktAttributes;
1818
identifier?: string;
1919
}
2020

@@ -43,16 +43,25 @@ export interface RoktPlacement {
4343
}
4444

4545
export interface RoktSelection {
46-
close: () => void;
47-
getPlacements: () => Promise<Array<RoktPlacement>>;
46+
close(): Promise<void>;
47+
getPlacements(): Promise<Array<RoktPlacement>>;
4848
on(eventName: string): RoktSubscriber<RoktPlacementEvent<unknown>>;
4949
ready(): Promise<void>;
5050
send(event: string, data?: unknown): Promise<void>;
51-
setAttributes(attributes: RoktPartnerAttributes): Promise<void>;
51+
setAttributes(attributes: RoktAttributes): Promise<void>;
5252
}
5353

5454
export as namespace mParticle;
5555
export {};
56+
57+
export interface LauncherOptions {
58+
noTargeting?: boolean | undefined;
59+
noFunctional?: boolean | undefined;
60+
[key: string]: unknown;
61+
}
62+
63+
export type AliasRequestScope = "device" | "mpid";
64+
5665
export interface MPConfiguration {
5766
isDevelopmentMode?: boolean | undefined;
5867
identifyRequest?: IdentifyRequest | undefined;
@@ -89,10 +98,53 @@ export interface MPConfiguration {
8998
* @warning only change minWebviewBridgeVersion if you are absolutely sure you know what you are doing
9099
*/
91100
minWebviewBridgeVersion?: 1 | 2 | undefined;
101+
// Additional configuration options
102+
aliasMaxWindow?: number | undefined;
103+
forceHttps?: boolean | undefined;
104+
integrationDelayTimeout?: number | undefined;
105+
isIOS?: boolean | undefined;
106+
maxProducts?: number | undefined;
107+
requestConfig?: boolean | undefined;
108+
useNativeSdk?: boolean | undefined;
109+
domain?: string | undefined;
110+
userAudienceUrl?: string | undefined;
111+
flags?: Dictionary | undefined;
112+
launcherOptions?: LauncherOptions | undefined;
113+
RoktExtensions?: Array<string> | undefined;
92114
}
93115

94116
export type MPForwarder = Dictionary;
95117

118+
export interface KitFilterSettings {
119+
eventTypeFilters: number[];
120+
eventNameFilters: number[];
121+
screenNameFilters: number[];
122+
screenAttributeFilters: number[];
123+
userIdentityFilters: number[];
124+
userAttributeFilters: number[];
125+
attributeFilters: number[];
126+
consentRegulationFilters: number[];
127+
consentRegulationPurposeFilters: number[];
128+
messageTypeFilters: number[];
129+
messageTypeStateFilters: number[];
130+
filteringEventAttributeValue: Record<string, unknown>;
131+
filteringUserAttributeValue: Record<string, unknown>;
132+
filteringConsentRuleValues: Record<string, unknown>;
133+
}
134+
135+
export class MPSideloadedKit {
136+
constructor(kitInstance: MPForwarder);
137+
kitInstance: MPForwarder;
138+
filterDictionary: KitFilterSettings;
139+
addEventTypeFilter(eventType: EventType): void;
140+
addEventNameFilter(eventType: EventType, eventName: string): void;
141+
addEventAttributeFilter(eventType: EventType, eventName: string, customAttributeKey: string): void;
142+
addScreenNameFilter(screenName: string): void;
143+
addScreenAttributeFilter(screenName: string, screenAttribute: string): void;
144+
addUserIdentityFilter(userIdentity: IdentityType): void;
145+
addUserAttributeFilter(userAttributeKey: string): void;
146+
}
147+
96148
export interface Logger {
97149
error?: ((error: string) => void) | undefined;
98150
warning?: ((error: string) => void) | undefined;
@@ -215,32 +267,36 @@ interface Upload {
215267
(): void;
216268
}
217269

270+
interface GenerateHash {
271+
(value: string): string;
272+
}
273+
218274
interface CreateConsentState {
219275
(): ConsentState;
220276
}
221277
interface CreateGDPRConsent {
222278
(
223279
consented: boolean,
224-
timestamp: number,
225-
consentDocument: string,
226-
location: string,
227-
hardwareId: string,
280+
timestamp?: number,
281+
consentDocument?: string,
282+
location?: string,
283+
hardwareId?: string,
228284
): PrivacyConsentState;
229285
}
230286
interface CreateCCPAConsent {
231287
(
232288
consented: boolean,
233-
timestamp: number,
234-
consentDocument: string,
235-
location: string,
236-
hardwareId: string,
289+
timestamp?: number,
290+
consentDocument?: string,
291+
location?: string,
292+
hardwareId?: string,
237293
): PrivacyConsentState;
238294
}
239295
interface AliasUsers {
240296
(aliasRequest: UserAliasRequest, callback?: AliasUsersCallback): void;
241297
}
242298
interface CreateAliasRequest {
243-
(sourceUser: User, destinationUser: User): UserAliasRequest;
299+
(sourceUser: User, destinationUser: User, scope?: AliasRequestScope): UserAliasRequest;
244300
}
245301

246302
interface GetCurrentUser {
@@ -367,7 +423,11 @@ interface Use {
367423
}
368424

369425
interface HashAttributes {
370-
(attributes: RoktPartnerAttributes): Promise<Record<string, string>>;
426+
(attributes: RoktAttributes): Promise<Record<string, string>>;
427+
}
428+
429+
interface HashSha256 {
430+
(attribute: RoktAttributeValueType): Promise<string | undefined | null>;
371431
}
372432

373433
interface SetExtensionData {
@@ -382,6 +442,7 @@ export const setDeviceId: SetDeviceId;
382442
export const getEnvironment: GetEnvironment;
383443
export function getInstance(instanceName?: string): mParticleInstance;
384444
export const getVersion: GetVersion;
445+
export const generateHash: GenerateHash;
385446
/**
386447
* @warning You should only use mParticle.init if you are in a self-hosted environment. https://docs.mparticle.com/developers/sdk/web/self-hosting/
387448
*/
@@ -414,7 +475,6 @@ export const upload: Upload;
414475
// Future optional changes once we migrate all core SDK files to TS. These are used internally only and should not be used by consumers of mParticle
415476
// export function addForwarder
416477
// export function configurePixel
417-
// export function generateHash
418478
// export function _setIntegrationDelay
419479
// export function _getIntegrationDelay
420480

@@ -436,17 +496,21 @@ export interface ConsentState {
436496
getCCPAConsentState: () => CCPAConsentState;
437497
removeGDPRConsentState: (purpose: string) => ConsentState;
438498
removeCCPAConsentState: () => ConsentState;
499+
/**
500+
* @deprecated Use removeCCPAConsentState instead
501+
*/
502+
removeCCPAState?: () => ConsentState;
439503
}
440504

441505
export interface GDPRConsentState {
442506
[key: string]: PrivacyConsentState;
443507
}
444508
export interface PrivacyConsentState {
445509
Consented: boolean;
446-
Timestamp: number;
447-
ConsentDocument: string;
448-
Location: string;
449-
HardwareId: string;
510+
Timestamp?: number;
511+
ConsentDocument?: string;
512+
Location?: string;
513+
HardwareId?: string;
450514
}
451515
export type CCPAConsentState = PrivacyConsentState;
452516

@@ -532,8 +596,8 @@ export enum ProductActionType {
532596

533597
export enum PromotionType {
534598
Unknown = 0,
535-
PromotionClick = 1,
536-
PromotionView = 2,
599+
PromotionView = 1,
600+
PromotionClick = 2,
537601
}
538602

539603
export namespace eCommerce {
@@ -559,6 +623,7 @@ export namespace eCommerce {
559623
export namespace Rokt {
560624
const selectPlacements: SelectPlacements;
561625
const hashAttributes: HashAttributes;
626+
const hashSha256: HashSha256;
562627
const setExtensionData: SetExtensionData;
563628
const use: Use;
564629
}
@@ -589,6 +654,7 @@ export interface User {
589654
isLoggedIn: () => boolean;
590655
getLastSeenTime: () => number;
591656
getFirstSeenTime: () => number;
657+
getUserAudiences?: (callback?: IdentityCallback) => void;
592658
}
593659
export type UserAttributesValue = string | number | boolean | null;
594660
export type AllUserAttributes = Record<string, UserAttributesValue | UserAttributesValue[]>;
@@ -629,6 +695,10 @@ interface Cart {
629695
* @deprecated Cart persistence in mParticle has been deprecated.
630696
*/
631697
clear: () => void;
698+
/**
699+
* @deprecated Cart Products have been deprecated
700+
*/
701+
getCartProducts?: () => Product[];
632702
}
633703

634704
export interface Product {
@@ -722,7 +792,7 @@ export interface IdentityResult {
722792
httpCode: any;
723793
getPreviousUser(): User;
724794
getUser(): User;
725-
body: IdentityResultBody;
795+
body: IdentityResultBody | IdentityModifyResultBody;
726796
}
727797

728798
export interface IdentityResultBody {
@@ -731,14 +801,22 @@ export interface IdentityResultBody {
731801
is_logged_in: boolean;
732802
// matched_identities should be UserIdentities + mpid, for not keep as object
733803
matched_identities: Record<string, unknown>;
804+
mpid?: MPID;
805+
}
806+
807+
export interface IdentityModifyResultBody {
808+
change_results?: {
809+
identity_type: string;
810+
modified_mpid: MPID;
811+
};
734812
}
735813

736814
export interface UserAliasRequest {
737815
destinationMpid: string;
738816
sourceMpid: string;
739817
startTime: number;
740818
endTime: number;
741-
scope?: string;
819+
scope?: AliasRequestScope;
742820
}
743821

744822
export interface AliasUsersCallback {
@@ -755,6 +833,7 @@ declare class mParticleInstance {
755833
setDeviceId: SetDeviceId;
756834
getEnvironment: GetEnvironment;
757835
getVersion: GetVersion;
836+
generateHash: GenerateHash;
758837
init: Init;
759838
isInitialized: IsInitialized;
760839
logBaseEvent: LogBaseEvent;
@@ -783,7 +862,6 @@ declare class mParticleInstance {
783862
// Future optional changes once we migrate all core SDK files to TS. These are used internally only and should not be used by consumers of mParticle
784863
// export function addForwarder
785864
// export function configurePixel
786-
// export function generateHash
787865
// export function _setIntegrationDelay
788866
// export function _getIntegrationDelay
789867

@@ -821,13 +899,15 @@ declare class mParticleInstance {
821899
Rokt: {
822900
selectPlacements: SelectPlacements;
823901
hashAttributes: HashAttributes;
902+
hashSha256: HashSha256;
824903
setExtensionData: SetExtensionData;
825904
use: Use;
826905
};
906+
MPSideloadedKit: typeof MPSideloadedKit;
827907
PromotionType: {
828908
Unknown: PromotionType.Unknown;
829-
PromotionClick: PromotionType.PromotionClick;
830909
PromotionView: PromotionType.PromotionView;
910+
PromotionClick: PromotionType.PromotionClick;
831911
};
832912
ProductActionType: {
833913
Unknown: ProductActionType.Unknown;

0 commit comments

Comments
 (0)