@ht-sdks/consent-manager 0.0.1

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.
Files changed (110) hide show
  1. package/LICENSE +45 -0
  2. package/README.md +851 -0
  3. package/commonjs/__tests__/consent-manager-builder/analytics.test.js +250 -0
  4. package/commonjs/__tests__/consent-manager-builder/fetch-destinations.test.js +155 -0
  5. package/commonjs/__tests__/consent-manager-builder/index.todo.js +327 -0
  6. package/commonjs/__tests__/consent-manager-builder/preferences.test.js +129 -0
  7. package/commonjs/__tests__/index.test.js +57 -0
  8. package/commonjs/consent-manager/banner.js +89 -0
  9. package/commonjs/consent-manager/buttons.js +18 -0
  10. package/commonjs/consent-manager/cancel-dialog.js +76 -0
  11. package/commonjs/consent-manager/categories.js +29 -0
  12. package/commonjs/consent-manager/container.js +169 -0
  13. package/commonjs/consent-manager/dialog.js +129 -0
  14. package/commonjs/consent-manager/font-styles.js +10 -0
  15. package/commonjs/consent-manager/index.js +244 -0
  16. package/commonjs/consent-manager/preference-dialog.js +178 -0
  17. package/commonjs/consent-manager-builder/analytics.js +76 -0
  18. package/commonjs/consent-manager-builder/fetch-destinations.js +104 -0
  19. package/commonjs/consent-manager-builder/index.js +330 -0
  20. package/commonjs/consent-manager-builder/preferences.js +82 -0
  21. package/commonjs/index.js +39 -0
  22. package/commonjs/standalone.js +86 -0
  23. package/commonjs/types.js +3 -0
  24. package/esm/__tests__/consent-manager-builder/analytics.test.js +245 -0
  25. package/esm/__tests__/consent-manager-builder/fetch-destinations.test.js +150 -0
  26. package/esm/__tests__/consent-manager-builder/index.todo.js +322 -0
  27. package/esm/__tests__/consent-manager-builder/preferences.test.js +124 -0
  28. package/esm/__tests__/index.test.js +55 -0
  29. package/esm/consent-manager/banner.js +65 -0
  30. package/esm/consent-manager/buttons.js +12 -0
  31. package/esm/consent-manager/cancel-dialog.js +52 -0
  32. package/esm/consent-manager/categories.js +26 -0
  33. package/esm/consent-manager/container.js +162 -0
  34. package/esm/consent-manager/dialog.js +105 -0
  35. package/esm/consent-manager/font-styles.js +8 -0
  36. package/esm/consent-manager/index.js +220 -0
  37. package/esm/consent-manager/preference-dialog.js +154 -0
  38. package/esm/consent-manager-builder/analytics.js +73 -0
  39. package/esm/consent-manager-builder/fetch-destinations.js +98 -0
  40. package/esm/consent-manager-builder/index.js +325 -0
  41. package/esm/consent-manager-builder/preferences.js +73 -0
  42. package/esm/index.js +28 -0
  43. package/esm/standalone.js +58 -0
  44. package/esm/types.js +1 -0
  45. package/package.json +168 -0
  46. package/src/__tests__/consent-manager-builder/analytics.test.ts +279 -0
  47. package/src/__tests__/consent-manager-builder/fetch-destinations.test.ts +89 -0
  48. package/src/__tests__/consent-manager-builder/index.todo.js +386 -0
  49. package/src/__tests__/consent-manager-builder/preferences.test.ts +156 -0
  50. package/src/__tests__/index.test.ts +68 -0
  51. package/src/consent-manager/banner.tsx +227 -0
  52. package/src/consent-manager/buttons.tsx +78 -0
  53. package/src/consent-manager/cancel-dialog.tsx +68 -0
  54. package/src/consent-manager/categories.ts +27 -0
  55. package/src/consent-manager/container.tsx +282 -0
  56. package/src/consent-manager/dialog.tsx +236 -0
  57. package/src/consent-manager/font-styles.tsx +14 -0
  58. package/src/consent-manager/index.tsx +327 -0
  59. package/src/consent-manager/preference-dialog.tsx +371 -0
  60. package/src/consent-manager-builder/analytics.ts +104 -0
  61. package/src/consent-manager-builder/fetch-destinations.ts +50 -0
  62. package/src/consent-manager-builder/index.tsx +426 -0
  63. package/src/consent-manager-builder/preferences.ts +100 -0
  64. package/src/index.ts +42 -0
  65. package/src/standalone.tsx +57 -0
  66. package/src/styled.d.ts +7 -0
  67. package/src/types.ts +151 -0
  68. package/standalone/consent-manager.js +23 -0
  69. package/standalone/consent-manager.js.map +1 -0
  70. package/types/__tests__/consent-manager-builder/analytics.test.d.ts +1 -0
  71. package/types/__tests__/consent-manager-builder/fetch-destinations.test.d.ts +1 -0
  72. package/types/__tests__/consent-manager-builder/index.todo.d.ts +1 -0
  73. package/types/__tests__/consent-manager-builder/preferences.test.d.ts +1 -0
  74. package/types/__tests__/index.test.d.ts +1 -0
  75. package/types/consent-manager/banner.d.ts +21 -0
  76. package/types/consent-manager/buttons.d.ts +13 -0
  77. package/types/consent-manager/cancel-dialog.d.ts +19 -0
  78. package/types/consent-manager/categories.d.ts +3 -0
  79. package/types/consent-manager/container.d.ts +35 -0
  80. package/types/consent-manager/dialog.d.ts +29 -0
  81. package/types/consent-manager/font-styles.d.ts +2 -0
  82. package/types/consent-manager/index.d.ts +35 -0
  83. package/types/consent-manager/preference-dialog.d.ts +32 -0
  84. package/types/consent-manager-builder/analytics.d.ts +14 -0
  85. package/types/consent-manager-builder/fetch-destinations.d.ts +2 -0
  86. package/types/consent-manager-builder/index.d.ts +126 -0
  87. package/types/consent-manager-builder/preferences.d.ts +26 -0
  88. package/types/index.d.ts +7 -0
  89. package/types/src/__tests__/consent-manager-builder/analytics.test.d.ts +1 -0
  90. package/types/src/__tests__/consent-manager-builder/fetch-destinations.test.d.ts +1 -0
  91. package/types/src/__tests__/consent-manager-builder/preferences.test.d.ts +1 -0
  92. package/types/src/__tests__/index.test.d.ts +1 -0
  93. package/types/src/consent-manager/banner.d.ts +21 -0
  94. package/types/src/consent-manager/buttons.d.ts +13 -0
  95. package/types/src/consent-manager/cancel-dialog.d.ts +19 -0
  96. package/types/src/consent-manager/categories.d.ts +3 -0
  97. package/types/src/consent-manager/container.d.ts +35 -0
  98. package/types/src/consent-manager/dialog.d.ts +29 -0
  99. package/types/src/consent-manager/font-styles.d.ts +2 -0
  100. package/types/src/consent-manager/index.d.ts +35 -0
  101. package/types/src/consent-manager/preference-dialog.d.ts +32 -0
  102. package/types/src/consent-manager-builder/analytics.d.ts +14 -0
  103. package/types/src/consent-manager-builder/fetch-destinations.d.ts +2 -0
  104. package/types/src/consent-manager-builder/index.d.ts +126 -0
  105. package/types/src/consent-manager-builder/preferences.d.ts +26 -0
  106. package/types/src/index.d.ts +7 -0
  107. package/types/src/standalone.d.ts +5 -0
  108. package/types/src/types.d.ts +131 -0
  109. package/types/standalone.d.ts +5 -0
  110. package/types/types.d.ts +131 -0
