@cmpsr/analytics
Advanced tools
Comparing version 0.5.2 to 0.6.0-20250124155300
@@ -10,2 +10,3 @@ import { FC, ReactNode } from 'react'; | ||
meta?: MetaConfig; | ||
disabledFunctions?: Record<string, string[]>; | ||
children: ReactNode; | ||
@@ -12,0 +13,0 @@ } |
@@ -107,11 +107,18 @@ /* eslint-disable prefer-rest-params */ "use strict"; | ||
var COOKIE_NAME = 'composer_anonymous_id'; | ||
var proxyToIntegrations = function(integrations, func, args) { | ||
var proxyToIntegrations = function(integrations, func, args, disabledFunctions) { | ||
integrations.forEach(function(integration) { | ||
return(// eslint-disable-next-line prefer-spread | ||
integration[func].apply(integration, args)); | ||
if (disabledFunctions && disabledFunctions[integration.constructor.name].includes(func)) { | ||
integration[func] = function() { | ||
return null; | ||
}; | ||
return; | ||
} | ||
// eslint-disable-next-line prefer-spread | ||
integration[func].apply(integration, args); | ||
}); | ||
}; | ||
var _AnalyticsProvider = function(_param) { | ||
var children = _param.children, props = _object_without_properties(_param, [ | ||
"children" | ||
var children = _param.children, _param_disabledFunctions = _param.disabledFunctions, disabledFunctions = _param_disabledFunctions === void 0 ? null : _param_disabledFunctions, props = _object_without_properties(_param, [ | ||
"children", | ||
"disabledFunctions" | ||
]); | ||
@@ -139,12 +146,12 @@ var anonymousId = (0, _react.useMemo)(function() { | ||
identify: function identify() { | ||
proxyToIntegrations(integrations, 'identify', Array.from(arguments)); | ||
proxyToIntegrations(integrations, 'identify', Array.from(arguments), disabledFunctions); | ||
}, | ||
group: function group() { | ||
proxyToIntegrations(integrations, 'group', Array.from(arguments)); | ||
proxyToIntegrations(integrations, 'group', Array.from(arguments), disabledFunctions); | ||
}, | ||
page: function page() { | ||
proxyToIntegrations(integrations, 'page', Array.from(arguments)); | ||
proxyToIntegrations(integrations, 'page', Array.from(arguments), disabledFunctions); | ||
}, | ||
track: function track() { | ||
proxyToIntegrations(integrations, 'track', Array.from(arguments)); | ||
proxyToIntegrations(integrations, 'track', Array.from(arguments), disabledFunctions); | ||
}, | ||
@@ -157,6 +164,6 @@ user: function() { | ||
reset: function reset() { | ||
proxyToIntegrations(integrations, 'reset', Array.from(arguments)); | ||
proxyToIntegrations(integrations, 'reset', Array.from(arguments), disabledFunctions); | ||
}, | ||
revenue: function revenue() { | ||
proxyToIntegrations(integrations, 'revenue', Array.from(arguments)); | ||
proxyToIntegrations(integrations, 'revenue', Array.from(arguments), disabledFunctions); | ||
} | ||
@@ -163,0 +170,0 @@ }; |
@@ -135,3 +135,11 @@ "use strict"; | ||
var amplitude = (0, _loadAmplitude.loadAmplitude)(); | ||
amplitude.init(config.apiKey); | ||
var _config_autoCaptureForms, _config_autoCaptureViews, _config_autoCaptureDownloads, _config_autoCaptureElementInteractions; | ||
amplitude.init(config.apiKey, { | ||
autocapture: { | ||
formInteractions: (_config_autoCaptureForms = config.autoCaptureForms) !== null && _config_autoCaptureForms !== void 0 ? _config_autoCaptureForms : true, | ||
pageViews: (_config_autoCaptureViews = config.autoCaptureViews) !== null && _config_autoCaptureViews !== void 0 ? _config_autoCaptureViews : true, | ||
fileDownloads: (_config_autoCaptureDownloads = config.autoCaptureDownloads) !== null && _config_autoCaptureDownloads !== void 0 ? _config_autoCaptureDownloads : true, | ||
elementInteractions: (_config_autoCaptureElementInteractions = config.autoCaptureElementInteractions) !== null && _config_autoCaptureElementInteractions !== void 0 ? _config_autoCaptureElementInteractions : true | ||
} | ||
}); | ||
}; |
export type AmplitudeConfig = { | ||
apiKey: string; | ||
autoCaptureForms?: boolean; | ||
autoCaptureViews?: boolean; | ||
autoCaptureDownloads?: boolean; | ||
autoCaptureElementInteractions?: boolean; | ||
}; |
@@ -10,3 +10,3 @@ { | ||
}, | ||
"version": "0.5.2", | ||
"version": "0.6.0-20250124155300", | ||
"author": "Steve Cox <stevejcox@me.com>", | ||
@@ -13,0 +13,0 @@ "license": "MIT", |
55824
1498