Skip to content

Commit

Permalink
OTT-1982: honor IFA over session_id if when ifa_type is absent (#895)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pubmatic-Supriya-Patil authored and AvinashKapre committed Sep 21, 2024
1 parent 3f5aaee commit d2a3d3f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/pubmatic/openwrap/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func updateDeviceIFADetails(dvc *models.DeviceCtx) {
} else {
deviceExt.DeleteIFAType()
}
} else if extSessionID != "" {
} else if extSessionID != "" && dvc.DeviceIFA == "" {
dvc.DeviceIFA = extSessionID
dvc.IFATypeID = ptrutil.ToPtr(models.DeviceIfaTypeIdSessionId)
deviceExt.SetIFAType(models.DeviceIFATypeSESSIONID)
Expand Down
45 changes: 44 additions & 1 deletion modules/pubmatic/openwrap/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,18 +390,61 @@ func TestUpdateDeviceIFADetails(t *testing.T) {
}(),
},
},
want: &models.DeviceCtx{
DeviceIFA: `existing_ifa_id`,
Ext: func() *models.ExtDevice {
deviceExt := &models.ExtDevice{}
deviceExt.SetSessionID(`sample_session_id`)
return deviceExt
}(),
},
},
{
name: `ifa_type_missing_ifa_empty_session_id_present`,
args: args{
dvc: &models.DeviceCtx{
DeviceIFA: "",
Ext: func() *models.ExtDevice {
deviceExt := &models.ExtDevice{}
deviceExt.SetSessionID(`sample_session_id`)
return deviceExt
}(),
},
},
want: &models.DeviceCtx{
IFATypeID: ptrutil.ToPtr(9),
DeviceIFA: `sample_session_id`,
Ext: func() *models.ExtDevice {
deviceExt := &models.ExtDevice{}
deviceExt.SetIFAType(models.DeviceIFATypeSESSIONID)
deviceExt.SetSessionID(`sample_session_id`)

return deviceExt
}(),
},
},
{
name: `ifa_type_missing_ifa_not_present_session_id_present`,
args: args{
dvc: &models.DeviceCtx{
Ext: func() *models.ExtDevice {
deviceExt := &models.ExtDevice{}
deviceExt.SetSessionID(`sample_session_id`)
return deviceExt
}(),
},
},
want: &models.DeviceCtx{
IFATypeID: ptrutil.ToPtr(9),
DeviceIFA: `sample_session_id`,
Ext: func() *models.ExtDevice {
deviceExt := &models.ExtDevice{}
deviceExt.SetIFAType(models.DeviceIFATypeSESSIONID)
deviceExt.SetSessionID(`sample_session_id`)
return deviceExt
}(),
},
},

// TODO: Add test cases.
}
for _, tt := range tests {
Expand Down

0 comments on commit d2a3d3f

Please sign in to comment.