@@ -0,0 +1,371 @@
1
+ import React, { PureComponent } from 'react'
2
+ import styled from '@emotion/styled'
3
+ import { css } from '@emotion/react'
4
+ import Dialog from './dialog'
5
+ import { DefaultButton, GreenButton } from './buttons'
6
+ import {
7
+ Destination,
8
+ CustomCategories,
9
+ CategoryPreferences,
10
+ PreferenceDialogTemplate
11
+ } from '../types'
12
+
13
+ const hideOnMobile = css`
14
+ @media (max-width: 600px) {
15
+ display: none;
16
+ }
17
+ `
18
+
19
+ const TableScroll = styled('div')`
20
+ overflow-x: auto;
21
+ margin-top: 16px;
22
+ `
23
+
24
+ const Table = styled('table')`
25
+ border-collapse: collapse;
26
+ font-size: 12px;
27
+ `
28
+
29
+ const ColumnHeading = styled('th')`
30
+ background: #f7f8fa;
31
+ color: #1f4160;
32
+ font-weight: 600;
33
+ text-align: left;
34
+ border-width: 2px;
35
+ `
36
+
37
+ const RowHeading = styled('th')`
38
+ font-weight: normal;
39
+ text-align: left;
40
+ `
41
+
42
+ const Row = styled('tr')`
43
+ th,
44
+ td {
45
+ vertical-align: top;
46
+ padding: 8px 12px;
47
+ border: 1px solid rgba(67, 90, 111, 0.114);
48
+ }
49
+ td {
50
+ border-top: none;
51
+ }
52
+ `
53
+
54
+ const InputCell = styled('td')`
55
+ input {
56
+ margin: 0px 6px 0px 0px;
57
+ vertical-align: middle;
58
+ }
59
+ label {
60
+ display: flex;
61
+ align-items: center;
62
+ margin-bottom: 8px;
63
+ white-space: nowrap;
64
+ }
65
+ td {
66
+ border: none;
67
+ vertical-align: middle;
68
+ }
69
+ `
70
+
71
+ interface PreferenceDialogProps {
72
+ innerRef: (element: HTMLElement | null) => void
73
+ onCancel: () => void
74
+ onSave: () => void
75
+ onChange: (name: string, value: boolean) => void
76
+ marketingDestinations: Destination[]
77
+ advertisingDestinations: Destination[]
78
+ functionalDestinations: Destination[]
79
+ marketingAndAnalytics?: boolean | null
80
+ advertising?: boolean | null
81
+ functional?: boolean | null
82
+ customCategories?: CustomCategories
83
+ destinations: Destination[]
84
+ preferences: CategoryPreferences
85
+ title: React.ReactNode
86
+ content: React.ReactNode
87
+ preferencesDialogTemplate?: PreferenceDialogTemplate
88
+ }
89
+
90
+ export default class PreferenceDialog extends PureComponent<PreferenceDialogProps, {}> {
91
+ static displayName = 'PreferenceDialog'
92
+
93
+ static defaultProps = {
94
+ marketingAndAnalytics: null,
95
+ advertising: null,
96
+ functional: null
97
+ }
98
+
99
+ render() {
100
+ const {
101
+ innerRef,
102
+ onCancel,
103
+ marketingDestinations,
104
+ advertisingDestinations,
105
+ functionalDestinations,
106
+ marketingAndAnalytics,
107
+ advertising,
108
+ functional,
109
+ customCategories,
110
+ destinations,
111
+ title,
112
+ content,
113
+ preferences,
114
+ preferencesDialogTemplate
115
+ } = this.props
116
+
117
+ const { headings, checkboxes, actionButtons } = preferencesDialogTemplate!
118
+
119
+ const functionalInfo = preferencesDialogTemplate?.categories!.find(c => c.key === 'functional')
120
+ const marketingInfo = preferencesDialogTemplate?.categories!.find(c => c.key === 'marketing')
121
+ const advertisingInfo = preferencesDialogTemplate?.categories!.find(
122
+ c => c.key === 'advertising'
123
+ )
124
+ const essentialInfo = preferencesDialogTemplate?.categories!.find(c => c.key === 'essential')
125
+
126
+ const buttons = (
127
+ <div>
128
+ <DefaultButton id="hightouchio_hightouchio_prefBtnCancel" type="button" onClick={onCancel}>
129
+ {actionButtons!.cancelValue}
130
+ </DefaultButton>
131
+ <GreenButton id="hightouchio_prefBtnSubmit" type="submit">
132
+ {actionButtons!.saveValue}
133
+ </GreenButton>
134
+ </div>
135
+ )
136
+
137
+ return (
138
+ <Dialog
139
+ innerRef={innerRef}
140
+ title={title}
141
+ buttons={buttons}
142
+ onCancel={onCancel}
143
+ onSubmit={this.handleSubmit}
144
+ >
145
+ {content}
146
+
147
+ <TableScroll id="hightouchio_prefTableScroll">
148
+ <Table id="hightouchio_prefTable">
149
+ <thead id="hightouchio_prefThead">
150
+ <Row>
151
+ <ColumnHeading scope="col">{headings!.allowValue}</ColumnHeading>
152
+ <ColumnHeading scope="col">{headings!.categoryValue}</ColumnHeading>
153
+ <ColumnHeading scope="col">{headings!.purposeValue}</ColumnHeading>
154
+ {/* <ColumnHeading scope="col" css={hideOnMobile}>
155
+ {headings!.toolsValue}
156
+ </ColumnHeading> */}
157
+ </Row>
158
+ </thead>
159
+
160
+ <tbody id="hightouchio_prefTbody">
161
+ {!customCategories && (
162
+ <>
163
+ <Row>
164
+ <InputCell>
165
+ <label>
166
+ <input
167
+ type="radio"
168
+ name="functional"
169
+ value="true"
170
+ checked={functional === true}
171
+ onChange={this.handleChange}
172
+ aria-label="Allow functional tracking"
173
+ required
174
+ />{' '}
175
+ {checkboxes!.yesValue}
176
+ </label>
177
+ <label>
178
+ <input
179
+ type="radio"
180
+ name="functional"
181
+ value="false"
182
+ checked={functional === false}
183
+ onChange={this.handleChange}
184
+ aria-label="Disallow functional tracking"
185
+ required
186
+ />{' '}
187
+ {checkboxes!.noValue}
188
+ </label>
189
+ </InputCell>
190
+ <RowHeading scope="row">{functionalInfo?.name}</RowHeading>
191
+ <td>
192
+ <p>{functionalInfo?.description}</p>
193
+ <p css={hideOnMobile}>{functionalInfo?.example}</p>
194
+ </td>
195
+ {/* <td css={hideOnMobile}>{functionalDestinations.map(d => d.name).join(', ')}</td> */}
196
+ </Row>
197
+
198
+ <Row>
199
+ <InputCell>
200
+ <label>
201
+ <input
202
+ type="radio"
203
+ name="marketingAndAnalytics"
204
+ value="true"
205
+ checked={marketingAndAnalytics === true}
206
+ onChange={this.handleChange}
207
+ aria-label="Allow marketing and analytics tracking"
208
+ required
209
+ />{' '}
210
+ {checkboxes!.yesValue}
211
+ </label>
212
+ <label>
213
+ <input
214
+ type="radio"
215
+ name="marketingAndAnalytics"
216
+ value="false"
217
+ checked={marketingAndAnalytics === false}
218
+ onChange={this.handleChange}
219
+ aria-label="Disallow marketing and analytics tracking"
220
+ required
221
+ />{' '}
222
+ {checkboxes!.noValue}
223
+ </label>
224
+ </InputCell>
225
+ <RowHeading scope="row">{marketingInfo?.name}</RowHeading>
226
+ <td>
227
+ <p>{marketingInfo?.description}</p>
228
+ <p css={hideOnMobile}>{marketingInfo?.example}</p>
229
+ </td>
230
+ {/* <td css={hideOnMobile}>{marketingDestinations.map(d => d.name).join(', ')}</td> */}
231
+ </Row>
232
+
233
+ <Row>
234
+ <InputCell>
235
+ <label>
236
+ <input
237
+ type="radio"
238
+ name="advertising"
239
+ value="true"
240
+ checked={advertising === true}
241
+ onChange={this.handleChange}
242
+ aria-label="Allow advertising tracking"
243
+ required
244
+ />{' '}
245
+ {checkboxes!.yesValue}
246
+ </label>
247
+ <label>
248
+ <input
249
+ type="radio"
250
+ name="advertising"
251
+ value="false"
252
+ checked={advertising === false}
253
+ onChange={this.handleChange}
254
+ aria-label="Disallow advertising tracking"
255
+ required
256
+ />{' '}
257
+ {checkboxes!.noValue}
258
+ </label>
259
+ </InputCell>
260
+ <RowHeading scope="row">{advertisingInfo?.name}</RowHeading>
261
+ <td>
262
+ <p>{advertisingInfo?.description}</p>
263
+ <p css={hideOnMobile}>{advertisingInfo?.example}</p>
264
+ </td>
265
+ {/* <td css={hideOnMobile}>
266
+ {advertisingDestinations.map(d => d.name).join(', ')}
267
+ </td> */}
268
+ </Row>
269
+
270
+ <Row>
271
+ <td>N/A</td>
272
+ <RowHeading scope="row">{essentialInfo?.name}</RowHeading>
273
+ <td>
274
+ <p>{essentialInfo?.description}</p>
275
+ <p>{essentialInfo?.example}</p>
276
+ </td>
277
+ {/* <td css={hideOnMobile} /> */}
278
+ </Row>
279
+ </>
280
+ )}
281
+
282
+ {customCategories &&
283
+ Object.entries(customCategories).map(
284
+ ([categoryName, { integrations, purpose }]) => (
285
+ <Row key={categoryName}>
286
+ <InputCell>
287
+ {preferences[categoryName] === 'N/A' ? (
288
+ <td>N/A</td>
289
+ ) : (
290
+ <>
291
+ <label>
292
+ <input
293
+ type="radio"
294
+ name={categoryName}
295
+ value="true"
296
+ checked={preferences[categoryName] === true}
297
+ onChange={this.handleChange}
298
+ aria-label={`Allow "${categoryName}" tracking`}
299
+ required
300
+ />{' '}
301
+ {checkboxes!.yesValue}
302
+ </label>
303
+ <label>
304
+ <input
305
+ type="radio"
306
+ name={categoryName}
307
+ value="false"
308
+ checked={preferences[categoryName] === false}
309
+ onChange={this.handleChange}
310
+ aria-label={`Disallow "${categoryName}" tracking`}
311
+ required
312
+ />{' '}
313
+ {checkboxes!.noValue}
314
+ </label>
315
+ </>
316
+ )}
317
+ </InputCell>
318
+ <RowHeading scope="row">{categoryName}</RowHeading>
319
+ <td>
320
+ <p>{purpose}</p>
321
+ </td>
322
+ {/* <td css={hideOnMobile}>
323
+ {destinations
324
+ .filter(d => integrations?.includes(d.id))
325
+ .map(d => d.name)
326
+ .join(', ')}
327
+ </td> */}
328
+ </Row>
329
+ )
330
+ )}
331
+ </tbody>
332
+ </Table>
333
+ </TableScroll>
334
+ </Dialog>
335
+ )
336
+ }
337
+
338
+ handleChange = e => {
339
+ const { onChange } = this.props
340
+ onChange(e.target.name, e.target.value === 'true')
341
+ }
342
+
343
+ handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
344
+ const {
345
+ onSave,
346
+ preferences,
347
+ marketingAndAnalytics,
348
+ advertising,
349
+ functional,
350
+ customCategories
351
+ } = this.props
352
+ e.preventDefault()
353
+ // Safe guard against browsers that don't prevent the
354
+ // submission of invalid forms (Safari < 10.1)
355
+ if (
356
+ !customCategories &&
357
+ (marketingAndAnalytics === null || advertising === null || functional === null)
358
+ ) {
359
+ return
360
+ }
361
+
362
+ // Safe guard against custom categories being null
363
+ if (
364
+ customCategories &&
365
+ Object.keys(customCategories).some(category => preferences[category] === null)
366
+ ) {
367
+ return
368
+ }
369
+ onSave()
370
+ }
371
+ }
@@ -0,0 +1,104 @@
1
+ import {
2
+ WindowWithHtEvents,
3
+ Destination,
4
+ DefaultDestinationBehavior,
5
+ CategoryPreferences,
6
+ Middleware,
7
+ HtEventsBrowserOptions
8
+ } from '../types'
9
+
10
+ interface AnalyticsParams {
11
+ writeKey: string
12
+ options?: HtEventsBrowserOptions
13
+ destinations: Destination[]
14
+ destinationPreferences: CategoryPreferences | null | undefined
15
+ isConsentRequired: boolean
16
+ shouldReload?: boolean
17
+ devMode?: boolean
18
+ defaultDestinationBehavior?: DefaultDestinationBehavior
19
+ categoryPreferences: CategoryPreferences | null | undefined
20
+ }
21
+
22
+ function getConsentMiddleware(
23
+ destinationPreferences,
24
+ categoryPreferences,
25
+ defaultDestinationBehavior
26
+ ): Middleware {
27
+ return ({ payload, next }) => {
28
+ payload.obj.context.consent = {
29
+ defaultDestinationBehavior,
30
+ categoryPreferences,
31
+ destinationPreferences
32
+ }
33
+ next(payload)
34
+ }
35
+ }
36
+
37
+ export default function conditionallyLoadAnalytics({
38
+ writeKey,
39
+ options,
40
+ destinations,
41
+ destinationPreferences,
42
+ isConsentRequired,
43
+ shouldReload = true,
44
+ devMode = false,
45
+ defaultDestinationBehavior,
46
+ categoryPreferences
47
+ }: AnalyticsParams) {
48
+ const wd = window as WindowWithHtEvents
49
+ if (!wd.htevents) return
50
+
51
+ const integrations = { All: false, 'Hightouch.io': true }
52
+
53
+ if (!destinationPreferences) {
54
+ if (isConsentRequired) {
55
+ return
56
+ }
57
+
58
+ // Load htevents normally when consent isn't required and there's no preferences
59
+ if (!wd.htevents.initialized) {
60
+ wd.htevents.load(writeKey, options)
61
+ }
62
+ return
63
+ }
64
+
65
+ for (const destination of destinations) {
66
+ // Was a preference explicitly set on this destination?
67
+ const explicitPreference = destination.id in destinationPreferences
68
+ if (!explicitPreference && defaultDestinationBehavior === 'enable') {
69
+ integrations[destination.id] = true
70
+ continue
71
+ }
72
+
73
+ const isEnabled = Boolean(destinationPreferences[destination.id])
74
+ integrations[destination.id] = isEnabled
75
+ }
76
+
77
+ // Reload the page if the trackers have already been initialised so that
78
+ // the user's new preferences can take affect
79
+ if (wd.htevents.initialized) {
80
+ if (shouldReload) {
81
+ console.debug('reloading to apply new tracking preferences')
82
+ window.location.reload()
83
+ }
84
+ return
85
+ }
86
+
87
+ if (devMode) return
88
+
89
+ // Don't load htevents if nothing has been enabled
90
+ const isAnythingEnabled =
91
+ Object.entries(integrations).some(([id, isEnabled]) => id !== 'Hightouch.io' && isEnabled) ||
92
+ Object.values(categoryPreferences || {}).some(Boolean)
93
+
94
+ if (isAnythingEnabled) {
95
+ const middleware = getConsentMiddleware(
96
+ destinationPreferences,
97
+ categoryPreferences,
98
+ defaultDestinationBehavior
99
+ )
100
+ wd.htevents.addSourceMiddleware(middleware)
101
+
102
+ wd.htevents.load(writeKey, { ...options, integrations })
103
+ }
104
+ }
@@ -0,0 +1,50 @@
1
+ import fetch from 'isomorphic-fetch'
2
+ import flatten from 'lodash/flatten'
3
+ import sortedUniqBy from 'lodash/sortedUniqBy'
4
+ import sortBy from 'lodash/sortBy'
5
+ import { Destination } from '../types'
6
+
7
+ async function fetchDestinationForWriteKey(
8
+ cdnHost: string,
9
+ writeKey: string
10
+ ): Promise<Destination[]> {
11
+ const res = await fetch(`https://${cdnHost}/v1/projects/${writeKey}/integrations`)
12
+
13
+ if (!res.ok) {
14
+ throw new Error(
15
+ `Failed to fetch integrations for write key ${writeKey}: HTTP ${res.status} ${res.statusText}`
16
+ )
17
+ }
18
+
19
+ const destinations = await res.json()
20
+
21
+ // Rename creationName to id to abstract the weird data model
22
+ for (const destination of destinations) {
23
+ // Because of the legacy Fullstory integration the creationName for this integration is the `name`
24
+ if (destination.name === 'Fullstory') {
25
+ destination.id = destination.name
26
+ } else {
27
+ destination.id = destination.creationName
28
+ }
29
+ delete destination.creationName
30
+ }
31
+
32
+ return destinations
33
+ }
34
+
35
+ export default async function fetchDestinations(
36
+ cdnHost: string,
37
+ writeKeys: string[]
38
+ ): Promise<Destination[]> {
39
+ const destinationsRequests: Promise<Destination[]>[] = []
40
+ for (const writeKey of writeKeys) {
41
+ destinationsRequests.push(fetchDestinationForWriteKey(cdnHost, writeKey))
42
+ }
43
+
44
+ let destinations = flatten(await Promise.all(destinationsRequests))
45
+ // Remove the dummy Repeater destination
46
+ destinations = destinations.filter(d => d.id !== 'Repeater')
47
+ destinations = sortBy(destinations, ['id'])
48
+ destinations = sortedUniqBy(destinations, 'id')
49
+ return destinations
50
+ }