Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTT-1982: Honor IFA over session_id if when ifa_type is absent #895

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading