Skip to content

Commit

Permalink
feat: add RFC 3999 fields that replace timestamps (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
figueredo authored Jul 24, 2024
1 parent 8c34eda commit 788eb42
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ try {
incogniaApi.registerFeedback({
installationId: 'installation_id',
accountId: 'account_id',
event: 'payment_accepted',
timestamp: 1610570403068 // milliseconds
event: FeedbackEvent.AccountTakeover,
occurredAt: '2024-07-22T15:20:00Z'
})
} catch (error) {
console.log(error.message)
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ export type RegisterFeedbackBodyProps = {
loginId?: string
paymentId?: string
signupId?: string
/** @deprecated use occurredAt instead */
timestamp?: number
occurredAt?: Date
[x: string]: any
}

Expand All @@ -130,7 +132,9 @@ export type RegisterTransactionProps = (
type TransactionLocation = {
latitude: number
longitude: number
/** @deprecated use collectedAt instead */
timestamp?: number
collectedAt?: Date
}

type AddressCoordinates = {
Expand Down
6 changes: 4 additions & 2 deletions test/formatting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ describe('convertObjectToSnakeCase', () => {
convertObjectToSnakeCase({
keyName: { nestedKey: 2 },
a: [{ nestedInArray: 'black_rice' }],
keyNameWithNumber60d: 3
keyNameWithNumber60d: 3,
keyValueIsDate: new Date('2024-07-17T01:02:03Z')
})
).toEqual({
key_name: { nested_key: 2 },
a: [{ nested_in_array: 'black_rice' }],
key_name_with_number_60d: 3
key_name_with_number_60d: 3,
key_value_is_date: '2024-07-17T01:02:03.000Z'
})
})
})
Expand Down
6 changes: 4 additions & 2 deletions test/incogniaApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ describe('API', () => {
loginId: 'login_id',
paymentId: 'payment_id',
signupId: 'signup_id',
timestamp: 123
timestamp: 123,
occurredAt: new Date("Jul 19 2024 01:02:03 UTC"),
},
{
dryRun: true
Expand All @@ -276,7 +277,8 @@ describe('API', () => {
login_id: 'login_id',
payment_id: 'payment_id',
signup_id: 'signup_id',
timestamp: 123
timestamp: 123,
occurred_at: '2024-07-19T01:02:03.000Z'
}

const expectedParams = {
Expand Down

0 comments on commit 788eb42

Please sign in to comment.