1- import { BrowserClient , BrowserConfig , EnrichmentPlugin , Event } from '@amplitude/analytics-core' ;
1+ import { BrowserClient , BrowserConfig , EnrichmentPlugin , Event , SpecialEventType } from '@amplitude/analytics-core' ;
22import * as sessionReplay from '@amplitude/session-replay-browser' ;
3+ import { getAnalyticsConnector } from '@amplitude/analytics-client-common' ;
4+ import { parseUserProperties } from './helpers' ;
35import { SessionReplayOptions } from './typings/session-replay' ;
46import { VERSION } from './version' ;
57import { AmplitudeSessionReplay } from '@amplitude/session-replay-browser' ;
@@ -21,6 +23,7 @@ export class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, Brow
2123 init : sessionReplay . init ,
2224 setSessionId : sessionReplay . setSessionId ,
2325 shutdown : sessionReplay . shutdown ,
26+ evaluateTargetingAndCapture : sessionReplay . evaluateTargetingAndCapture ,
2427 } ;
2528
2629 constructor ( options ?: SessionReplayOptions ) {
@@ -52,6 +55,8 @@ export class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, Brow
5255 } ;
5356 }
5457 }
58+ const identityStore = getAnalyticsConnector ( this . config . instanceName ) . identityStore ;
59+ const userProperties = identityStore . getIdentity ( ) . userProperties ;
5560
5661 this . srInitOptions = {
5762 instanceName : this . config . instanceName ,
@@ -77,6 +82,7 @@ export class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, Brow
7782 performanceConfig : this . options . performanceConfig ,
7883 storeType : this . options . storeType ,
7984 experimental : this . options . experimental ,
85+ userProperties : userProperties ,
8086 omitElementTags : this . options . omitElementTags ,
8187 applyBackgroundColorToBlockedElements : this . options . applyBackgroundColorToBlockedElements ,
8288 interactionConfig : this . options . interactionConfig ,
@@ -140,6 +146,11 @@ export class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, Brow
140146 // Treating config.sessionId as source of truth, if the event's session id doesn't match, the
141147 // event is not of the current session (offline/late events). In that case, don't tag the events
142148 if ( sessionId && sessionId === event . session_id ) {
149+ let userProperties ;
150+ if ( event . event_type === SpecialEventType . IDENTIFY ) {
151+ userProperties = parseUserProperties ( event ) ;
152+ }
153+ await this . sr . evaluateTargetingAndCapture ( { event, userProperties } ) ;
143154 const sessionRecordingProperties = this . sessionReplay . getSessionReplayProperties ( ) ;
144155 event . event_properties = {
145156 ...event . event_properties ,
0 commit comments