@theholocron/holocron-plugin-sentry 5.0.0-alpha.232 → 5.0.0-alpha.233

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 (2) hide show
  1. package/dist/index.mjs +91 -0
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -345,6 +345,96 @@ function integrationsProbe(deps) {
345
345
  };
346
346
  }
347
347
  //#endregion
348
+ //#region src/probes/rule-update.ts
349
+ const FROM = 5;
350
+ const TO = 10;
351
+ /** The detector the throwaway rule hangs on: the issue stream of `HOLOCRON_SENTRY_PROBE_PROJECT`, else of any project. */
352
+ async function detectorFor(deps, org) {
353
+ const client = deps.client();
354
+ const slug = (deps.env ?? process.env)["HOLOCRON_SENTRY_PROBE_PROJECT"];
355
+ const [detectors, projects] = await Promise.all([client.workflows.detectors(org), slug ? client.projects.list(org) : Promise.resolve([])]);
356
+ const streams = detectors.filter((d) => d.type === "issue_stream");
357
+ if (slug) {
358
+ const project = projects.find((p) => p.slug === slug);
359
+ if (!project) throw new Error(`Sentry project \`${slug}\` was not found in ${org}`);
360
+ const own = streams.find((d) => d.projectId === project.id);
361
+ if (!own) throw new Error(`Sentry project \`${slug}\` has no issue stream detector`);
362
+ return own.id;
363
+ }
364
+ const any = streams[0];
365
+ if (!any) throw new Error("no project has an issue stream detector to attach a throwaway rule to");
366
+ return any.id;
367
+ }
368
+ function ruleUpdateProbe(deps) {
369
+ return {
370
+ summary: "Make a disabled throwaway alert rule, change it the way the relay's adopt path does, read it back, delete it.",
371
+ writes: true,
372
+ async run(probe) {
373
+ const org = requireOrg(deps);
374
+ const client = deps.client();
375
+ const detectorId = await detectorFor(deps, org);
376
+ const body = {
377
+ name: `Holocron probe: throwaway rule (${(/* @__PURE__ */ new Date()).toISOString()})`,
378
+ enabled: false,
379
+ environment: null,
380
+ config: { frequency: FROM },
381
+ detectorIds: [detectorId],
382
+ triggers: {
383
+ logicType: "any-short",
384
+ conditions: [{
385
+ type: "new_high_priority_issue",
386
+ comparison: true,
387
+ conditionResult: true
388
+ }]
389
+ },
390
+ actionFilters: [{
391
+ logicType: "all",
392
+ conditions: [],
393
+ actions: []
394
+ }]
395
+ };
396
+ const created = await probe.write("create a disabled throwaway alert rule", async () => {
397
+ const wf = await client.workflows.create(org, body);
398
+ probe.cleanup(`the throwaway rule ${wf.id}`, () => client.workflows.delete(org, wf.id));
399
+ return wf;
400
+ });
401
+ if (!created) {
402
+ probe.say({
403
+ status: "info",
404
+ label: `would then change its frequency ${FROM} to ${TO} with PUT, read it back, and delete it`
405
+ });
406
+ return;
407
+ }
408
+ probe.say({
409
+ status: "ok",
410
+ label: "created",
411
+ detail: `rule ${created.id}, disabled`
412
+ });
413
+ const next = toInput(created);
414
+ next.config = {
415
+ ...created.config,
416
+ frequency: TO
417
+ };
418
+ await client.workflows.update(org, created.id, next);
419
+ probe.say({
420
+ status: "ok",
421
+ label: "PUT accepted"
422
+ });
423
+ const read = await client.workflows.get(org, created.id);
424
+ const kept = !read.enabled && read.detectorIds.includes(detectorId);
425
+ probe.say(read.config.frequency === TO && kept ? {
426
+ status: "ok",
427
+ label: "read back",
428
+ detail: `frequency ${read.config.frequency}, still disabled and attached`
429
+ } : {
430
+ status: "fail",
431
+ label: "read back differs",
432
+ detail: `frequency ${read.config.frequency} (sent ${TO}), enabled ${read.enabled}, detectors ${read.detectorIds.join(",")}`
433
+ });
434
+ }
435
+ };
436
+ }
437
+ //#endregion
348
438
  //#region src/probes/rules.ts
349
439
  function rulesProbe(deps) {
350
440
  return {
@@ -447,6 +537,7 @@ function sentryProbes(deps) {
447
537
  return {
448
538
  integrations: integrationsProbe(deps),
449
539
  rules: rulesProbe(deps),
540
+ "rule-update": ruleUpdateProbe(deps),
450
541
  "send-error": sendErrorProbe(deps)
451
542
  };
452
543
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-sentry",
3
- "version": "5.0.0-alpha.232",
3
+ "version": "5.0.0-alpha.233",
4
4
  "description": "Holocron plugin for Sentry. Implements the errors capability against Sentry's management API — project provisioning and DSN retrieval.",
5
5
  "keywords": [
6
6
  "errors",
@@ -33,7 +33,7 @@
33
33
  "@theholocron/eslint-config": "^8.8.2",
34
34
  "@theholocron/http-client": "^1.54.2",
35
35
  "@theholocron/misc-utils": "^1.16.0",
36
- "@theholocron/sentry-client": "^1.54.0",
36
+ "@theholocron/sentry-client": "^1.56.0",
37
37
  "@theholocron/tsconfig": "^8.8.2",
38
38
  "@theholocron/tsdown-config": "^8.8.2",
39
39
  "@theholocron/vitest-config": "^8.8.2",
@@ -48,12 +48,12 @@
48
48
  "tsx": "4.23.15",
49
49
  "typescript": "^5.9.3",
50
50
  "vitest": "^4.1.11",
51
- "@theholocron/cli": "5.0.0-alpha.232"
51
+ "@theholocron/cli": "5.0.0-alpha.233"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@theholocron/misc-utils": "^1.16.0",
55
- "@theholocron/sentry-client": "^1.54.0",
56
- "@theholocron/cli": "5.0.0-alpha.232"
55
+ "@theholocron/sentry-client": "^1.56.0",
56
+ "@theholocron/cli": "5.0.0-alpha.233"
57
57
  },
58
58
  "peerDependenciesMeta": {
59
59
  "@theholocron/sentry-client": {}