@10x-media/analytics 1.0.0-beta.7 → 1.0.0-beta.8

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.
Files changed (256) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +8 -2
  3. package/dist/adapters/ga4/ga4.js +3 -2
  4. package/dist/adapters/ga4/ga4.js.map +1 -1
  5. package/dist/adapters/plausible/plausible.js +2 -1
  6. package/dist/adapters/plausible/plausible.js.map +1 -1
  7. package/dist/capture/slots.js +16 -5
  8. package/dist/capture/slots.js.map +1 -1
  9. package/dist/capture/trackerConfig.d.ts +1 -0
  10. package/dist/capture/trackerConfig.js +28 -3
  11. package/dist/capture/trackerConfig.js.map +1 -1
  12. package/dist/charts/BarList.d.ts +15 -1
  13. package/dist/charts/BarList.js +34 -18
  14. package/dist/charts/BarList.js.map +1 -1
  15. package/dist/charts/TrendChart.d.ts +16 -3
  16. package/dist/charts/TrendChart.js +172 -106
  17. package/dist/charts/TrendChart.js.map +1 -1
  18. package/dist/charts/bars.d.ts +2 -0
  19. package/dist/charts/bars.js +2 -1
  20. package/dist/charts/bars.js.map +1 -1
  21. package/dist/charts/bucket.js +10 -1
  22. package/dist/charts/bucket.js.map +1 -1
  23. package/dist/charts/spline.js +2 -2
  24. package/dist/charts/spline.js.map +1 -1
  25. package/dist/charts/styles.js +18 -1
  26. package/dist/charts/styles.js.map +1 -1
  27. package/dist/core/cacheKey.js +13 -1
  28. package/dist/core/cacheKey.js.map +1 -1
  29. package/dist/core/contract.d.ts +14 -7
  30. package/dist/core/contract.js +29 -1
  31. package/dist/core/contract.js.map +1 -1
  32. package/dist/core/granularity.js +1 -1
  33. package/dist/core/options.d.ts +54 -5
  34. package/dist/core/options.js +59 -2
  35. package/dist/core/options.js.map +1 -1
  36. package/dist/core/scopedRead.js +33 -23
  37. package/dist/core/scopedRead.js.map +1 -1
  38. package/dist/core/serverEvent.d.ts +42 -0
  39. package/dist/core/serverEvent.js +12 -0
  40. package/dist/core/serverEvent.js.map +1 -0
  41. package/dist/exports/client.d.ts +8 -2
  42. package/dist/exports/client.js +6 -1
  43. package/dist/exports/rsc.d.ts +5 -1
  44. package/dist/exports/rsc.js +6 -3
  45. package/dist/exports/types.d.ts +12 -4
  46. package/dist/exports/types.js +2 -2
  47. package/dist/fields/AnalyticsPanelClient.js +1 -1
  48. package/dist/fields/AnalyticsPanelField.js +1 -1
  49. package/dist/fields/AnalyticsStatField.js +2 -2
  50. package/dist/fields/config/MetricSelectField.js +2 -2
  51. package/dist/fields/config/MetricSelectField.js.map +1 -1
  52. package/dist/fields/config/SourceSelectField.js +2 -2
  53. package/dist/fields/config/SourceSelectField.js.map +1 -1
  54. package/dist/fields/config/fetchSources.d.ts +5 -1
  55. package/dist/fields/readForDocument.d.ts +5 -0
  56. package/dist/fields/readForDocument.js +5 -5
  57. package/dist/fields/readForDocument.js.map +1 -1
  58. package/dist/goals/GoalSelectField.d.ts +7 -0
  59. package/dist/goals/GoalSelectField.js +77 -0
  60. package/dist/goals/GoalSelectField.js.map +1 -0
  61. package/dist/goals/collection.js +250 -0
  62. package/dist/goals/collection.js.map +1 -0
  63. package/dist/goals/currency.js +14 -0
  64. package/dist/goals/currency.js.map +1 -0
  65. package/dist/goals/fetchGoals.d.ts +18 -0
  66. package/dist/goals/fetchGoals.js +29 -0
  67. package/dist/goals/fetchGoals.js.map +1 -0
  68. package/dist/goals/goalField.d.ts +31 -0
  69. package/dist/goals/goalField.js +56 -0
  70. package/dist/goals/goalField.js.map +1 -0
  71. package/dist/goals/goalsEndpoint.d.ts +1 -0
  72. package/dist/goals/goalsEndpoint.js +55 -0
  73. package/dist/goals/goalsEndpoint.js.map +1 -0
  74. package/dist/goals/resolver.d.ts +8 -0
  75. package/dist/goals/resolver.js +147 -0
  76. package/dist/goals/resolver.js.map +1 -0
  77. package/dist/goals/trackGoalAction.d.ts +74 -0
  78. package/dist/goals/trackGoalAction.js +139 -0
  79. package/dist/goals/trackGoalAction.js.map +1 -0
  80. package/dist/goals/useAnalyticsGoals.d.ts +20 -0
  81. package/dist/goals/useAnalyticsGoals.js +67 -0
  82. package/dist/goals/useAnalyticsGoals.js.map +1 -0
  83. package/dist/index.d.ts +10 -3
  84. package/dist/index.js +74 -11
  85. package/dist/index.js.map +1 -1
  86. package/dist/native/ingest/device.js +11 -3
  87. package/dist/native/ingest/device.js.map +1 -1
  88. package/dist/native/ingest/endpoint.d.ts +1 -0
  89. package/dist/native/ingest/endpoint.js +2 -17
  90. package/dist/native/ingest/endpoint.js.map +1 -1
  91. package/dist/native/ingest/normalizeEvent.d.ts +20 -0
  92. package/dist/native/ingest/normalizeEvent.js +3 -2
  93. package/dist/native/ingest/normalizeEvent.js.map +1 -1
  94. package/dist/native/ingest/serverTrack.d.ts +20 -0
  95. package/dist/native/ingest/serverTrack.js +99 -0
  96. package/dist/native/ingest/serverTrack.js.map +1 -0
  97. package/dist/native/ingest/validate.js +27 -0
  98. package/dist/native/ingest/validate.js.map +1 -0
  99. package/dist/native/nativeAdapter.d.ts +1 -1
  100. package/dist/native/nativeAdapter.js +21 -10
  101. package/dist/native/nativeAdapter.js.map +1 -1
  102. package/dist/native/retention/pruneTask.js +1 -1
  103. package/dist/native/rollups/insertIfNew.js +36 -2
  104. package/dist/native/rollups/insertIfNew.js.map +1 -1
  105. package/dist/plugin/documentEndpoint.js +27 -9
  106. package/dist/plugin/documentEndpoint.js.map +1 -1
  107. package/dist/plugin/paths.js +5 -1
  108. package/dist/plugin/paths.js.map +1 -1
  109. package/dist/plugin/queryEndpoint.js +113 -0
  110. package/dist/plugin/queryEndpoint.js.map +1 -0
  111. package/dist/plugin/readContextForRequest.js +71 -0
  112. package/dist/plugin/readContextForRequest.js.map +1 -0
  113. package/dist/plugin/realtimeEndpoint.js +6 -3
  114. package/dist/plugin/realtimeEndpoint.js.map +1 -1
  115. package/dist/plugin/runtime.js +31 -1
  116. package/dist/plugin/runtime.js.map +1 -1
  117. package/dist/plugin/scopeFieldBoot.js +22 -0
  118. package/dist/plugin/scopeFieldBoot.js.map +1 -0
  119. package/dist/plugin/sourcesEndpoint.js +13 -51
  120. package/dist/plugin/sourcesEndpoint.js.map +1 -1
  121. package/dist/plugin/warmTask.js +0 -0
  122. package/dist/plugin/warmTask.js.map +1 -1
  123. package/dist/providers/collection.js +15 -9
  124. package/dist/providers/collection.js.map +1 -1
  125. package/dist/providers/resolver.js.map +1 -1
  126. package/dist/query/dates.js +64 -0
  127. package/dist/query/dates.js.map +1 -0
  128. package/dist/query/errors.d.ts +17 -0
  129. package/dist/query/errors.js +10 -0
  130. package/dist/query/errors.js.map +1 -0
  131. package/dist/query/fetchQuery.d.ts +59 -0
  132. package/dist/query/fetchQuery.js +110 -0
  133. package/dist/query/fetchQuery.js.map +1 -0
  134. package/dist/query/parse.d.ts +22 -0
  135. package/dist/query/parse.js +168 -0
  136. package/dist/query/parse.js.map +1 -0
  137. package/dist/query/response.d.ts +36 -0
  138. package/dist/timeframe/tz.js +17 -6
  139. package/dist/timeframe/tz.js.map +1 -1
  140. package/dist/translations/ar.js +98 -1
  141. package/dist/translations/ar.js.map +1 -1
  142. package/dist/translations/de.js +98 -1
  143. package/dist/translations/de.js.map +1 -1
  144. package/dist/translations/en.js +98 -1
  145. package/dist/translations/en.js.map +1 -1
  146. package/dist/translations/es.js +98 -1
  147. package/dist/translations/es.js.map +1 -1
  148. package/dist/translations/fr.js +98 -1
  149. package/dist/translations/fr.js.map +1 -1
  150. package/dist/translations/id.js +98 -1
  151. package/dist/translations/id.js.map +1 -1
  152. package/dist/translations/keys.d.ts +97 -0
  153. package/dist/translations/keys.js +98 -1
  154. package/dist/translations/keys.js.map +1 -1
  155. package/dist/translations/ko.js +98 -1
  156. package/dist/translations/ko.js.map +1 -1
  157. package/dist/translations/metricKeys.js +1 -1
  158. package/dist/translations/metricKeys.js.map +1 -1
  159. package/dist/translations/pt.js +98 -1
  160. package/dist/translations/pt.js.map +1 -1
  161. package/dist/translations/ru.js +98 -1
  162. package/dist/translations/ru.js.map +1 -1
  163. package/dist/translations/uk.js +98 -1
  164. package/dist/translations/uk.js.map +1 -1
  165. package/dist/translations/zh.js +98 -1
  166. package/dist/translations/zh.js.map +1 -1
  167. package/dist/view/AnalyticsNavLink.d.ts +19 -0
  168. package/dist/view/AnalyticsNavLink.js +40 -0
  169. package/dist/view/AnalyticsNavLink.js.map +1 -0
  170. package/dist/view/AnalyticsView.d.ts +23 -0
  171. package/dist/view/AnalyticsView.js +45 -0
  172. package/dist/view/AnalyticsView.js.map +1 -0
  173. package/dist/view/AnalyticsViewClient.d.ts +15 -0
  174. package/dist/view/AnalyticsViewClient.js +189 -0
  175. package/dist/view/AnalyticsViewClient.js.map +1 -0
  176. package/dist/view/authRedirect.js +32 -0
  177. package/dist/view/authRedirect.js.map +1 -0
  178. package/dist/view/conversionRate.js +18 -0
  179. package/dist/view/conversionRate.js.map +1 -0
  180. package/dist/view/dayRange.js +68 -0
  181. package/dist/view/dayRange.js.map +1 -0
  182. package/dist/view/gating.d.ts +1 -0
  183. package/dist/view/gating.js +105 -0
  184. package/dist/view/gating.js.map +1 -0
  185. package/dist/view/labels.js +44 -0
  186. package/dist/view/labels.js.map +1 -0
  187. package/dist/view/registerView.js +48 -0
  188. package/dist/view/registerView.js.map +1 -0
  189. package/dist/view/sections/Breakdowns.js +157 -0
  190. package/dist/view/sections/Breakdowns.js.map +1 -0
  191. package/dist/view/sections/EmptyStates.js +92 -0
  192. package/dist/view/sections/EmptyStates.js.map +1 -0
  193. package/dist/view/sections/FilterChips.js +41 -0
  194. package/dist/view/sections/FilterChips.js.map +1 -0
  195. package/dist/view/sections/GoalsPanel.js +81 -0
  196. package/dist/view/sections/GoalsPanel.js.map +1 -0
  197. package/dist/view/sections/OverviewCards.js +65 -0
  198. package/dist/view/sections/OverviewCards.js.map +1 -0
  199. package/dist/view/sections/RealtimeStrip.js +77 -0
  200. package/dist/view/sections/RealtimeStrip.js.map +1 -0
  201. package/dist/view/sections/Toolbar.js +179 -0
  202. package/dist/view/sections/Toolbar.js.map +1 -0
  203. package/dist/view/sections/Trend.js +119 -0
  204. package/dist/view/sections/Trend.js.map +1 -0
  205. package/dist/view/sections/styles.js +74 -0
  206. package/dist/view/sections/styles.js.map +1 -0
  207. package/dist/view/state.js +206 -0
  208. package/dist/view/state.js.map +1 -0
  209. package/dist/view/useViewQueries.js +150 -0
  210. package/dist/view/useViewQueries.js.map +1 -0
  211. package/dist/view/viewProps.d.ts +40 -0
  212. package/dist/view/viewProps.js +90 -0
  213. package/dist/view/viewProps.js.map +1 -0
  214. package/dist/widgets/AnalyticsBreakdownWidget.d.ts +2 -1
  215. package/dist/widgets/AnalyticsBreakdownWidget.js +22 -4
  216. package/dist/widgets/AnalyticsBreakdownWidget.js.map +1 -1
  217. package/dist/widgets/AnalyticsGoalsWidget.d.ts +14 -0
  218. package/dist/widgets/AnalyticsGoalsWidget.js +188 -0
  219. package/dist/widgets/AnalyticsGoalsWidget.js.map +1 -0
  220. package/dist/widgets/AnalyticsMetricWidget.d.ts +2 -1
  221. package/dist/widgets/AnalyticsMetricWidget.js +35 -12
  222. package/dist/widgets/AnalyticsMetricWidget.js.map +1 -1
  223. package/dist/widgets/AnalyticsRealtimeWidget.d.ts +2 -1
  224. package/dist/widgets/AnalyticsRealtimeWidget.js +42 -22
  225. package/dist/widgets/AnalyticsRealtimeWidget.js.map +1 -1
  226. package/dist/widgets/AnalyticsTrendWidget.d.ts +2 -1
  227. package/dist/widgets/AnalyticsTrendWidget.js +51 -15
  228. package/dist/widgets/AnalyticsTrendWidget.js.map +1 -1
  229. package/dist/widgets/WidgetViewLink.js +17 -0
  230. package/dist/widgets/WidgetViewLink.js.map +1 -0
  231. package/dist/widgets/breakdownTypes.js +28 -1
  232. package/dist/widgets/breakdownTypes.js.map +1 -1
  233. package/dist/widgets/cardChrome.js +31 -7
  234. package/dist/widgets/cardChrome.js.map +1 -1
  235. package/dist/widgets/range.js +43 -12
  236. package/dist/widgets/range.js.map +1 -1
  237. package/dist/widgets/readForWidget.d.ts +12 -0
  238. package/dist/widgets/readForWidget.js +6 -5
  239. package/dist/widgets/readForWidget.js.map +1 -1
  240. package/dist/widgets/readForWidgetBreakdown.d.ts +15 -0
  241. package/dist/widgets/readForWidgetBreakdown.js +10 -7
  242. package/dist/widgets/readForWidgetBreakdown.js.map +1 -1
  243. package/dist/widgets/readForWidgetGoals.d.ts +57 -0
  244. package/dist/widgets/readForWidgetGoals.js +126 -0
  245. package/dist/widgets/readForWidgetGoals.js.map +1 -0
  246. package/dist/widgets/readForWidgetSeries.d.ts +13 -0
  247. package/dist/widgets/readForWidgetSeries.js +30 -12
  248. package/dist/widgets/readForWidgetSeries.js.map +1 -1
  249. package/dist/widgets/registerWidgets.js +49 -6
  250. package/dist/widgets/registerWidgets.js.map +1 -1
  251. package/dist/widgets/types.js +12 -1
  252. package/dist/widgets/types.js.map +1 -1
  253. package/dist/widgets/viewLink.d.ts +22 -0
  254. package/dist/widgets/viewLink.js +83 -0
  255. package/dist/widgets/viewLink.js.map +1 -0
  256. package/package.json +9 -4
