opscms-analytics-plugin 1.0.3 → 1.0.5
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/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +29 -28
- package/dist/index.mjs +30 -29
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.5
|
|
4
|
+
|
|
5
|
+
Saving a new entry as the platform owner failed: the organization, which the form does not let anyone pick, was left empty. It now comes from the chosen site. Needs opscms-sdk 0.1.9 or later. No database change.
|
|
6
|
+
|
|
7
|
+
## 1.0.4
|
|
8
|
+
|
|
9
|
+
LinkedIn Insight Tag as a provider: a site enters its Partner ID, and the website loads the tag for visitors who allow marketing cookies, with nothing to add in a tag manager. The ID is checked when saved (a number). Adds a database change (the new provider).
|
|
10
|
+
|
|
3
11
|
## 1.0.3
|
|
4
12
|
|
|
5
13
|
The GA4 server secret is readable again by the ga4-send-event action: the field returned the mask to every caller, so server events would have been sent with "••••••••" as the API secret. It now gives the real value, decrypted, to the one caller that asks for it (context.preventMasking) and the mask to everyone else. No database change.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Per-site analytics for the OpsCMS platform, built with [`opscms-sdk`](../opscms-sdk).
|
|
4
4
|
|
|
5
|
-
- **`analytics-integrations`**: each site's own analytics providers: Google (GA4 and Tag Manager), Matomo, Plausible, Fathom, Umami, PostHog, or a custom
|
|
5
|
+
- **`analytics-integrations`**: each site's own analytics providers: Google (GA4 and Tag Manager), LinkedIn Insight Tag, Matomo, Plausible, Fathom, Umami, PostHog, or a custom
|
|
6
6
|
script. A site can run several at once. The server secret (GA4's Measurement Protocol secret) is encrypted under the site's key and shown masked; the
|
|
7
7
|
platform's public content API never returns it. A **custom script** is injected verbatim into every page of the site, so only the platform owner may write one.
|
|
8
8
|
- **The `ga4-send-event` workflow action**: carries out the platform's `send_analytics_event` block, sending a server-side event to GA4 with the site's own
|
package/dist/index.d.mts
CHANGED
|
@@ -40,8 +40,8 @@ declare const analyticsManifest: opscms_sdk.PluginManifest;
|
|
|
40
40
|
* every page of the site: as part of a script address and inside an inline snippet. So each is held to the shape a real one has, and
|
|
41
41
|
* nothing that could end a string or a tag is accepted. (The component that renders them escapes them as well; this is the first line.)
|
|
42
42
|
*/
|
|
43
|
-
/** `true`, or the sentence that tells the person what is wrong. Empty is allowed
|
|
44
|
-
declare function trackingIdProblem(value: unknown): true | string;
|
|
43
|
+
/** `true`, or the sentence that tells the person what is wrong. Empty is allowed (the field is optional), except for LinkedIn, which is nothing without its ID. */
|
|
44
|
+
declare function trackingIdProblem(value: unknown, provider?: unknown): true | string;
|
|
45
45
|
declare function tagIdProblem(value: unknown): true | string;
|
|
46
46
|
declare function serverUrlProblem(value: unknown): true | string;
|
|
47
47
|
|
|
@@ -62,7 +62,7 @@ declare function buildGa4Body(args: {
|
|
|
62
62
|
declare function ga4SendHandler(ctx: WorkflowActionContext): Promise<WorkflowStepResult>;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Per-site analytics: the `analytics-integrations` collection (each site's own Google, Matomo, Plausible, Fathom, Umami, PostHog or custom settings, with the
|
|
65
|
+
* Per-site analytics: the `analytics-integrations` collection (each site's own Google, LinkedIn, Matomo, Plausible, Fathom, Umami, PostHog or custom settings, with the
|
|
66
66
|
* secret encrypted), and the server-side GA4 workflow action (`ga4-send-event`) that reads them for the platform's `send_analytics_event` block.
|
|
67
67
|
*
|
|
68
68
|
* Meta's own server-side events are the Meta plugin's (`meta-conversion-event`), not this plugin's.
|
package/dist/index.d.ts
CHANGED
|
@@ -40,8 +40,8 @@ declare const analyticsManifest: opscms_sdk.PluginManifest;
|
|
|
40
40
|
* every page of the site: as part of a script address and inside an inline snippet. So each is held to the shape a real one has, and
|
|
41
41
|
* nothing that could end a string or a tag is accepted. (The component that renders them escapes them as well; this is the first line.)
|
|
42
42
|
*/
|
|
43
|
-
/** `true`, or the sentence that tells the person what is wrong. Empty is allowed
|
|
44
|
-
declare function trackingIdProblem(value: unknown): true | string;
|
|
43
|
+
/** `true`, or the sentence that tells the person what is wrong. Empty is allowed (the field is optional), except for LinkedIn, which is nothing without its ID. */
|
|
44
|
+
declare function trackingIdProblem(value: unknown, provider?: unknown): true | string;
|
|
45
45
|
declare function tagIdProblem(value: unknown): true | string;
|
|
46
46
|
declare function serverUrlProblem(value: unknown): true | string;
|
|
47
47
|
|
|
@@ -62,7 +62,7 @@ declare function buildGa4Body(args: {
|
|
|
62
62
|
declare function ga4SendHandler(ctx: WorkflowActionContext): Promise<WorkflowStepResult>;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Per-site analytics: the `analytics-integrations` collection (each site's own Google, Matomo, Plausible, Fathom, Umami, PostHog or custom settings, with the
|
|
65
|
+
* Per-site analytics: the `analytics-integrations` collection (each site's own Google, LinkedIn, Matomo, Plausible, Fathom, Umami, PostHog or custom settings, with the
|
|
66
66
|
* secret encrypted), and the server-side GA4 workflow action (`ga4-send-event`) that reads them for the platform's `send_analytics_event` block.
|
|
67
67
|
*
|
|
68
68
|
* Meta's own server-side events are the Meta plugin's (`meta-conversion-event`), not this plugin's.
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,11 @@ var import_opscms_sdk = require("opscms-sdk");
|
|
|
40
40
|
// src/integrationValues.ts
|
|
41
41
|
var ID = /^[A-Za-z0-9._:/-]{1,100}$/;
|
|
42
42
|
var TAG = /^[A-Za-z0-9_-]{1,40}$/;
|
|
43
|
-
|
|
43
|
+
var LINKEDIN_PARTNER = /^\d{3,12}$/;
|
|
44
|
+
function trackingIdProblem(value, provider) {
|
|
45
|
+
if (provider === "linkedin") {
|
|
46
|
+
return typeof value === "string" && LINKEDIN_PARTNER.test(value) ? true : "Enter the LinkedIn Partner ID: the number Campaign Manager shows with the Insight Tag, for example 1234567.";
|
|
47
|
+
}
|
|
44
48
|
if (value === void 0 || value === null || value === "") return true;
|
|
45
49
|
return typeof value === "string" && ID.test(value) ? true : "A tracking or site ID has only letters, digits and . _ : / - (for example G-ABC123, 3, or example.com).";
|
|
46
50
|
}
|
|
@@ -117,6 +121,7 @@ var AnalyticsIntegrations = {
|
|
|
117
121
|
{ label: "Fathom", value: "fathom" },
|
|
118
122
|
{ label: "Umami", value: "umami" },
|
|
119
123
|
{ label: "PostHog", value: "posthog" },
|
|
124
|
+
{ label: "LinkedIn Insight Tag", value: "linkedin" },
|
|
120
125
|
{ label: "Custom", value: "custom" }
|
|
121
126
|
]
|
|
122
127
|
},
|
|
@@ -124,10 +129,10 @@ var AnalyticsIntegrations = {
|
|
|
124
129
|
{
|
|
125
130
|
name: "trackingId",
|
|
126
131
|
type: "text",
|
|
127
|
-
validate: (value) => trackingIdProblem(value),
|
|
132
|
+
validate: (value, { siblingData }) => trackingIdProblem(value, siblingData?.provider),
|
|
128
133
|
admin: {
|
|
129
|
-
description: "Measurement / tracking ID \u2014 GA4 measurement ID (G-XXXX) for Google, or site ID for others. Leave blank if only using Tag Manager.",
|
|
130
|
-
condition: (_data, siblingData) => ["google", "matomo", "plausible", "fathom", "umami", "posthog"].includes(
|
|
134
|
+
description: "Measurement / tracking ID \u2014 GA4 measurement ID (G-XXXX) for Google, the Partner ID for LinkedIn, or the site ID for others. Leave blank if only using Tag Manager. The LinkedIn tag loads only for visitors who allow marketing cookies; do not also add it through a tag manager.",
|
|
135
|
+
condition: (_data, siblingData) => ["google", "matomo", "plausible", "fathom", "umami", "posthog", "linkedin"].includes(
|
|
131
136
|
siblingData?.provider
|
|
132
137
|
)
|
|
133
138
|
}
|
|
@@ -170,28 +175,10 @@ var AnalyticsIntegrations = {
|
|
|
170
175
|
}
|
|
171
176
|
},
|
|
172
177
|
// ── Relationships ───────────────────────────────────────────
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
required: true,
|
|
178
|
-
index: true,
|
|
179
|
-
admin: { description: "The site this integration applies to" },
|
|
180
|
-
// The value of `site` is decided by who is writing, not by what they submitted. Without this an editor could plant a `customScript` (rendered raw
|
|
181
|
-
// on every page) under another tenant's site: a cross-tenant stored-XSS path.
|
|
182
|
-
hooks: { beforeValidate: [import_opscms_sdk.tenancy.pinSite] }
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
name: "organization",
|
|
186
|
-
type: "relationship",
|
|
187
|
-
relationTo: "organizations",
|
|
188
|
-
required: true,
|
|
189
|
-
index: true,
|
|
190
|
-
admin: { readOnly: true, description: "Set from the site: a site belongs to exactly one organization." },
|
|
191
|
-
// Skipped on create (the hook sets it), so a read-only required field does not block the form.
|
|
192
|
-
validate: (value, { operation }) => operation === "create" || value != null ? true : "This field is required.",
|
|
193
|
-
hooks: { beforeValidate: [import_opscms_sdk.tenancy.pinOrganization] }
|
|
194
|
-
},
|
|
178
|
+
// `site` and `organization`. The value of `site` is decided by who is writing, not by what they submitted: without that an editor could plant a
|
|
179
|
+
// `customScript` (rendered raw on every page) under another tenant's site, a cross-tenant stored-XSS path. The organization is the site's, so the
|
|
180
|
+
// platform owner, who has none of their own, gets it from the site chosen.
|
|
181
|
+
...import_opscms_sdk.tenantFields,
|
|
195
182
|
{
|
|
196
183
|
name: "isActive",
|
|
197
184
|
type: "checkbox",
|
|
@@ -206,10 +193,20 @@ var import_opscms_sdk2 = require("opscms-sdk");
|
|
|
206
193
|
var analyticsManifest = (0, import_opscms_sdk2.definePluginManifest)({
|
|
207
194
|
key: "analytics",
|
|
208
195
|
name: "Analytics & Insights",
|
|
209
|
-
description: "Analytics integrations per site: Google (GA4 and Tag Manager), Matomo, Plausible, Fathom, Umami, PostHog or a custom script; server-side GA4 events; and the marketing dashboard. (Meta Pixel belongs to the Meta plugin.)",
|
|
196
|
+
description: "Analytics integrations per site: Google (GA4 and Tag Manager), LinkedIn Insight Tag, Matomo, Plausible, Fathom, Umami, PostHog or a custom script; server-side GA4 events; and the marketing dashboard. (Meta Pixel belongs to the Meta plugin.)",
|
|
210
197
|
category: "analytics",
|
|
211
198
|
icon: "icon.svg",
|
|
212
199
|
releases: [
|
|
200
|
+
{
|
|
201
|
+
version: "1.0.5",
|
|
202
|
+
date: "2026-11-30",
|
|
203
|
+
notes: ["Saving a new entry as the platform owner failed: the organization, which the form does not let anyone pick, was left empty. It now comes from the chosen site."]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
version: "1.0.4",
|
|
207
|
+
date: "2026-11-30",
|
|
208
|
+
notes: ["LinkedIn Insight Tag as a provider: a site enters its Partner ID, and the website loads the tag for visitors who allow marketing cookies, with nothing to add in a tag manager. The ID is checked when saved (a number)."]
|
|
209
|
+
},
|
|
213
210
|
{
|
|
214
211
|
version: "1.0.3",
|
|
215
212
|
date: "2026-11-17",
|
|
@@ -350,13 +347,17 @@ var migration = (0, import_opscms_sdk4.sqlMigration)("analytics:20261108_100000_
|
|
|
350
347
|
`DROP TYPE IF EXISTS "public"."enum_analytics_integrations_provider"`
|
|
351
348
|
]
|
|
352
349
|
});
|
|
350
|
+
var linkedinProvider = (0, import_opscms_sdk4.sqlMigration)("analytics:20261130_100000_linkedin_provider", {
|
|
351
|
+
up: [`ALTER TYPE "public"."enum_analytics_integrations_provider" ADD VALUE IF NOT EXISTS 'linkedin' BEFORE 'custom'`],
|
|
352
|
+
down: []
|
|
353
|
+
});
|
|
353
354
|
|
|
354
355
|
// src/index.ts
|
|
355
356
|
var analyticsPlugin = (0, import_opscms_sdk5.definePlugin)({
|
|
356
357
|
manifest: analyticsManifest,
|
|
357
358
|
collections: [AnalyticsIntegrations],
|
|
358
359
|
workflowActions: marketingActions,
|
|
359
|
-
migrations: [migration]
|
|
360
|
+
migrations: [migration, linkedinProvider]
|
|
360
361
|
});
|
|
361
362
|
// Annotate the CommonJS export names for ESM import in node:
|
|
362
363
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
import { definePlugin } from "opscms-sdk";
|
|
3
3
|
|
|
4
4
|
// src/AnalyticsIntegrations.ts
|
|
5
|
-
import { access, platform, secretField, SETTINGS_MASK,
|
|
5
|
+
import { access, platform, secretField, SETTINGS_MASK, tenantFields } from "opscms-sdk";
|
|
6
6
|
|
|
7
7
|
// src/integrationValues.ts
|
|
8
8
|
var ID = /^[A-Za-z0-9._:/-]{1,100}$/;
|
|
9
9
|
var TAG = /^[A-Za-z0-9_-]{1,40}$/;
|
|
10
|
-
|
|
10
|
+
var LINKEDIN_PARTNER = /^\d{3,12}$/;
|
|
11
|
+
function trackingIdProblem(value, provider) {
|
|
12
|
+
if (provider === "linkedin") {
|
|
13
|
+
return typeof value === "string" && LINKEDIN_PARTNER.test(value) ? true : "Enter the LinkedIn Partner ID: the number Campaign Manager shows with the Insight Tag, for example 1234567.";
|
|
14
|
+
}
|
|
11
15
|
if (value === void 0 || value === null || value === "") return true;
|
|
12
16
|
return typeof value === "string" && ID.test(value) ? true : "A tracking or site ID has only letters, digits and . _ : / - (for example G-ABC123, 3, or example.com).";
|
|
13
17
|
}
|
|
@@ -84,6 +88,7 @@ var AnalyticsIntegrations = {
|
|
|
84
88
|
{ label: "Fathom", value: "fathom" },
|
|
85
89
|
{ label: "Umami", value: "umami" },
|
|
86
90
|
{ label: "PostHog", value: "posthog" },
|
|
91
|
+
{ label: "LinkedIn Insight Tag", value: "linkedin" },
|
|
87
92
|
{ label: "Custom", value: "custom" }
|
|
88
93
|
]
|
|
89
94
|
},
|
|
@@ -91,10 +96,10 @@ var AnalyticsIntegrations = {
|
|
|
91
96
|
{
|
|
92
97
|
name: "trackingId",
|
|
93
98
|
type: "text",
|
|
94
|
-
validate: (value) => trackingIdProblem(value),
|
|
99
|
+
validate: (value, { siblingData }) => trackingIdProblem(value, siblingData?.provider),
|
|
95
100
|
admin: {
|
|
96
|
-
description: "Measurement / tracking ID \u2014 GA4 measurement ID (G-XXXX) for Google, or site ID for others. Leave blank if only using Tag Manager.",
|
|
97
|
-
condition: (_data, siblingData) => ["google", "matomo", "plausible", "fathom", "umami", "posthog"].includes(
|
|
101
|
+
description: "Measurement / tracking ID \u2014 GA4 measurement ID (G-XXXX) for Google, the Partner ID for LinkedIn, or the site ID for others. Leave blank if only using Tag Manager. The LinkedIn tag loads only for visitors who allow marketing cookies; do not also add it through a tag manager.",
|
|
102
|
+
condition: (_data, siblingData) => ["google", "matomo", "plausible", "fathom", "umami", "posthog", "linkedin"].includes(
|
|
98
103
|
siblingData?.provider
|
|
99
104
|
)
|
|
100
105
|
}
|
|
@@ -137,28 +142,10 @@ var AnalyticsIntegrations = {
|
|
|
137
142
|
}
|
|
138
143
|
},
|
|
139
144
|
// ── Relationships ───────────────────────────────────────────
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
required: true,
|
|
145
|
-
index: true,
|
|
146
|
-
admin: { description: "The site this integration applies to" },
|
|
147
|
-
// The value of `site` is decided by who is writing, not by what they submitted. Without this an editor could plant a `customScript` (rendered raw
|
|
148
|
-
// on every page) under another tenant's site: a cross-tenant stored-XSS path.
|
|
149
|
-
hooks: { beforeValidate: [tenancy.pinSite] }
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
name: "organization",
|
|
153
|
-
type: "relationship",
|
|
154
|
-
relationTo: "organizations",
|
|
155
|
-
required: true,
|
|
156
|
-
index: true,
|
|
157
|
-
admin: { readOnly: true, description: "Set from the site: a site belongs to exactly one organization." },
|
|
158
|
-
// Skipped on create (the hook sets it), so a read-only required field does not block the form.
|
|
159
|
-
validate: (value, { operation }) => operation === "create" || value != null ? true : "This field is required.",
|
|
160
|
-
hooks: { beforeValidate: [tenancy.pinOrganization] }
|
|
161
|
-
},
|
|
145
|
+
// `site` and `organization`. The value of `site` is decided by who is writing, not by what they submitted: without that an editor could plant a
|
|
146
|
+
// `customScript` (rendered raw on every page) under another tenant's site, a cross-tenant stored-XSS path. The organization is the site's, so the
|
|
147
|
+
// platform owner, who has none of their own, gets it from the site chosen.
|
|
148
|
+
...tenantFields,
|
|
162
149
|
{
|
|
163
150
|
name: "isActive",
|
|
164
151
|
type: "checkbox",
|
|
@@ -173,10 +160,20 @@ import { definePluginManifest } from "opscms-sdk";
|
|
|
173
160
|
var analyticsManifest = definePluginManifest({
|
|
174
161
|
key: "analytics",
|
|
175
162
|
name: "Analytics & Insights",
|
|
176
|
-
description: "Analytics integrations per site: Google (GA4 and Tag Manager), Matomo, Plausible, Fathom, Umami, PostHog or a custom script; server-side GA4 events; and the marketing dashboard. (Meta Pixel belongs to the Meta plugin.)",
|
|
163
|
+
description: "Analytics integrations per site: Google (GA4 and Tag Manager), LinkedIn Insight Tag, Matomo, Plausible, Fathom, Umami, PostHog or a custom script; server-side GA4 events; and the marketing dashboard. (Meta Pixel belongs to the Meta plugin.)",
|
|
177
164
|
category: "analytics",
|
|
178
165
|
icon: "icon.svg",
|
|
179
166
|
releases: [
|
|
167
|
+
{
|
|
168
|
+
version: "1.0.5",
|
|
169
|
+
date: "2026-11-30",
|
|
170
|
+
notes: ["Saving a new entry as the platform owner failed: the organization, which the form does not let anyone pick, was left empty. It now comes from the chosen site."]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
version: "1.0.4",
|
|
174
|
+
date: "2026-11-30",
|
|
175
|
+
notes: ["LinkedIn Insight Tag as a provider: a site enters its Partner ID, and the website loads the tag for visitors who allow marketing cookies, with nothing to add in a tag manager. The ID is checked when saved (a number)."]
|
|
176
|
+
},
|
|
180
177
|
{
|
|
181
178
|
version: "1.0.3",
|
|
182
179
|
date: "2026-11-17",
|
|
@@ -317,13 +314,17 @@ var migration = sqlMigration("analytics:20261108_100000_create_integrations", {
|
|
|
317
314
|
`DROP TYPE IF EXISTS "public"."enum_analytics_integrations_provider"`
|
|
318
315
|
]
|
|
319
316
|
});
|
|
317
|
+
var linkedinProvider = sqlMigration("analytics:20261130_100000_linkedin_provider", {
|
|
318
|
+
up: [`ALTER TYPE "public"."enum_analytics_integrations_provider" ADD VALUE IF NOT EXISTS 'linkedin' BEFORE 'custom'`],
|
|
319
|
+
down: []
|
|
320
|
+
});
|
|
320
321
|
|
|
321
322
|
// src/index.ts
|
|
322
323
|
var analyticsPlugin = definePlugin({
|
|
323
324
|
manifest: analyticsManifest,
|
|
324
325
|
collections: [AnalyticsIntegrations],
|
|
325
326
|
workflowActions: marketingActions,
|
|
326
|
-
migrations: [migration]
|
|
327
|
+
migrations: [migration, linkedinProvider]
|
|
327
328
|
});
|
|
328
329
|
export {
|
|
329
330
|
ANALYTICS_INTEGRATIONS,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opscms-analytics-plugin",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Per-site analytics for an OpsCMS platform: each site's own Google, Matomo, Plausible, Fathom, Umami, PostHog or custom settings, and the server-side GA4 workflow action.",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "Per-site analytics for an OpsCMS platform: each site's own Google, LinkedIn, Matomo, Plausible, Fathom, Umami, PostHog or custom settings, and the server-side GA4 workflow action.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"author": "IVarse",
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"opscms-sdk": "^0.1.
|
|
44
|
+
"opscms-sdk": "^0.1.9",
|
|
45
45
|
"payload": "^3.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|