|
1 | 1 | import HookStore from 'app/stores/hookStore';
|
2 | 2 |
|
3 | 3 | /**
|
4 |
| - * If the backend for `analytics` is reload, you will need to add the event `name` |
5 |
| - * to the inclusion list in https://github.com/getsentry/reload/blob/master/reload_app/events.py |
| 4 | + * Analytics and metric tracking functionality. |
6 | 5 | *
|
| 6 | + * These are primarily driven through hooks provided through the hookstore. For |
| 7 | + * sentry.io these are currently mapped to our in-house analytics backend |
| 8 | + * 'Reload' and the Amplitude service. |
7 | 9 | *
|
8 |
| - * If you are using `gauge` or `increment`, the metric names need to be added to |
9 |
| - * https://github.com/getsentry/reload/blob/master/reload_app/metrics/__init__.py |
| 10 | + * NOTE: sentry.io contributors, you will need to nesure that the eventKey |
| 11 | + * passed exists as an event key in the Reload events.py configuration: |
| 12 | + * |
| 13 | + * https://github.com/getsentry/reload/blob/master/reload_app/events.py |
| 14 | + * |
| 15 | + * NOTE: sentry.io contributors, if you are using `gauge` or `increment` the |
| 16 | + * name must be added to the Reload metrics module: |
| 17 | + * |
| 18 | + * https://github.com/getsentry/reload/blob/master/reload_app/metrics/__init__.py |
| 19 | + */ |
| 20 | + |
| 21 | +/** |
| 22 | + * This should be primarily used for product events. In that case where you |
| 23 | + * want to track some one-off Adhoc events, use the `trackAdhocEvent` function. |
| 24 | + * |
| 25 | + * Generally this is the function you will want to use for event tracking. |
| 26 | + * |
| 27 | + * Refer for the backend implementation provided through HookStore for more |
| 28 | + * details. |
| 29 | + * |
| 30 | + * @param {Object} options Event tracking options |
| 31 | + * @param {String} options.eventKey The string key of the event to track |
| 32 | + * @param {String} options.name The human readable string name of the event |
| 33 | + * @param {...Object} options.data The parameters of the event to track |
| 34 | + */ |
| 35 | +export const trackAnalyticsEvent = options => |
| 36 | + HookStore.get('analytics:track-event').forEach(cb => cb(options)); |
| 37 | + |
| 38 | +/** |
| 39 | + * This should be used for adhoc analytics tracking. |
| 40 | + * |
| 41 | + * This is used for high volume events, and events with unbounded parameters, |
| 42 | + * such as tracking search queries. |
| 43 | + * |
| 44 | + * Refer for the backend implementation provided through HookStore for a more |
| 45 | + * thorough explanation of when to use this. |
| 46 | + * |
| 47 | + * @param {Object} options Event tracking options |
| 48 | + * @param {String} options.eventKey The string key of the event to track |
| 49 | + * @param {...Object} options.data The parameters of the event to track |
10 | 50 | */
|
| 51 | +export const trackAdhocEvent = options => |
| 52 | + HookStore.get('analytics:track-adhoc-event').forEach(cb => cb(options)); |
11 | 53 |
|
12 | 54 | /**
|
13 | 55 | * @param {String} name The name of the event
|
14 | 56 | * @param {Object} data Additional event data to record
|
15 | 57 | */
|
16 |
| -export function analytics(name, data) { |
| 58 | +export const analytics = (name, data) => |
17 | 59 | HookStore.get('analytics:event').forEach(cb => cb(name, data));
|
18 |
| -} |
19 |
| - |
20 |
| -export function amplitude(name, organization_id, data) { |
21 |
| - HookStore.get('amplitude:event').forEach(cb => cb(name, organization_id, data)); |
22 |
| -} |
23 | 60 |
|
24 | 61 | /**
|
25 | 62 | * @param {String} name Metric name
|
26 | 63 | * @param {Number} value Value to record for this metric
|
27 | 64 | * @param {Object} tags An additional tags object
|
28 | 65 | */
|
29 |
| -export function metric(name, value, tags) { |
| 66 | +export const metric = (name, value, tags) => |
30 | 67 | HookStore.get('metrics:event').forEach(cb => cb(name, value, tags));
|
31 |
| -} |
32 | 68 |
|
33 | 69 | // JSDOM implements window.performance but not window.performance.mark
|
34 | 70 | const CAN_MARK =
|
|
0 commit comments