@flareapp/electron 2.5.0 → 2.5.1

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
@@ -51,6 +51,18 @@ When your renderer uses React, Vue, or Svelte, inject the Electron Flare instanc
51
51
  - [Electron + Vue](https://flareapp.io/docs/vue/electron/configuration)
52
52
  - [Electron + Svelte](https://flareapp.io/docs/svelte/electron/configuration)
53
53
 
54
+ ## Identifying users
55
+
56
+ Set the user in the main process; it is stamped on main-origin reports and on forwarded renderer reports:
57
+
58
+ ```ts
59
+ import { flare } from '@flareapp/electron/main';
60
+
61
+ flare.setUser({ id: 123, email: 'jane@example.com', fullName: 'Jane Doe' });
62
+ ```
63
+
64
+ Recognised fields: `id`, `email`, `fullName`, `ipAddress`; extra keys land in `user.attributes`. Pass `null` to clear. The main-process user is authoritative for forwarded renderer reports.
65
+
54
66
  ## Documentation
55
67
 
56
68
  Full documentation on the report flow, `beforeSubmit` filtering, sender trust, attaching users, and the framework integrations is available at [flareapp.io/docs/javascript/electron/how-it-works](https://flareapp.io/docs/javascript/electron/how-it-works).
package/dist/main.cjs CHANGED
@@ -34,7 +34,7 @@ let node_fs_promises = require("node:fs/promises");
34
34
  let node_url = require("node:url");
35
35
 
36
36
  //#region src/env.ts
37
- const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.5.0" : "?";
37
+ const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.5.1" : "?";
38
38
 
39
39
  //#endregion
40
40
  //#region src/types.ts
@@ -76,23 +76,12 @@ function collectElectronAppAttributes(app) {
76
76
  } catch {}
77
77
  return attrs;
78
78
  }
79
- /** Project a user into OTel enduser.* / client.address keys. */
80
- function projectUser(user) {
81
- const attrs = {};
82
- if (!user) return attrs;
83
- if (user.id !== void 0) attrs["enduser.id"] = String(user.id);
84
- if (user.email !== void 0) attrs["enduser.email"] = user.email;
85
- if (user.username !== void 0) attrs["enduser.username"] = user.username;
86
- if (user.ipAddress !== void 0) attrs["client.address"] = user.ipAddress;
87
- return attrs;
88
- }
89
79
  /** Build the ContextCollector core calls on every main-process report. */
90
- function makeElectronContextCollector(app, getUser) {
80
+ function makeElectronContextCollector(app) {
91
81
  return (_config) => ({
92
82
  "flare.entry_point.type": "server",
93
83
  "process.type": process.type ?? "browser",
94
- ...collectElectronAppAttributes(app),
95
- ...projectUser(getUser())
84
+ ...collectElectronAppAttributes(app)
96
85
  });
97
86
  }
98
87
 
@@ -293,7 +282,7 @@ var ElectronFlare = class extends _flareapp_core.Flare {
293
282
  app;
294
283
  ipcMain;
295
284
  options = { ...DEFAULT_ELECTRON_OPTIONS };
296
- user = null;
285
+ mainScope;
297
286
  isLit = false;
298
287
  handlerManager;
299
288
  renderGoneHandler = null;
@@ -305,9 +294,11 @@ var ElectronFlare = class extends _flareapp_core.Flare {
305
294
  mainSourcemapVersionId = "";
306
295
  constructor(deps) {
307
296
  const app = deps.app;
308
- const collector = makeElectronContextCollector(app, () => this.user);
297
+ const collector = makeElectronContextCollector(app);
309
298
  const flushScheduler = new ElectronFlushScheduler(app);
310
- super(new _flareapp_core.Api(), collector, new ElectronDiskFileReader(), new _flareapp_core.GlobalScopeProvider(), flushScheduler);
299
+ const mainScope = new _flareapp_core.GlobalScopeProvider();
300
+ super(new _flareapp_core.Api(), collector, new ElectronDiskFileReader(), mainScope, flushScheduler);
301
+ this.mainScope = mainScope;
311
302
  this.app = app;
312
303
  this.ipcMain = deps.ipcMain;
313
304
  this.flushScheduler = flushScheduler;
@@ -346,9 +337,6 @@ var ElectronFlare = class extends _flareapp_core.Flare {
346
337
  this.reconcileCrashListeners();
347
338
  return this;
348
339
  }
349
- setUser(user) {
350
- this.user = user;
351
- }
352
340
  dispose() {
353
341
  this.handlerManager.detach();
354
342
  this.detachCrashListeners();
@@ -409,9 +397,10 @@ var ElectronFlare = class extends _flareapp_core.Flare {
409
397
  });
410
398
  });
411
399
  }
412
- /** Overlay main-authoritative config + Electron metadata + user onto a forwarded report, then send. */
400
+ /** Overlay main-authoritative config + Electron metadata + user identity (from the main scope) onto a forwarded report, then send. */
413
401
  receiveRendererReport(report) {
414
- Object.assign(report.attributes, collectElectronAppAttributes(this.app), projectUser(this.user));
402
+ for (const key of _flareapp_core.USER_IDENTITY_KEYS) delete report.attributes[key];
403
+ Object.assign(report.attributes, collectElectronAppAttributes(this.app), (0, _flareapp_core.userIdentityAttributes)(this.mainScope.active()));
415
404
  overlayOrDelete(report.attributes, "service.stage", this.mainStage);
416
405
  overlayOrDelete(report.attributes, "service.version", this.mainVersion);
417
406
  if (this.mainSourcemapVersionId) report.sourcemapVersionId = this.mainSourcemapVersionId;
package/dist/main.d.cts CHANGED
@@ -1,14 +1,8 @@
1
- import { AttributeValue, Attributes, Config, Config as Config$1, DEFAULT_URL_DENYLIST, Flare, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, Report, Scope, SdkInfo, StackFrame, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
1
+ import { AttributeValue, Attributes, Config, Config as Config$1, DEFAULT_URL_DENYLIST, Flare, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, Report, Scope, SdkInfo, StackFrame, User, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
2
2
  import { App, IpcMain } from "electron";
3
3
 
4
4
  //#region src/types.d.ts
5
5
  type ElectronFatalMode = 'off' | 'report' | 'report-and-exit';
6
- type ElectronUser = {
7
- id?: string | number;
8
- email?: string;
9
- username?: string;
10
- ipAddress?: string;
11
- };
12
6
  /** A frame the IPC receiver evaluates for trust. Mirrors Electron's WebFrameMain shape we use. */
13
7
  type SenderFrame = {
14
8
  url: string;
@@ -35,7 +29,7 @@ declare class ElectronFlare extends Flare {
35
29
  private app;
36
30
  private ipcMain;
37
31
  private options;
38
- private user;
32
+ private mainScope;
39
33
  private isLit;
40
34
  private handlerManager;
41
35
  private renderGoneHandler;
@@ -49,7 +43,6 @@ declare class ElectronFlare extends Flare {
49
43
  configure(config: Partial<Config$1>): this;
50
44
  light(key?: string, debug?: boolean): this;
51
45
  configureElectron(partial: ElectronOptions): this;
52
- setUser(user: ElectronUser | null): void;
53
46
  dispose(): void;
54
47
  /** Attach or detach the process-gone listeners to match options.captureRenderProcessGone. Idempotent. */
55
48
  private reconcileCrashListeners;
@@ -61,7 +54,7 @@ declare class ElectronFlare extends Flare {
61
54
  * first, so the event loop is not kept alive unnecessarily.
62
55
  */
63
56
  flush(timeoutMs?: number): Promise<void>;
64
- /** Overlay main-authoritative config + Electron metadata + user onto a forwarded report, then send. */
57
+ /** Overlay main-authoritative config + Electron metadata + user identity (from the main scope) onto a forwarded report, then send. */
65
58
  private receiveRendererReport;
66
59
  }
67
60
  //#endregion
@@ -74,4 +67,4 @@ declare const FLARE_BRIDGE_KEY = "__flare";
74
67
  //#region src/main.d.ts
75
68
  declare const flare: ElectronFlare;
76
69
  //#endregion
77
- export { type AttributeValue, type Attributes, type Config, DEFAULT_URL_DENYLIST, type ElectronFatalMode, ElectronFlare, type ElectronOptions, type ElectronUser, FLARE_BRIDGE_KEY, FLARE_IPC_CHANNEL, GlobalScopeProvider, type Glow, Logger, type MessageLevel, NullFileReader, type Report, Scope, type SdkInfo, type SenderFrame, type StackFrame, convertToError, flare, redactUrlQuery, resolveDenylist };
70
+ export { type AttributeValue, type Attributes, type Config, DEFAULT_URL_DENYLIST, type ElectronFatalMode, ElectronFlare, type ElectronOptions, FLARE_BRIDGE_KEY, FLARE_IPC_CHANNEL, GlobalScopeProvider, type Glow, Logger, type MessageLevel, NullFileReader, type Report, Scope, type SdkInfo, type SenderFrame, type StackFrame, type User, convertToError, flare, redactUrlQuery, resolveDenylist };
package/dist/main.d.mts CHANGED
@@ -1,14 +1,8 @@
1
1
  import { App, IpcMain } from "electron";
2
- import { AttributeValue, Attributes, Config, Config as Config$1, DEFAULT_URL_DENYLIST, Flare, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, Report, Scope, SdkInfo, StackFrame, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
2
+ import { AttributeValue, Attributes, Config, Config as Config$1, DEFAULT_URL_DENYLIST, Flare, GlobalScopeProvider, Glow, Logger, MessageLevel, NullFileReader, Report, Scope, SdkInfo, StackFrame, User, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
3
3
 
4
4
  //#region src/types.d.ts
5
5
  type ElectronFatalMode = 'off' | 'report' | 'report-and-exit';
6
- type ElectronUser = {
7
- id?: string | number;
8
- email?: string;
9
- username?: string;
10
- ipAddress?: string;
11
- };
12
6
  /** A frame the IPC receiver evaluates for trust. Mirrors Electron's WebFrameMain shape we use. */
13
7
  type SenderFrame = {
14
8
  url: string;
@@ -35,7 +29,7 @@ declare class ElectronFlare extends Flare {
35
29
  private app;
36
30
  private ipcMain;
37
31
  private options;
38
- private user;
32
+ private mainScope;
39
33
  private isLit;
40
34
  private handlerManager;
41
35
  private renderGoneHandler;
@@ -49,7 +43,6 @@ declare class ElectronFlare extends Flare {
49
43
  configure(config: Partial<Config$1>): this;
50
44
  light(key?: string, debug?: boolean): this;
51
45
  configureElectron(partial: ElectronOptions): this;
52
- setUser(user: ElectronUser | null): void;
53
46
  dispose(): void;
54
47
  /** Attach or detach the process-gone listeners to match options.captureRenderProcessGone. Idempotent. */
55
48
  private reconcileCrashListeners;
@@ -61,7 +54,7 @@ declare class ElectronFlare extends Flare {
61
54
  * first, so the event loop is not kept alive unnecessarily.
62
55
  */
63
56
  flush(timeoutMs?: number): Promise<void>;
64
- /** Overlay main-authoritative config + Electron metadata + user onto a forwarded report, then send. */
57
+ /** Overlay main-authoritative config + Electron metadata + user identity (from the main scope) onto a forwarded report, then send. */
65
58
  private receiveRendererReport;
66
59
  }
67
60
  //#endregion
@@ -74,4 +67,4 @@ declare const FLARE_BRIDGE_KEY = "__flare";
74
67
  //#region src/main.d.ts
75
68
  declare const flare: ElectronFlare;
76
69
  //#endregion
77
- export { type AttributeValue, type Attributes, type Config, DEFAULT_URL_DENYLIST, type ElectronFatalMode, ElectronFlare, type ElectronOptions, type ElectronUser, FLARE_BRIDGE_KEY, FLARE_IPC_CHANNEL, GlobalScopeProvider, type Glow, Logger, type MessageLevel, NullFileReader, type Report, Scope, type SdkInfo, type SenderFrame, type StackFrame, convertToError, flare, redactUrlQuery, resolveDenylist };
70
+ export { type AttributeValue, type Attributes, type Config, DEFAULT_URL_DENYLIST, type ElectronFatalMode, ElectronFlare, type ElectronOptions, FLARE_BRIDGE_KEY, FLARE_IPC_CHANNEL, GlobalScopeProvider, type Glow, Logger, type MessageLevel, NullFileReader, type Report, Scope, type SdkInfo, type SenderFrame, type StackFrame, type User, convertToError, flare, redactUrlQuery, resolveDenylist };
package/dist/main.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { app, ipcMain } from "electron";
2
- import { Api, DEFAULT_URL_DENYLIST, Flare, GlobalScopeProvider, GlobalScopeProvider as GlobalScopeProvider$1, Logger, NullFileReader, Scope, convertToError, redactUrlQuery, resolveDenylist } from "@flareapp/core";
2
+ import { Api, DEFAULT_URL_DENYLIST, Flare, GlobalScopeProvider, GlobalScopeProvider as GlobalScopeProvider$1, Logger, NullFileReader, Scope, USER_IDENTITY_KEYS, convertToError, redactUrlQuery, resolveDenylist, userIdentityAttributes } from "@flareapp/core";
3
3
  import os from "node:os";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import { fileURLToPath } from "node:url";
6
6
 
7
7
  //#region src/env.ts
8
- const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.5.0" : "?";
8
+ const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.5.1" : "?";
9
9
 
10
10
  //#endregion
11
11
  //#region src/types.ts
@@ -47,23 +47,12 @@ function collectElectronAppAttributes(app) {
47
47
  } catch {}
48
48
  return attrs;
49
49
  }
50
- /** Project a user into OTel enduser.* / client.address keys. */
51
- function projectUser(user) {
52
- const attrs = {};
53
- if (!user) return attrs;
54
- if (user.id !== void 0) attrs["enduser.id"] = String(user.id);
55
- if (user.email !== void 0) attrs["enduser.email"] = user.email;
56
- if (user.username !== void 0) attrs["enduser.username"] = user.username;
57
- if (user.ipAddress !== void 0) attrs["client.address"] = user.ipAddress;
58
- return attrs;
59
- }
60
50
  /** Build the ContextCollector core calls on every main-process report. */
61
- function makeElectronContextCollector(app, getUser) {
51
+ function makeElectronContextCollector(app) {
62
52
  return (_config) => ({
63
53
  "flare.entry_point.type": "server",
64
54
  "process.type": process.type ?? "browser",
65
- ...collectElectronAppAttributes(app),
66
- ...projectUser(getUser())
55
+ ...collectElectronAppAttributes(app)
67
56
  });
68
57
  }
69
58
 
@@ -264,7 +253,7 @@ var ElectronFlare = class extends Flare {
264
253
  app;
265
254
  ipcMain;
266
255
  options = { ...DEFAULT_ELECTRON_OPTIONS };
267
- user = null;
256
+ mainScope;
268
257
  isLit = false;
269
258
  handlerManager;
270
259
  renderGoneHandler = null;
@@ -276,9 +265,11 @@ var ElectronFlare = class extends Flare {
276
265
  mainSourcemapVersionId = "";
277
266
  constructor(deps) {
278
267
  const app = deps.app;
279
- const collector = makeElectronContextCollector(app, () => this.user);
268
+ const collector = makeElectronContextCollector(app);
280
269
  const flushScheduler = new ElectronFlushScheduler(app);
281
- super(new Api(), collector, new ElectronDiskFileReader(), new GlobalScopeProvider$1(), flushScheduler);
270
+ const mainScope = new GlobalScopeProvider$1();
271
+ super(new Api(), collector, new ElectronDiskFileReader(), mainScope, flushScheduler);
272
+ this.mainScope = mainScope;
282
273
  this.app = app;
283
274
  this.ipcMain = deps.ipcMain;
284
275
  this.flushScheduler = flushScheduler;
@@ -317,9 +308,6 @@ var ElectronFlare = class extends Flare {
317
308
  this.reconcileCrashListeners();
318
309
  return this;
319
310
  }
320
- setUser(user) {
321
- this.user = user;
322
- }
323
311
  dispose() {
324
312
  this.handlerManager.detach();
325
313
  this.detachCrashListeners();
@@ -380,9 +368,10 @@ var ElectronFlare = class extends Flare {
380
368
  });
381
369
  });
382
370
  }
383
- /** Overlay main-authoritative config + Electron metadata + user onto a forwarded report, then send. */
371
+ /** Overlay main-authoritative config + Electron metadata + user identity (from the main scope) onto a forwarded report, then send. */
384
372
  receiveRendererReport(report) {
385
- Object.assign(report.attributes, collectElectronAppAttributes(this.app), projectUser(this.user));
373
+ for (const key of USER_IDENTITY_KEYS) delete report.attributes[key];
374
+ Object.assign(report.attributes, collectElectronAppAttributes(this.app), userIdentityAttributes(this.mainScope.active()));
386
375
  overlayOrDelete(report.attributes, "service.stage", this.mainStage);
387
376
  overlayOrDelete(report.attributes, "service.version", this.mainVersion);
388
377
  if (this.mainSourcemapVersionId) report.sourcemapVersionId = this.mainSourcemapVersionId;
package/dist/renderer.cjs CHANGED
@@ -8,7 +8,7 @@ const FLARE_BRIDGE_KEY = "__flare";
8
8
 
9
9
  //#endregion
10
10
  //#region src/env.ts
11
- const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.5.0" : "?";
11
+ const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.5.1" : "?";
12
12
 
13
13
  //#endregion
14
14
  //#region src/renderer/RendererFlare.ts
package/dist/renderer.mjs CHANGED
@@ -7,7 +7,7 @@ const FLARE_BRIDGE_KEY = "__flare";
7
7
 
8
8
  //#endregion
9
9
  //#region src/env.ts
10
- const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.5.0" : "?";
10
+ const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.5.1" : "?";
11
11
 
12
12
  //#endregion
13
13
  //#region src/renderer/RendererFlare.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flareapp/electron",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "Electron SDK for flareapp.io",
5
5
  "homepage": "https://flareapp.io",
6
6
  "bugs": {
@@ -62,8 +62,8 @@
62
62
  "release": "release-it"
63
63
  },
64
64
  "dependencies": {
65
- "@flareapp/core": "2.5.0",
66
- "@flareapp/js": "2.5.0"
65
+ "@flareapp/core": "2.5.1",
66
+ "@flareapp/js": "2.5.1"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "electron": ">=35"