Skip to content

Commit

Permalink
fix: added missing eu url in delete flow for amplitude destination (#…
Browse files Browse the repository at this point in the history
…3952)

Co-authored-by: Sudip Paul <[email protected]>
  • Loading branch information
manish339k and ItsSudip authored Jan 2, 2025
1 parent eaa68be commit ac673fc
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/v0/destinations/am/deleteUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const userDeletionHandler = async (userAttributes, config) => {
if (!config) {
throw new ConfigurationError('Config for deletion not present');
}
const { apiKey, apiSecret } = config;
const { apiKey, apiSecret, residencyServer } = config;
if (!apiKey || !apiSecret) {
throw new ConfigurationError('api key/secret for deletion not present');
}
Expand All @@ -27,7 +27,10 @@ const userDeletionHandler = async (userAttributes, config) => {
};
// Ref : https://www.docs.developers.amplitude.com/analytics/apis/user-privacy-api/#response
const batchEvents = getUserIdBatches(userAttributes, DELETE_MAX_BATCH_SIZE);
const url = 'https://amplitude.com/api/2/deletions/users';
const url =
residencyServer === 'EU'
? 'https://analytics.eu.amplitude.com/api/2/deletions/users'
: 'https://amplitude.com/api/2/deletions/users';
const endpointPath = '/api/2/deletions/users';
await Promise.all(
batchEvents.map(async (batch) => {
Expand Down
41 changes: 41 additions & 0 deletions test/integrations/destinations/am/deleteUsers/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,45 @@ export const data = [
},
},
},
{
name: 'am',
description: 'user deletion test with EU residencyServer',
feature: 'userDeletion',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
jobId: 'dummy-job-id',
destType: 'AM',
userAttributes: [
{
userId: 'test_user_id_1',
},
{
userId: 'test_user_id_2',
},
],
config: {
apiKey: '1234',
apiSecret: 'abcd',
residencyServer: 'EU',
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
statusCode: 200,
status: 'successful',
},
],
},
},
},
];
38 changes: 38 additions & 0 deletions test/integrations/destinations/am/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,44 @@ const deleteNwData = [
},
},
},
{
httpReq: {
method: 'post',
url: 'https://analytics.eu.amplitude.com/api/2/deletions/users',
data: {
user_ids: ['test_user_id_1', 'test_user_id_2'],
requester: 'RudderStack',
ignore_invalid_id: 'true',
},
headers: {
'Content-Type': 'application/json',
Authorization: 'Basic MTIzNDphYmNk',
},
},
httpRes: {
data: [
{
active_scrub_done_date: null,
amplitude_ids: [
{
amplitude_id: 44547850078,
requested_on_day: '2024-12-01',
requester: 'RudderStack',
},
{
amplitude_id: 44547886812,
requested_on_day: '2024-12-01',
requester: 'RudderStack',
},
],
app: '10000000',
day: '2025-01-10',
status: 'staging',
},
],
status: 200,
},
},
];

const deliveryNwData = [
Expand Down

0 comments on commit ac673fc

Please sign in to comment.