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/fruity-bottles-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scaleway/use-analytics": patch
---

remove fields from package.json
3 changes: 0 additions & 3 deletions packages/use-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
"engines": {
"node": ">=20.x"
},
"main": "./dist/index.cjs",
"sideEffects": false,
"type": "module",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/analytics/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/use-analytics/src/analytics/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ConsentOptions, LoadOptions } from '@rudderstack/analytics-js'

export const consentOptions: ConsentOptions = {
export const defaultConsentOptions: ConsentOptions = {
trackConsent: true,
discardPreConsentEvents: true,
storage: {
Expand Down
4 changes: 2 additions & 2 deletions packages/use-analytics/src/analytics/useAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect'
import { destSDKBaseURL, pluginsSDKBaseURL } from '../constants'
import type { CategoryKind } from '../types'
import { consentOptions, defaultLoadOptions } from './constants'
import { defaultConsentOptions, defaultLoadOptions } from './constants'
import { trackLink } from './segments/trackLink'
import type { TrackLink } from './segments/trackLink'
import { userMigrationsTraits } from './segments/userMigrationsTraits'
Expand Down Expand Up @@ -111,7 +111,7 @@
userMigrationsTraits(rudderAnalytics)

rudderAnalytics.consent({
...consentOptions,
...defaultConsentOptions,
consentManagement: {
enabled: true,
allowedConsentIds: allowedConsents,
Expand All @@ -126,7 +126,7 @@

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

Check warning on line 129 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)
})
} else if (shouldLoadAnalytics && !shouldLoad) {
Expand Down
3 changes: 2 additions & 1 deletion packages/use-analytics/src/cookies-consent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export {
CookieConsentProvider,
useCookieConsent,
} from './CookieConsentProvider'
// export { SegmentConsentMiddleware } from './SegmentConsentMiddleware'
export { CATEGORIES } from '../constants'
export type { AnalyticsIntegration, CategoryKind, Consents } from '../types'
14 changes: 12 additions & 2 deletions packages/use-analytics/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
export { AnalyticsProvider, useAnalytics, useDestinations } from './analytics'
export {
defaultLoadOptions,
defaultConsentOptions,
} from './analytics/constants'

export type {
Analytics,
OnEventError,
AnalyticsProviderProps,
} from './analytics/useAnalytics'

export { AnalyticsProvider, useAnalytics, useDestinations } from './analytics'
export type {
AnalyticsIntegration,
CategoryKind,
Consents,
Consent,
} from './types'
2 changes: 1 addition & 1 deletion packages/use-analytics/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
type Provider = 'custom'
type ResolutionStrategy = 'and' | 'or'

type Consents = { consent: CategoryKind }[]
export type Consents = { consent: CategoryKind }[]

type Destination = {
id: string
Expand Down 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: Destination[]
Expand Down
Loading