@@ -14,7 +14,7 @@ import { SDKIdentityApi } from "./identity.interfaces";
1414import { SDKLoggerApi } from "./sdkRuntimeModels" ;
1515import { IStore , LocalSessionAttributes } from "./store" ;
1616import { UserIdentities } from "@mparticle/web-sdk" ;
17- import { IdentityType } from "./types" ;
17+ import { IdentityType , PerformanceMarkType } from "./types" ;
1818
1919// https://docs.rokt.com/developers/integration-guides/web/library/attributes
2020export type RoktAttributeValueArray = Array < string | number | boolean > ;
@@ -101,7 +101,7 @@ export default class RoktManager {
101101 private logger : SDKLoggerApi ;
102102 private domain ?: string ;
103103 private mappedEmailShaIdentityType ?: string | null ;
104-
104+ private captureTiming ?: ( metricsName : string ) => void ;
105105 /**
106106 * Initializes the RoktManager with configuration settings and user data.
107107 *
@@ -110,6 +110,7 @@ export default class RoktManager {
110110 * @param {SDKIdentityApi } identityService - The mParticle Identity instance
111111 * @param {SDKLoggerApi } logger - The mParticle Logger instance
112112 * @param {IRoktOptions } options - Options for the RoktManager
113+ * @param {Function } captureTiming - Function to capture performance timing marks
113114 *
114115 * @throws Logs error to console if placementAttributesMapping parsing fails
115116 */
@@ -119,7 +120,8 @@ export default class RoktManager {
119120 identityService : SDKIdentityApi ,
120121 store : IStore ,
121122 logger ?: SDKLoggerApi ,
122- options ?: IRoktOptions
123+ options ?: IRoktOptions ,
124+ captureTiming ?: ( metricsName : string ) => void
123125 ) : void {
124126 const { userAttributeFilters, settings } = roktConfig || { } ;
125127 const { placementAttributesMapping, hashedEmailUserIdentityType } = settings || { } ;
@@ -128,6 +130,7 @@ export default class RoktManager {
128130 this . identityService = identityService ;
129131 this . store = store ;
130132 this . logger = logger ;
133+ this . captureTiming = captureTiming ;
131134
132135 this . filters = {
133136 userAttributeFilters,
@@ -177,6 +180,10 @@ export default class RoktManager {
177180 * });
178181 */
179182 public async selectPlacements ( options : IRoktSelectPlacementsOptions ) : Promise < IRoktSelection > {
183+ if ( this . captureTiming ) {
184+ this . captureTiming ( PerformanceMarkType . JointSdkSelectPlacements ) ;
185+ }
186+
180187 // Queue if kit isn't ready OR if identity is in flight
181188 if ( ! this . isReady ( ) || this . store ?. identityCallInFlight ) {
182189 return this . deferredCall < IRoktSelection > ( 'selectPlacements' , options ) ;
@@ -556,4 +563,4 @@ export default class RoktManager {
556563
557564 return false ; // Values are the same
558565 }
559- }
566+ }
0 commit comments