UNPKG

@tanglemedia/directus-extension-bundle-page-views

Version:

A Directus extension bundle that adds a page views collection and dashboard to track page views.

76 lines (72 loc) 1.4 kB
const COLLECTION_NAME = "tngl_page_views"; // preset that applies to any user or role const PRESETS = [ { collection: "tngl_page_views", icon: "bookmark_border", layout: "tabular", layout_options: { map: { clusterData: true, cameraOptions: { bbox: [ -123.58935164824834, 44.00103152922438, -98.15885239907448, 53.872158275764605, ], zoom: 5.177614598227907, pitch: 0, center: { lat: 49.18195391088818, lng: -110.87410202366124, }, bearing: 0, }, geometryField: "geolocation", displayTemplate: "{{visit_date}}", }, tabular: { widths: { city: 146.40625, device: 144, country: 174.796875, page_url: 253.380126953125, ip_address: 185.71356201171875, page_title: 189.4322509765625, visit_date: 209.83334350585935, }, }, }, layout_query: { map: { page: 1, limit: 1000, }, tabular: { page: 1, sort: ["-visit_date"], fields: [ "visit_date", "ip_address", "page_title", "page_url", "city", "country", "device", ], }, }, }, ]; export async function up(knex) { await knex("directus_presets").insert(PRESETS); } export async function down(knex) { await knex("directus_presets") .where({ user: null, role: null, bookmark: null, collection: COLLECTION_NAME, }) .del(); }