@mondaydotcomorg/z2h-shared-utils 0.19.1 → 0.20.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.
@@ -2,7 +2,7 @@ import { Api } from '@mondaydotcomorg/trident-backend-api';
2
2
 
3
3
  function getUserContext() {
4
4
  const user = Api.getPart('context')?.execution.get()?.user;
5
- return user ? { user_name: user.name } : {};
5
+ return user ? { user_name: user.name, user_email: user.email } : {};
6
6
  }
7
7
  /**
8
8
  * Sends a BI event via the Trident runtime's bigbrain tracker, auto-attaching the current user.
@@ -4,7 +4,7 @@ const tridentBackendApi = require('@mondaydotcomorg/trident-backend-api');
4
4
 
5
5
  function getUserContext() {
6
6
  const user = tridentBackendApi.Api.getPart('context')?.execution.get()?.user;
7
- return user ? { user_name: user.name } : {};
7
+ return user ? { user_name: user.name, user_email: user.email } : {};
8
8
  }
9
9
  /**
10
10
  * Sends a BI event via the Trident runtime's bigbrain tracker, auto-attaching the current user.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/z2h-shared-utils",
3
- "version": "0.19.1",
3
+ "version": "0.20.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -22,7 +22,7 @@ class FakeTracker {
22
22
  }
23
23
  }
24
24
 
25
- function mockParts({ tracker, user }: { tracker?: FakeTracker; user?: { name: string } }) {
25
+ function mockParts({ tracker, user }: { tracker?: FakeTracker; user?: { name: string; email: string } }) {
26
26
  getPartMock.mockImplementation((part: string) => {
27
27
  if (part === 'bigbrain') {
28
28
  return tracker ? { tracker } : undefined;
@@ -52,11 +52,15 @@ describe('trackEvent', () => {
52
52
 
53
53
  it('attaches the current user to the event', () => {
54
54
  const tracker = new FakeTracker();
55
- mockParts({ tracker, user: { name: 'Arielle' } });
55
+ mockParts({ tracker, user: { name: 'Arielle', email: 'arielle@monday.com' } });
56
56
 
57
57
  void trackEvent('z2h_agent_tool_call', { tool_name: 'execute' }, 'z2h-agent');
58
58
 
59
- expect(tracker.sent[0].data).toEqual({ user_name: 'Arielle', tool_name: 'execute' });
59
+ expect(tracker.sent[0].data).toEqual({
60
+ user_name: 'Arielle',
61
+ user_email: 'arielle@monday.com',
62
+ tool_name: 'execute',
63
+ });
60
64
  });
61
65
 
62
66
  it('drops the event with a warning when the bigbrain part is unavailable', () => {
@@ -1,9 +1,9 @@
1
1
  import { Api } from '@mondaydotcomorg/trident-backend-api';
2
2
  import type { RawUser } from '@mondaydotcomorg/bigbrain-types';
3
3
 
4
- function getUserContext(): { user_name?: string } {
4
+ function getUserContext(): { user_name?: string; user_email?: string } {
5
5
  const user = Api.getPart('context')?.execution.get()?.user as RawUser | undefined;
6
- return user ? { user_name: user.name } : {};
6
+ return user ? { user_name: user.name, user_email: user.email } : {};
7
7
  }
8
8
 
9
9
  /**