@widgetic/workflows 0.2.5 → 0.2.6

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/README.md CHANGED
@@ -42,8 +42,9 @@ Workflows are for **Teams and partner accounts** only. On Widgetic the page is
42
42
  - **Runs.** The _Runs_ tab shows how far visitors came over a range of days, as a Sankey diagram used as a funnel: a bar
43
43
  for each composition and a band for each way from one composition to the next, as wide as the number of visitors who
44
44
  went that way. Several bands that leave one bar are the alternatives of the workflow (each rule of a condition and its
45
- Default path is a band), a band that skips a step runs in a lane between the bars, and the hollow part of a bar is the
46
- visitors who reached it and did not go on. Counts only: what a visitor typed is never stored. It is drawn from the
45
+ Default path is a band), a band that skips a step runs in a lane between the bars, the hollow part of a bar is the
46
+ visitors who reached it and did not go on, and a red part under a bar is the times that composition could not be shown
47
+ (a failing step says where). Counts only: what a visitor typed is never stored. It is drawn from the
47
48
  three parts in `src/lib/editor/runs*.ts` (the model, the layout in pixels, the words) and
48
49
  `src/lib/components/editor/RunsFlow.svelte`, so the Widgetic site, the Shopify app and a partner's page all show the
49
50
  same chart.
@@ -2,7 +2,8 @@
2
2
  The Runs chart: how far visitors came in a workflow, drawn as a Sankey diagram used as a funnel. Every composition is a bar,
3
3
  every way from one composition to the next (a trigger, then any conditions after it) is a band between two bars, and the
4
4
  wider the band, the more visitors went that way. Several bands that leave one bar are the alternatives of a workflow; the
5
- part of a bar that is drawn hollow is the visitors who reached it and did not go on.
5
+ part of a bar that is drawn hollow is the visitors who reached it and did not go on, and the red part under a bar is the
6
+ times the composition could not be shown (tries, on the same scale: those visitors never came in, so it is apart from the bar).
6
7
 
7
8
  It shows counts only, as the Runs tab always did: never a visitor, never what a visitor typed.
8
9
 
@@ -221,6 +222,16 @@
221
222
  class="fill-none stroke-grey3"
222
223
  />
223
224
  {/if}
