Skip to content

Commit c03829d

Browse files
authored
fix: remove hard check for timestamp for airship (#4214)
* fix: remove hard check for timestamp for airship * fix: remove hard check for timestamp for airship
1 parent f6c54e8 commit c03829d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/v0/destinations/airship/utils.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ describe('Airship utils - convertToAirshipTimestamp', () => {
449449
input: '1742974069043000',
450450
output: '2025-03-26T07:27:49Z',
451451
},
452+
{
453+
description: 'should return formatted date time when date time string is passed',
454+
input: '2025-03-27 16:00:48 +0100',
455+
output: '2025-03-27T16:00:48Z',
456+
},
452457
{
453458
description: 'should throw an error when incorrect epoch second is passed',
454459
input: '17428871802',

src/v0/destinations/airship/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ export const convertToAirshipTimestamp = (timeValue: string | number): string =>
6363
}
6464

6565
// Check if the input is a valid date string
66-
if (typeof timestamp === 'string' && moment.utc(timestamp, moment.ISO_8601, true).isValid()) {
67-
return moment.utc(timestamp).format(AIRSHIP_TIMESTAMP_FORMAT);
66+
if (typeof timestamp === 'string') {
67+
const parsedDate = moment.utc(timestamp);
68+
if (!parsedDate.isValid()) {
69+
throw new InstrumentationError(`timestamp is not supported: ${timestamp}`);
70+
}
71+
return parsedDate.format(AIRSHIP_TIMESTAMP_FORMAT);
6872
}
6973

7074
// If it's a number, handle different timestamp formats

0 commit comments

Comments
 (0)