@socialgouv/matomo-postgres 1.1.4 → 1.2.0
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.
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/importDate.test.js.snap +100 -8
- package/src/__tests__/__snapshots__/importEvent.test.js.snap +90 -4
- package/src/__tests__/__snapshots__/index.test.js.snap +3 -1
- package/src/__tests__/importDate.test.js +4 -4
- package/src/__tests__/index.test.js +9 -5
- package/src/__tests__/visit.json +21 -0
- package/src/createTable.js +16 -1
- package/src/importEvent.js +2 -0
- package/types/index.d.ts +1 -0
- package/types/matomo.d.ts +1 -0
package/package.json
CHANGED
|
@@ -21,8 +21,8 @@ Array [
|
|
|
21
21
|
],
|
|
22
22
|
Array [
|
|
23
23
|
"insert into matomo
|
|
24
|
-
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, usercustomproperties, usercustomdimensions)
|
|
25
|
-
values ($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)
|
|
24
|
+
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_title, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, siteSearchKeyword, usercustomproperties, usercustomdimensions)
|
|
25
|
+
values ($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)
|
|
26
26
|
ON CONFLICT DO NOTHING",
|
|
27
27
|
Array [
|
|
28
28
|
"42",
|
|
@@ -42,6 +42,7 @@ Array [
|
|
|
42
42
|
"2021-08-20T21:55:12.000Z",
|
|
43
43
|
"123_0",
|
|
44
44
|
"event",
|
|
45
|
+
"Evènement",
|
|
45
46
|
"Ecommerce",
|
|
46
47
|
"Cart change",
|
|
47
48
|
"added - Basic Wetsuit",
|
|
@@ -49,6 +50,7 @@ Array [
|
|
|
49
50
|
48,
|
|
50
51
|
"2021-08-20T21:35:18.000Z",
|
|
51
52
|
"https://dive-shop.net/products/basic-wetsuit/",
|
|
53
|
+
undefined,
|
|
52
54
|
Object {
|
|
53
55
|
"page-author": "Julien",
|
|
54
56
|
"post-age": "-430 days",
|
|
@@ -64,8 +66,8 @@ Array [
|
|
|
64
66
|
],
|
|
65
67
|
Array [
|
|
66
68
|
"insert into matomo
|
|
67
|
-
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, usercustomproperties, usercustomdimensions)
|
|
68
|
-
values ($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)
|
|
69
|
+
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_title, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, siteSearchKeyword, usercustomproperties, usercustomdimensions)
|
|
70
|
+
values ($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)
|
|
69
71
|
ON CONFLICT DO NOTHING",
|
|
70
72
|
Array [
|
|
71
73
|
"42",
|
|
@@ -85,6 +87,7 @@ Array [
|
|
|
85
87
|
"2021-08-20T21:55:12.000Z",
|
|
86
88
|
"123_1",
|
|
87
89
|
"action",
|
|
90
|
+
"Divezone Brand Diving Boots - Divezone Store",
|
|
88
91
|
undefined,
|
|
89
92
|
undefined,
|
|
90
93
|
undefined,
|
|
@@ -92,6 +95,49 @@ Array [
|
|
|
92
95
|
"2",
|
|
93
96
|
"2021-08-20T21:30:25.000Z",
|
|
94
97
|
"https://dive-shop.net/products/diving-boots/",
|
|
98
|
+
undefined,
|
|
99
|
+
Object {},
|
|
100
|
+
Object {
|
|
101
|
+
"dimension1": "guest",
|
|
102
|
+
"dimension2": "julien",
|
|
103
|
+
"dimension3": "page",
|
|
104
|
+
"dimension4": "indonesia",
|
|
105
|
+
"dimension5": "diving",
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
],
|
|
109
|
+
Array [
|
|
110
|
+
"insert into matomo
|
|
111
|
+
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_title, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, siteSearchKeyword, usercustomproperties, usercustomdimensions)
|
|
112
|
+
values ($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)
|
|
113
|
+
ON CONFLICT DO NOTHING",
|
|
114
|
+
Array [
|
|
115
|
+
"42",
|
|
116
|
+
123,
|
|
117
|
+
"2",
|
|
118
|
+
"Argentine",
|
|
119
|
+
"Buenos Aires",
|
|
120
|
+
"Buenos Aires",
|
|
121
|
+
"Mac",
|
|
122
|
+
"Générique Bureau",
|
|
123
|
+
"Inconnu",
|
|
124
|
+
"300",
|
|
125
|
+
"23",
|
|
126
|
+
"returningCustomer",
|
|
127
|
+
"tests",
|
|
128
|
+
"24",
|
|
129
|
+
"2021-08-20T21:55:12.000Z",
|
|
130
|
+
"123_2",
|
|
131
|
+
"search",
|
|
132
|
+
"Divezone Brand Diving Boots - Divezone Store",
|
|
133
|
+
undefined,
|
|
134
|
+
undefined,
|
|
135
|
+
undefined,
|
|
136
|
+
undefined,
|
|
137
|
+
"2",
|
|
138
|
+
"2021-08-20T21:30:22.000Z",
|
|
139
|
+
"https://dive-shop.net/products/diving-boots/",
|
|
140
|
+
"scuba",
|
|
95
141
|
Object {},
|
|
96
142
|
Object {
|
|
97
143
|
"dimension1": "guest",
|
|
@@ -104,8 +150,8 @@ Array [
|
|
|
104
150
|
],
|
|
105
151
|
Array [
|
|
106
152
|
"insert into matomo
|
|
107
|
-
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, usercustomproperties, usercustomdimensions)
|
|
108
|
-
values ($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)
|
|
153
|
+
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_title, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, siteSearchKeyword, usercustomproperties, usercustomdimensions)
|
|
154
|
+
values ($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)
|
|
109
155
|
ON CONFLICT DO NOTHING",
|
|
110
156
|
Array [
|
|
111
157
|
"42",
|
|
@@ -125,6 +171,7 @@ Array [
|
|
|
125
171
|
"2021-08-20T21:55:12.000Z",
|
|
126
172
|
"124_0",
|
|
127
173
|
"event",
|
|
174
|
+
"Evènement",
|
|
128
175
|
"Ecommerce",
|
|
129
176
|
"Cart change",
|
|
130
177
|
"added - Basic Wetsuit",
|
|
@@ -132,6 +179,7 @@ Array [
|
|
|
132
179
|
48,
|
|
133
180
|
"2021-08-20T21:35:18.000Z",
|
|
134
181
|
"https://dive-shop.net/products/basic-wetsuit/",
|
|
182
|
+
undefined,
|
|
135
183
|
Object {
|
|
136
184
|
"page-author": "Julien",
|
|
137
185
|
"post-age": "-430 days",
|
|
@@ -147,8 +195,8 @@ Array [
|
|
|
147
195
|
],
|
|
148
196
|
Array [
|
|
149
197
|
"insert into matomo
|
|
150
|
-
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, usercustomproperties, usercustomdimensions)
|
|
151
|
-
values ($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)
|
|
198
|
+
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_title, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, siteSearchKeyword, usercustomproperties, usercustomdimensions)
|
|
199
|
+
values ($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)
|
|
152
200
|
ON CONFLICT DO NOTHING",
|
|
153
201
|
Array [
|
|
154
202
|
"42",
|
|
@@ -168,6 +216,7 @@ Array [
|
|
|
168
216
|
"2021-08-20T21:55:12.000Z",
|
|
169
217
|
"124_1",
|
|
170
218
|
"action",
|
|
219
|
+
"Divezone Brand Diving Boots - Divezone Store",
|
|
171
220
|
undefined,
|
|
172
221
|
undefined,
|
|
173
222
|
undefined,
|
|
@@ -175,6 +224,49 @@ Array [
|
|
|
175
224
|
"2",
|
|
176
225
|
"2021-08-20T21:30:25.000Z",
|
|
177
226
|
"https://dive-shop.net/products/diving-boots/",
|
|
227
|
+
undefined,
|
|
228
|
+
Object {},
|
|
229
|
+
Object {
|
|
230
|
+
"dimension1": "guest",
|
|
231
|
+
"dimension2": "julien",
|
|
232
|
+
"dimension3": "page",
|
|
233
|
+
"dimension4": "indonesia",
|
|
234
|
+
"dimension5": "diving",
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
],
|
|
238
|
+
Array [
|
|
239
|
+
"insert into matomo
|
|
240
|
+
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_title, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, siteSearchKeyword, usercustomproperties, usercustomdimensions)
|
|
241
|
+
values ($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)
|
|
242
|
+
ON CONFLICT DO NOTHING",
|
|
243
|
+
Array [
|
|
244
|
+
"42",
|
|
245
|
+
124,
|
|
246
|
+
"2",
|
|
247
|
+
"Argentine",
|
|
248
|
+
"Buenos Aires",
|
|
249
|
+
"Buenos Aires",
|
|
250
|
+
"Mac",
|
|
251
|
+
"Générique Bureau",
|
|
252
|
+
"Inconnu",
|
|
253
|
+
"300",
|
|
254
|
+
"23",
|
|
255
|
+
"returningCustomer",
|
|
256
|
+
"tests",
|
|
257
|
+
"24",
|
|
258
|
+
"2021-08-20T21:55:12.000Z",
|
|
259
|
+
"124_2",
|
|
260
|
+
"search",
|
|
261
|
+
"Divezone Brand Diving Boots - Divezone Store",
|
|
262
|
+
undefined,
|
|
263
|
+
undefined,
|
|
264
|
+
undefined,
|
|
265
|
+
undefined,
|
|
266
|
+
"2",
|
|
267
|
+
"2021-08-20T21:30:22.000Z",
|
|
268
|
+
"https://dive-shop.net/products/diving-boots/",
|
|
269
|
+
"scuba",
|
|
178
270
|
Object {},
|
|
179
271
|
Object {
|
|
180
272
|
"dimension1": "guest",
|
|
@@ -10,6 +10,7 @@ Array [
|
|
|
10
10
|
"action_id": "124_0",
|
|
11
11
|
"action_timespent": 48,
|
|
12
12
|
"action_timestamp": "2021-08-20T21:35:18.000Z",
|
|
13
|
+
"action_title": "Evènement",
|
|
13
14
|
"action_type": "event",
|
|
14
15
|
"action_url": "https://dive-shop.net/products/basic-wetsuit/",
|
|
15
16
|
"actions": "2",
|
|
@@ -23,6 +24,7 @@ Array [
|
|
|
23
24
|
"operatingsystemname": "Mac",
|
|
24
25
|
"region": "Buenos Aires",
|
|
25
26
|
"serverdateprettyfirstaction": "2021-08-20T21:55:12.000Z",
|
|
27
|
+
"siteSearchKeyword": undefined,
|
|
26
28
|
"sitename": "tests",
|
|
27
29
|
"usercustomdimensions": Object {
|
|
28
30
|
"dimension1": "guest",
|
|
@@ -47,6 +49,7 @@ Array [
|
|
|
47
49
|
"action_id": "124_1",
|
|
48
50
|
"action_timespent": "2",
|
|
49
51
|
"action_timestamp": "2021-08-20T21:30:25.000Z",
|
|
52
|
+
"action_title": "Divezone Brand Diving Boots - Divezone Store",
|
|
50
53
|
"action_type": "action",
|
|
51
54
|
"action_url": "https://dive-shop.net/products/diving-boots/",
|
|
52
55
|
"actions": "2",
|
|
@@ -60,6 +63,43 @@ Array [
|
|
|
60
63
|
"operatingsystemname": "Mac",
|
|
61
64
|
"region": "Buenos Aires",
|
|
62
65
|
"serverdateprettyfirstaction": "2021-08-20T21:55:12.000Z",
|
|
66
|
+
"siteSearchKeyword": undefined,
|
|
67
|
+
"sitename": "tests",
|
|
68
|
+
"usercustomdimensions": Object {
|
|
69
|
+
"dimension1": "guest",
|
|
70
|
+
"dimension2": "julien",
|
|
71
|
+
"dimension3": "page",
|
|
72
|
+
"dimension4": "indonesia",
|
|
73
|
+
"dimension5": "diving",
|
|
74
|
+
},
|
|
75
|
+
"usercustomproperties": Object {},
|
|
76
|
+
"userid": "24",
|
|
77
|
+
"visitduration": "300",
|
|
78
|
+
"visitortype": "returningCustomer",
|
|
79
|
+
},
|
|
80
|
+
Object {
|
|
81
|
+
"action_eventaction": undefined,
|
|
82
|
+
"action_eventcategory": undefined,
|
|
83
|
+
"action_eventname": undefined,
|
|
84
|
+
"action_eventvalue": undefined,
|
|
85
|
+
"action_id": "124_2",
|
|
86
|
+
"action_timespent": "2",
|
|
87
|
+
"action_timestamp": "2021-08-20T21:30:22.000Z",
|
|
88
|
+
"action_title": "Divezone Brand Diving Boots - Divezone Store",
|
|
89
|
+
"action_type": "search",
|
|
90
|
+
"action_url": "https://dive-shop.net/products/diving-boots/",
|
|
91
|
+
"actions": "2",
|
|
92
|
+
"city": "Buenos Aires",
|
|
93
|
+
"country": "Argentine",
|
|
94
|
+
"dayssincefirstvisit": "23",
|
|
95
|
+
"devicebrand": "Inconnu",
|
|
96
|
+
"devicemodel": "Générique Bureau",
|
|
97
|
+
"idsite": "42",
|
|
98
|
+
"idvisit": "124",
|
|
99
|
+
"operatingsystemname": "Mac",
|
|
100
|
+
"region": "Buenos Aires",
|
|
101
|
+
"serverdateprettyfirstaction": "2021-08-20T21:55:12.000Z",
|
|
102
|
+
"siteSearchKeyword": "scuba",
|
|
63
103
|
"sitename": "tests",
|
|
64
104
|
"usercustomdimensions": Object {
|
|
65
105
|
"dimension1": "guest",
|
|
@@ -80,8 +120,8 @@ exports[`importEvent: should extract events from matomo visit actionsDetails and
|
|
|
80
120
|
Array [
|
|
81
121
|
Array [
|
|
82
122
|
"insert into matomo
|
|
83
|
-
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, usercustomproperties, usercustomdimensions)
|
|
84
|
-
values ($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)
|
|
123
|
+
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_title, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, siteSearchKeyword, usercustomproperties, usercustomdimensions)
|
|
124
|
+
values ($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)
|
|
85
125
|
ON CONFLICT DO NOTHING",
|
|
86
126
|
Array [
|
|
87
127
|
"42",
|
|
@@ -101,6 +141,7 @@ Array [
|
|
|
101
141
|
"2021-08-20T21:55:12.000Z",
|
|
102
142
|
"124_0",
|
|
103
143
|
"event",
|
|
144
|
+
"Evènement",
|
|
104
145
|
"Ecommerce",
|
|
105
146
|
"Cart change",
|
|
106
147
|
"added - Basic Wetsuit",
|
|
@@ -108,6 +149,7 @@ Array [
|
|
|
108
149
|
48,
|
|
109
150
|
"2021-08-20T21:35:18.000Z",
|
|
110
151
|
"https://dive-shop.net/products/basic-wetsuit/",
|
|
152
|
+
undefined,
|
|
111
153
|
Object {
|
|
112
154
|
"page-author": "Julien",
|
|
113
155
|
"post-age": "-430 days",
|
|
@@ -123,8 +165,8 @@ Array [
|
|
|
123
165
|
],
|
|
124
166
|
Array [
|
|
125
167
|
"insert into matomo
|
|
126
|
-
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, usercustomproperties, usercustomdimensions)
|
|
127
|
-
values ($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)
|
|
168
|
+
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_title, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, siteSearchKeyword, usercustomproperties, usercustomdimensions)
|
|
169
|
+
values ($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)
|
|
128
170
|
ON CONFLICT DO NOTHING",
|
|
129
171
|
Array [
|
|
130
172
|
"42",
|
|
@@ -144,6 +186,7 @@ Array [
|
|
|
144
186
|
"2021-08-20T21:55:12.000Z",
|
|
145
187
|
"124_1",
|
|
146
188
|
"action",
|
|
189
|
+
"Divezone Brand Diving Boots - Divezone Store",
|
|
147
190
|
undefined,
|
|
148
191
|
undefined,
|
|
149
192
|
undefined,
|
|
@@ -151,6 +194,49 @@ Array [
|
|
|
151
194
|
"2",
|
|
152
195
|
"2021-08-20T21:30:25.000Z",
|
|
153
196
|
"https://dive-shop.net/products/diving-boots/",
|
|
197
|
+
undefined,
|
|
198
|
+
Object {},
|
|
199
|
+
Object {
|
|
200
|
+
"dimension1": "guest",
|
|
201
|
+
"dimension2": "julien",
|
|
202
|
+
"dimension3": "page",
|
|
203
|
+
"dimension4": "indonesia",
|
|
204
|
+
"dimension5": "diving",
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
],
|
|
208
|
+
Array [
|
|
209
|
+
"insert into matomo
|
|
210
|
+
(idsite, idvisit, actions, country, region, city, operatingsystemname, devicemodel, devicebrand, visitduration, dayssincefirstvisit, visitortype, sitename, userid, serverdateprettyfirstaction, action_id, action_type, action_title, action_eventcategory, action_eventaction, action_eventname, action_eventvalue, action_timespent, action_timestamp, action_url, siteSearchKeyword, usercustomproperties, usercustomdimensions)
|
|
211
|
+
values ($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)
|
|
212
|
+
ON CONFLICT DO NOTHING",
|
|
213
|
+
Array [
|
|
214
|
+
"42",
|
|
215
|
+
"124",
|
|
216
|
+
"2",
|
|
217
|
+
"Argentine",
|
|
218
|
+
"Buenos Aires",
|
|
219
|
+
"Buenos Aires",
|
|
220
|
+
"Mac",
|
|
221
|
+
"Générique Bureau",
|
|
222
|
+
"Inconnu",
|
|
223
|
+
"300",
|
|
224
|
+
"23",
|
|
225
|
+
"returningCustomer",
|
|
226
|
+
"tests",
|
|
227
|
+
"24",
|
|
228
|
+
"2021-08-20T21:55:12.000Z",
|
|
229
|
+
"124_2",
|
|
230
|
+
"search",
|
|
231
|
+
"Divezone Brand Diving Boots - Divezone Store",
|
|
232
|
+
undefined,
|
|
233
|
+
undefined,
|
|
234
|
+
undefined,
|
|
235
|
+
undefined,
|
|
236
|
+
"2",
|
|
237
|
+
"2021-08-20T21:30:22.000Z",
|
|
238
|
+
"https://dive-shop.net/products/diving-boots/",
|
|
239
|
+
"scuba",
|
|
154
240
|
Object {},
|
|
155
241
|
Object {
|
|
156
242
|
"dimension1": "guest",
|
|
@@ -86,8 +86,8 @@ test("importDate: should import when new results", async () => {
|
|
|
86
86
|
};
|
|
87
87
|
//@ts-expect-error
|
|
88
88
|
const imported = await importDate(fakeClient, matomoSpy, new Date("2021-08-03T00:00:00"));
|
|
89
|
-
expect(pgSpy.mock.calls.length).toEqual(
|
|
90
|
-
expect(imported.length).toEqual(
|
|
89
|
+
expect(pgSpy.mock.calls.length).toEqual(4);
|
|
90
|
+
expect(imported.length).toEqual(3);
|
|
91
91
|
expect(matomoSpy.mock.calls[0][0].filter_offset).toEqual(0);
|
|
92
92
|
});
|
|
93
93
|
|
|
@@ -110,8 +110,8 @@ test("importDate: should offset matomo calls when results already exist", async
|
|
|
110
110
|
};
|
|
111
111
|
//@ts-expect-error
|
|
112
112
|
const imported = await importDate(fakeClient, matomoSpy, new Date("2021-08-03T00:00:00"));
|
|
113
|
-
expect(pgSpy.mock.calls.length).toEqual(
|
|
114
|
-
expect(imported.length).toEqual(
|
|
113
|
+
expect(pgSpy.mock.calls.length).toEqual(4);
|
|
114
|
+
expect(imported.length).toEqual(3);
|
|
115
115
|
expect(matomoSpy.mock.calls[0][0].filter_offset).toEqual(42);
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -12,6 +12,7 @@ const matomoVisit = require("./visit.json");
|
|
|
12
12
|
|
|
13
13
|
const run = require("../index");
|
|
14
14
|
|
|
15
|
+
const NB_REQUEST_TO_INIT_DB = 5; // Number of query to init DB (createTable.js)
|
|
15
16
|
const TEST_DATE = new Date();
|
|
16
17
|
|
|
17
18
|
// @ts-ignore
|
|
@@ -84,10 +85,11 @@ test("run: should fetch the latest event date if no date provided", async () =>
|
|
|
84
85
|
expect(mock_matomoApi.mock.calls[0][0].filter_offset).toEqual(0);
|
|
85
86
|
|
|
86
87
|
// check db queries
|
|
87
|
-
expect(mock_pgQuery.mock.calls[
|
|
88
|
+
expect(mock_pgQuery.mock.calls[NB_REQUEST_TO_INIT_DB][0]).toEqual(
|
|
88
89
|
// call 0 is create table
|
|
89
90
|
// call 1 is add column usercustomdimension
|
|
90
91
|
// call 2 is add column action_url
|
|
92
|
+
// ...
|
|
91
93
|
//
|
|
92
94
|
"select action_timestamp from matomo order by action_timestamp desc limit 1"
|
|
93
95
|
);
|
|
@@ -128,7 +130,9 @@ test("run: should resume using latest event date - offset if no date provided",
|
|
|
128
130
|
expect(mock_matomoApi.mock.calls.length).toEqual(daysCount);
|
|
129
131
|
|
|
130
132
|
// check db queries
|
|
131
|
-
|
|
133
|
+
console.log("daysCount", daysCount);
|
|
134
|
+
//console.log("mock_pgQuery.mock.calls", mock_pgQuery.mock.calls);
|
|
135
|
+
expect(mock_pgQuery.mock.calls.length).toEqual(NB_REQUEST_TO_INIT_DB + 1 + daysCount * 7); // NB_REQUEST_TO_INIT_DB + select queries + days offset
|
|
132
136
|
});
|
|
133
137
|
|
|
134
138
|
test("run: should use today date if nothing in DB", async () => {
|
|
@@ -152,7 +156,7 @@ test("run: should use today date if nothing in DB", async () => {
|
|
|
152
156
|
expect(mock_matomoApi.mock.calls[0][0].date).toEqual(isoDate(TEST_DATE));
|
|
153
157
|
|
|
154
158
|
// check the 4 events inserted
|
|
155
|
-
expect(mock_pgQuery.mock.calls.length).toEqual(
|
|
159
|
+
expect(mock_pgQuery.mock.calls.length).toEqual(NB_REQUEST_TO_INIT_DB + 5); // NB_REQUEST_TO_INIT_DB + check date + latest + 2 inserts
|
|
156
160
|
});
|
|
157
161
|
|
|
158
162
|
test("run: should use given date if any", async () => {
|
|
@@ -172,7 +176,7 @@ test("run: should use given date if any", async () => {
|
|
|
172
176
|
await run(isoDate(addDays(TEST_DATE, -10)) + "T00:00:00.000Z");
|
|
173
177
|
|
|
174
178
|
expect(mock_matomoApi.mock.calls.length).toEqual(11);
|
|
175
|
-
expect(mock_pgQuery.mock.calls.length).toEqual(
|
|
179
|
+
expect(mock_pgQuery.mock.calls.length).toEqual(NB_REQUEST_TO_INIT_DB + 11 * 4); // NB_REQUEST_TO_INIT_DB + inserts. no initial select as date is provided
|
|
176
180
|
});
|
|
177
181
|
|
|
178
182
|
test("run: should use STARTDATE if any", async () => {
|
|
@@ -194,5 +198,5 @@ test("run: should use STARTDATE if any", async () => {
|
|
|
194
198
|
|
|
195
199
|
expect(mock_matomoApi.mock.calls.length).toEqual(6);
|
|
196
200
|
|
|
197
|
-
expect(mock_pgQuery.mock.calls.length).toEqual(
|
|
201
|
+
expect(mock_pgQuery.mock.calls.length).toEqual(NB_REQUEST_TO_INIT_DB + 1 + 6 * 4); // NB_REQUEST_TO_INIT_DB + initial select + inserts.
|
|
198
202
|
});
|
package/src/__tests__/visit.json
CHANGED
|
@@ -69,6 +69,27 @@
|
|
|
69
69
|
"dimension2": "julien",
|
|
70
70
|
"dimension4": "indonesia",
|
|
71
71
|
"dimension5": "diving"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"type": "search",
|
|
75
|
+
"url": "https://dive-shop.net/products/diving-boots/",
|
|
76
|
+
"pageTitle": "Divezone Brand Diving Boots - Divezone Store",
|
|
77
|
+
"pageIdAction": "60",
|
|
78
|
+
"idpageview": "8CDIez",
|
|
79
|
+
"serverTimePretty": "20 août 2021 21:30:25",
|
|
80
|
+
"pageId": "19696664",
|
|
81
|
+
"timeSpent": "2",
|
|
82
|
+
"timeSpentPretty": "2s",
|
|
83
|
+
"pageviewPosition": "5",
|
|
84
|
+
"title": "Divezone Brand Diving Boots - Divezone Store",
|
|
85
|
+
"subtitle": "https://dive-shop.net/products/diving-boots/",
|
|
86
|
+
"icon": "",
|
|
87
|
+
"iconSVG": "plugins/Morpheus/images/action.svg",
|
|
88
|
+
"timestamp": 1629495022,
|
|
89
|
+
"dimension2": "julien",
|
|
90
|
+
"dimension4": "indonesia",
|
|
91
|
+
"dimension5": "diving",
|
|
92
|
+
"siteSearchKeyword": "scuba"
|
|
72
93
|
}
|
|
73
94
|
]
|
|
74
95
|
}
|
package/src/createTable.js
CHANGED
|
@@ -33,7 +33,9 @@ async function createTable(client) {
|
|
|
33
33
|
action_timestamp timestamp with time zone,
|
|
34
34
|
usercustomproperties json,
|
|
35
35
|
usercustomdimensions json,
|
|
36
|
-
action_url text
|
|
36
|
+
action_url text,
|
|
37
|
+
sitesearchkeyword text,
|
|
38
|
+
action_title text
|
|
37
39
|
)`;
|
|
38
40
|
await client.query(text, []);
|
|
39
41
|
const addUserCustomDimensionColumn = `ALTER TABLE IF EXISTS ${client.escapeIdentifier(DESTINATION_TABLE)}
|
|
@@ -43,6 +45,19 @@ async function createTable(client) {
|
|
|
43
45
|
const addActionUrlColumn = `ALTER TABLE IF EXISTS ${client.escapeIdentifier(DESTINATION_TABLE)}
|
|
44
46
|
ADD COLUMN IF NOT EXISTS "action_url" text;`;
|
|
45
47
|
await client.query(addActionUrlColumn, []);
|
|
48
|
+
|
|
49
|
+
const addSiteSearchKeyword = `ALTER TABLE IF EXISTS ${client.escapeIdentifier(DESTINATION_TABLE)}
|
|
50
|
+
ADD COLUMN IF NOT EXISTS "sitesearchkeyword" text;`;
|
|
51
|
+
await client.query(addSiteSearchKeyword, []);
|
|
52
|
+
|
|
53
|
+
const addActionName = `ALTER TABLE IF EXISTS ${client.escapeIdentifier(DESTINATION_TABLE)}
|
|
54
|
+
ADD COLUMN IF NOT EXISTS "action_title" text;`;
|
|
55
|
+
await client.query(addActionName, []);
|
|
56
|
+
|
|
57
|
+
// --------------------------------------------- //
|
|
58
|
+
// If you add new query: Don't forget to update //
|
|
59
|
+
// const `NB_REQUEST_TO_INIT_DB` (index.test.js) //
|
|
60
|
+
// --------------------------------------------- //
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
module.exports = { createTable };
|
package/src/importEvent.js
CHANGED
|
@@ -42,6 +42,7 @@ const matomoProps = [
|
|
|
42
42
|
/** @type Record<string, (a: import("types/matomo").ActionDetail) => string | number> */
|
|
43
43
|
const actionProps = {
|
|
44
44
|
action_type: (action) => action.type,
|
|
45
|
+
action_title: (action) => action.title,
|
|
45
46
|
action_eventcategory: (action) => action.eventCategory,
|
|
46
47
|
action_eventaction: (action) => action.eventAction,
|
|
47
48
|
action_eventname: (action) => action.eventName,
|
|
@@ -49,6 +50,7 @@ const actionProps = {
|
|
|
49
50
|
action_timespent: (action) => action.timeSpent,
|
|
50
51
|
action_timestamp: (action) => new Date(action.timestamp * 1000).toISOString(),
|
|
51
52
|
action_url: (action) => action.url,
|
|
53
|
+
siteSearchKeyword: (action) => action.siteSearchKeyword,
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
/**
|
package/types/index.d.ts
CHANGED