1 | const axios = require('axios');
|
2 |
|
3 | module.exports = goldlog;
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | function goldlog(action, extraData = {}) {
|
12 | const realData = {
|
13 | action: `ice-devtools-${action}`,
|
14 | data: {
|
15 | ...extraData,
|
16 |
|
17 | },
|
18 | };
|
19 |
|
20 | const dataKeyArray = Object.keys(realData);
|
21 | const gokey = dataKeyArray.reduce((finnalStr, currentKey, index) => {
|
22 | const currentData =
|
23 | typeof realData[currentKey] === 'string'
|
24 | ? realData[currentKey]
|
25 | : JSON.stringify(realData[currentKey]);
|
26 | return `${finnalStr}${currentKey}=${currentData}${
|
27 | dataKeyArray.length - 1 === index ? '' : '&'
|
28 | }`;
|
29 | }, '');
|
30 |
|
31 | axios({
|
32 | method: 'post',
|
33 | url: 'http://gm.mmstat.com/iceteam.iceworks.log',
|
34 | data: {
|
35 | cache: Math.random(),
|
36 | gmkey: 'CLK',
|
37 | gokey: encodeURIComponent(gokey),
|
38 | logtype: '2',
|
39 | },
|
40 | }).then(() => {
|
41 | }).catch(() => {
|
42 | });
|
43 | }
|