aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/heap.ts
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-17 00:51:41 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-17 00:51:41 +0800
commit37d60dc39ea6476c3185e124175cb02d5e830250 (patch)
treede83087e501b5c9b236658ac65f13825ae070315 /packages/instant/src/util/heap.ts
parented26f5af985239e0dd91b68d4ec0aa264267acd6 (diff)
downloaddexon-0x-contracts-37d60dc39ea6476c3185e124175cb02d5e830250.tar.gz
dexon-0x-contracts-37d60dc39ea6476c3185e124175cb02d5e830250.tar.zst
dexon-0x-contracts-37d60dc39ea6476c3185e124175cb02d5e830250.zip
Typesafe analytic actions
Diffstat (limited to 'packages/instant/src/util/heap.ts')
-rw-r--r--packages/instant/src/util/heap.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/instant/src/util/heap.ts b/packages/instant/src/util/heap.ts
index 6d3c75ea7..5fd61b4c9 100644
--- a/packages/instant/src/util/heap.ts
+++ b/packages/instant/src/util/heap.ts
@@ -1,6 +1,7 @@
import { ObjectMap } from '@0x/types';
+import { logUtils } from '@0x/utils';
-import { HEAP_ANALYTICS_DEVELOPMENT_APP_ID } from '../constants';
+import { ANALYTICS_ENABLED, HEAP_ANALYTICS_DEVELOPMENT_APP_ID } from '../constants';
export interface HeapAnalytics {
loaded: boolean;
@@ -82,4 +83,20 @@ export const heapUtil = {
return setupZeroExInstantHeap();
},
+ evaluateHeapCall: (heapFunctionCall: (heap: HeapAnalytics) => void): void => {
+ if (!ANALYTICS_ENABLED) {
+ return;
+ }
+
+ const curHeap = heapUtil.getHeap();
+ if (curHeap) {
+ try {
+ heapFunctionCall(curHeap);
+ } catch (e) {
+ // We never want analytics to crash our React component
+ // TODO: error reporter here
+ logUtils.log('Analytics error', e);
+ }
+ }
+ },
};