Skip to content

Commit e3cb599

Browse files
Jaissica HoraJaissica Hora
authored andcommitted
feat: added terminate and getVersionId function
1 parent 7d0c493 commit e3cb599

5 files changed

Lines changed: 134 additions & 10 deletions

File tree

snippet.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
'hashAttributes',
5151
'setExtensionData',
5252
'use',
53+
'getVersion',
54+
'terminate',
5355
];
5456

5557
// iterates through methods above to create stubs

snippet.rokt.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
'hashAttributes',
5151
'setExtensionData',
5252
'use',
53+
'getVersion',
54+
'terminate',
5355
];
5456

5557
// iterates through methods above to create stubs

src/roktManager.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export interface IRoktLauncher {
3939
selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
4040
hashAttributes: (attributes: IRoktPartnerAttributes) => Promise<Record<string, string>>;
4141
use: <T = any>(name: string) => Promise<T>;
42+
getVersion: () => Promise<string>;
43+
terminate: () => Promise<void>;
4244
}
4345

4446
export interface IRoktMessage {
@@ -63,6 +65,8 @@ export interface IRoktKit {
6365
hashAttributes: (attributes: IRoktPartnerAttributes) => Promise<Record<string, string>>;
6466
selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
6567
setExtensionData<T>(extensionData: IRoktPartnerExtensionData<T>): void;
68+
terminate: () => Promise<void>;
69+
getVersion: () => Promise<string>;
6670
use: <T = any>(name: string) => Promise<T>;
6771
launcherOptions?: Dictionary<any>;
6872
}
@@ -265,6 +269,30 @@ export default class RoktManager {
265269
}
266270
}
267271

272+
public terminate(): Promise<void> {
273+
if (!this.isReady()) {
274+
return this.deferredCall<void>('terminate', {});
275+
}
276+
277+
try {
278+
return this.kit.terminate();
279+
} catch (error) {
280+
return Promise.reject(error instanceof Error ? error : new Error('Error terminating'));
281+
}
282+
}
283+
284+
public getVersion(): Promise<string> {
285+
if (!this.isReady()) {
286+
return this.deferredCall<string>('getVersion', {});
287+
}
288+
289+
try {
290+
return this.kit.launcher.getVersion();
291+
} catch (error) {
292+
return Promise.reject(error instanceof Error ? error : new Error('Error getting the version'));
293+
}
294+
}
295+
268296
public getLocalSessionAttributes(): LocalSessionAttributes {
269297
return this.store.getLocalSessionAttributes();
270298
}

0 commit comments

Comments
 (0)