-
Notifications
You must be signed in to change notification settings - Fork 182
/
analytics.stories.tsx
46 lines (38 loc) · 1.05 KB
/
analytics.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from 'react';
import Link from '../link/link';
import analytics from './analytics';
import AnalyticsCustomPlugin from './analytics__custom-plugin';
export default {
title: 'Components/Analytics',
parameters: {
notes:
'Provides a façade to Google Analytics and other web analytics services through a system of plugins.',
screenshots: {skip: true}
}
};
export const Analytics = () => {
const FLUSH_INTERVAL = 100;
const customPlugin = new AnalyticsCustomPlugin(
// eslint-disable-next-line no-console
events => console.log('Custom plugin receives:', events[0].category, events[0].action),
false,
FLUSH_INTERVAL
);
analytics.config([customPlugin]);
return (
<div>
<p>Click the link below and check the console output:</p>
<div>
<Link
pseudo
onClick={event => {
analytics.trackEvent('test-category', 'test-action');
event.preventDefault();
}}
>
Track click event
</Link>
</div>
</div>
);
};