Skip to content

Commit

Permalink
Make integration overridable in useAnalytics hook
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyyakym committed Jan 21, 2025
1 parent e587eb3 commit 6556f0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/analytics-nextjs/src/AnalyticsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface Context {
consent: Consent | null;
gallery?: PickedGalleryProperties;
newsroom?: PickedNewsroomProperties;
integrations?: Integrations;
story?: PickedStoryProperties;
trackingPermissions: TrackingPermissions;
trackingPolicy: TrackingPolicy;
Expand Down Expand Up @@ -210,6 +211,7 @@ export function AnalyticsProvider({
consent: null,
gallery,
newsroom,
integrations,
story,
trackingPermissions,
trackingPolicy,
Expand Down
4 changes: 3 additions & 1 deletion packages/analytics-nextjs/src/hooks/useAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ const NULL_USER = {
};

export function useAnalytics() {
const { analytics, consent, newsroom, trackingPermissions } = useAnalyticsContext();
const { analytics, consent, integrations, newsroom, trackingPermissions } =
useAnalyticsContext();
const analyticsRef = useLatest(analytics);

const integrationsRef = useLatest({
// eslint-disable-next-line @typescript-eslint/naming-convention
'Segment.io': trackingPermissions.canTrackToSegment,
Prezly: trackingPermissions.canTrackToPrezly,
Plausible: trackingPermissions.canTrackToPlausible,
...integrations,
});

const { value: deferredIdentity, set: setDeferredIdentity } = useLocalStorage<DeferredIdentity>(
Expand Down

0 comments on commit 6556f0d

Please sign in to comment.