diff --git a/src/__tests__/__snapshots__/importDate.test.js.snap b/src/__tests__/__snapshots__/importDate.test.js.snap index 800697d..eb82967 100644 --- a/src/__tests__/__snapshots__/importDate.test.js.snap +++ b/src/__tests__/__snapshots__/importDate.test.js.snap @@ -21,8 +21,8 @@ Array [ ], Array [ "insert into matomo - (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) - 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) + (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, dimension1, dimension2, dimension3, dimension4, dimension5, dimension6, dimension7, dimension8, dimension9, dimension10) + 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, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38) ON CONFLICT DO NOTHING", Array [ "42", @@ -57,17 +57,32 @@ Array [ }, Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, + "guest", + "julien", + "page", + "indonesia", + "diving", + "shop", + "v1.2.3", + "fr", + "light", + "36", ], ], Array [ "insert into matomo - (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) - 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) + (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, dimension1, dimension2, dimension3, dimension4, dimension5, dimension6, dimension7, dimension8, dimension9, dimension10) + 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, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38) ON CONFLICT DO NOTHING", Array [ "42", @@ -99,17 +114,32 @@ Array [ Object {}, Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, + "guest", + "julien", + "page", + "indonesia", + "diving", + "shop", + "v1.2.3", + "fr", + "light", + "36", ], ], Array [ "insert into matomo - (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) - 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) + (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, dimension1, dimension2, dimension3, dimension4, dimension5, dimension6, dimension7, dimension8, dimension9, dimension10) + 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, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38) ON CONFLICT DO NOTHING", Array [ "42", @@ -141,17 +171,32 @@ Array [ Object {}, Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, + "guest", + "julien", + "page", + "indonesia", + "diving", + "shop", + "v1.2.3", + "fr", + "light", + "36", ], ], Array [ "insert into matomo - (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) - 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) + (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, dimension1, dimension2, dimension3, dimension4, dimension5, dimension6, dimension7, dimension8, dimension9, dimension10) + 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, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38) ON CONFLICT DO NOTHING", Array [ "42", @@ -186,17 +231,32 @@ Array [ }, Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, + "guest", + "julien", + "page", + "indonesia", + "diving", + "shop", + "v1.2.3", + "fr", + "light", + "36", ], ], Array [ "insert into matomo - (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) - 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) + (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, dimension1, dimension2, dimension3, dimension4, dimension5, dimension6, dimension7, dimension8, dimension9, dimension10) + 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, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38) ON CONFLICT DO NOTHING", Array [ "42", @@ -228,17 +288,32 @@ Array [ Object {}, Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, + "guest", + "julien", + "page", + "indonesia", + "diving", + "shop", + "v1.2.3", + "fr", + "light", + "36", ], ], Array [ "insert into matomo - (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) - 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) + (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, dimension1, dimension2, dimension3, dimension4, dimension5, dimension6, dimension7, dimension8, dimension9, dimension10) + 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, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38) ON CONFLICT DO NOTHING", Array [ "42", @@ -270,11 +345,26 @@ Array [ Object {}, Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, + "guest", + "julien", + "page", + "indonesia", + "diving", + "shop", + "v1.2.3", + "fr", + "light", + "36", ], ], ] diff --git a/src/__tests__/__snapshots__/importEvent.test.js.snap b/src/__tests__/__snapshots__/importEvent.test.js.snap index 37f3162..48c7dad 100644 --- a/src/__tests__/__snapshots__/importEvent.test.js.snap +++ b/src/__tests__/__snapshots__/importEvent.test.js.snap @@ -19,6 +19,16 @@ Array [ "dayssincefirstvisit": "23", "devicebrand": "Inconnu", "devicemodel": "Générique Bureau", + "dimension1": "guest", + "dimension10": "36", + "dimension2": "julien", + "dimension3": "page", + "dimension4": "indonesia", + "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", "idsite": "42", "idvisit": "124", "operatingsystemname": "Mac", @@ -28,10 +38,15 @@ Array [ "sitename": "tests", "usercustomdimensions": Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, "usercustomproperties": Object { "page-author": "Julien", @@ -58,6 +73,16 @@ Array [ "dayssincefirstvisit": "23", "devicebrand": "Inconnu", "devicemodel": "Générique Bureau", + "dimension1": "guest", + "dimension10": "36", + "dimension2": "julien", + "dimension3": "page", + "dimension4": "indonesia", + "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", "idsite": "42", "idvisit": "124", "operatingsystemname": "Mac", @@ -67,10 +92,15 @@ Array [ "sitename": "tests", "usercustomdimensions": Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, "usercustomproperties": Object {}, "userid": "24", @@ -94,6 +124,16 @@ Array [ "dayssincefirstvisit": "23", "devicebrand": "Inconnu", "devicemodel": "Générique Bureau", + "dimension1": "guest", + "dimension10": "36", + "dimension2": "julien", + "dimension3": "page", + "dimension4": "indonesia", + "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", "idsite": "42", "idvisit": "124", "operatingsystemname": "Mac", @@ -103,10 +143,15 @@ Array [ "sitename": "tests", "usercustomdimensions": Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, "usercustomproperties": Object {}, "userid": "24", @@ -120,8 +165,8 @@ exports[`importEvent: should extract events from matomo visit actionsDetails and Array [ Array [ "insert into matomo - (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) - 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) + (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, dimension1, dimension2, dimension3, dimension4, dimension5, dimension6, dimension7, dimension8, dimension9, dimension10) + 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, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38) ON CONFLICT DO NOTHING", Array [ "42", @@ -156,17 +201,32 @@ Array [ }, Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, + "guest", + "julien", + "page", + "indonesia", + "diving", + "shop", + "v1.2.3", + "fr", + "light", + "36", ], ], Array [ "insert into matomo - (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) - 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) + (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, dimension1, dimension2, dimension3, dimension4, dimension5, dimension6, dimension7, dimension8, dimension9, dimension10) + 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, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38) ON CONFLICT DO NOTHING", Array [ "42", @@ -198,17 +258,32 @@ Array [ Object {}, Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, + "guest", + "julien", + "page", + "indonesia", + "diving", + "shop", + "v1.2.3", + "fr", + "light", + "36", ], ], Array [ "insert into matomo - (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) - 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) + (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, dimension1, dimension2, dimension3, dimension4, dimension5, dimension6, dimension7, dimension8, dimension9, dimension10) + 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, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38) ON CONFLICT DO NOTHING", Array [ "42", @@ -240,11 +315,26 @@ Array [ Object {}, Object { "dimension1": "guest", + "dimension10": "36", "dimension2": "julien", "dimension3": "page", "dimension4": "indonesia", "dimension5": "diving", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", }, + "guest", + "julien", + "page", + "indonesia", + "diving", + "shop", + "v1.2.3", + "fr", + "light", + "36", ], ], ] diff --git a/src/__tests__/__snapshots__/index.test.js.snap b/src/__tests__/__snapshots__/index.test.js.snap index a5ff9a4..cc9bef1 100644 --- a/src/__tests__/__snapshots__/index.test.js.snap +++ b/src/__tests__/__snapshots__/index.test.js.snap @@ -29,6 +29,16 @@ Array [ action_timestamp timestamp with time zone, usercustomproperties json, usercustomdimensions json, + dimension1 text, + dimension2 text, + dimension3 text, + dimension4 text, + dimension5 text, + dimension6 text, + dimension7 text, + dimension8 text, + dimension9 text, + dimension10 text, action_url text, sitesearchkeyword text, action_title text diff --git a/src/__tests__/index.test.js b/src/__tests__/index.test.js index 4ad8528..4417241 100644 --- a/src/__tests__/index.test.js +++ b/src/__tests__/index.test.js @@ -12,7 +12,7 @@ const matomoVisit = require("./visit.json"); const run = require("../index"); -const NB_REQUEST_TO_INIT_DB = 10; // Number of query to init DB (createTable.js) +const NB_REQUEST_TO_INIT_DB = 20; // Number of query to init DB (createTable.js) const TEST_DATE = new Date(); // @ts-ignore @@ -130,8 +130,6 @@ test("run: should resume using latest event date - offset if no date provided", expect(mock_matomoApi.mock.calls.length).toEqual(daysCount); // check db queries - console.log("daysCount", daysCount); - //console.log("mock_pgQuery.mock.calls", mock_pgQuery.mock.calls); expect(mock_pgQuery.mock.calls.length).toEqual(NB_REQUEST_TO_INIT_DB + 1 + daysCount * 7); // NB_REQUEST_TO_INIT_DB + select queries + days offset }); @@ -152,7 +150,6 @@ test("run: should use today date if nothing in DB", async () => { // check matomo requests expect(mock_matomoApi.mock.calls.length).toEqual(1); - console.log(TEST_DATE, isoDate(TEST_DATE)); expect(mock_matomoApi.mock.calls[0][0].date).toEqual(isoDate(TEST_DATE)); // check the 4 events inserted diff --git a/src/__tests__/visit.json b/src/__tests__/visit.json index 89968b9..430e575 100644 --- a/src/__tests__/visit.json +++ b/src/__tests__/visit.json @@ -15,6 +15,11 @@ "city": "Buenos Aires", "dimension1": "guest", "dimension3": "page", + "dimension6": "shop", + "dimension7": "v1.2.3", + "dimension8": "fr", + "dimension9": "light", + "dimension10": "36", "firstActionTimestamp": 1629496512, "actionDetails": [ { diff --git a/src/createTable.js b/src/createTable.js index a4802f5..4aa63ab 100644 --- a/src/createTable.js +++ b/src/createTable.js @@ -35,6 +35,16 @@ async function createTable(client) { action_timestamp timestamp with time zone, usercustomproperties json, usercustomdimensions json, + dimension1 text, + dimension2 text, + dimension3 text, + dimension4 text, + dimension5 text, + dimension6 text, + dimension7 text, + dimension8 text, + dimension9 text, + dimension10 text, action_url text, sitesearchkeyword text, action_title text @@ -48,6 +58,16 @@ async function createTable(client) { `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "sitesearchkeyword" text;`, `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "action_title" text;`, `ALTER TABLE IF EXISTS ${table} ALTER COLUMN action_eventvalue TYPE decimal USING action_eventvalue::decimal;`, + `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "dimension1" text;`, + `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "dimension2" text;`, + `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "dimension3" text;`, + `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "dimension4" text;`, + `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "dimension5" text;`, + `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "dimension6" text;`, + `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "dimension7" text;`, + `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "dimension8" text;`, + `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "dimension9" text;`, + `ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "dimension10" text;`, `CREATE INDEX IF NOT EXISTS idx_action_timestamp ON ${table} (action_timestamp);`, `CREATE INDEX IF NOT EXISTS idx_idvisit ON ${table}(idvisit);`, `CREATE INDEX IF NOT EXISTS idx_action_eventcategory ON ${table}(action_eventcategory);`, diff --git a/src/importEvent.js b/src/importEvent.js index a0b9f73..983f846 100644 --- a/src/importEvent.js +++ b/src/importEvent.js @@ -73,7 +73,7 @@ const getEventsFromMatomoVisit = (matomoVisit) => { /** @type {Record} */ const usercustomdimensions = {}; - for (let k = 1; k < 10; k++) { + for (let k = 1; k < 11; k++) { const dimension = `dimension${k}`; const value = actionDetail[dimension] || matomoVisit[dimension]; if (!value) continue; // max 10 custom variables @@ -92,7 +92,11 @@ const getEventsFromMatomoVisit = (matomoVisit) => { }), // custom variables usercustomproperties, + // custom dimensions + // We keep both for backwards compatibility. + // Current implementation is flat with one column for each dimension. usercustomdimensions, + ...usercustomdimensions, }; return event; }); diff --git a/types/matomo.d.ts b/types/matomo.d.ts index d322a9c..05ab095 100644 --- a/types/matomo.d.ts +++ b/types/matomo.d.ts @@ -96,6 +96,11 @@ export type Visit = { dimension3?: string; dimension4?: string; dimension5?: string; + dimension6?: string; + dimension7?: string; + dimension8?: string; + dimension9?: string; + dimension10?: string; experiments: Experiment[]; customVariables: any; formConversions: number;