Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-use-analytics-api
Advanced tools
Readme
Read the official documentation.
👁️ Full Example
For components, check out: React Analytics Charts
The useAnalyticsApi
hook can be used to load and ready the Google Analytics Embed API in React.
What is the Google Analytics Embed API? It is a JavaScript library that allows you to easily create and embed Google Analytics charts on a third-party website in a matter of minutes.
This library also provides helper hooks for the API's built-in components:
Looking for components? A full React component library that wraps these hooks is now available! Check out React Analytics Charts.
window
dependence
window
, but this hook pulls the API into a singleton to limit window
dependence.npm i react-use-analytics-api
To load the Google Analytics Embed API, use the useAnalyticsApi
hook:
import { useAnalyticsApi } from "react-use-analytics-api";
Then in your function component:
const { ready, gapi, authorized, error } = useAnalyticsApi();
When ready
is true
, the gapi
object will be set to the loaded and ready-to-use Google Analytics Embed API. The gapi
object will be undefined
until it is ready to use.
The authorized
property will be true
when the user is authorized, false
otherwise.
From here, you can authorize the user, render a view selector, and render charts... or do anything else you want with the API!
🏁 For a full example demonstrating all features of this library including full auth flow, see the useDataChart example. This is a great starting point for building your own charts dashboard. You can also check out React Analytics Charts which is built on this hooks library.
Type definitions have been included for TypeScript support.
Logo graphics by Twemoji, licensed under CC-BY 4.0. Favicon by favicon.io.
Open source software is awesome and so are you. 😎
Feel free to submit a pull request for bugs or additions, and make sure to update tests as appropriate. If you find a mistake in the docs, send a PR! Even the smallest changes help.
For major changes, open an issue first to discuss what you'd like to change.
See Kindling for npm script documentation.
If you found this project helpful, let the community know by giving it a star: 👉⭐
Copyright © 2020 Justin Mahar https://github.com/justinmahar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
FAQs
[⛔️ DEPRECATED] React hook for loading the Google Analytics Embed API.
The npm package react-use-analytics-api receives a total of 366 weekly downloads. As such, react-use-analytics-api popularity was classified as not popular.
We found that react-use-analytics-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.