repl.it
@sidraval/

FrontMushyNotifications

Flow

No description

fork
loading
Files
  • src
    • index.js
    • math.js
  • .flowconfig
  • yarn.lock
  • Packager files
  • package.json
src/index.js
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
// @flow

const analyticsEvents = {
  onClick: {
    name: "onClick",
    description: "Link click"
  },
  onHover: {
    name: "onHover",
    description: "Link hover"
  }
}

function buildAnalyticsObject(
  eventName: string,
  metadata: Object
): {
  name: string,
  description: string,
  currentPageUrl: string,
  linkUrl: string
} | null {
  const analyticsData = analyticsEvents[eventName];

  if (!analyticsData) {
    return null;
  }

  return {
    ...analyticsData,
    ...metadata
  };
}