opscms-analytics-plugin 1.0.2 → 1.0.4

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.4
4
+
5
+ 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).
6
+
7
+ ## 1.0.3
8
+
9
+ 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.
10
+
3
11
  ## 1.0.2
4
12
 
5
13
  The plugin's release list names 1.0.1, so the version the admin shows is the package's. No other 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: the field is optional. */
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: the field is optional. */
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
- function trackingIdProblem(value) {
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
  }
@@ -64,6 +68,27 @@ function serverUrlProblem(value) {
64
68
 
65
69
  // src/AnalyticsIntegrations.ts
66
70
  var ANALYTICS_INTEGRATIONS = "analytics-integrations";
71
+ function apiSecretField() {
72
+ const field = (0, import_opscms_sdk.secretField)(ANALYTICS_INTEGRATIONS, "apiSecret", {
73
+ label: "API secret",
74
+ description: "Server secret: the GA4 Measurement Protocol API secret.",
75
+ condition: (_data, siblingData) => siblingData?.provider === "google"
76
+ });
77
+ return {
78
+ ...field,
79
+ hooks: {
80
+ ...field.hooks,
81
+ afterRead: [
82
+ ({ value, req, context }) => {
83
+ if (typeof value !== "string" || !value) return value;
84
+ const asked = (req?.context ?? context)?.preventMasking === true;
85
+ if (!asked) return import_opscms_sdk.SETTINGS_MASK;
86
+ return value.startsWith("enc:") ? (0, import_opscms_sdk.platform)().secrets.decrypt(value) : value;
87
+ }
88
+ ]
89
+ }
90
+ };
91
+ }
67
92
  var onlySuperAdminField = ({ req }) => req?.user?.role === "super-admin";
68
93
  var AnalyticsIntegrations = {
69
94
  slug: ANALYTICS_INTEGRATIONS,
@@ -96,6 +121,7 @@ var AnalyticsIntegrations = {
96
121
  { label: "Fathom", value: "fathom" },
97
122
  { label: "Umami", value: "umami" },
98
123
  { label: "PostHog", value: "posthog" },
124
+ { label: "LinkedIn Insight Tag", value: "linkedin" },
99
125
  { label: "Custom", value: "custom" }
100
126
  ]
101
127
  },
@@ -103,10 +129,10 @@ var AnalyticsIntegrations = {
103
129
  {
104
130
  name: "trackingId",
105
131
  type: "text",
106
- validate: (value) => trackingIdProblem(value),
132
+ validate: (value, { siblingData }) => trackingIdProblem(value, siblingData?.provider),
107
133
  admin: {
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.",
109
- 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(
110
136
  siblingData?.provider
111
137
  )
112
138
  }
@@ -123,11 +149,7 @@ var AnalyticsIntegrations = {
123
149
  // Server-side secret: the GA4 Measurement Protocol api_secret. Encrypted at rest under the site's key and shown masked; the real value is read only by the
124
150
  // ga4-send-event workflow action, which asks for it explicitly (`context.preventMasking`). Anyone else, an anonymous request to the platform's public content
125
151
  // delivery API included, gets the mask: the field fails CLOSED.
126
- (0, import_opscms_sdk.secretField)(ANALYTICS_INTEGRATIONS, "apiSecret", {
127
- label: "API secret",
128
- description: "Server secret: the GA4 Measurement Protocol API secret.",
129
- condition: (_data, siblingData) => siblingData?.provider === "google"
130
- }),
152
+ apiSecretField(),
131
153
  {
132
154
  name: "serverUrl",
133
155
  type: "text",
@@ -189,10 +211,20 @@ var import_opscms_sdk2 = require("opscms-sdk");
189
211
  var analyticsManifest = (0, import_opscms_sdk2.definePluginManifest)({
190
212
  key: "analytics",
191
213
  name: "Analytics & Insights",
192
- 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.)",
214
+ 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.)",
193
215
  category: "analytics",
194
216
  icon: "icon.svg",
195
217
  releases: [
218
+ {
219
+ version: "1.0.4",
220
+ date: "2026-11-30",
221
+ 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)."]
222
+ },
223
+ {
224
+ version: "1.0.3",
225
+ date: "2026-11-17",
226
+ notes: ['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 "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" 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.']
227
+ },
196
228
  {
197
229
  version: "1.0.2",
198
230
  date: "2026-11-16",
@@ -328,13 +360,17 @@ var migration = (0, import_opscms_sdk4.sqlMigration)("analytics:20261108_100000_
328
360
  `DROP TYPE IF EXISTS "public"."enum_analytics_integrations_provider"`
329
361
  ]
330
362
  });
363
+ var linkedinProvider = (0, import_opscms_sdk4.sqlMigration)("analytics:20261130_100000_linkedin_provider", {
364
+ up: [`ALTER TYPE "public"."enum_analytics_integrations_provider" ADD VALUE IF NOT EXISTS 'linkedin' BEFORE 'custom'`],
365
+ down: []
366
+ });
331
367
 
332
368
  // src/index.ts
333
369
  var analyticsPlugin = (0, import_opscms_sdk5.definePlugin)({
334
370
  manifest: analyticsManifest,
335
371
  collections: [AnalyticsIntegrations],
336
372
  workflowActions: marketingActions,
337
- migrations: [migration]
373
+ migrations: [migration, linkedinProvider]
338
374
  });
339
375
  // Annotate the CommonJS export names for ESM import in node:
340
376
  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, secretField, tenancy } from "opscms-sdk";
5
+ import { access, platform, secretField, SETTINGS_MASK, tenancy } 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
- function trackingIdProblem(value) {
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
  }
@@ -31,6 +35,27 @@ function serverUrlProblem(value) {
31
35
 
32
36
  // src/AnalyticsIntegrations.ts
33
37
  var ANALYTICS_INTEGRATIONS = "analytics-integrations";
38
+ function apiSecretField() {
39
+ const field = secretField(ANALYTICS_INTEGRATIONS, "apiSecret", {
40
+ label: "API secret",
41
+ description: "Server secret: the GA4 Measurement Protocol API secret.",
42
+ condition: (_data, siblingData) => siblingData?.provider === "google"
43
+ });
44
+ return {
45
+ ...field,
46
+ hooks: {
47
+ ...field.hooks,
48
+ afterRead: [
49
+ ({ value, req, context }) => {
50
+ if (typeof value !== "string" || !value) return value;
51
+ const asked = (req?.context ?? context)?.preventMasking === true;
52
+ if (!asked) return SETTINGS_MASK;
53
+ return value.startsWith("enc:") ? platform().secrets.decrypt(value) : value;
54
+ }
55
+ ]
56
+ }
57
+ };
58
+ }
34
59
  var onlySuperAdminField = ({ req }) => req?.user?.role === "super-admin";
35
60
  var AnalyticsIntegrations = {
36
61
  slug: ANALYTICS_INTEGRATIONS,
@@ -63,6 +88,7 @@ var AnalyticsIntegrations = {
63
88
  { label: "Fathom", value: "fathom" },
64
89
  { label: "Umami", value: "umami" },
65
90
  { label: "PostHog", value: "posthog" },
91
+ { label: "LinkedIn Insight Tag", value: "linkedin" },
66
92
  { label: "Custom", value: "custom" }
67
93
  ]
68
94
  },
@@ -70,10 +96,10 @@ var AnalyticsIntegrations = {
70
96
  {
71
97
  name: "trackingId",
72
98
  type: "text",
73
- validate: (value) => trackingIdProblem(value),
99
+ validate: (value, { siblingData }) => trackingIdProblem(value, siblingData?.provider),
74
100
  admin: {
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.",
76
- 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(
77
103
  siblingData?.provider
78
104
  )
79
105
  }
@@ -90,11 +116,7 @@ var AnalyticsIntegrations = {
90
116
  // Server-side secret: the GA4 Measurement Protocol api_secret. Encrypted at rest under the site's key and shown masked; the real value is read only by the
91
117
  // ga4-send-event workflow action, which asks for it explicitly (`context.preventMasking`). Anyone else, an anonymous request to the platform's public content
92
118
  // delivery API included, gets the mask: the field fails CLOSED.
93
- secretField(ANALYTICS_INTEGRATIONS, "apiSecret", {
94
- label: "API secret",
95
- description: "Server secret: the GA4 Measurement Protocol API secret.",
96
- condition: (_data, siblingData) => siblingData?.provider === "google"
97
- }),
119
+ apiSecretField(),
98
120
  {
99
121
  name: "serverUrl",
100
122
  type: "text",
@@ -156,10 +178,20 @@ import { definePluginManifest } from "opscms-sdk";
156
178
  var analyticsManifest = definePluginManifest({
157
179
  key: "analytics",
158
180
  name: "Analytics & Insights",
159
- 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.)",
181
+ 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.)",
160
182
  category: "analytics",
161
183
  icon: "icon.svg",
162
184
  releases: [
185
+ {
186
+ version: "1.0.4",
187
+ date: "2026-11-30",
188
+ 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)."]
189
+ },
190
+ {
191
+ version: "1.0.3",
192
+ date: "2026-11-17",
193
+ notes: ['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 "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" 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.']
194
+ },
163
195
  {
164
196
  version: "1.0.2",
165
197
  date: "2026-11-16",
@@ -186,13 +218,13 @@ var analyticsManifest = definePluginManifest({
186
218
  });
187
219
 
188
220
  // src/marketingActions.ts
189
- import { platform } from "opscms-sdk";
221
+ import { platform as platform2 } from "opscms-sdk";
190
222
  var HTTP_TIMEOUT_MS = 8e3;
191
223
  function resolveParams(mapping, ctx) {
192
224
  const out = {};
193
225
  for (const [key, tpl] of Object.entries(mapping ?? {})) {
194
226
  if (typeof tpl === "string") {
195
- const resolved = platform().notifications.renderTemplate(tpl, ctx);
227
+ const resolved = platform2().notifications.renderTemplate(tpl, ctx);
196
228
  if (resolved !== void 0 && resolved !== null && resolved !== "") out[key] = String(resolved);
197
229
  }
198
230
  }
@@ -295,13 +327,17 @@ var migration = sqlMigration("analytics:20261108_100000_create_integrations", {
295
327
  `DROP TYPE IF EXISTS "public"."enum_analytics_integrations_provider"`
296
328
  ]
297
329
  });
330
+ var linkedinProvider = sqlMigration("analytics:20261130_100000_linkedin_provider", {
331
+ up: [`ALTER TYPE "public"."enum_analytics_integrations_provider" ADD VALUE IF NOT EXISTS 'linkedin' BEFORE 'custom'`],
332
+ down: []
333
+ });
298
334
 
299
335
  // src/index.ts
300
336
  var analyticsPlugin = definePlugin({
301
337
  manifest: analyticsManifest,
302
338
  collections: [AnalyticsIntegrations],
303
339
  workflowActions: marketingActions,
304
- migrations: [migration]
340
+ migrations: [migration, linkedinProvider]
305
341
  });
306
342
  export {
307
343
  ANALYTICS_INTEGRATIONS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opscms-analytics-plugin",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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",