@dapperlabs/react-analytics
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -160,2 +160,7 @@ 'use strict'; | ||
}, []); | ||
var alias = React.useCallback(function (userId, previousUserId) { | ||
if (!window.analytics) return; | ||
if (!userId) return window.analytics.reset(); | ||
window.analytics.alias(userId, previousUserId); | ||
}, []); | ||
var trackButtonClick = React.useCallback(function () { | ||
@@ -184,2 +189,3 @@ var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
identify: identify, | ||
alias: alias, | ||
trackButtonClick: trackButtonClick, | ||
@@ -186,0 +192,0 @@ trackPageView: trackPageView, |
{ | ||
"name": "@dapperlabs/react-analytics", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "A utility to connect react projects to segment", | ||
@@ -5,0 +5,0 @@ "repository": "github:dapperlabs/react-analytics", |
# react-analytics π©βπ¬ | ||
Convenience component for creating a connecting to segment. | ||
Convenience component for creating a connection to segment. | ||
@@ -9,2 +9,3 @@ ## Values provided on context: | ||
- `identify`: function | ||
- `alias`: function | ||
- `trackButtonClick`: function | ||
@@ -29,3 +30,3 @@ - `trackPageView`: function | ||
<AnalyticsProvider | ||
clientSideId={process.env.SEGMENT_WRITE_TOKEN} | ||
segmentWriteToken={process.env.SEGMENT_WRITE_TOKEN} | ||
> | ||
@@ -41,3 +42,3 @@ <MyDApp /> | ||
Context is directly available via `import { AnalyticsContext } from '@dapperlabs/react-analytics` and can be consumed however you'd like: | ||
Context is directly available via `import { AnalyticsContext } from '@dapperlabs/react-analytics'` and can be consumed however you'd like: | ||
@@ -50,3 +51,3 @@ - `useContext(AnalyticsContext)` **πIDEAL π** | ||
import React, { useContext, useRef } from 'react'; | ||
import { AnalyticsContext } from '@dapperlabs/analytics'; | ||
import { AnalyticsContext } from '@dapperlabs/react-analytics'; | ||
@@ -53,0 +54,0 @@ function Button({ children, id, onClick, trackingProperties }) { |
@@ -22,2 +22,8 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; | ||
const alias = useCallback((userId, previousUserId) => { | ||
if (!window.analytics) return; | ||
if (!userId) return window.analytics.reset(); | ||
window.analytics.alias(userId, previousUserId); | ||
}, []); | ||
const trackButtonClick = useCallback((properties = {}) => { | ||
@@ -41,2 +47,3 @@ if (!window.analytics) return; | ||
identify, | ||
alias, | ||
trackButtonClick, | ||
@@ -43,0 +50,0 @@ trackPageView, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
39717
14
749
76
1