@customerio/cdp-analytics-browser 0.3.11 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,7 +26,10 @@ export interface InboxMessage {
26
26
  readonly properties: { [key: string]: any }
27
27
 
28
28
  // When the message was sent
29
- readonly sentAt: string
29
+ readonly sentAt: Date
30
+
31
+ // When the message expires
32
+ readonly expiresAt?: Date
30
33
 
31
34
  // Optional message type
32
35
  readonly type: string
@@ -92,11 +95,12 @@ function createInboxMessage(
92
95
  gistMessage: GistInboxMessage
93
96
  ): InboxMessage {
94
97
  return {
95
- sentAt: gistMessage.sentAt,
98
+ sentAt: new Date(gistMessage.sentAt),
99
+ expiresAt: gistMessage.expiry ? new Date(gistMessage.expiry) : undefined,
96
100
  messageId: gistMessage.queueId,
97
101
  opened: gistMessage?.opened === true,
98
102
  properties: gistMessage.properties,
99
- type: gistMessage.type || "",
103
+ type: gistMessage.type || '',
100
104
  topics: gistMessage.topics || [],
101
105
  trackClick: (trackedResponse?: string) => {
102
106
  if(typeof gistMessage.deliveryId === 'undefined' || gistMessage.deliveryId === '') {
@@ -134,6 +138,10 @@ async function getFilteredMessages(
134
138
  return []
135
139
  }
136
140
 
141
+ allMessages = allMessages.slice().sort((a, b) => {
142
+ return new Date(b.sentAt).getTime() - new Date(a.sentAt).getTime()
143
+ })
144
+
137
145
  if (topics.length === 0) {
138
146
  return allMessages
139
147
  }