@lancom/shared 0.0.370 → 0.0.372

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.
@@ -1,6 +1,5 @@
1
1
  import { mapGetters, mapActions, mapMutations } from 'vuex';
2
2
  import api from '@lancom/shared/assets/js/api';
3
- import gtm from '@lancom/shared/assets/js/utils/gtm';
4
3
  import gapis from '@lancom/shared/assets/js/utils/gapis';
5
4
  import { price, shortDate, tax } from '@lancom/shared/assets/js/utils/filters';
6
5
  import { convertQuoteToOrder } from '@lancom/shared/assets/js/utils/quote';
@@ -43,7 +42,7 @@ export default {
43
42
  this.processing = true;
44
43
  this.order = await this.createOrder({ ...option });
45
44
  this.setOrder(this.order);
46
- gtm.purchase(this.order, this.currency);
45
+ // gtm.purchase(this.order, this.currency);
47
46
  gapis.surveyOptin(this.order, this.shop);
48
47
  this.clear();
49
48
  } catch (e) {
package/nuxt.config.js CHANGED
@@ -68,7 +68,8 @@ module.exports = (config, axios, { raygunClient, publicPath, productUrlToEditor
68
68
  ],
69
69
  serverMiddleware: [
70
70
  '@/node_modules/@lancom/shared/plugins/headers',
71
- '@/node_modules/@lancom/shared/server-middleware/robots'
71
+ '@/node_modules/@lancom/shared/server-middleware/robots',
72
+ '@/node_modules/@lancom/shared/server-middleware/leads'
72
73
  ],
73
74
  modules: [
74
75
  'nuxt-helmet',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.370",
3
+ "version": "0.0.372",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
@@ -10,6 +10,7 @@
10
10
  "license": "ISC",
11
11
  "homepage": "https://bitbucket.org/simpletee/lancom-shared#readme",
12
12
  "dependencies": {
13
+ "basic-auth": "^2.0.1",
13
14
  "lodash.get": "^4.4.2",
14
15
  "vue2-hammer": "^2.1.2"
15
16
  },
@@ -0,0 +1,69 @@
1
+ const axios = require('axios');
2
+ const basicAuth = require('basic-auth');
3
+
4
+ const API_URL = process.client ? process.env.API_URL : process.env.LOCAL_API_URL;
5
+ const HOST_NAME = process.env.HOST_NAME;
6
+
7
+ const LEAD_ADMIN = 'ladmin';
8
+ const LEAD_ADMIN_PASS = 'ladmin2sad$S';
9
+
10
+ module.exports = async function (req, res, next) {
11
+ if (req.url === '/lead/leads.csv') {
12
+ const credentials = basicAuth(req);
13
+
14
+ if (!credentials || credentials.name !== LEAD_ADMIN || credentials.pass !== LEAD_ADMIN_PASS) {
15
+ res.setHeader('WWW-Authenticate', 'Basic realm="Access restricted"');
16
+ res.statusCode = 401;
17
+ return res.end('Authentication required.');
18
+ }
19
+
20
+ const leads = (await axios.get(`${API_URL}/shop/${HOST_NAME}/leads`)).data;
21
+ // console.log('leads: ', leads);
22
+
23
+ const csvHeaders = [
24
+ 'conversion_action',
25
+ 'conversion_event_time',
26
+ 'gclid',
27
+ 'hashed_email',
28
+ 'hashed_phone_number',
29
+ 'conversion_value',
30
+ 'currency_code',
31
+ 'transaction_id'
32
+ ];
33
+
34
+ const csvRows = leads
35
+ // .reduce((rows, lead) => {
36
+ // if (lead.order) {
37
+ // rows.push({ ...lead, type: 'converted_lead', code: lead.order.code });
38
+ // }
39
+ // if (lead.quote) {
40
+ // rows.push({ ...lead, type: 'qualified_lead', code: lead.quote.code });
41
+ // }
42
+ // if ((lead.quote || lead.order) && lead.contact) {
43
+ // rows.push({ ...lead, type: 'contact_form', code: lead.contact.code });
44
+ // }
45
+ // return rows;
46
+ // }, [])
47
+ .map(lead => [
48
+ lead.action,
49
+ (new Date(lead.createdAt)).toISOString().replace(/\.[0-9]*Z/, '+00:00').replace('Z', '+00:00'),
50
+ lead.googleClickId,
51
+ lead.hashedEmail,
52
+ lead.hashedPhoneNumber,
53
+ lead.conversionValue,
54
+ lead.conversion?.isoCode || 'AUD',
55
+ lead.code
56
+ ]);
57
+
58
+ const csvContent = [
59
+ csvHeaders.join(','),
60
+ ...csvRows.map(row => row.join(','))
61
+ ].join('\n');
62
+
63
+ res.setHeader('Content-Type', 'text/csv');
64
+ res.end(csvContent);
65
+ return;
66
+ }
67
+
68
+ next();
69
+ }
package/store/index.js CHANGED
@@ -120,8 +120,8 @@ export const actions = {
120
120
  dispatch('cart/calculateCartPrice', { shop, country });
121
121
  }
122
122
  }
123
- if (state?.googleClickId || query.gclid) {
124
- commit('setGoogleClickId', state?.googleClickId || query.gclid);
123
+ if (query.gclid || state?.googleClickId) {
124
+ commit('setGoogleClickId', query.gclid || state?.googleClickId);
125
125
  }
126
126
  const closedNotification = localStorage.getItem(CLOSED_NOTIFICATION);
127
127
  if (notificationBar?.text === closedNotification) {