@@ -0,0 +1,147 @@
1
+ import { GOAL_SLUG_PATTERN } from "./types.js";
2
+ /**
3
+ * A scoped install stores install-wide goals with no scope at all, so a null scope has to
4
+ * match both an absent field and an empty string (same shape the providers lookup uses).
5
+ * The empty string is not castable on a relationship-typed `scopeField`, so install-wide
6
+ * lookups on a host-owned relationship field fail the read and resolve config goals only.
7
+ */
8
+ const goalScopeWhere = (scopeField, scope) => scope === null ? { or: [{ [scopeField]: { equals: null } }, { [scopeField]: { equals: "" } }] } : { [scopeField]: { equals: scope } };
9
+ const text = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
10
+ const object = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
11
+ const docToMatch = (value) => {
12
+ const raw = object(value);
13
+ switch (raw?.kind) {
14
+ case "goal": return { kind: "goal" };
15
+ case "event": {
16
+ const name = text(raw.name);
17
+ return name ? {
18
+ kind: "event",
19
+ name
20
+ } : null;
21
+ }
22
+ case "path": {
23
+ const pattern = text(raw.pattern);
24
+ return pattern ? {
25
+ kind: "path",
26
+ pattern
27
+ } : null;
28
+ }
29
+ default: return null;
30
+ }
31
+ };
32
+ /**
33
+ * One goal document as the matcher sees it, or null when the document cannot produce a
34
+ * usable goal. Editors can save a half-filled draft, so a document missing the part its
35
+ * match kind needs is skipped rather than allowed to match everything or nothing.
36
+ */
37
+ const docToGoal = (doc) => {
38
+ if (doc.enabled === false) return null;
39
+ const slug = text(doc.slug);
40
+ if (!slug || !GOAL_SLUG_PATTERN.test(slug)) return null;
41
+ const match = docToMatch(doc.match);
42
+ if (!match) return null;
43
+ const raw = object(doc.value);
44
+ const fixed = raw?.fixed;
45
+ if (fixed !== null && fixed !== void 0) {
46
+ if (typeof fixed !== "number" || !Number.isFinite(fixed) || fixed < 0) return null;
47
+ }
48
+ const prop = text(raw?.prop);
49
+ const value = typeof fixed === "number" || prop ? {
50
+ ...typeof fixed === "number" ? { fixed } : {},
51
+ ...prop ? { prop } : {}
52
+ } : void 0;
53
+ const currency = text(doc.currency);
54
+ return {
55
+ slug,
56
+ name: text(doc.name) ?? slug,
57
+ match,
58
+ ...value ? { value } : {},
59
+ ...currency ? { currency } : {}
60
+ };
61
+ };
62
+ const mergeDetailed = (config, collection) => {
63
+ const bySlug = /* @__PURE__ */ new Map();
64
+ for (const goal of collection) if (!bySlug.has(goal.slug)) bySlug.set(goal.slug, goal);
65
+ const out = [];
66
+ const taken = /* @__PURE__ */ new Set();
67
+ for (const goal of config) {
68
+ const override = bySlug.get(goal.slug);
69
+ out.push(override ? {
70
+ goal: override,
71
+ source: "collection"
72
+ } : {
73
+ goal,
74
+ source: "config"
75
+ });
76
+ taken.add(goal.slug);
77
+ }
78
+ for (const [slug, goal] of bySlug) if (!taken.has(slug)) out.push({
79
+ goal,
80
+ source: "collection"
81
+ });
82
+ return out;
83
+ };
84
+ /** The resolver an install without the goals collection gets: config goals, no reads. */
85
+ const configGoalsResolver = (config) => {
86
+ const detailed = mergeDetailed(config, []);
87
+ return {
88
+ resolve: async () => config,
89
+ resolveDetailed: async () => detailed,
90
+ invalidate: () => {}
91
+ };
92
+ };
93
+ /**
94
+ * Merges the goals collection over the config goals, cached per scope for a short TTL so
95
+ * ingest (which resolves goals on every event) does not query the collection per request.
96
+ * Invalidation clears all scopes at once: a document's scope can itself change, so evicting
97
+ * one scope could leave a stale entry under the other.
98
+ */
99
+ const createGoalsResolver = (args) => {
100
+ const ttlMs = args.ttlMs ?? 3e4;
101
+ const now = args.now ?? Date.now;
102
+ const configGoals = mergeDetailed(args.config, []);
103
+ const cache = /* @__PURE__ */ new Map();
104
+ const load = async (req, scope) => {
105
+ try {
106
+ const { docs } = await req.payload.find({
107
+ collection: args.slug,
108
+ where: args.scoped ? { and: [{ enabled: { equals: true } }, goalScopeWhere(args.scopeField, scope)] } : { enabled: { equals: true } },
109
+ limit: 500,
110
+ pagination: false,
111
+ depth: 0,
112
+ overrideAccess: true,
113
+ req
114
+ });
115
+ const goals = [];
116
+ for (const doc of docs) {
117
+ const goal = docToGoal(doc);
118
+ if (goal) goals.push(goal);
119
+ }
120
+ return mergeDetailed(args.config, goals);
121
+ } catch (err) {
122
+ req.payload.logger?.warn?.(`analytics: goals collection read failed for scope "${scope ?? ""}", falling back to config goals: ${String(err)}`);
123
+ return configGoals;
124
+ }
125
+ };
126
+ const resolveDetailed = async (req, scope) => {
127
+ const key = scope ?? "";
128
+ const at = now();
129
+ const hit = cache.get(key);
130
+ if (hit && hit.expiresAt > at) return hit.goals;
131
+ const goals = await load(req, args.scoped ? scope ?? null : null);
132
+ cache.set(key, {
133
+ goals,
134
+ expiresAt: at + ttlMs
135
+ });
136
+ return goals;
137
+ };
138
+ return {
139
+ resolve: async (req, scope) => (await resolveDetailed(req, scope)).map((entry) => entry.goal),
140
+ resolveDetailed,
141
+ invalidate: () => cache.clear()
142
+ };
143
+ };
144
+ //#endregion
145
+ export { configGoalsResolver, createGoalsResolver, goalScopeWhere };
146
+
147
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","names":[],"sources":["../../src/goals/resolver.ts"],"sourcesContent":["import type { PayloadRequest, Where } from 'payload'\nimport { GOAL_SLUG_PATTERN, type Goal, type GoalMatch } from './types'\n\nexport const GOALS_CACHE_TTL_MS = 30_000\n\n/** Where a resolved goal came from; Task 2's endpoint shows it next to the goal. */\nexport type GoalSource = 'config' | 'collection'\n\nexport interface ResolvedGoal {\n\tgoal: Goal\n\tsource: GoalSource\n}\n\nexport interface GoalsResolver {\n\tresolve: (req: PayloadRequest, scope?: string | null) => Promise<Goal[]>\n\tresolveDetailed: (req: PayloadRequest, scope?: string | null) => Promise<ResolvedGoal[]>\n\t/** Drops every cached scope; wired to the goals collection's change hooks. */\n\tinvalidate: () => void\n}\n\n/**\n * A scoped install stores install-wide goals with no scope at all, so a null scope has to\n * match both an absent field and an empty string (same shape the providers lookup uses).\n * The empty string is not castable on a relationship-typed `scopeField`, so install-wide\n * lookups on a host-owned relationship field fail the read and resolve config goals only.\n */\nexport const goalScopeWhere = (scopeField: string, scope: string | null): Where =>\n\tscope === null\n\t\t? { or: [{ [scopeField]: { equals: null } }, { [scopeField]: { equals: '' } }] }\n\t\t: { [scopeField]: { equals: scope } }\n\nconst text = (value: unknown): string | undefined =>\n\ttypeof value === 'string' && value.trim() !== '' ? value : undefined\n\nconst object = (value: unknown): Record<string, unknown> | undefined =>\n\tvalue && typeof value === 'object' && !Array.isArray(value)\n\t\t? (value as Record<string, unknown>)\n\t\t: undefined\n\nconst docToMatch = (value: unknown): GoalMatch | null => {\n\tconst raw = object(value)\n\tswitch (raw?.kind) {\n\t\tcase 'goal':\n\t\t\treturn { kind: 'goal' }\n\t\tcase 'event': {\n\t\t\tconst name = text(raw.name)\n\t\t\treturn name ? { kind: 'event', name } : null\n\t\t}\n\t\tcase 'path': {\n\t\t\tconst pattern = text(raw.pattern)\n\t\t\treturn pattern ? { kind: 'path', pattern } : null\n\t\t}\n\t\tdefault:\n\t\t\treturn null\n\t}\n}\n\n/**\n * One goal document as the matcher sees it, or null when the document cannot produce a\n * usable goal. Editors can save a half-filled draft, so a document missing the part its\n * match kind needs is skipped rather than allowed to match everything or nothing.\n */\nexport const docToGoal = (doc: Record<string, unknown>): Goal | null => {\n\tif (doc.enabled === false) {\n\t\treturn null\n\t}\n\tconst slug = text(doc.slug)\n\tif (!slug || !GOAL_SLUG_PATTERN.test(slug)) {\n\t\treturn null\n\t}\n\tconst match = docToMatch(doc.match)\n\tif (!match) {\n\t\treturn null\n\t}\n\tconst raw = object(doc.value)\n\tconst fixed = raw?.fixed\n\tif (fixed !== null && fixed !== undefined) {\n\t\tif (typeof fixed !== 'number' || !Number.isFinite(fixed) || fixed < 0) {\n\t\t\treturn null\n\t\t}\n\t}\n\tconst prop = text(raw?.prop)\n\tconst value =\n\t\ttypeof fixed === 'number' || prop\n\t\t\t? { ...(typeof fixed === 'number' ? { fixed } : {}), ...(prop ? { prop } : {}) }\n\t\t\t: undefined\n\tconst currency = text(doc.currency)\n\treturn {\n\t\tslug,\n\t\tname: text(doc.name) ?? slug,\n\t\tmatch,\n\t\t...(value ? { value } : {}),\n\t\t...(currency ? { currency } : {}),\n\t}\n}\n\nconst mergeDetailed = (config: Goal[], collection: Goal[]): ResolvedGoal[] => {\n\tconst bySlug = new Map<string, Goal>()\n\tfor (const goal of collection) {\n\t\tif (!bySlug.has(goal.slug)) {\n\t\t\tbySlug.set(goal.slug, goal)\n\t\t}\n\t}\n\tconst out: ResolvedGoal[] = []\n\tconst taken = new Set<string>()\n\tfor (const goal of config) {\n\t\tconst override = bySlug.get(goal.slug)\n\t\tout.push(override ? { goal: override, source: 'collection' } : { goal, source: 'config' })\n\t\ttaken.add(goal.slug)\n\t}\n\tfor (const [slug, goal] of bySlug) {\n\t\tif (!taken.has(slug)) {\n\t\t\tout.push({ goal, source: 'collection' })\n\t\t}\n\t}\n\treturn out\n}\n\n/**\n * Config order first, with a collection goal replacing the config goal of the same slug in\n * place, then the collection's own extras. Editors adjust what config declared without\n * reordering the reports built on it.\n */\nexport const mergeGoals = (config: Goal[], collection: Goal[]): Goal[] =>\n\tmergeDetailed(config, collection).map((entry) => entry.goal)\n\n/** The resolver an install without the goals collection gets: config goals, no reads. */\nexport const configGoalsResolver = (config: Goal[]): GoalsResolver => {\n\tconst detailed = mergeDetailed(config, [])\n\treturn {\n\t\tresolve: async () => config,\n\t\tresolveDetailed: async () => detailed,\n\t\tinvalidate: () => {},\n\t}\n}\n\nexport interface CreateGoalsResolverArgs {\n\tslug: string\n\tscopeField: string\n\t/** True when the install configured a scopeResolver; unscoped installs ignore scope. */\n\tscoped: boolean\n\tconfig: Goal[]\n\tttlMs?: number\n\tnow?: () => number\n}\n\n/**\n * Merges the goals collection over the config goals, cached per scope for a short TTL so\n * ingest (which resolves goals on every event) does not query the collection per request.\n * Invalidation clears all scopes at once: a document's scope can itself change, so evicting\n * one scope could leave a stale entry under the other.\n */\nexport const createGoalsResolver = (args: CreateGoalsResolverArgs): GoalsResolver => {\n\tconst ttlMs = args.ttlMs ?? GOALS_CACHE_TTL_MS\n\tconst now = args.now ?? Date.now\n\tconst configGoals = mergeDetailed(args.config, [])\n\tconst cache = new Map<string, { goals: ResolvedGoal[]; expiresAt: number }>()\n\n\tconst load = async (req: PayloadRequest, scope: string | null): Promise<ResolvedGoal[]> => {\n\t\ttry {\n\t\t\tconst { docs } = await req.payload.find({\n\t\t\t\tcollection: args.slug as never,\n\t\t\t\twhere: args.scoped\n\t\t\t\t\t? { and: [{ enabled: { equals: true } }, goalScopeWhere(args.scopeField, scope)] }\n\t\t\t\t\t: { enabled: { equals: true } },\n\t\t\t\tlimit: 500,\n\t\t\t\tpagination: false,\n\t\t\t\tdepth: 0,\n\t\t\t\toverrideAccess: true,\n\t\t\t\treq,\n\t\t\t})\n\t\t\tconst goals: Goal[] = []\n\t\t\tfor (const doc of docs as unknown as Array<Record<string, unknown>>) {\n\t\t\t\tconst goal = docToGoal(doc)\n\t\t\t\tif (goal) {\n\t\t\t\t\tgoals.push(goal)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mergeDetailed(args.config, goals)\n\t\t} catch (err) {\n\t\t\t// Goal matching must not take ingest down with the collection: config goals still\n\t\t\t// match, and the failed result is cached so a broken read is not retried per event.\n\t\t\treq.payload.logger?.warn?.(\n\t\t\t\t`analytics: goals collection read failed for scope \"${scope ?? ''}\", falling back to config goals: ${String(err)}`\n\t\t\t)\n\t\t\treturn configGoals\n\t\t}\n\t}\n\n\tconst resolveDetailed = async (\n\t\treq: PayloadRequest,\n\t\tscope?: string | null\n\t): Promise<ResolvedGoal[]> => {\n\t\tconst key = scope ?? ''\n\t\tconst at = now()\n\t\tconst hit = cache.get(key)\n\t\tif (hit && hit.expiresAt > at) {\n\t\t\treturn hit.goals\n\t\t}\n\t\tconst goals = await load(req, args.scoped ? (scope ?? null) : null)\n\t\tcache.set(key, { goals, expiresAt: at + ttlMs })\n\t\treturn goals\n\t}\n\n\treturn {\n\t\tresolve: async (req, scope) => (await resolveDetailed(req, scope)).map((entry) => entry.goal),\n\t\tresolveDetailed,\n\t\tinvalidate: () => cache.clear(),\n\t}\n}\n"],"mappings":"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"}
@@ -0,0 +1,74 @@
1
+ import { Field, Payload, PayloadRequest } from "payload";
2
+
3
+ //#region src/goals/trackGoalAction.d.ts
4
+ /** The action type form-builder stores as the block slug on a form's `actions` array. */
5
+ declare const GOAL_ACTION_TYPE = "analyticsGoal";
6
+ /**
7
+ * The run context form-builder hands a post-submit action, narrowed to what goal tracking
8
+ * reads. A structural subset rather than an import: analytics never depends on form-builder
9
+ * at runtime, so an install without it still resolves this module.
10
+ */
11
+ interface GoalActionRunArgs {
12
+ form: {
13
+ id: number | string;
14
+ title?: string;
15
+ };
16
+ submissionId: number | string;
17
+ /** One entry per answered field, keyed by the field's machine name. */
18
+ values: Array<{
19
+ field: string;
20
+ value: unknown;
21
+ }>;
22
+ config: Record<string, unknown>;
23
+ payload: Payload;
24
+ /**
25
+ * The request the action runs under. On a queued dispatch this is the job runner's own
26
+ * request, not the visitor's, so it carries neither the submitting host nor the tenant.
27
+ */
28
+ req?: PayloadRequest;
29
+ }
30
+ /**
31
+ * Structural counterpart of form-builder's `ActionDefinition<Record<string, unknown>>`; a
32
+ * value of this type is assignable to it, which `trackGoalAction.test.ts` pins.
33
+ */
34
+ interface GoalActionDefinition {
35
+ type: typeof GOAL_ACTION_TYPE;
36
+ label: string | Record<string, string>;
37
+ config: Field[];
38
+ run: (args: GoalActionRunArgs) => Promise<void>;
39
+ }
40
+ interface TrackGoalActionOptions {
41
+ /**
42
+ * Site the completion belongs to. Falls back to the submitting request's host, then to
43
+ * the host of `serverURL`. Set it whenever a jobs runner queues actions: the runner's
44
+ * request carries the CMS host at best, and often no host at all.
45
+ */
46
+ hostname?: string | ((args: GoalActionRunArgs) => string);
47
+ /** Page the completion is attributed to. Defaults to `/forms/<form id>`. */
48
+ path?: string | ((args: GoalActionRunArgs) => string);
49
+ /**
50
+ * Analytics boundary to stamp; `null` is install-wide. Leave unset and the scope resolves
51
+ * from the action's request, which on a queued dispatch is the runner's rather than the
52
+ * submitter's and so usually lands install-wide. Set it on any scoped install whose
53
+ * actions are queued, since the submitter's tenant cannot be recovered there.
54
+ */
55
+ scope?: string | null | ((args: GoalActionRunArgs) => string | null | Promise<string | null>);
56
+ }
57
+ /**
58
+ * A form-builder post-submit action that completes an analytics goal, authored per form in
59
+ * the admin: pick the goal, optionally a revenue value (fixed, or read from a submission
60
+ * field) and its currency. Register it through form-builder's `actions` option under
61
+ * {@link GOAL_ACTION_TYPE}.
62
+ *
63
+ * Needs the native adapter, since it records through {@link trackServerEvent}. `essential`
64
+ * is deliberately unset: a goal is a measurement, so a failed write is logged and the
65
+ * submission still succeeds.
66
+ *
67
+ * On any install with a jobs runner, form-builder queues non-essential actions, and the
68
+ * queued run carries the runner's request rather than the visitor's. Set `hostname` (and
69
+ * `scope`, on a scoped install) there, since neither can be recovered from that request.
70
+ */
71
+ declare const trackGoalAction: (options?: TrackGoalActionOptions) => GoalActionDefinition;
72
+ //#endregion
73
+ export { GOAL_ACTION_TYPE, GoalActionDefinition, GoalActionRunArgs, TrackGoalActionOptions, trackGoalAction };
74
+ //# sourceMappingURL=trackGoalAction.d.ts.map
@@ -0,0 +1,139 @@
1
+ import { keys } from "../translations/keys.js";
2
+ import { labelForKey } from "../translations/server.js";
3
+ import { validateCurrency } from "./currency.js";
4
+ import { AnalyticsTrackError } from "../core/serverEvent.js";
5
+ import { trackServerEvent } from "../native/ingest/serverTrack.js";
6
+ import { goalField, goalSlug } from "./goalField.js";
7
+ //#region src/goals/trackGoalAction.ts
8
+ /** The action type form-builder stores as the block slug on a form's `actions` array. */
9
+ const GOAL_ACTION_TYPE = "analyticsGoal";
10
+ const configFields = () => [
11
+ goalField({
12
+ name: "goal",
13
+ required: true
14
+ }),
15
+ {
16
+ name: "value",
17
+ type: "number",
18
+ min: 0,
19
+ label: labelForKey(keys.goalFieldValue)
20
+ },
21
+ {
22
+ name: "valueFrom",
23
+ type: "text",
24
+ label: labelForKey(keys.actionGoalFieldValueFrom),
25
+ admin: { description: labelForKey(keys.actionGoalFieldValueFromHelp) }
26
+ },
27
+ {
28
+ name: "currency",
29
+ type: "text",
30
+ label: labelForKey(keys.goalFieldCurrency),
31
+ validate: validateCurrency
32
+ }
33
+ ];
34
+ const finiteNumber = (value) => {
35
+ if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
36
+ if (typeof value === "string" && value.trim() !== "") {
37
+ const parsed = Number(value);
38
+ return Number.isFinite(parsed) ? parsed : void 0;
39
+ }
40
+ };
41
+ const nonEmpty = (value) => {
42
+ if (typeof value !== "string") return;
43
+ const trimmed = value.trim();
44
+ return trimmed === "" ? void 0 : trimmed;
45
+ };
46
+ const fromOption = (option, args) => nonEmpty(typeof option === "function" ? option(args) : option ?? void 0);
47
+ /**
48
+ * The host out of a `Host` header. An IPv6 literal keeps its brackets, which is what the URL
49
+ * spec and every other hostname in the pipeline use; only a bracketed or single-colon host
50
+ * can carry a port, so a bare `::1` is left whole rather than truncated at its last colon.
51
+ */
52
+ const stripPort = (host) => {
53
+ const bracketed = /^(\[[^\]]+\])(?::\d+)?$/.exec(host);
54
+ if (bracketed?.[1]) return bracketed[1];
55
+ if (host.indexOf(":") !== host.lastIndexOf(":")) return host;
56
+ return host.replace(/:\d+$/, "");
57
+ };
58
+ const serverUrlHost = (payload) => {
59
+ const serverURL = nonEmpty(payload.config?.serverURL);
60
+ if (!serverURL) return;
61
+ try {
62
+ return nonEmpty(new URL(serverURL).hostname);
63
+ } catch {
64
+ return;
65
+ }
66
+ };
67
+ /**
68
+ * The option, then the submitting request, then the install's own `serverURL`. The queued
69
+ * dispatch path reaches the last two with the runner's request, so an install that queues
70
+ * actions and serves more than one site has to say which site in the option.
71
+ */
72
+ const hostnameFor = (options, args) => {
73
+ const configured = fromOption(options.hostname, args);
74
+ if (configured) return configured.toLowerCase();
75
+ const header = nonEmpty(args.req?.headers.get("host"));
76
+ const fromHeader = header ? nonEmpty(stripPort(header)) : void 0;
77
+ if (fromHeader) return fromHeader.toLowerCase();
78
+ const fromServerUrl = serverUrlHost(args.payload);
79
+ if (fromServerUrl) return fromServerUrl.toLowerCase();
80
+ throw new AnalyticsTrackError("analytics: trackGoalAction could not resolve a hostname; set the `hostname` option, or configure `serverURL`, since a queued run has no submitting request");
81
+ };
82
+ /** The fixed value wins; otherwise the named answer, and only when it reads as a number. */
83
+ const valueFor = (args) => {
84
+ const fixed = finiteNumber(args.config.value);
85
+ if (fixed !== void 0) return fixed;
86
+ const field = nonEmpty(args.config.valueFrom);
87
+ if (!field) return;
88
+ return finiteNumber(args.values.find((entry) => entry.field === field)?.value);
89
+ };
90
+ const propsFor = (args) => {
91
+ const props = {
92
+ formId: String(args.form.id),
93
+ submissionId: String(args.submissionId)
94
+ };
95
+ const title = nonEmpty(args.form.title);
96
+ if (title) props.formTitle = title;
97
+ return props;
98
+ };
99
+ const scopeFor = async (options, args) => {
100
+ if (options.scope === void 0) return {};
101
+ return { scope: typeof options.scope === "function" ? await options.scope(args) : options.scope };
102
+ };
103
+ /**
104
+ * A form-builder post-submit action that completes an analytics goal, authored per form in
105
+ * the admin: pick the goal, optionally a revenue value (fixed, or read from a submission
106
+ * field) and its currency. Register it through form-builder's `actions` option under
107
+ * {@link GOAL_ACTION_TYPE}.
108
+ *
109
+ * Needs the native adapter, since it records through {@link trackServerEvent}. `essential`
110
+ * is deliberately unset: a goal is a measurement, so a failed write is logged and the
111
+ * submission still succeeds.
112
+ *
113
+ * On any install with a jobs runner, form-builder queues non-essential actions, and the
114
+ * queued run carries the runner's request rather than the visitor's. Set `hostname` (and
115
+ * `scope`, on a scoped install) there, since neither can be recovered from that request.
116
+ */
117
+ const trackGoalAction = (options = {}) => ({
118
+ type: GOAL_ACTION_TYPE,
119
+ label: keys.actionGoalLabel,
120
+ config: configFields(),
121
+ run: async (args) => {
122
+ const slug = goalSlug(args.config.goal);
123
+ if (!slug) throw new AnalyticsTrackError("analytics: trackGoalAction has no goal configured");
124
+ await trackServerEvent(args.payload, {
125
+ type: "goal",
126
+ name: slug,
127
+ path: fromOption(options.path, args) ?? `/forms/${args.form.id}`,
128
+ hostname: hostnameFor(options, args),
129
+ value: valueFor(args),
130
+ currency: nonEmpty(args.config.currency),
131
+ props: propsFor(args),
132
+ ...await scopeFor(options, args)
133
+ }, { req: args.req });
134
+ }
135
+ });
136
+ //#endregion
137
+ export { GOAL_ACTION_TYPE, trackGoalAction };
138
+
139
+ //# sourceMappingURL=trackGoalAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackGoalAction.js","names":[],"sources":["../../src/goals/trackGoalAction.ts"],"sourcesContent":["import type { Field, Payload, PayloadRequest } from 'payload'\nimport { AnalyticsTrackError } from '../core/serverEvent'\nimport { trackServerEvent } from '../native/ingest/serverTrack'\nimport { keys } from '../translations/keys'\nimport { labelForKey } from '../translations/server'\nimport { validateCurrency } from './currency'\nimport { goalField, goalSlug } from './goalField'\n\n/** The action type form-builder stores as the block slug on a form's `actions` array. */\nexport const GOAL_ACTION_TYPE = 'analyticsGoal'\n\n/**\n * The run context form-builder hands a post-submit action, narrowed to what goal tracking\n * reads. A structural subset rather than an import: analytics never depends on form-builder\n * at runtime, so an install without it still resolves this module.\n */\nexport interface GoalActionRunArgs {\n\tform: { id: number | string; title?: string }\n\tsubmissionId: number | string\n\t/** One entry per answered field, keyed by the field's machine name. */\n\tvalues: Array<{ field: string; value: unknown }>\n\tconfig: Record<string, unknown>\n\tpayload: Payload\n\t/**\n\t * The request the action runs under. On a queued dispatch this is the job runner's own\n\t * request, not the visitor's, so it carries neither the submitting host nor the tenant.\n\t */\n\treq?: PayloadRequest\n}\n\n/**\n * Structural counterpart of form-builder's `ActionDefinition<Record<string, unknown>>`; a\n * value of this type is assignable to it, which `trackGoalAction.test.ts` pins.\n */\nexport interface GoalActionDefinition {\n\ttype: typeof GOAL_ACTION_TYPE\n\tlabel: string | Record<string, string>\n\tconfig: Field[]\n\trun: (args: GoalActionRunArgs) => Promise<void>\n}\n\nexport interface TrackGoalActionOptions {\n\t/**\n\t * Site the completion belongs to. Falls back to the submitting request's host, then to\n\t * the host of `serverURL`. Set it whenever a jobs runner queues actions: the runner's\n\t * request carries the CMS host at best, and often no host at all.\n\t */\n\thostname?: string | ((args: GoalActionRunArgs) => string)\n\t/** Page the completion is attributed to. Defaults to `/forms/<form id>`. */\n\tpath?: string | ((args: GoalActionRunArgs) => string)\n\t/**\n\t * Analytics boundary to stamp; `null` is install-wide. Leave unset and the scope resolves\n\t * from the action's request, which on a queued dispatch is the runner's rather than the\n\t * submitter's and so usually lands install-wide. Set it on any scoped install whose\n\t * actions are queued, since the submitter's tenant cannot be recovered there.\n\t */\n\tscope?: string | null | ((args: GoalActionRunArgs) => string | null | Promise<string | null>)\n}\n\nconst configFields = (): Field[] => [\n\tgoalField({ name: 'goal', required: true }),\n\t{\n\t\tname: 'value',\n\t\ttype: 'number',\n\t\tmin: 0,\n\t\tlabel: labelForKey(keys.goalFieldValue),\n\t},\n\t{\n\t\tname: 'valueFrom',\n\t\ttype: 'text',\n\t\tlabel: labelForKey(keys.actionGoalFieldValueFrom),\n\t\tadmin: { description: labelForKey(keys.actionGoalFieldValueFromHelp) },\n\t},\n\t{\n\t\tname: 'currency',\n\t\ttype: 'text',\n\t\tlabel: labelForKey(keys.goalFieldCurrency),\n\t\tvalidate: validateCurrency,\n\t},\n]\n\nconst finiteNumber = (value: unknown): number | undefined => {\n\tif (typeof value === 'number') {\n\t\treturn Number.isFinite(value) ? value : undefined\n\t}\n\tif (typeof value === 'string' && value.trim() !== '') {\n\t\tconst parsed = Number(value)\n\t\treturn Number.isFinite(parsed) ? parsed : undefined\n\t}\n\treturn undefined\n}\n\nconst nonEmpty = (value: unknown): string | undefined => {\n\tif (typeof value !== 'string') {\n\t\treturn undefined\n\t}\n\tconst trimmed = value.trim()\n\treturn trimmed === '' ? undefined : trimmed\n}\n\nconst fromOption = (\n\toption: string | ((args: GoalActionRunArgs) => string) | undefined,\n\targs: GoalActionRunArgs\n): string | undefined =>\n\tnonEmpty(typeof option === 'function' ? option(args) : (option ?? undefined))\n\n/**\n * The host out of a `Host` header. An IPv6 literal keeps its brackets, which is what the URL\n * spec and every other hostname in the pipeline use; only a bracketed or single-colon host\n * can carry a port, so a bare `::1` is left whole rather than truncated at its last colon.\n */\nconst stripPort = (host: string): string => {\n\tconst bracketed = /^(\\[[^\\]]+\\])(?::\\d+)?$/.exec(host)\n\tif (bracketed?.[1]) {\n\t\treturn bracketed[1]\n\t}\n\tif (host.indexOf(':') !== host.lastIndexOf(':')) {\n\t\treturn host\n\t}\n\treturn host.replace(/:\\d+$/, '')\n}\n\nconst serverUrlHost = (payload: Payload): string | undefined => {\n\tconst serverURL = nonEmpty(payload.config?.serverURL)\n\tif (!serverURL) {\n\t\treturn undefined\n\t}\n\ttry {\n\t\treturn nonEmpty(new URL(serverURL).hostname)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/**\n * The option, then the submitting request, then the install's own `serverURL`. The queued\n * dispatch path reaches the last two with the runner's request, so an install that queues\n * actions and serves more than one site has to say which site in the option.\n */\nconst hostnameFor = (options: TrackGoalActionOptions, args: GoalActionRunArgs): string => {\n\tconst configured = fromOption(options.hostname, args)\n\tif (configured) {\n\t\treturn configured.toLowerCase()\n\t}\n\tconst header = nonEmpty(args.req?.headers.get('host'))\n\tconst fromHeader = header ? nonEmpty(stripPort(header)) : undefined\n\tif (fromHeader) {\n\t\treturn fromHeader.toLowerCase()\n\t}\n\tconst fromServerUrl = serverUrlHost(args.payload)\n\tif (fromServerUrl) {\n\t\treturn fromServerUrl.toLowerCase()\n\t}\n\tthrow new AnalyticsTrackError(\n\t\t'analytics: trackGoalAction could not resolve a hostname; set the `hostname` option, or configure `serverURL`, since a queued run has no submitting request'\n\t)\n}\n\n/** The fixed value wins; otherwise the named answer, and only when it reads as a number. */\nconst valueFor = (args: GoalActionRunArgs): number | undefined => {\n\tconst fixed = finiteNumber(args.config.value)\n\tif (fixed !== undefined) {\n\t\treturn fixed\n\t}\n\tconst field = nonEmpty(args.config.valueFrom)\n\tif (!field) {\n\t\treturn undefined\n\t}\n\treturn finiteNumber(args.values.find((entry) => entry.field === field)?.value)\n}\n\nconst propsFor = (args: GoalActionRunArgs): Record<string, unknown> => {\n\tconst props: Record<string, unknown> = {\n\t\tformId: String(args.form.id),\n\t\tsubmissionId: String(args.submissionId),\n\t}\n\tconst title = nonEmpty(args.form.title)\n\tif (title) {\n\t\tprops.formTitle = title\n\t}\n\treturn props\n}\n\nconst scopeFor = async (\n\toptions: TrackGoalActionOptions,\n\targs: GoalActionRunArgs\n): Promise<{ scope?: string | null }> => {\n\tif (options.scope === undefined) {\n\t\treturn {}\n\t}\n\treturn { scope: typeof options.scope === 'function' ? await options.scope(args) : options.scope }\n}\n\n/**\n * A form-builder post-submit action that completes an analytics goal, authored per form in\n * the admin: pick the goal, optionally a revenue value (fixed, or read from a submission\n * field) and its currency. Register it through form-builder's `actions` option under\n * {@link GOAL_ACTION_TYPE}.\n *\n * Needs the native adapter, since it records through {@link trackServerEvent}. `essential`\n * is deliberately unset: a goal is a measurement, so a failed write is logged and the\n * submission still succeeds.\n *\n * On any install with a jobs runner, form-builder queues non-essential actions, and the\n * queued run carries the runner's request rather than the visitor's. Set `hostname` (and\n * `scope`, on a scoped install) there, since neither can be recovered from that request.\n */\nexport const trackGoalAction = (options: TrackGoalActionOptions = {}): GoalActionDefinition => ({\n\ttype: GOAL_ACTION_TYPE,\n\tlabel: keys.actionGoalLabel,\n\tconfig: configFields(),\n\trun: async (args) => {\n\t\tconst slug = goalSlug(args.config.goal)\n\t\tif (!slug) {\n\t\t\tthrow new AnalyticsTrackError('analytics: trackGoalAction has no goal configured')\n\t\t}\n\t\tawait trackServerEvent(\n\t\t\targs.payload,\n\t\t\t{\n\t\t\t\ttype: 'goal',\n\t\t\t\tname: slug,\n\t\t\t\tpath: fromOption(options.path, args) ?? `/forms/${args.form.id}`,\n\t\t\t\thostname: hostnameFor(options, args),\n\t\t\t\tvalue: valueFor(args),\n\t\t\t\tcurrency: nonEmpty(args.config.currency),\n\t\t\t\tprops: propsFor(args),\n\t\t\t\t...(await scopeFor(options, args)),\n\t\t\t},\n\t\t\t{ req: args.req }\n\t\t)\n\t},\n})\n"],"mappings":"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"}
@@ -0,0 +1,20 @@
1
+ import { GoalsResponse } from "./fetchGoals.js";
2
+
3
+ //#region src/goals/useAnalyticsGoals.d.ts
4
+ interface AnalyticsGoals {
5
+ /** Null until the fetch settles, and on a failed one: not the same thing as none. */
6
+ goals: GoalsResponse['goals'] | null;
7
+ collection: GoalsResponse['collection'];
8
+ /** The fetch settled in failure, so a picker can say so instead of claiming none exist. */
9
+ error: boolean;
10
+ }
11
+ /**
12
+ * Fetches the caller-scope goal list for the admin goal picker. `goals` stays null while
13
+ * the fetch is in flight, when it fails, and when there is no authenticated user yet, so
14
+ * a picker can tell "still loading" from "this scope has no goals". Goals fetched for a
15
+ * previous user are never returned while a new user's fetch is pending.
16
+ */
17
+ declare const useAnalyticsGoals: () => AnalyticsGoals;
18
+ //#endregion
19
+ export { useAnalyticsGoals };
20
+ //# sourceMappingURL=useAnalyticsGoals.d.ts.map
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ import { fetchGoals } from "./fetchGoals.js";
3
+ import { useEffect, useState } from "react";
4
+ import { useAuth, useConfig } from "@payloadcms/ui";
5
+ //#region src/goals/useAnalyticsGoals.ts
6
+ const EMPTY = {
7
+ collection: null,
8
+ error: false,
9
+ goals: null
10
+ };
11
+ const FAILED = {
12
+ collection: null,
13
+ error: true,
14
+ goals: null
15
+ };
16
+ /**
17
+ * Fetches the caller-scope goal list for the admin goal picker. `goals` stays null while
18
+ * the fetch is in flight, when it fails, and when there is no authenticated user yet, so
19
+ * a picker can tell "still loading" from "this scope has no goals". Goals fetched for a
20
+ * previous user are never returned while a new user's fetch is pending.
21
+ */
22
+ const useAnalyticsGoals = () => {
23
+ const { user } = useAuth();
24
+ const { config: { routes: { api }, serverURL } } = useConfig();
25
+ const userKey = String(user?.id ?? "");
26
+ const [state, setState] = useState({
27
+ data: EMPTY,
28
+ key: ""
29
+ });
30
+ useEffect(() => {
31
+ if (!userKey) {
32
+ setState({
33
+ data: EMPTY,
34
+ key: ""
35
+ });
36
+ return;
37
+ }
38
+ let cancelled = false;
39
+ fetchGoals(serverURL ?? "", api, userKey).then(({ collection, goals }) => {
40
+ if (!cancelled) setState({
41
+ data: {
42
+ collection,
43
+ error: false,
44
+ goals
45
+ },
46
+ key: userKey
47
+ });
48
+ }).catch(() => {
49
+ if (!cancelled) setState({
50
+ data: FAILED,
51
+ key: userKey
52
+ });
53
+ });
54
+ return () => {
55
+ cancelled = true;
56
+ };
57
+ }, [
58
+ api,
59
+ serverURL,
60
+ userKey
61
+ ]);
62
+ return state.key === userKey ? state.data : EMPTY;
63
+ };
64
+ //#endregion
65
+ export { useAnalyticsGoals };
66
+
67
+ //# sourceMappingURL=useAnalyticsGoals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnalyticsGoals.js","names":[],"sources":["../../src/goals/useAnalyticsGoals.ts"],"sourcesContent":["'use client'\n\nimport { useAuth, useConfig } from '@payloadcms/ui'\nimport { useEffect, useState } from 'react'\nimport { fetchGoals, type GoalsResponse } from './fetchGoals'\n\nexport interface AnalyticsGoals {\n\t/** Null until the fetch settles, and on a failed one: not the same thing as none. */\n\tgoals: GoalsResponse['goals'] | null\n\tcollection: GoalsResponse['collection']\n\t/** The fetch settled in failure, so a picker can say so instead of claiming none exist. */\n\terror: boolean\n}\n\nconst EMPTY: AnalyticsGoals = { collection: null, error: false, goals: null }\nconst FAILED: AnalyticsGoals = { collection: null, error: true, goals: null }\n\n/**\n * Fetches the caller-scope goal list for the admin goal picker. `goals` stays null while\n * the fetch is in flight, when it fails, and when there is no authenticated user yet, so\n * a picker can tell \"still loading\" from \"this scope has no goals\". Goals fetched for a\n * previous user are never returned while a new user's fetch is pending.\n */\nexport const useAnalyticsGoals = (): AnalyticsGoals => {\n\tconst { user } = useAuth()\n\tconst {\n\t\tconfig: {\n\t\t\troutes: { api },\n\t\t\tserverURL,\n\t\t},\n\t} = useConfig()\n\tconst userKey = String(user?.id ?? '')\n\tconst [state, setState] = useState<{ key: string; data: AnalyticsGoals }>({\n\t\tdata: EMPTY,\n\t\tkey: '',\n\t})\n\n\tuseEffect(() => {\n\t\tif (!userKey) {\n\t\t\tsetState({ data: EMPTY, key: '' })\n\t\t\treturn\n\t\t}\n\t\tlet cancelled = false\n\t\tfetchGoals(serverURL ?? '', api, userKey)\n\t\t\t.then(({ collection, goals }) => {\n\t\t\t\tif (!cancelled) setState({ data: { collection, error: false, goals }, key: userKey })\n\t\t\t})\n\t\t\t.catch(() => {\n\t\t\t\tif (!cancelled) setState({ data: FAILED, key: userKey })\n\t\t\t})\n\t\treturn () => {\n\t\t\tcancelled = true\n\t\t}\n\t}, [api, serverURL, userKey])\n\n\treturn state.key === userKey ? state.data : EMPTY\n}\n"],"mappings":";;;;;AAcA,MAAM,QAAwB;CAAE,YAAY;CAAM,OAAO;CAAO,OAAO;AAAK;AAC5E,MAAM,SAAyB;CAAE,YAAY;CAAM,OAAO;CAAM,OAAO;AAAK;;;;;;;AAQ5E,MAAa,0BAA0C;CACtD,MAAM,EAAE,SAAS,QAAQ;CACzB,MAAM,EACL,QAAQ,EACP,QAAQ,EAAE,OACV,gBAEE,UAAU;CACd,MAAM,UAAU,OAAO,MAAM,MAAM,EAAE;CACrC,MAAM,CAAC,OAAO,YAAY,SAAgD;EACzE,MAAM;EACN,KAAK;CACN,CAAC;CAED,gBAAgB;EACf,IAAI,CAAC,SAAS;GACb,SAAS;IAAE,MAAM;IAAO,KAAK;GAAG,CAAC;GACjC;EACD;EACA,IAAI,YAAY;EAChB,WAAW,aAAa,IAAI,KAAK,OAAO,EACtC,MAAM,EAAE,YAAY,YAAY;GAChC,IAAI,CAAC,WAAW,SAAS;IAAE,MAAM;KAAE;KAAY,OAAO;KAAO;IAAM;IAAG,KAAK;GAAQ,CAAC;EACrF,CAAC,EACA,YAAY;GACZ,IAAI,CAAC,WAAW,SAAS;IAAE,MAAM;IAAQ,KAAK;GAAQ,CAAC;EACxD,CAAC;EACF,aAAa;GACZ,YAAY;EACb;CACD,GAAG;EAAC;EAAK;EAAW;CAAO,CAAC;CAE5B,OAAO,MAAM,QAAQ,UAAU,MAAM,OAAO;AAC7C"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,17 @@
1
1
  import { Goal, GoalMatch, TrackerGoal } from "./goals/types.js";
2
+ import { AnalyticsTrackError, ServerEventInput, ServerTrack, ServerTrackOptions } from "./core/serverEvent.js";
2
3
  import { PLATFORM_SCOPE } from "./core/contract.js";
4
+ import { GoalsResponse, WireGoal } from "./goals/fetchGoals.js";
5
+ import { QueryError, QueryErrorCode } from "./query/errors.js";
6
+ import { QueryErrorResponse, QueryResponse, QuerySourceRef, SerializedAnalyticsQuery } from "./query/response.js";
3
7
  import { AnalyticsBinding, BindingContext, HostnameResolver, PathResolver } from "./binding/types.js";
4
- import { CustomWidgetDef } from "./widgets/customWidget.js";
5
- import { AnalyticsAccessOptions, AnalyticsCaptureOptions, AnalyticsGoalsOptions, AnalyticsPluginOptions, AutoCaptureOptions, CaptureConsentOption, ConsentMode, ConsentResolver, PlatformReadAccess, ProvidersCollectionOptions, ProvidersOptions, ProvidersResolve, ScopeResolver, ScopesResolver, TimezoneResolver } from "./core/options.js";
6
8
  import { TimeframePreset } from "./timeframe/presets.js";
9
+ import { CustomWidgetDef } from "./widgets/customWidget.js";
10
+ import { AnalyticsAccessOptions, AnalyticsCaptureOptions, AnalyticsGoalsCollectionOptions, AnalyticsGoalsOptions, AnalyticsPluginOptions, AnalyticsReadAccess, AnalyticsViewAccess, AnalyticsViewOptions, AutoCaptureOptions, CaptureConsentOption, ConsentMode, ConsentResolver, PlatformReadAccess, ProvidersCollectionOptions, ProvidersOptions, ProvidersResolve, ScopeResolver, ScopesResolver, TimezoneResolver } from "./core/options.js";
7
11
  import { AnalyticsFieldsOptions, AnalyticsMetricLabel, AnalyticsMetricLabels, AnalyticsStatOptions, AnalyticsStatRowOptions, AnalyticsTabOptions, analyticsFields, analyticsStat, analyticsStatRow, analyticsTab, analyticsTabsField } from "./fields/factories.js";
12
+ import { GoalFieldOptions, goalField, goalSlug } from "./goals/goalField.js";
13
+ import { GOAL_ACTION_TYPE, GoalActionDefinition, GoalActionRunArgs, TrackGoalActionOptions, trackGoalAction } from "./goals/trackGoalAction.js";
14
+ import { trackServerEvent } from "./native/ingest/serverTrack.js";
8
15
  import { analyticsDefaultWidgets } from "./widgets/defaults.js";
9
16
 
10
17
  //#region src/index.d.ts
@@ -15,5 +22,5 @@ declare module 'payload' {
15
22
  }
16
23
  declare const analytics: (options: AnalyticsPluginOptions) => import("payload").Plugin;
17
24
  //#endregion
18
- export { type AnalyticsAccessOptions, type AnalyticsBinding, type AnalyticsCaptureOptions, type AnalyticsFieldsOptions, type AnalyticsGoalsOptions, type AnalyticsMetricLabel, type AnalyticsMetricLabels, type AnalyticsPluginOptions, type AnalyticsStatOptions, type AnalyticsStatRowOptions, type AnalyticsTabOptions, type AutoCaptureOptions, type BindingContext, type CaptureConsentOption, type ConsentMode, type ConsentResolver, type CustomWidgetDef, type Goal, type GoalMatch, type HostnameResolver, PLATFORM_SCOPE, type PathResolver, type PlatformReadAccess, type AnalyticsPluginOptions as PluginOptions, type ProvidersCollectionOptions, type ProvidersOptions, type ProvidersResolve, type ScopeResolver, type ScopesResolver, type TimeframePreset, type TimezoneResolver, type TrackerGoal, analytics, analyticsDefaultWidgets, analyticsFields, analyticsStat, analyticsStatRow, analyticsTab, analyticsTabsField };
25
+ export { type AnalyticsAccessOptions, type AnalyticsBinding, type AnalyticsCaptureOptions, type AnalyticsFieldsOptions, type AnalyticsGoalsCollectionOptions, type AnalyticsGoalsOptions, type AnalyticsMetricLabel, type AnalyticsMetricLabels, type AnalyticsPluginOptions, type AnalyticsReadAccess, type AnalyticsStatOptions, type AnalyticsStatRowOptions, type AnalyticsTabOptions, AnalyticsTrackError, type AnalyticsViewAccess, type AnalyticsViewOptions, type AutoCaptureOptions, type BindingContext, type CaptureConsentOption, type ConsentMode, type ConsentResolver, type CustomWidgetDef, GOAL_ACTION_TYPE, type Goal, type GoalActionDefinition, type GoalActionRunArgs, type GoalFieldOptions, type GoalMatch, type GoalsResponse, type HostnameResolver, PLATFORM_SCOPE, type PathResolver, type PlatformReadAccess, type AnalyticsPluginOptions as PluginOptions, type ProvidersCollectionOptions, type ProvidersOptions, type ProvidersResolve, type QueryError, type QueryErrorCode, type QueryErrorResponse, type QueryResponse, type QuerySourceRef, type ScopeResolver, type ScopesResolver, type SerializedAnalyticsQuery, type ServerEventInput, type ServerTrack, type ServerTrackOptions, type TimeframePreset, type TimezoneResolver, type TrackGoalActionOptions, type TrackerGoal, type WireGoal, analytics, analyticsDefaultWidgets, analyticsFields, analyticsStat, analyticsStatRow, analyticsTab, analyticsTabsField, goalField, goalSlug, trackGoalAction, trackServerEvent };
19
26
  //# sourceMappingURL=index.d.ts.map