New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@firebase/analytics

Package Overview
Dependencies
Maintainers
5
Versions
2534
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/analytics - npm Package Compare versions

Comparing version 0.2.4-canary.4d23f9c to 0.2.4-canary.ed4b147

28

dist/index.cjs.js

@@ -32,2 +32,3 @@ 'use strict';

var ORIGIN_KEY = 'origin';
var GTAG_URL = 'https://www.googletagmanager.com/gtag/js';
var GtagCommand;

@@ -219,5 +220,2 @@ (function (GtagCommand) {

}
function hasDataLayer(dataLayerName) {
return Array.isArray(window[dataLayerName]);
}
function insertScriptTag(dataLayerName) {

@@ -227,3 +225,3 @@ var script = document.createElement('script');

// without fid. We will initialize ga-id using gtag (config) command together with fid.
script.src = "https://www.googletagmanager.com/gtag/js?l=" + dataLayerName;
script.src = GTAG_URL + "?l=" + dataLayerName;
script.async = true;

@@ -238,7 +236,7 @@ document.head.appendChild(script);

var dataLayer = [];
if (hasDataLayer(dataLayerName)) {
if (Array.isArray(window[dataLayerName])) {
dataLayer = window[dataLayerName];
}
else {
dataLayer = window[dataLayerName] = [];
window[dataLayerName] = dataLayer;
}

@@ -349,2 +347,15 @@ return dataLayer;

}
/**
* Returns first script tag in DOM matching our gtag url pattern.
*/
function findGtagScriptOnPage() {
var scriptTags = window.document.getElementsByTagName('script');
for (var _i = 0, _a = Object.values(scriptTags); _i < _a.length; _i++) {
var tag = _a[_i];
if (tag.src && tag.src.includes(GTAG_URL)) {
return tag;
}
}
return null;
}

@@ -466,5 +477,4 @@ /**

// of dataLayer and global gtag function.
// Presence of previously existing dataLayer used to detect if user has
// already put the gtag snippet on this page.
if (!hasDataLayer(dataLayerName)) {
// Detect if user has already put the gtag <script> tag on this page.
if (!findGtagScriptOnPage()) {
insertScriptTag(dataLayerName);

@@ -471,0 +481,0 @@ }

@@ -26,2 +26,3 @@ import firebase from '@firebase/app';

var ORIGIN_KEY = 'origin';
var GTAG_URL = 'https://www.googletagmanager.com/gtag/js';
var GtagCommand;

@@ -213,5 +214,2 @@ (function (GtagCommand) {

}
function hasDataLayer(dataLayerName) {
return Array.isArray(window[dataLayerName]);
}
function insertScriptTag(dataLayerName) {

@@ -221,3 +219,3 @@ var script = document.createElement('script');

// without fid. We will initialize ga-id using gtag (config) command together with fid.
script.src = "https://www.googletagmanager.com/gtag/js?l=" + dataLayerName;
script.src = GTAG_URL + "?l=" + dataLayerName;
script.async = true;

@@ -232,7 +230,7 @@ document.head.appendChild(script);

var dataLayer = [];
if (hasDataLayer(dataLayerName)) {
if (Array.isArray(window[dataLayerName])) {
dataLayer = window[dataLayerName];
}
else {
dataLayer = window[dataLayerName] = [];
window[dataLayerName] = dataLayer;
}

@@ -343,2 +341,15 @@ return dataLayer;

}
/**
* Returns first script tag in DOM matching our gtag url pattern.
*/
function findGtagScriptOnPage() {
var scriptTags = window.document.getElementsByTagName('script');
for (var _i = 0, _a = Object.values(scriptTags); _i < _a.length; _i++) {
var tag = _a[_i];
if (tag.src && tag.src.includes(GTAG_URL)) {
return tag;
}
}
return null;
}

@@ -460,5 +471,4 @@ /**

// of dataLayer and global gtag function.
// Presence of previously existing dataLayer used to detect if user has
// already put the gtag snippet on this page.
if (!hasDataLayer(dataLayerName)) {
// Detect if user has already put the gtag <script> tag on this page.
if (!findGtagScriptOnPage()) {
insertScriptTag(dataLayerName);

@@ -465,0 +475,0 @@ }

@@ -25,2 +25,3 @@ import firebase from '@firebase/app';

const ORIGIN_KEY = 'origin';
const GTAG_URL = 'https://www.googletagmanager.com/gtag/js';
var GtagCommand;

@@ -200,5 +201,2 @@ (function (GtagCommand) {

}
function hasDataLayer(dataLayerName) {
return Array.isArray(window[dataLayerName]);
}
function insertScriptTag(dataLayerName) {

@@ -208,3 +206,3 @@ const script = document.createElement('script');

// without fid. We will initialize ga-id using gtag (config) command together with fid.
script.src = `https://www.googletagmanager.com/gtag/js?l=${dataLayerName}`;
script.src = `${GTAG_URL}?l=${dataLayerName}`;
script.async = true;

@@ -219,7 +217,7 @@ document.head.appendChild(script);

let dataLayer = [];
if (hasDataLayer(dataLayerName)) {
if (Array.isArray(window[dataLayerName])) {
dataLayer = window[dataLayerName];
}
else {
dataLayer = window[dataLayerName] = [];
window[dataLayerName] = dataLayer;
}

@@ -322,2 +320,14 @@ return dataLayer;

}
/**
* Returns first script tag in DOM matching our gtag url pattern.
*/
function findGtagScriptOnPage() {
const scriptTags = window.document.getElementsByTagName('script');
for (const tag of Object.values(scriptTags)) {
if (tag.src && tag.src.includes(GTAG_URL)) {
return tag;
}
}
return null;
}

@@ -436,5 +446,4 @@ /**

// of dataLayer and global gtag function.
// Presence of previously existing dataLayer used to detect if user has
// already put the gtag snippet on this page.
if (!hasDataLayer(dataLayerName)) {
// Detect if user has already put the gtag <script> tag on this page.
if (!findGtagScriptOnPage()) {
insertScriptTag(dataLayerName);

@@ -441,0 +450,0 @@ }

@@ -20,2 +20,3 @@ /**

export declare const ORIGIN_KEY = "origin";
export declare const GTAG_URL = "https://www.googletagmanager.com/gtag/js";
export declare enum GtagCommand {

@@ -22,0 +23,0 @@ EVENT = "event",

@@ -29,3 +29,2 @@ /**

export declare function initializeGAId(app: FirebaseApp, gtagCore: Gtag): Promise<void>;
export declare function hasDataLayer(dataLayerName: string): boolean;
export declare function insertScriptTag(dataLayerName: string): void;

@@ -51,1 +50,5 @@ /** Get reference to, or create, global datalayer.

};
/**
* Returns first script tag in DOM matching our gtag url pattern.
*/
export declare function findGtagScriptOnPage(): HTMLScriptElement | null;

@@ -1,18 +0,1 @@

/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare function findGtagScriptOnPage(): HTMLScriptElement | null;
export declare function removeGtagScript(): void;
{
"name": "@firebase/analytics",
"version": "0.2.4-canary.4d23f9c",
"version": "0.2.4-canary.ed4b147",
"description": "A analytics package for new firebase packages",

@@ -22,9 +22,9 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",

"peerDependencies": {
"@firebase/app": "0.4.22-canary.4d23f9c",
"@firebase/app-types": "0.4.7-canary.4d23f9c"
"@firebase/app": "0.4.22-canary.ed4b147",
"@firebase/app-types": "0.4.7-canary.ed4b147"
},
"dependencies": {
"@firebase/analytics-types": "0.2.2-canary.4d23f9c",
"@firebase/installations": "0.3.3-canary.4d23f9c",
"@firebase/util": "0.2.31-canary.4d23f9c",
"@firebase/analytics-types": "0.2.2-canary.ed4b147",
"@firebase/installations": "0.3.3-canary.ed4b147",
"@firebase/util": "0.2.31-canary.ed4b147",
"tslib": "1.10.0"

@@ -31,0 +31,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc