Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eleven-cloths-wish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scaleway/use-analytics": patch
---

fix useless props: essentialDestinations, better typing
1 change: 1 addition & 0 deletions packages/use-analytics/src/analytics/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const defaultLoadOptions: LoadOptions = {
anonymousIdOptions: {
autoCapture: {
enabled: true,
source: 'segment',
},
},
sessions: {
Expand Down
2 changes: 1 addition & 1 deletion packages/use-analytics/src/analytics/useAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

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

type EventFunction = (...args: never[]) => Promise<void>
type EventFunction = (...args: never[]) => Promise<void> | void
type Events = Record<
string,
(analytics?: Analytics, onEventError?: OnEventError) => EventFunction
Expand Down Expand Up @@ -129,7 +129,7 @@

analytics.ready(() => {
// @ts-expect-error blabla
setAnalytics({ ...analytics, trackLink: trackLink(analytics) })

Check warning on line 132 in packages/use-analytics/src/analytics/useAnalytics.tsx

View workflow job for this annotation

GitHub Actions / lint

`trackLink` is deprecated. this function is a wrapper of a Track to facilitate the migration from segment to rudderstack
setIsAnalyticsReady(true)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ import { uniq } from '../helpers/array'
import { IS_CLIENT } from '../helpers/isClient'
import { stringToHash } from '../helpers/misc'
import { isCategoryKind } from '../types'
import type {
Config,
Consent,
Destination,
Destinations,
EssentialDestination,
} from '../types'
import type { Config, Consent, Destination, Destinations } from '../types'

type Context = {
destinations: Destinations
Expand All @@ -55,7 +49,6 @@ export const useCookieConsent = (): Context => {
export const CookieConsentProvider = ({
children,
isConsentRequired,
essentialDestinations,
manualDestinations,
config,
cookiePrefix = COOKIE_PREFIX,
Expand All @@ -64,7 +57,6 @@ export const CookieConsentProvider = ({
cookiesOptions = COOKIES_OPTIONS,
}: PropsWithChildren<{
isConsentRequired: boolean
essentialDestinations: EssentialDestination[]
manualDestinations?: Destinations
config: Config
cookiePrefix?: string
Expand Down Expand Up @@ -93,17 +85,9 @@ export const CookieConsentProvider = ({
category: dest.consents[0] ?? 'essential',
}) satisfies Destination,
),
...essentialDestinations.map(
dest =>
({
name: dest.name,
displayName: dest.displayName,
category: 'essential',
}) satisfies Destination,
),
...(manualDestinations ?? []),
]),
[analyticsDestinations, essentialDestinations, manualDestinations],
[analyticsDestinations, manualDestinations],
)

// We compute a hash with all the integrations that are enabled
Expand Down
8 changes: 6 additions & 2 deletions packages/use-analytics/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export { AnalyticsProvider, useAnalytics, useDestinations } from './analytics'
export {
AnalyticsProvider,
useAnalytics,
useDestinations,
userMigrationsTraits,
} from './analytics'
export {
defaultLoadOptions,
defaultConsentOptions,
Expand All @@ -11,7 +16,6 @@ export type {
} from './analytics/useAnalytics'
export type {
AnalyticsIntegration,
EssentialDestination,
Destination,
CategoryKind,
Consents,
Expand Down
1 change: 0 additions & 1 deletion packages/use-analytics/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
id: string
name: string
writeKey: string
config: Record<string, any>

Check warning on line 44 in packages/use-analytics/src/types.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
enabled: boolean
workspaceId: string
destinations: RudderDestination[]
Expand All @@ -61,7 +61,6 @@
name: string
displayName: string
}
export type EssentialDestination = Pick<Destination, 'displayName' | 'name'>

export type Destinations = Destination[]

Expand Down
Loading