Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@devboldly/react-use-google-analytics-embed-api

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devboldly/react-use-google-analytics-embed-api - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

32

dist/hooks/useGoogleAnalyticsEmbedApi.js

@@ -15,19 +15,17 @@ "use strict";

var _b = React.useState(undefined), gapi = _b[0], setGapi = _b[1];
var namespace = '__USE_GOOGLE_ANALYTICS_EMBED_API_HOOK__';
var _c = react_use_window_global_1.useWindowGlobal('analyticsReady', false, namespace), globalAnalyticsReady = _c.value, setGlobalAnalyticsReady = _c.setValue, globalAnalyticsReadyLoaded = _c.loaded;
var _d = react_use_window_global_1.useWindowGlobal('requestMade', false, namespace), globalRequestMade = _d.value, setGlobalRequestMade = _d.setValue, globalRequestMadeLoaded = _d.loaded;
var globalNamespace = '__USE_GOOGLE_ANALYTICS_EMBED_API_HOOK__';
var _c = react_use_window_global_1.useWindowGlobal(globalNamespace, 'analyticsReady', false), readyLoading = _c[0], ready = _c[1], setReady = _c[2];
var _d = react_use_window_global_1.useWindowGlobal(globalNamespace, 'requestMade', false), requestMadeLoading = _d[0], requestMade = _d[1], setRequestMade = _d[2];
React.useEffect(function () {
try {
if (typeof window !== 'undefined' && globalAnalyticsReadyLoaded && globalRequestMadeLoaded) {
if (typeof window !== 'undefined' && !readyLoading && !requestMadeLoading) {
var win_1 = window;
if (globalAnalyticsReady) {
if (ready && typeof gapi === 'undefined') {
// If it's already been loaded into window, set ready to true and set the api.
// We only want to load once.
console.log('Using already loaded gapi...');
setGapi(win_1.gapi);
}
else if (!globalRequestMade) {
setGlobalRequestMade(true);
else if (!requestMade) {
setRequestMade(true);
// Call the code from Google to load the API globally.
console.log('Not globally ready. Loading API...');
loadGoogleApi();

@@ -40,5 +38,4 @@ // At this point, gapi has been partially loaded into window.

// At this point, we can use the Analytics Embed API!
console.log('Gapi loaded! Setting to ready');
setGapi(win_1.gapi);
setGlobalAnalyticsReady(true);
setReady(true);
});

@@ -55,13 +52,4 @@ }

}
}, [
setGapi,
error,
setGlobalAnalyticsReady,
globalAnalyticsReady,
globalAnalyticsReadyLoaded,
globalRequestMadeLoaded,
globalRequestMade,
setGlobalRequestMade,
]);
return { ready: !!globalAnalyticsReady, gapi: gapi, error: error };
}, [setGapi, error, setReady, ready, requestMade, setRequestMade, gapi, readyLoading, requestMadeLoading]);
return { ready: !!ready, gapi: gapi, error: error };
};

@@ -68,0 +56,0 @@ /**

{
"name": "@devboldly/react-use-google-analytics-embed-api",
"version": "0.0.11",
"version": "0.0.12",
"author": "Dev Boldly <devboldly@gmail.com>",

@@ -30,3 +30,3 @@ "description": "React hook to async load the Google Analytics Embed API.",

"dependencies": {
"@devboldly/react-use-window-global": "0.0.3"
"@devboldly/react-use-window-global": "0.0.6"
},

@@ -33,0 +33,0 @@ "peerDependencies": {

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