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

fix: handling invalid timestamp for adjust source #3866

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
15 changes: 11 additions & 4 deletions src/v0/sources/adjust/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,18 @@ const processEvent = (inputEvent) => {
message.properties = { ...message.properties, ...customProperties };

if (formattedPayload.created_at) {
const ts = new Date(formattedPayload.created_at * 1000).toISOString();
message.setProperty('originalTimestamp', ts);
message.setProperty('timestamp', ts);
const rawTimestamp = formattedPayload.created_at;
try {
const createdAt = Number(rawTimestamp);
const ts = new Date(createdAt * 1000).toISOString();
message.setProperty('originalTimestamp', ts);
message.setProperty('timestamp', ts);
} catch (error) {
throw new TransformationError(
`[Adjust] Invalid timestamp "${rawTimestamp}": ${error.message}`,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write in it's own method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

}

// adjust does not has the concept of user but we need to set some random anonymousId in order to make the server accept the message
message.anonymousId = generateUUID();
return message;
Expand Down
53 changes: 53 additions & 0 deletions test/integrations/sources/adjust/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,57 @@ export const data = [
defaultMockFns();
},
},
{
name: 'adjust',
description: 'Simple track call with wrong created at',
module: 'source',
version: 'v0',
skipGo: 'FIXME',
input: {
request: {
body: [
{
id: 'adjust',
query_parameters: {
gps_adid: ['38400000-8cf0-11bd-b23e-10b96e40000d'],
adid: ['18546f6171f67e29d1cb983322ad1329'],
tracker_token: ['abc'],
custom: ['custom'],
tracker_name: ['dummy'],
created_at: ['test'],
event_name: ['Click'],
},
updated_at: '2023-02-10T12:16:07.251Z',
created_at: 'test',
},
],
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
pathSuffix: '',
},
output: {
response: {
status: 200,
body: [
{
error: '[Adjust] Invalid timestamp "test": Invalid time value',
statTags: {
destinationId: 'Non determinable',
errorCategory: 'transformation',
implementation: 'native',
module: 'source',
workspaceId: 'Non determinable',
},
statusCode: 400,
},
],
},
},
mockFns: () => {
defaultMockFns();
},
},
];
Loading