Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { mobileStorePlatform } from './utilMobileSignup';
const analytics = vi.hoisted(() => ({
order: [] as string[],
identifyMobileCapture: vi.fn((email: string) => {
analytics.order.push(`identify:${email}`);
}),
track: vi.fn((event: string, data?: Record<string, unknown>) => {
analytics.order.push(`${event}:${String(data?.button_name)}`);
}),
}));
vi.mock('./utilAnalytic', () => ({
analytics: {
identifyMobileCapture: analytics.identifyMobileCapture,
track: analytics.track,
},
}));
describe('mobileStorePlatform', () => {
it.each([
['Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X)', 5, 'ios'],
['Mozilla/5.0 (iPad; CPU OS 17_0 like Mac OS X)', 5, 'ios'],
['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)', 5, 'ios'],
['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)', 0, undefined],
['Mozilla/5.0 (Linux; Android 14; Pixel 8)', 5, 'android'],
['Mozilla/5.0 (X11; Linux x86_64)', 0, undefined],
])('%s with %i touch points → %s', (userAgent, maxTouchPoints, expected) => {
expect(mobileStorePlatform(userAgent, maxTouchPoints)).toBe(expected);
});
});
describe('recordMobileSignupSubmitted', () => {
beforeEach(() => {
analytics.order.length = 0;
analytics.identifyMobileCapture.mockClear();
analytics.track.mockClear();
});
it('identifies the normalized email before mobile_signup_submitted', async () => {
const { recordMobileSignupSubmitted } = await import('./utilMobileSignup');
expect(
recordMobileSignupSubmitted(' [email protected] ', {
buttonName: 'mobile_signup_page',
pageLocation: 'https://macro.com/mobile-signup',
})
).toBe('[email protected]');
expect(analytics.order).toEqual([
'identify:[email protected]',
'mobile_signup_submitted:mobile_signup_page',
]);
expect(analytics.track).toHaveBeenCalledWith('mobile_signup_submitted', {
page_location: 'https://macro.com/mobile-signup',
button_name: 'mobile_signup_page',
});
});
it('does not identify or track an address the form would reject', async () => {
const { recordMobileSignupSubmitted } = await import('./utilMobileSignup');
expect(
recordMobileSignupSubmitted('not-an-email', {
buttonName: 'mobile_signup_page',
pageLocation: 'https://macro.com/mobile-signup',
})
).toBeNull();
expect(analytics.order).toEqual([]);
});
});