@openedx/paragon 22.0.0-alpha.24 → 22.0.0-alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ const helpCommand = require('../lib/help');
5
5
  const buildTokensCommand = require('../lib/build-tokens');
6
6
  const replaceVariablesCommand = require('../lib/replace-variables');
7
7
  const buildScssCommand = require('../lib/build-scss');
8
- const { sendTrackInfo } = require('../utils');
8
+ const { sendTrackInfo } = require('../lib/utils');
9
9
  const versionCommand = require('../lib/version');
10
10
 
11
11
  const commandAliases = {
package/lib/utils.js CHANGED
@@ -1,4 +1,25 @@
1
- // eslint-disable-next-line import/prefer-default-export
1
+ const axios = require('axios');
2
+
3
+ /**
4
+ * Sends request to the Netlify function to inform about specified event.
5
+ * @param {string} eventId - tracking event id
6
+ * @param {object} properties - tracking properties
7
+ */
8
+ function sendTrackInfo(eventId, properties) {
9
+ const { BASE_URL, TRACK_ANONYMOUS_ANALYTICS } = process.env;
10
+ if (TRACK_ANONYMOUS_ANALYTICS) {
11
+ const url = `${BASE_URL}/.netlify/functions/sendTrackData`;
12
+ axios.post(url, { eventId, properties })
13
+ .then(result => {
14
+ // eslint-disable-next-line no-console
15
+ console.log(`Track info is successfully sent (status ${result.status})`);
16
+ }).catch(error => {
17
+ // eslint-disable-next-line no-console
18
+ console.log(`Track info request failed (${error})`);
19
+ });
20
+ }
21
+ }
22
+
2
23
  function capitalize(str) {
3
24
  if (typeof str !== 'string' || str.length === 0) {
4
25
  return '';
@@ -6,4 +27,4 @@ function capitalize(str) {
6
27
  return str.charAt(0).toUpperCase() + str.slice(1);
7
28
  }
8
29
 
9
- module.exports = { capitalize };
30
+ module.exports = { sendTrackInfo, capitalize };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openedx/paragon",
3
- "version": "22.0.0-alpha.24",
3
+ "version": "22.0.0-alpha.25",
4
4
  "description": "Accessible, responsive UI component library based on Bootstrap.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",