Skip to content

Commit

Permalink
[PPPSYS-42941] Fix IS_DEBUG variable #12 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieltwork authored Aug 29, 2023
1 parent efde05f commit 8df6c3a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PiwikProWindow } from "../interfaces/piwikpro.window";

function init(containerId: string, containerUrl: string, nonce?: string) {
if (!containerId) {
console.error('Empty tracking code for Piwik Pro.');
Expand Down Expand Up @@ -31,7 +33,10 @@ tags.async=!0,tags.src="${containerUrl}/containers/"+id+".js"+qPString,scripts.p
head.appendChild(s);
}

export const IS_DEBUG = process.env.DEBUG || process.env.NODE_ENV === 'development';
export const IS_DEBUG =
(typeof process !== 'undefined' && process.env.NODE_ENV === 'development') ||
(typeof window !== 'undefined' && (window as PiwikProWindow).IS_DEBUG) ||
false

export default {
init
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/piwikpro.window.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface PiwikProWindow extends Window {
_paq?: any;
dataLayer?: any;
IS_DEBUG?: boolean;
}

0 comments on commit 8df6c3a

Please sign in to comment.