MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / sessionToJSON

Function sessionToJSON

packages/core/src/session.ts:140–159  ·  view source on GitHub ↗

* Serializes a passed session object to a JSON object with a slightly different structure. * This is necessary because the Sentry backend requires a slightly different schema of a session * than the one the JS SDKs use internally. * * @param session the session to be converted * * @returns a J

(session: Session)

Source from the content-addressed store, hash-verified

138 * @returns a JSON object of the passed session
139 */
140function sessionToJSON(session: Session): SerializedSession {
141 return {
142 sid: `${session.sid}`,
143 init: session.init,
144 // Make sure that sec is converted to ms for date constructor
145 started: new Date(session.started * 1000).toISOString(),
146 timestamp: new Date(session.timestamp * 1000).toISOString(),
147 status: session.status,
148 errors: session.errors,
149 did: typeof session.did === 'number' || typeof session.did === 'string' ? `${session.did}` : undefined,
150 duration: session.duration,
151 abnormal_mechanism: session.abnormal_mechanism,
152 attrs: {
153 release: session.release,
154 environment: session.environment,
155 ip_address: session.ipAddress,
156 user_agent: session.userAgent,
157 },
158 };
159}

Callers 1

makeSessionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected