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

Function buildSession

test/fixtures.ts:133–180  ·  view source on GitHub ↗
(
  now: Date,
  projectId: string,
  id: string,
  profileId: string,
  daysBack: number,
  overrides: Record<string, unknown> = {}
)

Source from the content-addressed store, hash-verified

131}
132
133function buildSession(
134 now: Date,
135 projectId: string,
136 id: string,
137 profileId: string,
138 daysBack: number,
139 overrides: Record<string, unknown> = {}
140) {
141 return {
142 id,
143 project_id: projectId,
144 profile_id: profileId,
145 device_id: `dev-${profileId.replace('profile-', '')}`,
146 created_at: timeAgo(now, daysBack),
147 ended_at: timeAgo(now, daysBack),
148 is_bounce: false,
149 entry_origin: 'https://example.com',
150 entry_path: '/home',
151 exit_origin: 'https://example.com',
152 exit_path: '/home',
153 screen_view_count: 1,
154 revenue: 0,
155 event_count: 1,
156 duration: 120,
157 country: 'US',
158 region: '',
159 city: '',
160 device: 'desktop',
161 brand: '',
162 model: '',
163 browser: 'Chrome',
164 browser_version: '',
165 os: '',
166 os_version: '',
167 utm_medium: '',
168 utm_source: '',
169 utm_campaign: '',
170 utm_content: '',
171 utm_term: '',
172 referrer: '',
173 referrer_name: '',
174 referrer_type: '',
175 sign: 1,
176 version: 1,
177 properties: {},
178 ...overrides,
179 };
180}
181
182async function insertFixtures(client: ChClient, projectId: string) {
183 const now = new Date();

Callers 1

insertFixturesFunction · 0.70

Calls 2

replaceMethod · 0.80
timeAgoFunction · 0.70

Tested by

no test coverage detected