gtm-event-tracker
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -6,13 +6,13 @@ "use strict"; | ||
function throwIsServer() { | ||
throw new error_1.WarningError('window.dataLayer is not available on server-side. Make sure to only trigger events after your app is running on the client-side.'); | ||
throw new error_1.WarningError(`Triggering events is not possible on server-side.\n\nMake sure to only trigger events after your app is running on the client-side.`); | ||
} | ||
exports.throwIsServer = throwIsServer; | ||
function throwIsNotDefined() { | ||
throw new error_1.WarningError('window.dataLayer is not defined. Probably you forgot to add the Google Tag Manager script to your application.'); | ||
throw new error_1.WarningError(`The targetProperty is not defined.\n\nMake sure you didn't forget to add Google Tag Manager's script in your application.\n\nIf you did but you don't use the default 'window.dataLayer' array, you can set your custom targetProperty with the configure function.`); | ||
} | ||
exports.throwIsNotDefined = throwIsNotDefined; | ||
function throwIsNotArray() { | ||
throw new error_1.WarningError('window.dataLayer is not an array. Make sure you installed Google Tag Manager correctly.'); | ||
throw new error_1.WarningError(`The targetProperty is not an array.\n\nEither you didn't installed Google Tag Manager correctly or you configured the targetProperty incorrectly.`); | ||
} | ||
exports.throwIsNotArray = throwIsNotArray; | ||
//# sourceMappingURL=data-layer-error.js.map |
@@ -1,3 +0,4 @@ | ||
import type { DataLayerFunctions } from './data-layer-types'; | ||
export declare function createDataLayerModule(): DataLayerFunctions; | ||
import type { EventProperties, DataLayerFunctions } from './data-layer-types'; | ||
export declare function getDefaultTargetProperty(): EventProperties[]; | ||
export declare function createDataLayer(): DataLayerFunctions; | ||
export declare const dataLayer: DataLayerFunctions; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.dataLayer = exports.createDataLayerModule = void 0; | ||
exports.dataLayer = exports.createDataLayer = exports.getDefaultTargetProperty = void 0; | ||
const data_layer_error_1 = require("./data-layer-error"); | ||
function createDataLayerModule() { | ||
function getDefaultTargetProperty() { | ||
return window.dataLayer; | ||
} | ||
exports.getDefaultTargetProperty = getDefaultTargetProperty; | ||
function createDataLayer() { | ||
function addEvent(payload) { | ||
window.dataLayer.push(payload); | ||
const targetProperty = getDefaultTargetProperty(); | ||
targetProperty.push(payload); | ||
} | ||
function assertIsAvailable() { | ||
const isServer = () => typeof window === 'undefined'; | ||
const isDefined = () => typeof window.dataLayer !== 'undefined'; | ||
const isArray = () => Array.isArray(window.dataLayer); | ||
const isDefined = () => typeof getDefaultTargetProperty() !== 'undefined'; | ||
const isArray = () => Array.isArray(getDefaultTargetProperty()); | ||
if (isServer()) | ||
@@ -25,4 +30,4 @@ (0, data_layer_error_1.throwIsServer)(); | ||
} | ||
exports.createDataLayerModule = createDataLayerModule; | ||
exports.dataLayer = createDataLayerModule(); | ||
exports.createDataLayer = createDataLayer; | ||
exports.dataLayer = createDataLayer(); | ||
//# sourceMappingURL=data-layer.js.map |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "A type-safe, reusable, and flexible way for triggering Google Tag Manager track events.", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43872
949