225
+ {#if step.failedHeight > 0}
226
+ <!-- The times the composition could not be shown: red, under the bar and apart from it, since those tries never came in. -->
227
+ <rect
228
+ x={step.x}
229
+ y={step.failedY}
230
+ width={RUNS_FLOW_METRICS.barWidth}
231
+ height={step.failedHeight}
232
+ class="fill-error"
233
+ />
234
+ {/if}
224
235
  <!-- The words are HTML in the drawing, so that a long name is cut with an ellipsis and a language that reads right to left is set properly. -->
225
236
  <foreignObject
226
237
  x={step.x}
@@ -11,6 +11,10 @@ import type { RunsFlow, RunsFlowLink, RunsFlowStep } from './runsFlow.js';
11
11
  * width of a band can be compared with any other. A bar or a band that would be too thin to see is given a least thickness
12
12
  * (the scale is not bent for it), and a bar is never thinner than the bands it holds.
13
13
  *
14
+ * The times a composition could not be shown are drawn on that same scale, as a red part under the bar and not inside it:
15
+ * they are tries, and the visitors of those tries never came in, so they are no part of what entered. (A visitor who is
16
+ * tried twice is counted twice; the words under the name say "could not be shown", not "visitors".)
17
+ *
14
18
  * A band that skips a column (a visitor who goes from the first composition to the third) runs through that column in a
15
19
  * lane of its own, between the bars, so that it never goes behind a bar or under a label. A lane is a place in the column,
16
20
  * ordered and spaced like a bar, and the band is one curve through all its lanes.
@@ -38,6 +42,10 @@ export declare const RUNS_FLOW_METRICS: {
38
42
  readonly emptyLinkThickness: 32;
39
43
  /** The part of a bar that did not go on is never thinner than this, so that it can be seen. */
40
44
  readonly minStayedHeight: 3;
45
+ /** The red part under a bar (the times it could not be shown) is never thinner than this, so that it can be seen. */
46
+ readonly minFailedHeight: 3;
47
+ /** The space between the bottom of a bar and the red part under it. */
48
+ readonly failedGap: 2;
41
49
  /** What the bars of the busiest column add up to, when the workflow is small. */
42
50
  readonly barsBudget: 240;
43
51
  readonly minHeight: 280;
@@ -62,6 +70,9 @@ export interface PlacedStep extends RunsFlowStep {
62
70
  /** The part of the bar that did not go on, at the bottom of it (0 high when all of them did, or there is no way on). */
63
71
  stayedY: number;
64
72
  stayedHeight: number;
73
+ /** The times it could not be shown, as a red part under the bar and apart from it (0 high when there were none). */
74
+ failedY: number;
75
+ failedHeight: number;
65
76
  }
66
77
  /** The place where a band runs through a column it skips: as wide as a bar, `x` is its left edge and `y` its middle. */
67
78
  export interface PlacedLane {
@@ -10,6 +10,10 @@
10
10
  * width of a band can be compared with any other. A bar or a band that would be too thin to see is given a least thickness
11
11
  * (the scale is not bent for it), and a bar is never thinner than the bands it holds.
12
12
  *
13
+ * The times a composition could not be shown are drawn on that same scale, as a red part under the bar and not inside it:
14
+ * they are tries, and the visitors of those tries never came in, so they are no part of what entered. (A visitor who is
15
+ * tried twice is counted twice; the words under the name say "could not be shown", not "visitors".)
16
+ *
13
17
  * A band that skips a column (a visitor who goes from the first composition to the third) runs through that column in a
14
18
  * lane of its own, between the bars, so that it never goes behind a bar or under a label. A lane is a place in the column,
15
19
  * ordered and spaced like a bar, and the band is one curve through all its lanes.
@@ -37,6 +41,10 @@ export const RUNS_FLOW_METRICS = {
37
41
  emptyLinkThickness: 32,
38
42
  /** The part of a bar that did not go on is never thinner than this, so that it can be seen. */
39
43
  minStayedHeight: 3,
44
+ /** The red part under a bar (the times it could not be shown) is never thinner than this, so that it can be seen. */
45
+ minFailedHeight: 3,
46
+ /** The space between the bottom of a bar and the red part under it. */
47
+ failedGap: 2,
40
48
  /** What the bars of the busiest column add up to, when the workflow is small. */
41
49
  barsBudget: 240,
42
50
  minHeight: 280,
@@ -165,10 +173,18 @@ export function layoutRunsFlow(flow, options) {
165
173
  : 0;
166
174
  /** The space an item has above it: room for the label of the bar it is (the label is in `labelHeightOf`) or the gap of a lane. */
167
175
  const gapBefore = (item) => item.kind === 'bar' ? metrics.stepGap : metrics.laneGap;
176
+ /** The times a bar could not be shown: 0 for a lane, and for a bar that was always shown. */
177
+ const triesOf = (item) => (item.kind === 'bar' ? item.step.failed : 0);
178
+ /** The space between a bar and the red part under it, which only a bar that could not be shown has. */
179
+ const gapAfter = (item) => (triesOf(item) > 0 ? metrics.failedGap : 0);
168
180
  /** What a column needs for its labels and the gaps between its items, whatever the bars come to. */
169
- const overheadOf = (column) => column.reduce((total, item, position) => total + labelHeightOf(item) + (position > 0 ? gapBefore(item) : 0), 0);
170
- /** What an item stands for, in visitors: a bar's size, and the value of the band a lane carries. */
171
- const visitorsOf = (item) => item.kind === 'bar' ? item.step.size : item.band.value;
181
+ const overheadOf = (column) => column.reduce((total, item, position) => total + labelHeightOf(item) + gapAfter(item) + (position > 0 ? gapBefore(item) : 0), 0);
182
+ /**
183
+ * What an item stands for, in visitors: a bar's size, and the value of the band a lane carries. The red part under a bar is
184
+ * on the same scale, so the times the bar could not be shown count with it; in a chart nobody was counted in there is no
185
+ * scale, and the red part has its least height.
186
+ */
187
+ const visitorsOf = (item) => item.kind === 'bar' ? item.step.size + (flow.hasVisitors ? triesOf(item) : 0) : item.band.value;
172
188
  const tallestOverhead = Math.max(...columns.map(overheadOf));
173
189
  const wantedHeight = Math.max(metrics.minHeight, 2 * metrics.paddingY + tallestOverhead + metrics.barsBudget);
174
190
  // Pixels of height for one visitor: the busiest column, the one that fills its height first, sets it for every column.
@@ -196,8 +212,13 @@ export function layoutRunsFlow(flow, options) {
196
212
  const barHeightOf = (item) => item.kind === 'bar'
197
213
  ? Math.max(metrics.minBarHeight, item.step.size * pixelsPerVisitor, thicknessSum(piecesOutOf.get(item) ?? []), thicknessSum(piecesInto.get(item) ?? []))
198
214
  : thicknessOf(item.band);
215
+ /** The red part under a bar: the times it could not be shown, on the scale of the chart and never thinner than the least. */
216
+ const failedHeightOf = (item) => triesOf(item) > 0
217
+ ? Math.max(metrics.minFailedHeight, flow.hasVisitors ? triesOf(item) * pixelsPerVisitor : 0)
218
+ : 0;
199
219
  // ---- down ---------------------------------------------------------------------------------------------------------
200
- const contentHeightOf = (column) => overheadOf(column) + column.reduce((total, item) => total + barHeightOf(item), 0);
220
+ const contentHeightOf = (column) => overheadOf(column) +
221
+ column.reduce((total, item) => total + barHeightOf(item) + failedHeightOf(item), 0);
201
222
  const height = Math.max(metrics.minHeight, 2 * metrics.paddingY + Math.max(...columns.map(contentHeightOf)));
202
223
  /** Where an item is: the left edge, and the top and height of the bar or lane. */
203
224
  const seatOf = new Map();
@@ -212,7 +233,9 @@ export function layoutRunsFlow(flow, options) {
212
233
  const barHeight = barHeightOf(item);
213
234
  const barY = cursor + labelHeight;
214
235
  seatOf.set(item, { x: round(columnX(columnNumber)), barY, barHeight });
215
- cursor = barY + barHeight;
236
+ // The red part is under the bar, and what follows in the column starts under it.
237
+ const failedHeight = failedHeightOf(item);
238
+ cursor = barY + barHeight + (failedHeight > 0 ? gapAfter(item) + failedHeight : 0);
216
239
  if (item.kind !== 'bar')
217
240
  return;
218
241
  const leavingThickness = thicknessSum(piecesOutOf.get(item) ?? []);
@@ -230,7 +253,9 @@ export function layoutRunsFlow(flow, options) {
230
253
  labelHeight,
231
254
  labelWidth: round(Math.max(60, labelWidthOf(columnNumber))),
232
255
  stayedY: round(barY + barHeight - stayedHeight),
233
- stayedHeight: round(stayedHeight)
256
+ stayedHeight: round(stayedHeight),
257
+ failedY: round(barY + barHeight + (failedHeight > 0 ? gapAfter(item) : 0)),
258
+ failedHeight: round(failedHeight)
234
259
  });
235
260
  });
236
261
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/workflows",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Workflows for Widgetic: chain compositions together with filters that decide which composition an embed shows. One Svelte package that the Widgetic site, partners and Shopify all load.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",