MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / testDirectMethodAPI

Function testDirectMethodAPI

packages/sdks/web/src/types.debug.ts:21–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19
20// Test direct method API
21function testDirectMethodAPI() {
22 // ✅ Should work - correct direct method syntax
23 window.op.track('button_clicked', { location: 'header' });
24 window.op.identify({ profileId: 'user123', email: 'test@example.com' });
25 window.op.screenView('/page', { title: 'Test Page' });
26 window.op.screenView({ title: 'Test Page' }); // Overload with just properties
27 window.op.setGlobalProperties({ version: '1.0.0' });
28 window.op.revenue(1000, { currency: 'USD' });
29 window.op.pendingRevenue(500, { productId: '123' });
30 window.op.flushRevenue();
31 window.op.clearRevenue();
32 window.op.fetchDeviceId();
33 window.op.getDeviceId();
34
35 // ❌ Should error - wrong arguments for track
36 // @ts-expect-error - track expects (name: string, properties?: TrackProperties)
37 window.op.track(123);
38
39 // ❌ Should error - wrong arguments for identify
40 // @ts-expect-error - identify expects IdentifyPayload
41 window.op.identify('user123');
42}
43
44// Test queue property
45function testQueueProperty() {

Callers

nothing calls this directly

Calls 10

trackMethod · 0.45
identifyMethod · 0.45
screenViewMethod · 0.45
setGlobalPropertiesMethod · 0.45
revenueMethod · 0.45
pendingRevenueMethod · 0.45
flushRevenueMethod · 0.45
clearRevenueMethod · 0.45
fetchDeviceIdMethod · 0.45
getDeviceIdMethod · 0.45

Tested by

no test coverage detected