Skip to content

Commit 36ab1ed

Browse files
committed
fix: correct actor name field mapping in session info
Changed identifyActorName to use the dedicated userName field from the identify response instead of extracting it from nested userData.name property
1 parent c3c0080 commit 36ab1ed

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/modules/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function getSessionInfo(
6666
clientName: clientInfo?.name,
6767
clientVersion: clientInfo?.version,
6868
identifyActorGivenId: actorInfo?.userId,
69-
identifyActorName: actorInfo?.userData?.name,
69+
identifyActorName: actorInfo?.userName,
7070
identifyActorData: actorInfo?.userData || {},
7171
};
7272

src/tests/identify.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ describe("Identify Feature", () => {
457457
describe("Identity Data in Session Info", () => {
458458
it("should populate actorGivenId, actorName, and actorData in session info", async () => {
459459
const testUserId = `session-user-${randomUUID()}`;
460+
const testUserName = `Session User ${randomUUID()}`;
460461
const testUserData = {
461462
name: `Session Test User ${randomUUID()}`,
462463
role: "Developer",
@@ -468,6 +469,7 @@ describe("Identify Feature", () => {
468469
enableTracing: true,
469470
identify: async () => ({
470471
userId: testUserId,
472+
userName: testUserName,
471473
userData: testUserData,
472474
}),
473475
});
@@ -490,7 +492,7 @@ describe("Identify Feature", () => {
490492

491493
expect(sessionInfo).toBeDefined();
492494
expect(sessionInfo?.identifyActorGivenId).toBe(testUserId);
493-
expect(sessionInfo?.identifyActorName).toBe(testUserData.name);
495+
expect(sessionInfo?.identifyActorName).toBe(testUserName);
494496
expect(sessionInfo?.identifyActorData).toEqual(testUserData);
495497
});
496498

@@ -499,6 +501,7 @@ describe("Identify Feature", () => {
499501
await eventCapture.start();
500502

501503
const testUserId = `event-user-${randomUUID()}`;
504+
const testUserName = `Event User ${randomUUID()}`;
502505
const testUserData = {
503506
name: `Event Test User ${randomUUID()}`,
504507
subscription: "premium",
@@ -509,6 +512,7 @@ describe("Identify Feature", () => {
509512
enableTracing: true,
510513
identify: async () => ({
511514
userId: testUserId,
515+
userName: testUserName,
512516
userData: testUserData,
513517
}),
514518
});
@@ -539,7 +543,7 @@ describe("Identify Feature", () => {
539543

540544
const data = getServerTrackingData(server.server);
541545
expect(data?.sessionInfo.identifyActorGivenId).toBe(testUserId);
542-
expect(data?.sessionInfo.identifyActorName).toBe(testUserData.name);
546+
expect(data?.sessionInfo.identifyActorName).toBe(testUserName);
543547
expect(data?.sessionInfo.identifyActorData).toEqual(testUserData);
544548

545549
await eventCapture.stop();

src/tests/redaction.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ describe("redactEvent integration tests", () => {
437437
redactSensitiveInformation: redactSensitiveData,
438438
identify: async () => ({
439439
userId: "test-user-123",
440+
userName: "John Doe",
440441
userData: {
441442
email: "user@example.com",
442443
apiKey: "secret-api-key-123",
443-
name: "John Doe",
444444
},
445445
}),
446446
});
@@ -618,8 +618,8 @@ describe("redactEvent integration tests", () => {
618618
redactSensitiveInformation: aggressiveRedact,
619619
identify: async () => ({
620620
userId: "user-with-id-123",
621+
userName: "David Smith",
621622
userData: {
622-
name: "David Smith",
623623
internalId: "internal-id-456",
624624
},
625625
}),

0 commit comments

Comments
 (0)