gtm-event-tracker
Advanced tools
Comparing version 1.7.0-beta.2 to 1.7.0-beta.3
import type { EventProperties, DataLayerFunctions } from './data-layer-types'; | ||
export declare function getDefaultTargetProperty(): EventProperties[]; | ||
export declare function createDataLayer(): DataLayerFunctions; | ||
declare type DataLayerOptions = Partial<{ | ||
targetProperty: EventProperties[]; | ||
}>; | ||
export declare function createDataLayer(options?: DataLayerOptions): DataLayerFunctions; | ||
export declare const dataLayer: DataLayerFunctions; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.dataLayer = exports.createDataLayer = exports.getDefaultTargetProperty = void 0; | ||
exports.dataLayer = exports.createDataLayer = void 0; | ||
const data_layer_error_1 = require("./data-layer-error"); | ||
function getDefaultTargetProperty() { | ||
return window.dataLayer; | ||
} | ||
exports.getDefaultTargetProperty = getDefaultTargetProperty; | ||
function createDataLayer() { | ||
function createDataLayer(options = {}) { | ||
function getTargetProperty() { | ||
var _a; | ||
const defaultTarget = window.dataLayer; | ||
return (_a = options.targetProperty) !== null && _a !== void 0 ? _a : defaultTarget; | ||
} | ||
function addEvent(payload) { | ||
const targetProperty = getDefaultTargetProperty(); | ||
const targetProperty = getTargetProperty(); | ||
targetProperty.push(payload); | ||
@@ -16,4 +17,4 @@ } | ||
const isServer = () => typeof window === 'undefined'; | ||
const isDefined = () => typeof getDefaultTargetProperty() !== 'undefined'; | ||
const isArray = () => Array.isArray(getDefaultTargetProperty()); | ||
const isDefined = () => typeof getTargetProperty() !== 'undefined'; | ||
const isArray = () => Array.isArray(getTargetProperty()); | ||
if (isServer()) | ||
@@ -20,0 +21,0 @@ (0, data_layer_error_1.throwIsServer)(); |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.7.0-beta.2", | ||
"version": "1.7.0-beta.3", | ||
"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
40121
756