New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@socialgouv/matomo-postgres

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@socialgouv/matomo-postgres - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

docker/Dockerfile

2

package.json
{
"name": "@socialgouv/matomo-postgres",
"description": "Extract visitor events from Matomo API and push to Postgres",
"version": "1.3.1",
"version": "1.4.0",
"types": "types/index.d.ts",

@@ -6,0 +6,0 @@ "license": "Apache-2.0",

@@ -7,4 +7,8 @@ # @socialgouv/matomo-postgres

Use [pg_partman](https://github.com/pgpartman/pg_partman) to partition data by month.
## Usage
Create the [initial table](./initial.sql) database table then run the following job with correct environment variables.
```sh

@@ -34,5 +38,5 @@ npx @socialgouv/matomo-postgres

export MATOMO_KEY=
export DESTINATION_TABLE=
export STARTDATE=
export OFFSET=
export DESTINATION_TABLE= # optional
export STARTDATE= # optional
export OFFSET= # optional
export PGDATABASE=postgres://postgres:postgres@127.0.0.1:5455/postgres

@@ -39,0 +43,0 @@ yarn start

@@ -15,3 +15,3 @@ const mock_pgQuery = jest.fn();

const NB_REQUEST_TO_INIT_DB = 21; // Number of query to init DB (createTable.js)
const NB_REQUEST_TO_INIT_DB = 1; // Number of query to init DB (createTable.js)
const TEST_DATE = new Date();

@@ -90,7 +90,2 @@

expect(mock_pgQuery.mock.calls[NB_REQUEST_TO_INIT_DB][0]).toEqual(
// call 0 is create table
// call 1 is add column usercustomdimension
// call 2 is add column action_url
// ...
//
"select action_timestamp from matomo order by action_timestamp desc limit 1"

@@ -97,0 +92,0 @@ );

@@ -11,4 +11,8 @@ const { Client } = require("pg");

const table = client.escapeIdentifier(DESTINATION_TABLE);
const text = `CREATE TABLE IF NOT EXISTS ${table}
(
const text = `
CREATE SCHEMA IF NOT EXISTS partman;
CREATE EXTENSION IF NOT EXISTS pg_partman SCHEMA partman;
CREATE TABLE IF NOT EXISTS ${table}
(
idsite text,

@@ -29,3 +33,3 @@ idvisit text,

serverdateprettyfirstaction date,
action_id text UNIQUE,
action_id text,
action_type text,

@@ -37,3 +41,3 @@ action_eventcategory text,

action_timespent text,
action_timestamp timestamp with time zone,
action_timestamp timestamp with time zone DEFAULT now(),
usercustomproperties json,

@@ -54,34 +58,9 @@ usercustomdimensions json,

action_title text
)`;
) PARTITION BY RANGE (action_timestamp);
`;
await client.query(text, []);
const migrations = [
`ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "usercustomdimensions" json;`,
`ALTER TABLE IF EXISTS ${table} ADD COLUMN IF NOT EXISTS "action_url" text;`,
`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);`,
`CREATE INDEX IF NOT EXISTS idx_action_type ON ${table}(action_type);`,
`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_action_eventaction ON ${table}(action_eventaction);`,
];
const migrations = [];
// --------------------------------------------- //
// If you add new query: Don't forget to update //
// const `NB_REQUEST_TO_INIT_DB` (index.test.js) //
// --------------------------------------------- //
for (const query of migrations) {

@@ -88,0 +67,0 @@ await client.query(query, []);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc