gtm-event-tracker
Advanced tools
Comparing version 1.7.0-beta.1 to 1.7.0-beta.2
@@ -45,4 +45,2 @@ /** | ||
log: (action: LoggerAction) => void; | ||
warn: (action: LoggerAction) => void; | ||
error: (action: LoggerAction) => void; | ||
}; | ||
@@ -49,0 +47,0 @@ |
import type { LoggerFunctions, Logger } from './types'; | ||
declare type LoggerOptions = { | ||
declare type LoggerOptions = Partial<{ | ||
logger: Logger; | ||
isEnabled?: boolean; | ||
}; | ||
export declare const defaultLogger: Logger; | ||
export declare function createLogger(options: LoggerOptions): LoggerFunctions; | ||
}>; | ||
export declare function createLogger(options?: LoggerOptions): LoggerFunctions; | ||
/** | ||
@@ -9,0 +7,0 @@ * Sets a custom logger. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLogger = exports.setLogger = exports.createLogger = exports.defaultLogger = void 0; | ||
exports.defaultLogger = console; | ||
const disabledLogger = { | ||
log: () => null, | ||
warn: () => null, | ||
error: () => null, | ||
}; | ||
function createLogger(options) { | ||
exports.getLogger = exports.setLogger = exports.createLogger = void 0; | ||
function createLogger(options = {}) { | ||
var _a; | ||
const isLogsEnabled = (_a = options.isEnabled) !== null && _a !== void 0 ? _a : false; | ||
let logger = options.logger; | ||
const defaultLogger = console; | ||
let logger = (_a = options.logger) !== null && _a !== void 0 ? _a : defaultLogger; | ||
function getLogger() { | ||
return isLogsEnabled ? logger : disabledLogger; | ||
return logger; | ||
} | ||
@@ -23,3 +17,3 @@ function setLogger(targetLogger) { | ||
exports.createLogger = createLogger; | ||
const loggerFunctions = createLogger({ logger: exports.defaultLogger }); | ||
const loggerFunctions = createLogger(); | ||
/** | ||
@@ -26,0 +20,0 @@ * Sets a custom logger. |
@@ -25,4 +25,2 @@ import { EventProperties } from '../data-layer'; | ||
log: (action: LoggerAction) => void; | ||
warn: (action: LoggerAction) => void; | ||
error: (action: LoggerAction) => void; | ||
}; | ||
@@ -29,0 +27,0 @@ export declare type LoggerFunctions = Readonly<{ |
@@ -38,3 +38,3 @@ "use strict"; | ||
contextName: context.options.name, | ||
currentProps: currentProps, | ||
currentProps, | ||
newProps: newPropsCopy, | ||
@@ -41,0 +41,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.7.0-beta.1", | ||
"version": "1.7.0-beta.2", | ||
"description": "A type-safe, reusable, and flexible way for triggering Google Tag Manager track events.", | ||
@@ -26,3 +26,3 @@ "keywords": [ | ||
"build:ts": "npm-run-all ts:compile ts:replace-alias", | ||
"lint": "eslint . --ext js,ts --fix", | ||
"lint": "eslint . --ext js,ts", | ||
"test": "npm-run-all test:api-report test:unit:coverage", | ||
@@ -29,0 +29,0 @@ "test:unit": "jest", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
39982
74
752