Skip to content

Commit af36a6e

Browse files
authored
fix(analytics): remove essentials destinations (#2677)
Signed-off-by: protobuf-ci-cd <[email protected]>
1 parent 57995b4 commit af36a6e

File tree

6 files changed

+15
-22
lines changed

6 files changed

+15
-22
lines changed

.changeset/eleven-cloths-wish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@scaleway/use-analytics": patch
3+
---
4+
5+
fix useless props: essentialDestinations, better typing

packages/use-analytics/src/analytics/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const defaultLoadOptions: LoadOptions = {
5252
anonymousIdOptions: {
5353
autoCapture: {
5454
enabled: true,
55+
source: 'segment',
5556
},
5657
},
5758
sessions: {

packages/use-analytics/src/analytics/useAnalytics.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type { Analytics }
1818

1919
export type OnEventError = (error: Error) => Promise<void> | void
2020

21-
type EventFunction = (...args: never[]) => Promise<void>
21+
type EventFunction = (...args: never[]) => Promise<void> | void
2222
type Events = Record<
2323
string,
2424
(analytics?: Analytics, onEventError?: OnEventError) => EventFunction

packages/use-analytics/src/cookies-consent/CookieConsentProvider.tsx

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ import { uniq } from '../helpers/array'
2222
import { IS_CLIENT } from '../helpers/isClient'
2323
import { stringToHash } from '../helpers/misc'
2424
import { isCategoryKind } from '../types'
25-
import type {
26-
Config,
27-
Consent,
28-
Destination,
29-
Destinations,
30-
EssentialDestination,
31-
} from '../types'
25+
import type { Config, Consent, Destination, Destinations } from '../types'
3226

3327
type Context = {
3428
destinations: Destinations
@@ -55,7 +49,6 @@ export const useCookieConsent = (): Context => {
5549
export const CookieConsentProvider = ({
5650
children,
5751
isConsentRequired,
58-
essentialDestinations,
5952
manualDestinations,
6053
config,
6154
cookiePrefix = COOKIE_PREFIX,
@@ -64,7 +57,6 @@ export const CookieConsentProvider = ({
6457
cookiesOptions = COOKIES_OPTIONS,
6558
}: PropsWithChildren<{
6659
isConsentRequired: boolean
67-
essentialDestinations: EssentialDestination[]
6860
manualDestinations?: Destinations
6961
config: Config
7062
cookiePrefix?: string
@@ -93,17 +85,9 @@ export const CookieConsentProvider = ({
9385
category: dest.consents[0] ?? 'essential',
9486
}) satisfies Destination,
9587
),
96-
...essentialDestinations.map(
97-
dest =>
98-
({
99-
name: dest.name,
100-
displayName: dest.displayName,
101-
category: 'essential',
102-
}) satisfies Destination,
103-
),
10488
...(manualDestinations ?? []),
10589
]),
106-
[analyticsDestinations, essentialDestinations, manualDestinations],
90+
[analyticsDestinations, manualDestinations],
10791
)
10892

10993
// We compute a hash with all the integrations that are enabled

packages/use-analytics/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
export { AnalyticsProvider, useAnalytics, useDestinations } from './analytics'
1+
export {
2+
AnalyticsProvider,
3+
useAnalytics,
4+
useDestinations,
5+
userMigrationsTraits,
6+
} from './analytics'
27
export {
38
defaultLoadOptions,
49
defaultConsentOptions,
@@ -11,7 +16,6 @@ export type {
1116
} from './analytics/useAnalytics'
1217
export type {
1318
AnalyticsIntegration,
14-
EssentialDestination,
1519
Destination,
1620
CategoryKind,
1721
Consents,

packages/use-analytics/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export type Destination = {
6161
name: string
6262
displayName: string
6363
}
64-
export type EssentialDestination = Pick<Destination, 'displayName' | 'name'>
6564

6665
export type Destinations = Destination[]
6766

0 commit comments

Comments
 (0)