From 5304cd81dda6180bfbf0ee824634f75ffe571db3 Mon Sep 17 00:00:00 2001 From: emkis Date: Sat, 18 Mar 2023 13:58:09 +0000 Subject: [PATCH] feat(shared): throw error code in production --- .../configuration/configuration-errors.ts | 9 +++-- src/shared/data-layer/data-layer-error.ts | 35 ++++++++++--------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/shared/configuration/configuration-errors.ts b/src/shared/configuration/configuration-errors.ts index 47dff48..648e865 100644 --- a/src/shared/configuration/configuration-errors.ts +++ b/src/shared/configuration/configuration-errors.ts @@ -1,7 +1,10 @@ import { EventTrackerError } from '@/shared/error' export function throwNoConfigurationProvided() { - throw new EventTrackerError( - `You've called configure function without a configuration object.` - ) + const message = + process.env.NODE_ENV === 'production' + ? '1' + : `You've called configure function without a configuration object.` + + throw new EventTrackerError(message) } diff --git a/src/shared/data-layer/data-layer-error.ts b/src/shared/data-layer/data-layer-error.ts index 1a9152d..d3d6614 100644 --- a/src/shared/data-layer/data-layer-error.ts +++ b/src/shared/data-layer/data-layer-error.ts @@ -1,27 +1,28 @@ import { EventTrackerError } from '@/shared/error' export function throwIsServer() { - throw new EventTrackerError( - 'Triggering events is not possible on server-side.' + - '\n\n' + - 'Make sure to only trigger events after your app is running on the client-side.' - ) + const message = + process.env.NODE_ENV === 'production' + ? '1' + : 'Triggering events is not possible on server-side. Make sure to only trigger events after your app is running on the client-side.' + + throw new EventTrackerError(message) } export function throwIsNotDefined() { - throw new EventTrackerError( - 'The targetProperty is not defined.' + - '\n\n' + - `Make sure you didn't forget to add Google Tag Manager's script in your application.` + - '\n\n' + - `If you did but you don't use the default 'window.dataLayer' array, you can set your custom targetProperty with the configure function.` - ) + const message = + process.env.NODE_ENV === 'production' + ? '1' + : `The targetProperty is not defined. Make sure you didn't forget to add Google Tag Manager's script in your application. If you did but you don't use the default 'window.dataLayer' array, you can set your custom targetProperty with the configure function.` + + throw new EventTrackerError(message) } export function throwIsNotArray() { - throw new EventTrackerError( - 'The targetProperty is not an array.' + - '\n\n' + - `Either you didn't installed Google Tag Manager correctly or you configured the targetProperty incorrectly.` - ) + const message = + process.env.NODE_ENV === 'production' + ? '1' + : `The targetProperty is not an array. Either you didn't installed Google Tag Manager correctly or you configured the targetProperty incorrectly.` + + throw new EventTrackerError(message) }