@cmpsr/analytics
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -1,3 +0,4 @@ | ||
import React, { ReactNode } from 'react'; | ||
import { FC, ReactNode } from 'react'; | ||
import { ISegmentConfig, IGAConfig, IGTagConfig } from './integrations'; | ||
import { AmplitudeConfig } from './integrations/amplitude'; | ||
export interface IAnalyticsProvider { | ||
@@ -7,5 +8,6 @@ segment?: ISegmentConfig; | ||
ga?: IGAConfig; | ||
amplitude?: AmplitudeConfig; | ||
children: ReactNode; | ||
} | ||
export declare const _AnalyticsProvider: React.FC<IAnalyticsProvider>; | ||
export declare const AnalyticsProvider: React.FC<IAnalyticsProvider>; | ||
export declare const _AnalyticsProvider: FC<IAnalyticsProvider>; | ||
export declare const AnalyticsProvider: FC<IAnalyticsProvider>; |
@@ -19,3 +19,3 @@ /* eslint-disable prefer-rest-params */ "use strict"; | ||
}); | ||
var _react = /*#__PURE__*/ _interop_require_default(require("react")); | ||
var _react = /*#__PURE__*/ _interop_require_wildcard(require("react")); | ||
var _AnalyticsContext = require("./AnalyticsContext"); | ||
@@ -25,2 +25,3 @@ var _integrations = require("./integrations/index"); | ||
var _jscookie = /*#__PURE__*/ _interop_require_default(require("js-cookie")); | ||
var _amplitude = require("./integrations/amplitude/index"); | ||
function _interop_require_default(obj) { | ||
@@ -31,2 +32,41 @@ return obj && obj.__esModule ? obj : { | ||
} | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== "function") return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function(nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interop_require_wildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") { | ||
return { | ||
default: obj | ||
}; | ||
} | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = {}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
function _object_without_properties(source, excluded) { | ||
@@ -62,3 +102,4 @@ if (source == null) return {}; | ||
gtag: _integrations.GTag, | ||
segment: _integrations.Segment | ||
segment: _integrations.Segment, | ||
amplitude: _amplitude.Amplitude | ||
}; | ||
@@ -77,3 +118,3 @@ var ssr = !(typeof window !== "undefined" && window.document && window.document.createElement); | ||
]); | ||
var anonymousId = _react.default.useMemo(function() { | ||
var anonymousId = (0, _react.useMemo)(function() { | ||
var id = _jscookie.default.get(COOKIE_NAME) || (0, _uuid.v1)(); | ||
@@ -85,3 +126,3 @@ _jscookie.default.set(COOKIE_NAME, id, { | ||
}, []); | ||
var integrations = _react.default.useMemo(function() { | ||
var integrations = (0, _react.useMemo)(function() { | ||
var enabledIntegrations = Object.keys(supportedIntegrations).filter(function(integration) { | ||
@@ -97,3 +138,3 @@ if (props[integration]) { | ||
}, []); | ||
var context = _react.default.useMemo(function() { | ||
var context = (0, _react.useMemo)(function() { | ||
return { | ||
@@ -100,0 +141,0 @@ identify: function identify() { |
@@ -10,3 +10,3 @@ { | ||
}, | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"author": "Steve Cox <stevejcox@me.com>", | ||
@@ -13,0 +13,0 @@ "license": "MIT", |
37922
48
1092