Skip to content

Commit a709498

Browse files
authored
feat(analytics): default config (#2679)
Signed-off-by: protobuf-ci-cd <protobuf-ci-cd@scaleway.com>
1 parent d29c667 commit a709498

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

.changeset/quiet-corners-change.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+
change default config

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import type { ConsentOptions, LoadOptions } from '@rudderstack/analytics-js'
22

33
export const defaultConsentOptions: ConsentOptions = {
4-
trackConsent: true,
5-
discardPreConsentEvents: true,
4+
trackConsent: false,
5+
/**
6+
* The discardPreConsentEvents parameter in RudderStack's JavaScript SDK determines what happens to events that are generated before the user provides consent (pre-consent events):
7+
*/
8+
discardPreConsentEvents: false,
69
storage: {
710
type: 'cookieStorage',
811
},

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,11 @@ export function AnalyticsProvider<T extends Events>({
128128
})
129129

130130
analytics.ready(() => {
131-
// @ts-expect-error blabla
131+
// @ts-expect-error tracklink is added to the analytics setup to simplify migration from segment, should be remove.
132132
setAnalytics({ ...analytics, trackLink: trackLink(analytics) })
133133
setIsAnalyticsReady(true)
134134
})
135135
}
136-
// else if (!shouldLoad && !needConsent ) {
137-
// // When user has refused tracking, set ready anyway
138-
// setIsAnalyticsReady(true)
139-
// }
140136
}, [onError, settings, loadOptions, shouldLoad])
141137

142138
const value = useMemo<AnalyticsContextInterface<T>>(() => {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const useDestinations = (config: Config) => {
3636
AnalyticsIntegration[] | undefined
3737
>(undefined)
3838

39+
// TODO: use useDataloader to add more cache.
3940
useEffect(() => {
4041
const fetchDestinations = async () => {
4142
if (config.analytics?.cdnURL && config.analytics.writeKey) {
@@ -52,6 +53,8 @@ export const useDestinations = (config: Config) => {
5253
if (!response.ok) {
5354
throw new Error('Failed to fetch integrations from source')
5455
}
56+
57+
// TODO: use zod to safe parse and add an error callback in case the schema changed.
5558
const json = (await response.json()) as AnalyticsConfig
5659

5760
return transformConfigToDestinations(json)

0 commit comments

Comments
 (0)