File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -201,13 +201,20 @@ export async function insertOutgoingLink(
201201
202202 const now = Date . now ( ) ;
203203
204+ const salt = await getDailySalt ( ) ;
205+
206+ let anonymousId = sanitizeString (
207+ linkData . anonymousId ,
208+ VALIDATION_LIMITS . SHORT_STRING_MAX_LENGTH
209+ ) ;
210+ if ( anonymousId ) {
211+ anonymousId = saltAnonymousId ( anonymousId , salt ) ;
212+ }
213+
204214 const outgoingLinkEvent : CustomOutgoingLink = {
205215 id : randomUUID ( ) ,
206216 client_id : clientId ,
207- anonymous_id : sanitizeString (
208- linkData . anonymousId ,
209- VALIDATION_LIMITS . SHORT_STRING_MAX_LENGTH
210- ) ,
217+ anonymous_id : anonymousId ,
211218 session_id : validateSessionId ( linkData . sessionId ) ,
212219 href : sanitizeString ( linkData . href , VALIDATION_LIMITS . PATH_MAX_LENGTH ) ,
213220 text : sanitizeString ( linkData . text , VALIDATION_LIMITS . TEXT_MAX_LENGTH ) ,
Original file line number Diff line number Diff line change @@ -71,7 +71,9 @@ function processTrackEventData(
7171 trackData . anonymousId ,
7272 VALIDATION_LIMITS . SHORT_STRING_MAX_LENGTH
7373 ) ;
74- anonymousId = saltAnonymousId ( anonymousId , salt ) ;
74+ if ( anonymousId ) {
75+ anonymousId = saltAnonymousId ( anonymousId , salt ) ;
76+ }
7577
7678 return {
7779 id : randomUUID ( ) ,
@@ -141,19 +143,26 @@ function processTrackEventData(
141143 } ) ;
142144}
143145
144- function processOutgoingLinkData (
146+ async function processOutgoingLinkData (
145147 linkData : any ,
146148 clientId : string
147- ) : CustomOutgoingLink {
149+ ) : Promise < CustomOutgoingLink > {
148150 const timestamp = parseTimestamp ( linkData . timestamp ) ;
149151
152+ const salt = await getDailySalt ( ) ;
153+
154+ let anonymousId = sanitizeString (
155+ linkData . anonymousId ,
156+ VALIDATION_LIMITS . SHORT_STRING_MAX_LENGTH
157+ ) ;
158+ if ( anonymousId ) {
159+ anonymousId = saltAnonymousId ( anonymousId , salt ) ;
160+ }
161+
150162 return {
151163 id : randomUUID ( ) ,
152164 client_id : clientId ,
153- anonymous_id : sanitizeString (
154- linkData . anonymousId ,
155- VALIDATION_LIMITS . SHORT_STRING_MAX_LENGTH
156- ) ,
165+ anonymous_id : anonymousId ,
157166 session_id : validateSessionId ( linkData . sessionId ) ,
158167 href : sanitizeString ( linkData . href , VALIDATION_LIMITS . PATH_MAX_LENGTH ) ,
159168 text : sanitizeString ( linkData . text , VALIDATION_LIMITS . TEXT_MAX_LENGTH ) ,
You can’t perform that action at this time.
0 commit comments