Skip to content

Commit 4f4b168

Browse files
feat: Add hashAttributes method to RoktManager (#1021)
1 parent f01e409 commit 4f4b168

File tree

2 files changed

+204
-31
lines changed

2 files changed

+204
-31
lines changed

src/roktManager.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface IRoktSelection {
2424

2525
export interface IRoktLauncher {
2626
selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
27+
hashAttributes: (attributes: IRoktPartnerAttributes) => Promise<Record<string, string>>;
2728
}
2829

2930
export interface IRoktMessage {
@@ -43,6 +44,7 @@ export interface IRoktKit {
4344
launcher: IRoktLauncher | null;
4445
userAttributes: Dictionary<string>;
4546
selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
47+
hashAttributes: (attributes: IRoktPartnerAttributes) => Promise<Record<string, string>>;
4648
}
4749

4850
export interface IRoktManagerOptions {
@@ -136,6 +138,22 @@ export default class RoktManager {
136138
}
137139
}
138140

141+
public hashAttributes(attributes: IRoktPartnerAttributes): Promise<Record<string, string>> {
142+
if (!this.isReady()) {
143+
this.queueMessage({
144+
methodName: 'hashAttributes',
145+
payload: attributes,
146+
});
147+
return Promise.resolve({} as Record<string, string>);
148+
}
149+
150+
try {
151+
return this.kit.hashAttributes(attributes);
152+
} catch (error) {
153+
return Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred'));
154+
}
155+
}
156+
139157
private isReady(): boolean {
140158
// The Rokt Manager is ready when a kit is attached and has a launcher
141159
return Boolean(this.kit && this.kit.launcher);

0 commit comments

Comments
 (0)