Skip to content

Commit 9438f61

Browse files
committed
Replace inline logging with logToConsole plugin
1 parent c32181d commit 9438f61

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

packages/analytics-nextjs/src/AnalyticsProvider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { PropsWithChildren } from 'react';
1010
import { createContext, useContext, useEffect, useState } from 'react';
1111

1212
import { isTrackingCookieAllowed } from './lib';
13-
import { normalizePrezlyMetaPlugin, sendEventToPrezlyPlugin } from './plugins';
13+
import { logToConsole, normalizePrezlyMetaPlugin, sendEventToPrezlyPlugin } from './plugins';
1414
import { TrackingPolicy } from './types';
1515
import type {
1616
PickedGalleryProperties,
@@ -99,6 +99,7 @@ export function AnalyticsProvider({
9999
...(uuid
100100
? [sendEventToPrezlyPlugin(uuid), normalizePrezlyMetaPlugin()]
101101
: []),
102+
...(process.env.NODE_ENV === 'production' ? [] : [logToConsole()]),
102103
...(plugins || []),
103104
],
104105
},

packages/analytics-nextjs/src/hooks/useAnalytics.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ export function useAnalytics() {
6767
(userId: string, traits: object = {}, callback?: () => void) => {
6868
const extendedTraits = injectPrezlyMeta(traits);
6969

70-
if (process.env.NODE_ENV !== 'production') {
71-
// eslint-disable-next-line no-console
72-
console.log(`analytics.identify(${stringify(userId, extendedTraits)})`);
73-
}
74-
7570
if (trackingPolicy === TrackingPolicy.CONSENT_TO_IDENTIFY && !consent) {
7671
setDeferredIdentity({ userId, traits: extendedTraits });
7772
if (callback) {
@@ -92,11 +87,6 @@ export function useAnalytics() {
9287

9388
const alias = useCallback(
9489
(userId: string, previousId: string) => {
95-
if (process.env.NODE_ENV !== 'production') {
96-
// eslint-disable-next-line no-console
97-
console.log(`analytics.alias(${stringify(userId, previousId)})`);
98-
}
99-
10090
addToQueue(() => {
10191
if (analyticsRef.current && analyticsRef.current.alias) {
10292
analyticsRef.current.alias(userId, previousId);
@@ -110,11 +100,6 @@ export function useAnalytics() {
110100
(category?: string, name?: string, properties: object = {}, callback?: () => void) => {
111101
const extendedProperties = injectPrezlyMeta(properties);
112102

113-
if (process.env.NODE_ENV !== 'production') {
114-
// eslint-disable-next-line no-console
115-
console.log(`analytics.page(${stringify(category, name, extendedProperties)})`);
116-
}
117-
118103
addToQueue(() => {
119104
if (analyticsRef.current && analyticsRef.current.page) {
120105
analyticsRef.current.page(category, name, extendedProperties, {}, callback);
@@ -128,11 +113,6 @@ export function useAnalytics() {
128113
(event: string, properties: object = {}, callback?: () => void) => {
129114
const extendedProperties = injectPrezlyMeta(properties);
130115

131-
if (process.env.NODE_ENV !== 'production') {
132-
// eslint-disable-next-line no-console
133-
console.log(`analytics.track(${stringify(event, extendedProperties)})`);
134-
}
135-
136116
addToQueue(() => {
137117
if (analyticsRef.current && analyticsRef.current.track) {
138118
analyticsRef.current.track(event, extendedProperties, {}, callback);

0 commit comments

Comments
 (0)