@customerio/cdp-analytics-browser 0.4.1 → 0.4.2

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.
@@ -1,6 +1,8 @@
1
1
  import { Analytics } from '../../core/analytics'
2
2
  import { JourneysEvents } from './events'
3
3
 
4
+ const CIO_TOPIC_PREFIX = '_cio'
5
+
4
6
  export interface GistInboxMessage {
5
7
  messageType: string
6
8
  expiry: string
@@ -143,14 +145,25 @@ async function getFilteredMessages(
143
145
  })
144
146
 
145
147
  if (topics.length === 0) {
146
- return allMessages
148
+ return allMessages.filter((message) => {
149
+ const messageTopics = message.topics
150
+ if (!messageTopics || messageTopics.length === 0) {
151
+ return true
152
+ }
153
+ return !messageTopics.some((topic) => topic.startsWith(CIO_TOPIC_PREFIX))
154
+ })
147
155
  }
148
156
 
157
+ const hasCioTopic = topics.some((topic) => topic.startsWith(CIO_TOPIC_PREFIX))
158
+
149
159
  return allMessages.filter((message) => {
150
160
  const messageTopics = message.topics
151
161
  if (!messageTopics || messageTopics.length === 0) {
152
162
  return false
153
163
  }
164
+ if (!hasCioTopic && messageTopics.some((topic) => topic.startsWith(CIO_TOPIC_PREFIX))) {
165
+ return false
166
+ }
154
167
  return messageTopics.some((messageTopic) => topics.includes(messageTopic))
155
168
  })
156
169
  }