@forge/bridge 5.17.0-next.9-experimental-a344346 → 5.18.0-next.0
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 +23 -2
- package/out/frontendCustomMetrics/frontendCustomMetrics.d.ts +17 -0
- package/out/frontendCustomMetrics/frontendCustomMetrics.d.ts.map +1 -0
- package/out/frontendCustomMetrics/frontendCustomMetrics.js +61 -0
- package/out/frontendCustomMetrics/index.d.ts +2 -0
- package/out/frontendCustomMetrics/index.d.ts.map +1 -0
- package/out/frontendCustomMetrics/index.js +4 -0
- package/out/index.d.ts +1 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# @forge/bridge
|
|
2
2
|
|
|
3
|
-
## 5.
|
|
3
|
+
## 5.18.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b0b69a2: **Experimental — not yet ready for use.** Add a new `frontendCustomMetrics` namespace providing `frontendCustomMetrics.counter(name)` with `incr()` and `incrBy(value)` for emitting frontend custom metrics. `incrBy(value)` rejects if `value <= 0`. The metric name must exactly match a metric registered in the Forge Dev Console.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 561f8f4: Remove "storage" module from "@forge/api"
|
|
12
|
+
- Updated dependencies [814b8fe]
|
|
13
|
+
- Updated dependencies [55c1371]
|
|
14
|
+
- Updated dependencies [1a461c3]
|
|
15
|
+
- @forge/manifest@12.9.1-next.0
|
|
16
|
+
|
|
17
|
+
## 5.17.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
6
20
|
|
|
@@ -20,7 +34,14 @@
|
|
|
20
34
|
- Updated dependencies [b7b1f36]
|
|
21
35
|
- Updated dependencies [ee691bf]
|
|
22
36
|
- Updated dependencies [9f3add6]
|
|
23
|
-
- @forge/manifest@12.9.0
|
|
37
|
+
- @forge/manifest@12.9.0
|
|
38
|
+
|
|
39
|
+
## 5.17.0-next.10
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [ee691bf]
|
|
44
|
+
- @forge/manifest@12.9.0-next.6
|
|
24
45
|
|
|
25
46
|
## 5.17.0-next.9
|
|
26
47
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Counter {
|
|
2
|
+
incr: () => Promise<void>;
|
|
3
|
+
incrBy: (value: number) => Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Public namespace for emitting Forge frontend custom metrics from a Forge UI app.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { frontendCustomMetrics } from '@forge/bridge';
|
|
10
|
+
* const c = frontendCustomMetrics.counter('button-click');
|
|
11
|
+
* c.incr(); // increment by 1
|
|
12
|
+
* c.incrBy(5); // increment by 5 (rejects if value <= 0)
|
|
13
|
+
*/
|
|
14
|
+
export declare const frontendCustomMetrics: {
|
|
15
|
+
counter: (name: string) => Counter;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=frontendCustomMetrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontendCustomMetrics.d.ts","sourceRoot":"","sources":["../../src/frontendCustomMetrics/frontendCustomMetrics.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAkDD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB;oBAvBX,MAAM,KAAG,OAAO;CAuBS,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.frontendCustomMetrics = void 0;
|
|
4
|
+
const bridge_1 = require("../bridge");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const callBridge = (0, bridge_1.getCallBridge)();
|
|
7
|
+
const emit = async (customMetricName, value) => {
|
|
8
|
+
await callBridge('emitFrontendCustomMetric', {
|
|
9
|
+
customMetricName,
|
|
10
|
+
value
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
const MAX_METRIC_NAME_LENGTH = 50;
|
|
14
|
+
// Must start and end with an alphanumeric character and may only contain
|
|
15
|
+
// letters, numbers, dots (.) and hyphens (-) in between.
|
|
16
|
+
const METRIC_NAME_REGEX = /^[a-zA-Z0-9]([a-zA-Z0-9.-]*[a-zA-Z0-9])?$/;
|
|
17
|
+
/**
|
|
18
|
+
* Validates a custom metric name against the same rules enforced when
|
|
19
|
+
* registering a metric in the developer console. Throws synchronously so
|
|
20
|
+
* developer errors fail fast without a wasted bridge round-trip.
|
|
21
|
+
*
|
|
22
|
+
* Note: this is a best-effort, client-side convenience check. The metric name
|
|
23
|
+
* must still match a custom metric registered in the developer console, which
|
|
24
|
+
* remains the source of truth and is validated by the backend.
|
|
25
|
+
*/
|
|
26
|
+
const validateMetricName = (name) => {
|
|
27
|
+
if (name.trim().length === 0) {
|
|
28
|
+
throw new errors_1.BridgeAPIError('Custom metric name cannot be empty');
|
|
29
|
+
}
|
|
30
|
+
if (name.length > MAX_METRIC_NAME_LENGTH) {
|
|
31
|
+
throw new errors_1.BridgeAPIError(`Custom metric name cannot exceed ${MAX_METRIC_NAME_LENGTH} characters`);
|
|
32
|
+
}
|
|
33
|
+
if (!METRIC_NAME_REGEX.test(name)) {
|
|
34
|
+
throw new errors_1.BridgeAPIError('Custom metric name must start and end with alphanumeric characters and can only contain letters, numbers, dots (.), and hyphens (-)');
|
|
35
|
+
}
|
|
36
|
+
if (name.includes('..') || name.includes('--')) {
|
|
37
|
+
throw new errors_1.BridgeAPIError('Custom metric name cannot contain consecutive dots or hyphens');
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const counter = (name) => {
|
|
41
|
+
validateMetricName(name);
|
|
42
|
+
return {
|
|
43
|
+
incr: () => emit(name, 1),
|
|
44
|
+
incrBy: (value) => {
|
|
45
|
+
if (value <= 0) {
|
|
46
|
+
throw new errors_1.BridgeAPIError('Counter value must be a positive number');
|
|
47
|
+
}
|
|
48
|
+
return emit(name, value);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Public namespace for emitting Forge frontend custom metrics from a Forge UI app.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* import { frontendCustomMetrics } from '@forge/bridge';
|
|
57
|
+
* const c = frontendCustomMetrics.counter('button-click');
|
|
58
|
+
* c.incr(); // increment by 1
|
|
59
|
+
* c.incrBy(5); // increment by 5 (rejects if value <= 0)
|
|
60
|
+
*/
|
|
61
|
+
exports.frontendCustomMetrics = { counter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/frontendCustomMetrics/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
package/out/index.d.ts
CHANGED
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -18,3 +18,4 @@ exports.i18n = tslib_1.__importStar(require("./i18n"));
|
|
|
18
18
|
tslib_1.__exportStar(require("./permissions"), exports);
|
|
19
19
|
tslib_1.__exportStar(require("./object-store"), exports);
|
|
20
20
|
tslib_1.__exportStar(require("./featureFlags"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./frontendCustomMetrics"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bridge",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.0-next.0",
|
|
4
4
|
"description": "Forge bridge API for custom UI apps",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@forge/i18n": "0.0.7",
|
|
20
20
|
"@forge/resolver": "1.8.0",
|
|
21
21
|
"@types/history": "^4.7.11",
|
|
22
|
-
"@forge/manifest": "12.9.
|
|
22
|
+
"@forge/manifest": "12.9.1-next.0",
|
|
23
23
|
"@types/iframe-resizer": "^3.5.8",
|
|
24
24
|
"iframe-resizer": "^4.4.5"
|
|
25
25
|
},
|