opscms-analytics-plugin 1.0.0 → 1.0.2
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/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +52 -2
- package/dist/index.mjs +48 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
The plugin's release list names 1.0.1, so the version the admin shows is the package's. No other change.
|
|
6
|
+
|
|
7
|
+
## 1.0.1
|
|
8
|
+
|
|
9
|
+
A site admin's tracking ID, Tag Manager ID and server address are checked when saved: each must have the shape a real one has, so nothing that could end a string or a tag in the inline snippet is accepted (the server address must be https, with no login in it). Empty stays allowed.
|
|
10
|
+
|
|
3
11
|
## 1.0.0
|
|
4
12
|
|
|
5
13
|
First release as a package of its own (it was part of the platform's code). Keeps a site's analytics providers in its own table,
|
package/dist/index.d.mts
CHANGED
|
@@ -33,6 +33,18 @@ declare const AnalyticsIntegrations: CollectionConfig;
|
|
|
33
33
|
|
|
34
34
|
declare const analyticsManifest: opscms_sdk.PluginManifest;
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* What an analytics integration's own values may look like.
|
|
38
|
+
*
|
|
39
|
+
* A site's admin types these (the customer's own script is a separate field only the platform owner can write), and they end up inside
|
|
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
|
+
* 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
|
+
*/
|
|
43
|
+
/** `true`, or the sentence that tells the person what is wrong. Empty is allowed: the field is optional. */
|
|
44
|
+
declare function trackingIdProblem(value: unknown): true | string;
|
|
45
|
+
declare function tagIdProblem(value: unknown): true | string;
|
|
46
|
+
declare function serverUrlProblem(value: unknown): true | string;
|
|
47
|
+
|
|
36
48
|
/** Resolve a field_mapping of { paramName: "{{template}}" } against the workflow context. */
|
|
37
49
|
declare function resolveParams(mapping: Record<string, unknown> | null | undefined, ctx: Record<string, unknown>): Record<string, string>;
|
|
38
50
|
/** Build the GA4 Measurement Protocol request body. Exposed for unit verification. */
|
|
@@ -57,4 +69,4 @@ declare function ga4SendHandler(ctx: WorkflowActionContext): Promise<WorkflowSte
|
|
|
57
69
|
*/
|
|
58
70
|
declare const analyticsPlugin: opscms_sdk.PlatformPlugin;
|
|
59
71
|
|
|
60
|
-
export { ANALYTICS_INTEGRATIONS, AnalyticsIntegrations, analyticsManifest, analyticsPlugin, buildGa4Body, ga4SendHandler, resolveParams };
|
|
72
|
+
export { ANALYTICS_INTEGRATIONS, AnalyticsIntegrations, analyticsManifest, analyticsPlugin, buildGa4Body, ga4SendHandler, resolveParams, serverUrlProblem, tagIdProblem, trackingIdProblem };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,18 @@ declare const AnalyticsIntegrations: CollectionConfig;
|
|
|
33
33
|
|
|
34
34
|
declare const analyticsManifest: opscms_sdk.PluginManifest;
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* What an analytics integration's own values may look like.
|
|
38
|
+
*
|
|
39
|
+
* A site's admin types these (the customer's own script is a separate field only the platform owner can write), and they end up inside
|
|
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
|
+
* 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
|
+
*/
|
|
43
|
+
/** `true`, or the sentence that tells the person what is wrong. Empty is allowed: the field is optional. */
|
|
44
|
+
declare function trackingIdProblem(value: unknown): true | string;
|
|
45
|
+
declare function tagIdProblem(value: unknown): true | string;
|
|
46
|
+
declare function serverUrlProblem(value: unknown): true | string;
|
|
47
|
+
|
|
36
48
|
/** Resolve a field_mapping of { paramName: "{{template}}" } against the workflow context. */
|
|
37
49
|
declare function resolveParams(mapping: Record<string, unknown> | null | undefined, ctx: Record<string, unknown>): Record<string, string>;
|
|
38
50
|
/** Build the GA4 Measurement Protocol request body. Exposed for unit verification. */
|
|
@@ -57,4 +69,4 @@ declare function ga4SendHandler(ctx: WorkflowActionContext): Promise<WorkflowSte
|
|
|
57
69
|
*/
|
|
58
70
|
declare const analyticsPlugin: opscms_sdk.PlatformPlugin;
|
|
59
71
|
|
|
60
|
-
export { ANALYTICS_INTEGRATIONS, AnalyticsIntegrations, analyticsManifest, analyticsPlugin, buildGa4Body, ga4SendHandler, resolveParams };
|
|
72
|
+
export { ANALYTICS_INTEGRATIONS, AnalyticsIntegrations, analyticsManifest, analyticsPlugin, buildGa4Body, ga4SendHandler, resolveParams, serverUrlProblem, tagIdProblem, trackingIdProblem };
|
package/dist/index.js
CHANGED
|
@@ -26,13 +26,43 @@ __export(index_exports, {
|
|
|
26
26
|
analyticsPlugin: () => analyticsPlugin,
|
|
27
27
|
buildGa4Body: () => buildGa4Body,
|
|
28
28
|
ga4SendHandler: () => ga4SendHandler,
|
|
29
|
-
resolveParams: () => resolveParams
|
|
29
|
+
resolveParams: () => resolveParams,
|
|
30
|
+
serverUrlProblem: () => serverUrlProblem,
|
|
31
|
+
tagIdProblem: () => tagIdProblem,
|
|
32
|
+
trackingIdProblem: () => trackingIdProblem
|
|
30
33
|
});
|
|
31
34
|
module.exports = __toCommonJS(index_exports);
|
|
32
35
|
var import_opscms_sdk5 = require("opscms-sdk");
|
|
33
36
|
|
|
34
37
|
// src/AnalyticsIntegrations.ts
|
|
35
38
|
var import_opscms_sdk = require("opscms-sdk");
|
|
39
|
+
|
|
40
|
+
// src/integrationValues.ts
|
|
41
|
+
var ID = /^[A-Za-z0-9._:/-]{1,100}$/;
|
|
42
|
+
var TAG = /^[A-Za-z0-9_-]{1,40}$/;
|
|
43
|
+
function trackingIdProblem(value) {
|
|
44
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
45
|
+
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
|
+
}
|
|
47
|
+
function tagIdProblem(value) {
|
|
48
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
49
|
+
return typeof value === "string" && TAG.test(value) ? true : "A Tag Manager container ID looks like GTM-ABC123.";
|
|
50
|
+
}
|
|
51
|
+
function serverUrlProblem(value) {
|
|
52
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
53
|
+
if (typeof value !== "string" || value.length > 300 || /[\s"'<>`\\]/.test(value)) return "That is not a web address.";
|
|
54
|
+
let url;
|
|
55
|
+
try {
|
|
56
|
+
url = new URL(value);
|
|
57
|
+
} catch {
|
|
58
|
+
return "That is not a web address (it should look like https://analytics.example.com/).";
|
|
59
|
+
}
|
|
60
|
+
if (url.protocol !== "https:") return "The address must start with https:// (a page served over https cannot load a script from plain http).";
|
|
61
|
+
if (url.username || url.password) return "The address cannot contain a username or password.";
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/AnalyticsIntegrations.ts
|
|
36
66
|
var ANALYTICS_INTEGRATIONS = "analytics-integrations";
|
|
37
67
|
var onlySuperAdminField = ({ req }) => req?.user?.role === "super-admin";
|
|
38
68
|
var AnalyticsIntegrations = {
|
|
@@ -73,6 +103,7 @@ var AnalyticsIntegrations = {
|
|
|
73
103
|
{
|
|
74
104
|
name: "trackingId",
|
|
75
105
|
type: "text",
|
|
106
|
+
validate: (value) => trackingIdProblem(value),
|
|
76
107
|
admin: {
|
|
77
108
|
description: "Measurement / tracking ID \u2014 GA4 measurement ID (G-XXXX) for Google, or site ID for others. Leave blank if only using Tag Manager.",
|
|
78
109
|
condition: (_data, siblingData) => ["google", "matomo", "plausible", "fathom", "umami", "posthog"].includes(
|
|
@@ -83,6 +114,7 @@ var AnalyticsIntegrations = {
|
|
|
83
114
|
{
|
|
84
115
|
name: "tagId",
|
|
85
116
|
type: "text",
|
|
117
|
+
validate: (value) => tagIdProblem(value),
|
|
86
118
|
admin: {
|
|
87
119
|
description: "Google Tag Manager container ID (GTM-XXXX). Leave blank if not using Tag Manager.",
|
|
88
120
|
condition: (_data, siblingData) => siblingData?.provider === "google"
|
|
@@ -99,6 +131,7 @@ var AnalyticsIntegrations = {
|
|
|
99
131
|
{
|
|
100
132
|
name: "serverUrl",
|
|
101
133
|
type: "text",
|
|
134
|
+
validate: (value) => serverUrlProblem(value),
|
|
102
135
|
admin: {
|
|
103
136
|
description: "Self-hosted instance URL (Matomo, Umami, Plausible, PostHog)",
|
|
104
137
|
condition: (_data, siblingData) => ["matomo", "plausible", "umami", "posthog"].includes(siblingData?.provider)
|
|
@@ -160,6 +193,20 @@ var analyticsManifest = (0, import_opscms_sdk2.definePluginManifest)({
|
|
|
160
193
|
category: "analytics",
|
|
161
194
|
icon: "icon.svg",
|
|
162
195
|
releases: [
|
|
196
|
+
{
|
|
197
|
+
version: "1.0.2",
|
|
198
|
+
date: "2026-11-16",
|
|
199
|
+
notes: [
|
|
200
|
+
"The version the admin shows is the package's own (this release lists the one before it)."
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
version: "1.0.1",
|
|
205
|
+
date: "2026-11-16",
|
|
206
|
+
notes: [
|
|
207
|
+
"A site admin's tracking ID, Tag Manager ID and server address are checked when saved: each must have the shape a real one has, so nothing that could end a string or a tag in the inline snippet is accepted (the server address must be https, with no login in it)."
|
|
208
|
+
]
|
|
209
|
+
},
|
|
163
210
|
{
|
|
164
211
|
version: "1.0.0",
|
|
165
212
|
date: "2026-11-05",
|
|
@@ -297,5 +344,8 @@ var analyticsPlugin = (0, import_opscms_sdk5.definePlugin)({
|
|
|
297
344
|
analyticsPlugin,
|
|
298
345
|
buildGa4Body,
|
|
299
346
|
ga4SendHandler,
|
|
300
|
-
resolveParams
|
|
347
|
+
resolveParams,
|
|
348
|
+
serverUrlProblem,
|
|
349
|
+
tagIdProblem,
|
|
350
|
+
trackingIdProblem
|
|
301
351
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,33 @@ import { definePlugin } from "opscms-sdk";
|
|
|
3
3
|
|
|
4
4
|
// src/AnalyticsIntegrations.ts
|
|
5
5
|
import { access, secretField, tenancy } from "opscms-sdk";
|
|
6
|
+
|
|
7
|
+
// src/integrationValues.ts
|
|
8
|
+
var ID = /^[A-Za-z0-9._:/-]{1,100}$/;
|
|
9
|
+
var TAG = /^[A-Za-z0-9_-]{1,40}$/;
|
|
10
|
+
function trackingIdProblem(value) {
|
|
11
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
12
|
+
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
|
+
}
|
|
14
|
+
function tagIdProblem(value) {
|
|
15
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
16
|
+
return typeof value === "string" && TAG.test(value) ? true : "A Tag Manager container ID looks like GTM-ABC123.";
|
|
17
|
+
}
|
|
18
|
+
function serverUrlProblem(value) {
|
|
19
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
20
|
+
if (typeof value !== "string" || value.length > 300 || /[\s"'<>`\\]/.test(value)) return "That is not a web address.";
|
|
21
|
+
let url;
|
|
22
|
+
try {
|
|
23
|
+
url = new URL(value);
|
|
24
|
+
} catch {
|
|
25
|
+
return "That is not a web address (it should look like https://analytics.example.com/).";
|
|
26
|
+
}
|
|
27
|
+
if (url.protocol !== "https:") return "The address must start with https:// (a page served over https cannot load a script from plain http).";
|
|
28
|
+
if (url.username || url.password) return "The address cannot contain a username or password.";
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/AnalyticsIntegrations.ts
|
|
6
33
|
var ANALYTICS_INTEGRATIONS = "analytics-integrations";
|
|
7
34
|
var onlySuperAdminField = ({ req }) => req?.user?.role === "super-admin";
|
|
8
35
|
var AnalyticsIntegrations = {
|
|
@@ -43,6 +70,7 @@ var AnalyticsIntegrations = {
|
|
|
43
70
|
{
|
|
44
71
|
name: "trackingId",
|
|
45
72
|
type: "text",
|
|
73
|
+
validate: (value) => trackingIdProblem(value),
|
|
46
74
|
admin: {
|
|
47
75
|
description: "Measurement / tracking ID \u2014 GA4 measurement ID (G-XXXX) for Google, or site ID for others. Leave blank if only using Tag Manager.",
|
|
48
76
|
condition: (_data, siblingData) => ["google", "matomo", "plausible", "fathom", "umami", "posthog"].includes(
|
|
@@ -53,6 +81,7 @@ var AnalyticsIntegrations = {
|
|
|
53
81
|
{
|
|
54
82
|
name: "tagId",
|
|
55
83
|
type: "text",
|
|
84
|
+
validate: (value) => tagIdProblem(value),
|
|
56
85
|
admin: {
|
|
57
86
|
description: "Google Tag Manager container ID (GTM-XXXX). Leave blank if not using Tag Manager.",
|
|
58
87
|
condition: (_data, siblingData) => siblingData?.provider === "google"
|
|
@@ -69,6 +98,7 @@ var AnalyticsIntegrations = {
|
|
|
69
98
|
{
|
|
70
99
|
name: "serverUrl",
|
|
71
100
|
type: "text",
|
|
101
|
+
validate: (value) => serverUrlProblem(value),
|
|
72
102
|
admin: {
|
|
73
103
|
description: "Self-hosted instance URL (Matomo, Umami, Plausible, PostHog)",
|
|
74
104
|
condition: (_data, siblingData) => ["matomo", "plausible", "umami", "posthog"].includes(siblingData?.provider)
|
|
@@ -130,6 +160,20 @@ var analyticsManifest = definePluginManifest({
|
|
|
130
160
|
category: "analytics",
|
|
131
161
|
icon: "icon.svg",
|
|
132
162
|
releases: [
|
|
163
|
+
{
|
|
164
|
+
version: "1.0.2",
|
|
165
|
+
date: "2026-11-16",
|
|
166
|
+
notes: [
|
|
167
|
+
"The version the admin shows is the package's own (this release lists the one before it)."
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
version: "1.0.1",
|
|
172
|
+
date: "2026-11-16",
|
|
173
|
+
notes: [
|
|
174
|
+
"A site admin's tracking ID, Tag Manager ID and server address are checked when saved: each must have the shape a real one has, so nothing that could end a string or a tag in the inline snippet is accepted (the server address must be https, with no login in it)."
|
|
175
|
+
]
|
|
176
|
+
},
|
|
133
177
|
{
|
|
134
178
|
version: "1.0.0",
|
|
135
179
|
date: "2026-11-05",
|
|
@@ -266,5 +310,8 @@ export {
|
|
|
266
310
|
analyticsPlugin,
|
|
267
311
|
buildGa4Body,
|
|
268
312
|
ga4SendHandler,
|
|
269
|
-
resolveParams
|
|
313
|
+
resolveParams,
|
|
314
|
+
serverUrlProblem,
|
|
315
|
+
tagIdProblem,
|
|
316
|
+
trackingIdProblem
|
|
270
317
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opscms-analytics-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
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.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|