posthog-js 1.396.7 → 1.396.8

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.
package/dist/logs.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(){"use strict";function r(){return r=Object.assign?Object.assign.bind():function(r){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var e in n)({}).hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r},r.apply(null,arguments)}var t="undefined"!=typeof window?window:void 0,n="undefined"!=typeof globalThis?globalThis:t;"undefined"==typeof self&&(n.self=n),"undefined"==typeof File&&(n.File=function(){}),null!=n&&n.XMLHttpRequest&&new n.XMLHttpRequest;var e=null!=t?t:{},i={}.toString,o=Array.isArray||function(r){return"[object Array]"===i.call(r)},u=r=>r===Object(r)&&!o(r),f=(r,t,n)=>n.remaining>0?t.length>n.remaining?(r.push(t.slice(0,n.remaining)),n.remaining=0,n.truncated=!0,!1):(r.push(t),n.remaining-=t.length,!0):(n.truncated=!0,!1),a=(r,t,n)=>{var e=JSON.stringify(r);if(n.remaining>=e.length)return f(t,e,n);if(n.truncated=!0,2>n.remaining)return!1;for(var i=0,o=Math.min(r.length,n.remaining-2);o>i;){var u=Math.ceil((i+o)/2);JSON.stringify(r.slice(0,u)).length>n.remaining?o=u-1:i=u}return f(t,JSON.stringify(r.slice(0,i)),n)},c=r=>void 0!==r&&"function"!=typeof r&&"symbol"!=typeof r&&"bigint"!=typeof r,v=(r,t,n)=>{if(!n.truncated){if(n.keysRemaining-=1,n.sizeRemaining-=String(t).length+r.length,0>=n.keysRemaining||0>=n.sizeRemaining)return n.truncated=!0,void(n.result.attributes_truncated=!0);n.result[r]=t}},l=(r,t,n)=>{if(!n.truncated)if(u(r)){if(n.seen.has(r))return void v(t||"circular","[Circular]",n);n.seen.add(r);try{for(var e in r)try{if(!{}.hasOwnProperty.call(r,e))continue;if(l(r[e],t?t+"."+e:e,n),n.truncated)return}catch(r){continue}}catch(r){}}else v(t,r,n)},y=function(r,t,n,e,v,d){if(void 0===v&&(v=!1),!c(r))return!v||f(t,"null",n);if(null===r||(r=>{try{return"[object Number]"==i.call(t=r)&&t==t||(r=>"[object Boolean]"===i.call(r))(r)}catch(r){return!1}var t})(r))return f(t,JSON.stringify(r),n);if("string"==typeof r)return a(r,t,n);if(!u(r)&&!o(r))return f(t,JSON.stringify(r),n);if(e.has(r))return a("[Circular]",t,n);e.add(r);try{var b=r.toJSON;if("function"==typeof b)return y(b.call(r),t,n,e,v)}catch(r){}try{var s={}.toString.call(r);if("[object String]"===s)return a(String(r.valueOf()),t,n);if("[object Number]"===s||"[object Boolean]"===s)return f(t,JSON.stringify(r.valueOf()),n)}catch(r){}if(r instanceof Error){var h={};try{for(var g in r)({}).hasOwnProperty.call(r,g)&&(h[g]=r[g])}catch(r){}try{h.name=r.name}catch(r){}try{h.message=r.message}catch(r){}try{h.stack=r.stack}catch(r){}return y(h,t,n,e,v,d)}if(o(r)){if(!f(t,"[",n))return!1;for(var S=0;r.length>S;S++){if(S>0&&!f(t,",",n))return!1;var O=void 0;try{O=r[S]}catch(r){O=void 0}if(!y(O,t,n,e,!0))return!1}return f(t,"]",n)}if(!f(t,"{",n))return!1;var j=!0;try{for(var w in r)if({}.hasOwnProperty.call(r,w)){if(0>=n.remaining)return n.truncated=!0,!1;var p=void 0;try{p=r[w]}catch(r){continue}if(d)try{l(p,w,d)}catch(r){}if(c(p)){var N=(j?"":",")+JSON.stringify(w)+":";if(N.length>=n.remaining)return n.truncated=!0,!1;var J=t.length,m=n.remaining,k=n.truncated;if(!f(t,N,n))return!1;var A=t.length,z=y(p,t,n,e,!1),B=n.truncated;if(t.length!==A){if(j=!1,!z)return!1}else if(t.length=J,n.remaining=m,n.truncated=z?k:B,!z)return!1}}}catch(r){}return f(t,"}",n)},d={debug:"debug",log:"info",warn:"warn",error:"error",info:"info"};e.__PosthogExtensions__=e.__PosthogExtensions__||{},e.__PosthogExtensions__.logs={initializeLogs(t){var n={host:e.location.host},i=function(i){var o;e.console[i]=(o=e.console[i],function(){for(var a=arguments.length,c=new Array(a),v=0;a>v;v++)c[v]=arguments[v];try{if(c.length>0&&t.is_capturing()){var l,{body:b,truncated:s,attributes:h}=((r,t)=>{for(var n=[],e={remaining:1e4,truncated:!1},i=u(r[0])?{result:{},keysRemaining:50,sizeRemaining:1e4,truncated:!1,seen:new WeakSet([r[0]])}:void 0,o=0;r.length>o&&(0>=o||f(n," ",e))&&y(r[o],n,e,new WeakSet,!1,0===o?i:void 0);o++);return{body:n.join("")+(e.truncated?"...":""),truncated:e.truncated,attributes:(null==i?void 0:i.result)||{}}})(c),g=r({},n,s?{body_truncated:"true"}:{});null==(l=t.logs)||l.le({level:d[i],body:b,attributes:r({"log.source":"console."+i},g,h)})}}catch(r){}finally{o.apply(e.console,c)}})};for(var o of Object.keys(d))i(o)}}}();
1
+ !function(){"use strict";function r(){return r=Object.assign?Object.assign.bind():function(r){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var e in n)({}).hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r},r.apply(null,arguments)}var t="undefined"!=typeof window?window:void 0,n="undefined"!=typeof globalThis?globalThis:t;"undefined"==typeof self&&(n.self=n),"undefined"==typeof File&&(n.File=function(){}),null!=n&&n.XMLHttpRequest&&new n.XMLHttpRequest;var e=null!=t?t:{},i={}.toString,o=Array.isArray||function(r){return"[object Array]"===i.call(r)},u=r=>r===Object(r)&&!o(r),a=(r,t,n)=>n.remaining>0?t.length>n.remaining?(r.push(t.slice(0,n.remaining)),n.remaining=0,n.truncated=!0,!1):(r.push(t),n.remaining-=t.length,!0):(n.truncated=!0,!1),f=(r,t,n)=>{var e=JSON.stringify(r);if(n.remaining>=e.length)return a(t,e,n);if(n.truncated=!0,2>n.remaining)return!1;for(var i=0,o=Math.min(r.length,n.remaining-2);o>i;){var u=Math.ceil((i+o)/2);JSON.stringify(r.slice(0,u)).length>n.remaining?o=u-1:i=u}return a(t,JSON.stringify(r.slice(0,i)),n)},c=r=>void 0!==r&&"function"!=typeof r&&"symbol"!=typeof r&&"bigint"!=typeof r,v=(r,t,n)=>{if(!n.truncated){if(n.keysRemaining-=1,n.sizeRemaining-=String(t).length+r.length,0>=n.keysRemaining||0>=n.sizeRemaining)return n.truncated=!0,void(n.result.attributes_truncated=!0);n.result[r]=t}},l=(r,t,n)=>{if(!n.truncated)if(u(r)){if(n.seen.has(r))return void v(t||"circular","[Circular]",n);n.seen.add(r);try{for(var e in r)try{if(!{}.hasOwnProperty.call(r,e))continue;if(l(r[e],t?t+"."+e:e,n),n.truncated)return}catch(r){continue}}catch(r){}}else v(t,r,n)},y=function(r,t,n,e,v,d){if(void 0===v&&(v=!1),!c(r))return!v||a(t,"null",n);if(null===r||(r=>{try{return"[object Number]"==i.call(t=r)&&t==t||(r=>"[object Boolean]"===i.call(r))(r)}catch(r){return!1}var t})(r))return a(t,JSON.stringify(r),n);if("string"==typeof r)return f(r,t,n);if(!u(r)&&!o(r))return a(t,JSON.stringify(r),n);if(e.has(r))return f("[Circular]",t,n);e.add(r);try{var b=r.toJSON;if("function"==typeof b)return y(b.call(r),t,n,e,v)}catch(r){}try{var s={}.toString.call(r);if("[object String]"===s)return f(String(r.valueOf()),t,n);if("[object Number]"===s||"[object Boolean]"===s)return a(t,JSON.stringify(r.valueOf()),n)}catch(r){}if(r instanceof Error){var h={};try{for(var g in r)({}).hasOwnProperty.call(r,g)&&(h[g]=r[g])}catch(r){}try{h.name=r.name}catch(r){}try{h.message=r.message}catch(r){}try{h.stack=r.stack}catch(r){}return y(h,t,n,e,v,d)}if(o(r)){if(!a(t,"[",n))return!1;for(var S=0;r.length>S;S++){if(S>0&&!a(t,",",n))return!1;var O=void 0;try{O=r[S]}catch(r){O=void 0}if(!y(O,t,n,e,!0))return!1}return a(t,"]",n)}if(!a(t,"{",n))return!1;var j=!0;try{for(var w in r)if({}.hasOwnProperty.call(r,w)){if(0>=n.remaining)return n.truncated=!0,!1;var p=void 0;try{p=r[w]}catch(r){continue}if(d)try{l(p,w,d)}catch(r){}if(c(p)){var N=(j?"":",")+JSON.stringify(w)+":";if(N.length>=n.remaining)return n.truncated=!0,!1;var J=t.length,m=n.remaining,k=n.truncated;if(!a(t,N,n))return!1;var A=t.length,z=y(p,t,n,e,!1),B=n.truncated;if(t.length!==A){if(j=!1,!z)return!1}else if(t.length=J,n.remaining=m,n.truncated=z?k:B,!z)return!1}}}catch(r){}return a(t,"}",n)},d={debug:"debug",log:"info",warn:"warn",error:"error",info:"info"};e.__PosthogExtensions__=e.__PosthogExtensions__||{},e.__PosthogExtensions__.logs={initializeLogs(t){var n={host:e.location.host},i=!1,o=function(o){var f=e.console[o],c=(f=>function(){for(var c=!1,v=arguments.length,l=new Array(v),b=0;v>b;b++)l[b]=arguments[b];try{if(l.length>0&&!i&&t.is_capturing()){var s;i=!0,c=!0;var{body:h,truncated:g,attributes:S}=((r,t)=>{for(var n=[],e={remaining:1e4,truncated:!1},i=u(r[0])?{result:{},keysRemaining:50,sizeRemaining:1e4,truncated:!1,seen:new WeakSet([r[0]])}:void 0,o=0;r.length>o&&(0>=o||a(n," ",e))&&y(r[o],n,e,new WeakSet,!1,0===o?i:void 0);o++);return{body:n.join("")+(e.truncated?"...":""),truncated:e.truncated,attributes:(null==i?void 0:i.result)||{}}})(l),O=r({},n,g?{body_truncated:"true"}:{});null==(s=t.logs)||s.le({level:d[o],body:h,attributes:r({"log.source":"console."+o},O,S)})}}catch(r){}finally{c&&(i=!1),f.apply(e.console,l)}})(f);c.__rrweb_original__=(r=>{for(;null!=(t=r)&&t.__rrweb_original__;){var t;r=r.__rrweb_original__}return r})(f),e.console[o]=c};for(var f of Object.keys(d))o(f)}}}();
2
2
  //# sourceMappingURL=logs.js.map
package/dist/logs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logs.js","sources":["../src/utils/globals.ts","../../core/dist/utils/type-utils.mjs","../src/entrypoints/logs.ts"],"sourcesContent":["import type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ExternalIntegrationKind,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n SessionStartReason,\n} from '../types'\nimport type {\n ConversationsRemoteConfig,\n GetMessagesResponse,\n GetTicketsOptions,\n GetTicketsResponse,\n MarkAsReadResponse,\n RestoreFromTokenResponse,\n RequestRestoreLinkResponse,\n SendMessageResponse,\n UserProvidedTraits,\n} from '../posthog-conversations-types'\n// only importing types here, so won't affect the bundle\n// eslint-disable-next-line posthog-js/no-external-replay-imports\nimport type { SessionRecordingStatus, TriggerType } from '../extensions/replay/external/triggerMatching'\nimport type { TracingHeadersDistinctId, TracingHeadersHostnames } from '../extensions/tracing-headers-types'\nimport { eventWithTime } from '../extensions/replay/types/rrweb-types'\nimport { ErrorTracking } from '@posthog/core'\n\n/*\n * Global helpers to protect access to browser globals in a way that is safer for different targets\n * like DOM, SSR, Web workers etc.\n *\n * NOTE: Typically we want the \"window\" but globalThis works for both the typical browser context as\n * well as other contexts such as the web worker context. Window is still exported for any bits that explicitly require it.\n * If in doubt - export the global you need from this file and use that as an optional value. This way the code path is forced\n * to handle the case where the global is not available.\n */\n\n// eslint-disable-next-line no-restricted-globals\nconst win: (Window & typeof globalThis) | undefined = typeof window !== 'undefined' ? window : undefined\n\nexport type AssignableWindow = Window &\n typeof globalThis & {\n /*\n * Main PostHog instance\n */\n posthog: any\n\n /*\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n */\n __PosthogExtensions__?: PostHogExtensions\n\n /**\n * When loading remote config, we assign it to this global configuration\n * for ease of sharing it with the rest of the SDK\n */\n _POSTHOG_REMOTE_CONFIG?: Record<\n string,\n {\n config: RemoteConfig\n siteApps: SiteAppLoader[]\n }\n >\n\n /**\n * If this is set on the window, our logger will log to the console\n * for ease of debugging. Used for testing purposes only.\n *\n * @see {Config.DEBUG} from config.ts\n */\n POSTHOG_DEBUG: any\n\n // Exposed by the browser\n doNotTrack: any\n\n // See entrypoints/customizations.full.ts\n posthogCustomizations: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/exception-autocapture.ts\n *\n * @deprecated use `__PosthogExtensions__.errorWrappingFunctions` instead\n */\n posthogErrorWrappingFunctions: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrweb` instead\n */\n rrweb: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrwebConsoleRecord` instead\n */\n rrwebConsoleRecord: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.getRecordNetworkPlugin` instead\n */\n getRecordNetworkPlugin: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/web-vitals.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogWebVitalsCallbacks` instead\n */\n postHogWebVitalsCallbacks: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/tracing-headers.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogTracingHeadersPatchFns` instead\n */\n postHogTracingHeadersPatchFns: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/surveys.ts\n *\n * @deprecated use `__PosthogExtensions__.generateSurveys` instead\n */\n extendPostHogWithSurveys: any\n\n /*\n * These are used to handle our toolbar state.\n * @see {Toolbar} from extensions/toolbar.ts\n */\n ph_load_toolbar: any\n ph_load_editor: any\n ph_toolbar_state: any\n } & Record<`__$$ph_site_app_${string}`, any>\n\n/**\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n * changes to this interface can be breaking changes for users of the SDK\n */\n\nexport type ExternalExtensionKind = 'intercom-integration' | 'crisp-chat-integration'\n\nexport type PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'web-vitals-with-attribution'\n | 'recorder'\n | 'lazy-recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'logs'\n | 'conversations'\n | 'product-tours'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n | ExternalExtensionKind\n\nexport interface LazyLoadedSessionRecordingInterface {\n start: (startReason?: SessionStartReason) => void\n stop: () => void\n discard: () => void\n sessionId: string\n status: SessionRecordingStatus\n onRRwebEmit: (rawEvent: eventWithTime) => void\n log: (message: string, level: 'log' | 'warn' | 'error') => void\n sdkDebugProperties: Properties\n overrideLinkedFlag: () => void\n overrideSampling: () => void\n overrideTrigger: (triggerType: TriggerType) => void\n isStarted: boolean\n tryAddCustomEvent(tag: string, payload: any): boolean\n}\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\n}\n\nexport interface LazyLoadedConversationsInterface {\n // Widget control\n show: () => void\n hide: () => void\n isVisible: () => boolean\n\n // Lifecycle\n reset: () => void\n\n // Identity verification\n setIdentity: () => void\n clearIdentity: () => void\n\n // API methods\n sendMessage: (message: string, userTraits?: UserProvidedTraits, newTicket?: boolean) => Promise<SendMessageResponse>\n getMessages: (ticketId?: string, after?: string) => Promise<GetMessagesResponse>\n markAsRead: (ticketId?: string) => Promise<MarkAsReadResponse>\n getTickets: (options?: GetTicketsOptions) => Promise<GetTicketsResponse>\n requestRestoreLink: (email: string) => Promise<RequestRestoreLinkResponse>\n restoreFromToken: (restoreToken: string) => Promise<RestoreFromTokenResponse>\n restoreFromUrlToken: () => Promise<RestoreFromTokenResponse | null>\n getCurrentTicketId: () => string | null\n getWidgetSessionId: () => string\n}\n\ninterface PostHogExtensions {\n loadExternalDependency?: (\n posthog: PostHog,\n kind: PostHogExtensionKind,\n callback: (error?: string | Event, event?: Event) => void\n ) => void\n\n loadSiteApp?: (posthog: PostHog, appUrl: string, callback: (error?: string | Event, event?: Event) => void) => void\n\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapConsoleError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n }\n rrweb?: { record: any; version: string; wasMaxDepthReached?: () => boolean; resetMaxDepthState?: () => void }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n generateSurveys?: (posthog: PostHog, isSurveysEnabled: boolean) => any | undefined\n generateProductTours?: (posthog: PostHog, isEnabled: boolean) => any | undefined\n logs?: {\n initializeLogs?: (posthog: PostHog) => any | undefined\n }\n postHogWebVitalsCallbacks?: {\n onLCP: (metric: any) => void\n onCLS: (metric: any) => void\n onFCP: (metric: any) => void\n onINP: (metric: any) => void\n }\n /**\n * @deprecated\n *\n * this was introduced briefly, it is now always a no-op and only kept for backwards compatibility\n */\n loadWebVitalsCallbacks?: (useAttribution?: boolean) => PostHogExtensions['postHogWebVitalsCallbacks']\n tracingHeadersPatchFns?: {\n _patchFetch: (\n hostnames: TracingHeadersHostnames,\n distinctId: TracingHeadersDistinctId,\n sessionManager?: SessionIdManager\n ) => () => void\n _patchXHR: (\n hostnames: TracingHeadersHostnames,\n distinctId: TracingHeadersDistinctId,\n sessionManager?: SessionIdManager\n ) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n integrations?: {\n [K in ExternalIntegrationKind]?: { start: (posthog: PostHog) => void; stop: () => void }\n }\n initSessionRecording?: (ph: PostHog) => LazyLoadedSessionRecordingInterface\n initConversations?: (config: ConversationsRemoteConfig, posthog: PostHog) => LazyLoadedConversationsInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\n\n// React Native polyfills for posthog-js compatibility\nif (typeof self === 'undefined') {\n ;(global as any).self = global\n}\nif (typeof File === 'undefined') {\n ;(global as any).File = function () {}\n}\n\nexport const navigator = global?.navigator\nexport const document = global?.document\nexport const location = global?.location\nexport const fetch = global?.fetch\nexport const XMLHttpRequest =\n global?.XMLHttpRequest && 'withCredentials' in new global.XMLHttpRequest() ? global.XMLHttpRequest : undefined\nexport const AbortController = global?.AbortController\nexport const CompressionStream = global?.CompressionStream\nexport const userAgent = navigator?.userAgent\nexport const assignableWindow: AssignableWindow = win ?? ({} as any)\n\nexport function isBrowserOnline(): boolean {\n return !!(win && win.navigator.onLine !== false)\n}\n\nexport { win as window }\n","import { knownUnsafeEditableEvent, knownUnsafeEditableEventProperty } from \"../types.mjs\";\nimport { includes } from \"./string-utils.mjs\";\nconst nativeIsArray = Array.isArray;\nconst ObjProto = Object.prototype;\nconst type_utils_hasOwnProperty = ObjProto.hasOwnProperty;\nconst type_utils_toString = ObjProto.toString;\nconst isArray = nativeIsArray || function(obj) {\n return '[object Array]' === type_utils_toString.call(obj);\n};\nconst isFunction = (x)=>'function' == typeof x;\nconst isNativeFunction = (x)=>isFunction(x) && -1 !== x.toString().indexOf('[native code]');\nconst isObject = (x)=>x === Object(x) && !isArray(x);\nconst isEmptyObject = (x)=>{\n if (isObject(x)) {\n for(const key in x)if (type_utils_hasOwnProperty.call(x, key)) return false;\n return true;\n }\n return false;\n};\nconst isUndefined = (x)=>void 0 === x;\nconst isString = (x)=>'[object String]' == type_utils_toString.call(x);\nconst isEmptyString = (x)=>isString(x) && 0 === x.trim().length;\nconst isNull = (x)=>null === x;\nconst isNullish = (x)=>isUndefined(x) || isNull(x);\nconst isNumber = (x)=>'[object Number]' == type_utils_toString.call(x) && x === x;\nconst isPositiveNumber = (value)=>isNumber(value) && value > 0;\nconst isBoolean = (x)=>'[object Boolean]' === type_utils_toString.call(x);\nconst isFormData = (x)=>x instanceof FormData;\nconst isFile = (x)=>x instanceof File;\nconst isPlainError = (x)=>x instanceof Error;\nconst isKnownUnsafeEditableEvent = (x)=>includes(knownUnsafeEditableEvent, x);\nconst isKnownUnsafeEditableEventProperty = (x)=>includes(knownUnsafeEditableEventProperty, x);\nfunction isPrimitive(value) {\n return null === value || 'object' != typeof value;\n}\nfunction isBuiltin(candidate, className) {\n return Object.prototype.toString.call(candidate) === `[object ${className}]`;\n}\nfunction isError(candidate) {\n switch(Object.prototype.toString.call(candidate)){\n case '[object Error]':\n case '[object Exception]':\n case '[object DOMException]':\n case '[object DOMError]':\n case '[object WebAssembly.Exception]':\n return true;\n default:\n return isInstanceOf(candidate, Error);\n }\n}\nfunction isErrorEvent(event) {\n return isBuiltin(event, 'ErrorEvent');\n}\nfunction isEvent(candidate) {\n return 'undefined' != typeof Event && isInstanceOf(candidate, Event);\n}\nfunction isPlainObject(candidate) {\n return isBuiltin(candidate, 'Object');\n}\nfunction isInstanceOf(candidate, base) {\n try {\n return candidate instanceof base;\n } catch {\n return false;\n }\n}\nconst yesLikeValues = [\n true,\n 'true',\n 1,\n '1',\n 'yes'\n];\nconst isYesLike = (val)=>includes(yesLikeValues, val);\nconst noLikeValues = [\n false,\n 'false',\n 0,\n '0',\n 'no'\n];\nconst isNoLike = (val)=>includes(noLikeValues, val);\nexport { type_utils_hasOwnProperty as hasOwnProperty, isArray, isBoolean, isBuiltin, isEmptyObject, isEmptyString, isError, isErrorEvent, isEvent, isFile, isFormData, isFunction, isKnownUnsafeEditableEvent, isKnownUnsafeEditableEventProperty, isNativeFunction, isNoLike, isNull, isNullish, isNumber, isObject, isPlainError, isPlainObject, isPositiveNumber, isPrimitive, isString, isUndefined, isYesLike, noLikeValues, yesLikeValues };\n","import { assignableWindow } from '../utils/globals'\nimport { PostHog } from '../posthog-core'\nimport { isArray, isBoolean, isFunction, isNull, isNumber, isObject } from '@posthog/core'\nimport type { LogSeverityLevel } from '@posthog/types'\n\nconst LOG_BODY_SIZE_LIMIT = 10000\nconst LOG_ATTRIBUTES_LIMIT = 50\n\ntype StringifyBudget = {\n remaining: number\n truncated: boolean\n}\n\ntype AttributeCollector = {\n result: Record<string, any>\n keysRemaining: number\n sizeRemaining: number\n truncated: boolean\n seen: WeakSet<object>\n}\n\nconst appendWithLimit = (parts: string[], text: string, budget: StringifyBudget): boolean => {\n if (budget.remaining <= 0) {\n budget.truncated = true\n return false\n }\n\n if (text.length <= budget.remaining) {\n parts.push(text)\n budget.remaining -= text.length\n return true\n }\n\n parts.push(text.slice(0, budget.remaining))\n budget.remaining = 0\n budget.truncated = true\n return false\n}\n\nconst stringifyStringWithLimit = (value: string, parts: string[], budget: StringifyBudget): boolean => {\n const serialized = JSON.stringify(value)\n if (serialized.length <= budget.remaining) {\n return appendWithLimit(parts, serialized, budget)\n }\n\n budget.truncated = true\n if (budget.remaining < 2) {\n return false\n }\n\n let low = 0\n let high = Math.min(value.length, budget.remaining - 2)\n while (low < high) {\n const mid = Math.ceil((low + high) / 2)\n if (JSON.stringify(value.slice(0, mid)).length <= budget.remaining) {\n low = mid\n } else {\n high = mid - 1\n }\n }\n\n return appendWithLimit(parts, JSON.stringify(value.slice(0, low)), budget)\n}\n\nconst isJSONSerializablePrimitive = (value: any): boolean =>\n typeof value !== 'undefined' &&\n typeof value !== 'function' &&\n typeof value !== 'symbol' &&\n typeof value !== 'bigint'\n\nconst isNumberOrBoolean = (value: any): boolean => {\n try {\n return isNumber(value) || isBoolean(value)\n } catch {\n return false\n }\n}\n\nconst collectAttributeValue = (key: string, value: any, collector: AttributeCollector): void => {\n if (collector.truncated) {\n return\n }\n\n collector.keysRemaining -= 1\n collector.sizeRemaining -= String(value).length + key.length\n if (collector.keysRemaining <= 0 || collector.sizeRemaining <= 0) {\n collector.truncated = true\n collector.result['attributes_truncated'] = true\n return\n }\n\n collector.result[key] = value\n}\n\nconst collectFlattenedAttributes = (value: any, key: string, collector: AttributeCollector): void => {\n if (collector.truncated) {\n return\n }\n\n if (isObject(value)) {\n if (collector.seen.has(value)) {\n collectAttributeValue(key || 'circular', '[Circular]', collector)\n return\n }\n collector.seen.add(value)\n\n try {\n for (const childKey in value) {\n try {\n if (!Object.prototype.hasOwnProperty.call(value, childKey)) {\n continue\n }\n const childValue = value[childKey]\n collectFlattenedAttributes(childValue, key ? `${key}.${childKey}` : childKey, collector)\n if (collector.truncated) {\n return\n }\n } catch {\n continue\n }\n }\n } catch {\n // we'll omit this object's properties considering we can't enumerate them\n }\n return\n }\n\n collectAttributeValue(key, value, collector)\n}\n\nconst stringifyValueWithLimit = (\n value: any,\n parts: string[],\n budget: StringifyBudget,\n seen: WeakSet<object>,\n inArray = false,\n attributeCollector?: AttributeCollector\n): boolean => {\n if (!isJSONSerializablePrimitive(value)) {\n return inArray ? appendWithLimit(parts, 'null', budget) : true\n }\n\n if (isNull(value) || isNumberOrBoolean(value)) {\n return appendWithLimit(parts, JSON.stringify(value), budget)\n }\n\n if (typeof value === 'string') {\n return stringifyStringWithLimit(value, parts, budget)\n }\n\n if (!isObject(value) && !isArray(value)) {\n return appendWithLimit(parts, JSON.stringify(value), budget)\n }\n\n if (seen.has(value)) {\n return stringifyStringWithLimit('[Circular]', parts, budget)\n }\n seen.add(value)\n\n try {\n const toJSON = (value as any).toJSON\n if (isFunction(toJSON)) {\n return stringifyValueWithLimit(toJSON.call(value), parts, budget, seen, inArray)\n }\n } catch {\n // If toJSON can't be read or throws, fall through to safe property enumeration.\n }\n\n try {\n const objectTag = Object.prototype.toString.call(value)\n if (objectTag === '[object String]') {\n return stringifyStringWithLimit(String(value.valueOf()), parts, budget)\n }\n\n if (objectTag === '[object Number]' || objectTag === '[object Boolean]') {\n return appendWithLimit(parts, JSON.stringify(value.valueOf()), budget)\n }\n } catch {\n // If Object.prototype.toString or valueOf throws, fall through to safe property enumeration.\n }\n\n if (value instanceof Error) {\n const errorObject: Record<string, any> = {}\n try {\n for (const key in value) {\n if (Object.prototype.hasOwnProperty.call(value, key)) {\n errorObject[key] = value[key as keyof Error]\n }\n }\n } catch {}\n try {\n errorObject.name = value.name\n } catch {}\n try {\n errorObject.message = value.message\n } catch {}\n try {\n errorObject.stack = value.stack\n } catch {}\n return stringifyValueWithLimit(errorObject, parts, budget, seen, inArray, attributeCollector)\n }\n\n if (isArray(value)) {\n if (!appendWithLimit(parts, '[', budget)) {\n return false\n }\n for (let i = 0; i < value.length; i++) {\n if (i > 0 && !appendWithLimit(parts, ',', budget)) {\n return false\n }\n let item\n try {\n item = value[i]\n } catch {\n item = undefined\n }\n if (!stringifyValueWithLimit(item, parts, budget, seen, true)) {\n return false\n }\n }\n return appendWithLimit(parts, ']', budget)\n }\n\n if (!appendWithLimit(parts, '{', budget)) {\n return false\n }\n let isFirst = true\n try {\n for (const key in value) {\n if (!Object.prototype.hasOwnProperty.call(value, key)) {\n continue\n }\n if (budget.remaining <= 0) {\n budget.truncated = true\n return false\n }\n\n let propertyValue\n try {\n propertyValue = value[key]\n } catch {\n continue\n }\n if (attributeCollector) {\n try {\n collectFlattenedAttributes(propertyValue, key, attributeCollector)\n } catch {\n // we'll omit this object's attributes considering we can't read them safely\n }\n }\n\n if (!isJSONSerializablePrimitive(propertyValue)) {\n continue\n }\n\n const propertyPrefix = `${isFirst ? '' : ','}${JSON.stringify(key)}:`\n if (propertyPrefix.length >= budget.remaining) {\n budget.truncated = true\n return false\n }\n\n const partsBeforeProperty = parts.length\n const remainingBeforeProperty = budget.remaining\n const truncatedBeforeProperty = budget.truncated\n if (!appendWithLimit(parts, propertyPrefix, budget)) {\n return false\n }\n\n const partsBeforeValue = parts.length\n const serialized = stringifyValueWithLimit(propertyValue, parts, budget, seen, false)\n const truncatedAfterValue = budget.truncated\n if (parts.length === partsBeforeValue) {\n parts.length = partsBeforeProperty\n budget.remaining = remainingBeforeProperty\n budget.truncated = serialized ? truncatedBeforeProperty : truncatedAfterValue\n if (!serialized) {\n return false\n }\n continue\n }\n\n isFirst = false\n if (!serialized) {\n return false\n }\n }\n } catch {\n // we'll omit this object's properties considering we can't enumerate them\n }\n return appendWithLimit(parts, '}', budget)\n}\n\nconst stringifyArgsSafely = (\n args: any[],\n sizeLimit: number\n): { body: string; truncated: boolean; attributes: Record<string, any> } => {\n const parts: string[] = []\n const budget = { remaining: sizeLimit, truncated: false }\n const attributeCollector = isObject(args[0])\n ? {\n result: {} as Record<string, any>,\n keysRemaining: LOG_ATTRIBUTES_LIMIT,\n sizeRemaining: LOG_BODY_SIZE_LIMIT,\n truncated: false,\n seen: new WeakSet<object>([args[0]]),\n }\n : undefined\n\n for (let i = 0; i < args.length; i++) {\n if (i > 0 && !appendWithLimit(parts, ' ', budget)) {\n break\n }\n if (\n !stringifyValueWithLimit(\n args[i],\n parts,\n budget,\n new WeakSet<object>(),\n false,\n i === 0 ? attributeCollector : undefined\n )\n ) {\n break\n }\n }\n\n return {\n body: parts.join('') + (budget.truncated ? '...' : ''),\n truncated: budget.truncated,\n attributes: attributeCollector?.result || {},\n }\n}\n\ntype ConsoleLevel = 'debug' | 'log' | 'warn' | 'error' | 'info'\n\n// Console method → OTLP severity level. `log` and `info` both map to `info`;\n// the originating method is preserved separately via the `log.source` attribute.\nconst LEVEL_MAP: Record<ConsoleLevel, LogSeverityLevel> = {\n debug: 'debug',\n log: 'info',\n warn: 'warn',\n error: 'error',\n info: 'info',\n}\n\nconst initializeLogs = (posthog: PostHog) => {\n // `host` is carried here because the core SDK context has no equivalent. Session\n // attributes (window.id, sessionStartTimestamp, lastActivityTimestamp) are added\n // downstream by the core pipeline from the SDK context, alongside sessionId.\n const attributes: Record<string, string> = { host: assignableWindow.location.host }\n\n for (const level of Object.keys(LEVEL_MAP) as ConsoleLevel[]) {\n const logWrapper =\n (originalConsoleLog: any) =>\n (...args: any[]) => {\n try {\n if (args.length > 0 && posthog.is_capturing()) {\n const {\n body,\n truncated,\n attributes: flattenedAttributes,\n } = stringifyArgsSafely(args, LOG_BODY_SIZE_LIMIT)\n const logAttributes = {\n ...attributes,\n ...(truncated ? { body_truncated: 'true' } : {}),\n }\n // The core pipeline adds posthogDistinctId and url.full from the SDK context.\n posthog.logs?._captureConsoleLog({\n level: LEVEL_MAP[level],\n body,\n attributes: {\n 'log.source': `console.${level}`,\n ...logAttributes,\n ...flattenedAttributes,\n },\n })\n }\n } catch {\n // Capture must never break the page's own console output, so the\n // real console call below always runs even if capture throws.\n } finally {\n originalConsoleLog.apply(assignableWindow.console, args)\n }\n }\n\n const originalConsoleLog = assignableWindow.console[level]\n assignableWindow.console[level] = logWrapper(originalConsoleLog)\n }\n}\n\nassignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {}\nassignableWindow.__PosthogExtensions__.logs = { initializeLogs }\n"],"names":["win","window","undefined","global","globalThis","self","File","XMLHttpRequest","assignableWindow","type_utils_toString","Object","prototype","toString","isArray","Array","obj","call","isObject","x","appendWithLimit","parts","text","budget","remaining","length","push","slice","truncated","stringifyStringWithLimit","value","serialized","JSON","stringify","low","high","Math","min","mid","ceil","isJSONSerializablePrimitive","collectAttributeValue","key","collector","keysRemaining","sizeRemaining","String","result","collectFlattenedAttributes","seen","has","add","childKey","hasOwnProperty","_unused2","_unused3","stringifyValueWithLimit","inArray","attributeCollector","isBoolean","_unused","isNumberOrBoolean","toJSON","_unused4","objectTag","valueOf","_unused5","Error","errorObject","_unused6","name","_unused7","message","_unused8","stack","_unused9","i","item","_unused0","isFirst","propertyValue","_unused1","_unused10","propertyPrefix","partsBeforeProperty","remainingBeforeProperty","truncatedBeforeProperty","partsBeforeValue","truncatedAfterValue","_unused11","LEVEL_MAP","debug","log","warn","error","info","__PosthogExtensions__","logs","initializeLogs","posthog","attributes","host","location","_loop","level","originalConsoleLog","console","_len","arguments","args","_key2","is_capturing","_posthog$logs","body","flattenedAttributes","stringifyArgsSafely","sizeLimit","WeakSet","join","logAttributes","_extends","body_truncated","_captureConsoleLog","_unused12","apply","keys"],"mappings":"iPAuCA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AlB1C,OAAkB,EAAlBA,EAAoBX,SAAU,CAAA,EAC7C,EA+BuBoE,CAAoBN,GAClBU,EAAaC,KACZpB,EACCxE,EAAY,CAAE6F,eAAgB,QAAW,IAGrC,OAAZT,EAAAb,EAAQF,OAARe,EAAcU,GAAmB,CAC7BlB,MAAOd,EAAUc,GACjBS,OACAb,WAAUoB,EAAA,CACN,aAAY,WAAahB,GACtBe,EACAL,IAGf,CACJ,CAAE,MAAAS,GAEE,CACH,QACGlB,EAAmBmB,MAAMnH,EAAiBiG,QAASG,EACvD,CACJ,EAIR,EApCA,IAAK,IAAML,KAAS7F,OAAOkH,KAAKnC,GAAUa,EAAAC,EAAA"}
1
+ {"version":3,"file":"logs.js","sources":["../src/utils/globals.ts","../../core/dist/utils/type-utils.mjs","../src/entrypoints/logs.ts"],"sourcesContent":["import type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ExternalIntegrationKind,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n SessionStartReason,\n} from '../types'\nimport type {\n ConversationsRemoteConfig,\n GetMessagesResponse,\n GetTicketsOptions,\n GetTicketsResponse,\n MarkAsReadResponse,\n RestoreFromTokenResponse,\n RequestRestoreLinkResponse,\n SendMessageResponse,\n UserProvidedTraits,\n} from '../posthog-conversations-types'\n// only importing types here, so won't affect the bundle\n// eslint-disable-next-line posthog-js/no-external-replay-imports\nimport type { SessionRecordingStatus, TriggerType } from '../extensions/replay/external/triggerMatching'\nimport type { TracingHeadersDistinctId, TracingHeadersHostnames } from '../extensions/tracing-headers-types'\nimport { eventWithTime } from '../extensions/replay/types/rrweb-types'\nimport { ErrorTracking } from '@posthog/core'\n\n/*\n * Global helpers to protect access to browser globals in a way that is safer for different targets\n * like DOM, SSR, Web workers etc.\n *\n * NOTE: Typically we want the \"window\" but globalThis works for both the typical browser context as\n * well as other contexts such as the web worker context. Window is still exported for any bits that explicitly require it.\n * If in doubt - export the global you need from this file and use that as an optional value. This way the code path is forced\n * to handle the case where the global is not available.\n */\n\n// eslint-disable-next-line no-restricted-globals\nconst win: (Window & typeof globalThis) | undefined = typeof window !== 'undefined' ? window : undefined\n\nexport type AssignableWindow = Window &\n typeof globalThis & {\n /*\n * Main PostHog instance\n */\n posthog: any\n\n /*\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n */\n __PosthogExtensions__?: PostHogExtensions\n\n /**\n * When loading remote config, we assign it to this global configuration\n * for ease of sharing it with the rest of the SDK\n */\n _POSTHOG_REMOTE_CONFIG?: Record<\n string,\n {\n config: RemoteConfig\n siteApps: SiteAppLoader[]\n }\n >\n\n /**\n * If this is set on the window, our logger will log to the console\n * for ease of debugging. Used for testing purposes only.\n *\n * @see {Config.DEBUG} from config.ts\n */\n POSTHOG_DEBUG: any\n\n // Exposed by the browser\n doNotTrack: any\n\n // See entrypoints/customizations.full.ts\n posthogCustomizations: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/exception-autocapture.ts\n *\n * @deprecated use `__PosthogExtensions__.errorWrappingFunctions` instead\n */\n posthogErrorWrappingFunctions: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrweb` instead\n */\n rrweb: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrwebConsoleRecord` instead\n */\n rrwebConsoleRecord: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.getRecordNetworkPlugin` instead\n */\n getRecordNetworkPlugin: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/web-vitals.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogWebVitalsCallbacks` instead\n */\n postHogWebVitalsCallbacks: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/tracing-headers.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogTracingHeadersPatchFns` instead\n */\n postHogTracingHeadersPatchFns: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/surveys.ts\n *\n * @deprecated use `__PosthogExtensions__.generateSurveys` instead\n */\n extendPostHogWithSurveys: any\n\n /*\n * These are used to handle our toolbar state.\n * @see {Toolbar} from extensions/toolbar.ts\n */\n ph_load_toolbar: any\n ph_load_editor: any\n ph_toolbar_state: any\n } & Record<`__$$ph_site_app_${string}`, any>\n\n/**\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n * changes to this interface can be breaking changes for users of the SDK\n */\n\nexport type ExternalExtensionKind = 'intercom-integration' | 'crisp-chat-integration'\n\nexport type PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'web-vitals-with-attribution'\n | 'recorder'\n | 'lazy-recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'logs'\n | 'conversations'\n | 'product-tours'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n | ExternalExtensionKind\n\nexport interface LazyLoadedSessionRecordingInterface {\n start: (startReason?: SessionStartReason) => void\n stop: () => void\n discard: () => void\n sessionId: string\n status: SessionRecordingStatus\n onRRwebEmit: (rawEvent: eventWithTime) => void\n log: (message: string, level: 'log' | 'warn' | 'error') => void\n sdkDebugProperties: Properties\n overrideLinkedFlag: () => void\n overrideSampling: () => void\n overrideTrigger: (triggerType: TriggerType) => void\n isStarted: boolean\n tryAddCustomEvent(tag: string, payload: any): boolean\n}\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\n}\n\nexport interface LazyLoadedConversationsInterface {\n // Widget control\n show: () => void\n hide: () => void\n isVisible: () => boolean\n\n // Lifecycle\n reset: () => void\n\n // Identity verification\n setIdentity: () => void\n clearIdentity: () => void\n\n // API methods\n sendMessage: (message: string, userTraits?: UserProvidedTraits, newTicket?: boolean) => Promise<SendMessageResponse>\n getMessages: (ticketId?: string, after?: string) => Promise<GetMessagesResponse>\n markAsRead: (ticketId?: string) => Promise<MarkAsReadResponse>\n getTickets: (options?: GetTicketsOptions) => Promise<GetTicketsResponse>\n requestRestoreLink: (email: string) => Promise<RequestRestoreLinkResponse>\n restoreFromToken: (restoreToken: string) => Promise<RestoreFromTokenResponse>\n restoreFromUrlToken: () => Promise<RestoreFromTokenResponse | null>\n getCurrentTicketId: () => string | null\n getWidgetSessionId: () => string\n}\n\ninterface PostHogExtensions {\n loadExternalDependency?: (\n posthog: PostHog,\n kind: PostHogExtensionKind,\n callback: (error?: string | Event, event?: Event) => void\n ) => void\n\n loadSiteApp?: (posthog: PostHog, appUrl: string, callback: (error?: string | Event, event?: Event) => void) => void\n\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapConsoleError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n }\n rrweb?: { record: any; version: string; wasMaxDepthReached?: () => boolean; resetMaxDepthState?: () => void }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n generateSurveys?: (posthog: PostHog, isSurveysEnabled: boolean) => any | undefined\n generateProductTours?: (posthog: PostHog, isEnabled: boolean) => any | undefined\n logs?: {\n initializeLogs?: (posthog: PostHog) => any | undefined\n }\n postHogWebVitalsCallbacks?: {\n onLCP: (metric: any) => void\n onCLS: (metric: any) => void\n onFCP: (metric: any) => void\n onINP: (metric: any) => void\n }\n /**\n * @deprecated\n *\n * this was introduced briefly, it is now always a no-op and only kept for backwards compatibility\n */\n loadWebVitalsCallbacks?: (useAttribution?: boolean) => PostHogExtensions['postHogWebVitalsCallbacks']\n tracingHeadersPatchFns?: {\n _patchFetch: (\n hostnames: TracingHeadersHostnames,\n distinctId: TracingHeadersDistinctId,\n sessionManager?: SessionIdManager\n ) => () => void\n _patchXHR: (\n hostnames: TracingHeadersHostnames,\n distinctId: TracingHeadersDistinctId,\n sessionManager?: SessionIdManager\n ) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n integrations?: {\n [K in ExternalIntegrationKind]?: { start: (posthog: PostHog) => void; stop: () => void }\n }\n initSessionRecording?: (ph: PostHog) => LazyLoadedSessionRecordingInterface\n initConversations?: (config: ConversationsRemoteConfig, posthog: PostHog) => LazyLoadedConversationsInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\n\n// React Native polyfills for posthog-js compatibility\nif (typeof self === 'undefined') {\n ;(global as any).self = global\n}\nif (typeof File === 'undefined') {\n ;(global as any).File = function () {}\n}\n\nexport const navigator = global?.navigator\nexport const document = global?.document\nexport const location = global?.location\nexport const fetch = global?.fetch\nexport const XMLHttpRequest =\n global?.XMLHttpRequest && 'withCredentials' in new global.XMLHttpRequest() ? global.XMLHttpRequest : undefined\nexport const AbortController = global?.AbortController\nexport const CompressionStream = global?.CompressionStream\nexport const userAgent = navigator?.userAgent\nexport const assignableWindow: AssignableWindow = win ?? ({} as any)\n\nexport function isBrowserOnline(): boolean {\n return !!(win && win.navigator.onLine !== false)\n}\n\nexport { win as window }\n","import { knownUnsafeEditableEvent, knownUnsafeEditableEventProperty } from \"../types.mjs\";\nimport { includes } from \"./string-utils.mjs\";\nconst nativeIsArray = Array.isArray;\nconst ObjProto = Object.prototype;\nconst type_utils_hasOwnProperty = ObjProto.hasOwnProperty;\nconst type_utils_toString = ObjProto.toString;\nconst isArray = nativeIsArray || function(obj) {\n return '[object Array]' === type_utils_toString.call(obj);\n};\nconst isFunction = (x)=>'function' == typeof x;\nconst isNativeFunction = (x)=>isFunction(x) && -1 !== x.toString().indexOf('[native code]');\nconst isObject = (x)=>x === Object(x) && !isArray(x);\nconst isEmptyObject = (x)=>{\n if (isObject(x)) {\n for(const key in x)if (type_utils_hasOwnProperty.call(x, key)) return false;\n return true;\n }\n return false;\n};\nconst isUndefined = (x)=>void 0 === x;\nconst isString = (x)=>'[object String]' == type_utils_toString.call(x);\nconst isEmptyString = (x)=>isString(x) && 0 === x.trim().length;\nconst isNull = (x)=>null === x;\nconst isNullish = (x)=>isUndefined(x) || isNull(x);\nconst isNumber = (x)=>'[object Number]' == type_utils_toString.call(x) && x === x;\nconst isPositiveNumber = (value)=>isNumber(value) && value > 0;\nconst isBoolean = (x)=>'[object Boolean]' === type_utils_toString.call(x);\nconst isFormData = (x)=>x instanceof FormData;\nconst isFile = (x)=>x instanceof File;\nconst isPlainError = (x)=>x instanceof Error;\nconst isKnownUnsafeEditableEvent = (x)=>includes(knownUnsafeEditableEvent, x);\nconst isKnownUnsafeEditableEventProperty = (x)=>includes(knownUnsafeEditableEventProperty, x);\nfunction isPrimitive(value) {\n return null === value || 'object' != typeof value;\n}\nfunction isBuiltin(candidate, className) {\n return Object.prototype.toString.call(candidate) === `[object ${className}]`;\n}\nfunction isError(candidate) {\n switch(Object.prototype.toString.call(candidate)){\n case '[object Error]':\n case '[object Exception]':\n case '[object DOMException]':\n case '[object DOMError]':\n case '[object WebAssembly.Exception]':\n return true;\n default:\n return isInstanceOf(candidate, Error);\n }\n}\nfunction isErrorEvent(event) {\n return isBuiltin(event, 'ErrorEvent');\n}\nfunction isEvent(candidate) {\n return 'undefined' != typeof Event && isInstanceOf(candidate, Event);\n}\nfunction isPlainObject(candidate) {\n return isBuiltin(candidate, 'Object');\n}\nfunction isInstanceOf(candidate, base) {\n try {\n return candidate instanceof base;\n } catch {\n return false;\n }\n}\nconst yesLikeValues = [\n true,\n 'true',\n 1,\n '1',\n 'yes'\n];\nconst isYesLike = (val)=>includes(yesLikeValues, val);\nconst noLikeValues = [\n false,\n 'false',\n 0,\n '0',\n 'no'\n];\nconst isNoLike = (val)=>includes(noLikeValues, val);\nexport { type_utils_hasOwnProperty as hasOwnProperty, isArray, isBoolean, isBuiltin, isEmptyObject, isEmptyString, isError, isErrorEvent, isEvent, isFile, isFormData, isFunction, isKnownUnsafeEditableEvent, isKnownUnsafeEditableEventProperty, isNativeFunction, isNoLike, isNull, isNullish, isNumber, isObject, isPlainError, isPlainObject, isPositiveNumber, isPrimitive, isString, isUndefined, isYesLike, noLikeValues, yesLikeValues };\n","import { assignableWindow } from '../utils/globals'\nimport { PostHog } from '../posthog-core'\nimport { isArray, isBoolean, isFunction, isNull, isNumber, isObject } from '@posthog/core'\nimport type { LogSeverityLevel } from '@posthog/types'\n\nconst LOG_BODY_SIZE_LIMIT = 10000\nconst LOG_ATTRIBUTES_LIMIT = 50\n\ntype StringifyBudget = {\n remaining: number\n truncated: boolean\n}\n\ntype AttributeCollector = {\n result: Record<string, any>\n keysRemaining: number\n sizeRemaining: number\n truncated: boolean\n seen: WeakSet<object>\n}\n\nconst appendWithLimit = (parts: string[], text: string, budget: StringifyBudget): boolean => {\n if (budget.remaining <= 0) {\n budget.truncated = true\n return false\n }\n\n if (text.length <= budget.remaining) {\n parts.push(text)\n budget.remaining -= text.length\n return true\n }\n\n parts.push(text.slice(0, budget.remaining))\n budget.remaining = 0\n budget.truncated = true\n return false\n}\n\nconst stringifyStringWithLimit = (value: string, parts: string[], budget: StringifyBudget): boolean => {\n const serialized = JSON.stringify(value)\n if (serialized.length <= budget.remaining) {\n return appendWithLimit(parts, serialized, budget)\n }\n\n budget.truncated = true\n if (budget.remaining < 2) {\n return false\n }\n\n let low = 0\n let high = Math.min(value.length, budget.remaining - 2)\n while (low < high) {\n const mid = Math.ceil((low + high) / 2)\n if (JSON.stringify(value.slice(0, mid)).length <= budget.remaining) {\n low = mid\n } else {\n high = mid - 1\n }\n }\n\n return appendWithLimit(parts, JSON.stringify(value.slice(0, low)), budget)\n}\n\nconst isJSONSerializablePrimitive = (value: any): boolean =>\n typeof value !== 'undefined' &&\n typeof value !== 'function' &&\n typeof value !== 'symbol' &&\n typeof value !== 'bigint'\n\nconst isNumberOrBoolean = (value: any): boolean => {\n try {\n return isNumber(value) || isBoolean(value)\n } catch {\n return false\n }\n}\n\nconst collectAttributeValue = (key: string, value: any, collector: AttributeCollector): void => {\n if (collector.truncated) {\n return\n }\n\n collector.keysRemaining -= 1\n collector.sizeRemaining -= String(value).length + key.length\n if (collector.keysRemaining <= 0 || collector.sizeRemaining <= 0) {\n collector.truncated = true\n collector.result['attributes_truncated'] = true\n return\n }\n\n collector.result[key] = value\n}\n\nconst collectFlattenedAttributes = (value: any, key: string, collector: AttributeCollector): void => {\n if (collector.truncated) {\n return\n }\n\n if (isObject(value)) {\n if (collector.seen.has(value)) {\n collectAttributeValue(key || 'circular', '[Circular]', collector)\n return\n }\n collector.seen.add(value)\n\n try {\n for (const childKey in value) {\n try {\n if (!Object.prototype.hasOwnProperty.call(value, childKey)) {\n continue\n }\n const childValue = value[childKey]\n collectFlattenedAttributes(childValue, key ? `${key}.${childKey}` : childKey, collector)\n if (collector.truncated) {\n return\n }\n } catch {\n continue\n }\n }\n } catch {\n // we'll omit this object's properties considering we can't enumerate them\n }\n return\n }\n\n collectAttributeValue(key, value, collector)\n}\n\nconst stringifyValueWithLimit = (\n value: any,\n parts: string[],\n budget: StringifyBudget,\n seen: WeakSet<object>,\n inArray = false,\n attributeCollector?: AttributeCollector\n): boolean => {\n if (!isJSONSerializablePrimitive(value)) {\n return inArray ? appendWithLimit(parts, 'null', budget) : true\n }\n\n if (isNull(value) || isNumberOrBoolean(value)) {\n return appendWithLimit(parts, JSON.stringify(value), budget)\n }\n\n if (typeof value === 'string') {\n return stringifyStringWithLimit(value, parts, budget)\n }\n\n if (!isObject(value) && !isArray(value)) {\n return appendWithLimit(parts, JSON.stringify(value), budget)\n }\n\n if (seen.has(value)) {\n return stringifyStringWithLimit('[Circular]', parts, budget)\n }\n seen.add(value)\n\n try {\n const toJSON = (value as any).toJSON\n if (isFunction(toJSON)) {\n return stringifyValueWithLimit(toJSON.call(value), parts, budget, seen, inArray)\n }\n } catch {\n // If toJSON can't be read or throws, fall through to safe property enumeration.\n }\n\n try {\n const objectTag = Object.prototype.toString.call(value)\n if (objectTag === '[object String]') {\n return stringifyStringWithLimit(String(value.valueOf()), parts, budget)\n }\n\n if (objectTag === '[object Number]' || objectTag === '[object Boolean]') {\n return appendWithLimit(parts, JSON.stringify(value.valueOf()), budget)\n }\n } catch {\n // If Object.prototype.toString or valueOf throws, fall through to safe property enumeration.\n }\n\n if (value instanceof Error) {\n const errorObject: Record<string, any> = {}\n try {\n for (const key in value) {\n if (Object.prototype.hasOwnProperty.call(value, key)) {\n errorObject[key] = value[key as keyof Error]\n }\n }\n } catch {}\n try {\n errorObject.name = value.name\n } catch {}\n try {\n errorObject.message = value.message\n } catch {}\n try {\n errorObject.stack = value.stack\n } catch {}\n return stringifyValueWithLimit(errorObject, parts, budget, seen, inArray, attributeCollector)\n }\n\n if (isArray(value)) {\n if (!appendWithLimit(parts, '[', budget)) {\n return false\n }\n for (let i = 0; i < value.length; i++) {\n if (i > 0 && !appendWithLimit(parts, ',', budget)) {\n return false\n }\n let item\n try {\n item = value[i]\n } catch {\n item = undefined\n }\n if (!stringifyValueWithLimit(item, parts, budget, seen, true)) {\n return false\n }\n }\n return appendWithLimit(parts, ']', budget)\n }\n\n if (!appendWithLimit(parts, '{', budget)) {\n return false\n }\n let isFirst = true\n try {\n for (const key in value) {\n if (!Object.prototype.hasOwnProperty.call(value, key)) {\n continue\n }\n if (budget.remaining <= 0) {\n budget.truncated = true\n return false\n }\n\n let propertyValue\n try {\n propertyValue = value[key]\n } catch {\n continue\n }\n if (attributeCollector) {\n try {\n collectFlattenedAttributes(propertyValue, key, attributeCollector)\n } catch {\n // we'll omit this object's attributes considering we can't read them safely\n }\n }\n\n if (!isJSONSerializablePrimitive(propertyValue)) {\n continue\n }\n\n const propertyPrefix = `${isFirst ? '' : ','}${JSON.stringify(key)}:`\n if (propertyPrefix.length >= budget.remaining) {\n budget.truncated = true\n return false\n }\n\n const partsBeforeProperty = parts.length\n const remainingBeforeProperty = budget.remaining\n const truncatedBeforeProperty = budget.truncated\n if (!appendWithLimit(parts, propertyPrefix, budget)) {\n return false\n }\n\n const partsBeforeValue = parts.length\n const serialized = stringifyValueWithLimit(propertyValue, parts, budget, seen, false)\n const truncatedAfterValue = budget.truncated\n if (parts.length === partsBeforeValue) {\n parts.length = partsBeforeProperty\n budget.remaining = remainingBeforeProperty\n budget.truncated = serialized ? truncatedBeforeProperty : truncatedAfterValue\n if (!serialized) {\n return false\n }\n continue\n }\n\n isFirst = false\n if (!serialized) {\n return false\n }\n }\n } catch {\n // we'll omit this object's properties considering we can't enumerate them\n }\n return appendWithLimit(parts, '}', budget)\n}\n\nconst stringifyArgsSafely = (\n args: any[],\n sizeLimit: number\n): { body: string; truncated: boolean; attributes: Record<string, any> } => {\n const parts: string[] = []\n const budget = { remaining: sizeLimit, truncated: false }\n const attributeCollector = isObject(args[0])\n ? {\n result: {} as Record<string, any>,\n keysRemaining: LOG_ATTRIBUTES_LIMIT,\n sizeRemaining: LOG_BODY_SIZE_LIMIT,\n truncated: false,\n seen: new WeakSet<object>([args[0]]),\n }\n : undefined\n\n for (let i = 0; i < args.length; i++) {\n if (i > 0 && !appendWithLimit(parts, ' ', budget)) {\n break\n }\n if (\n !stringifyValueWithLimit(\n args[i],\n parts,\n budget,\n new WeakSet<object>(),\n false,\n i === 0 ? attributeCollector : undefined\n )\n ) {\n break\n }\n }\n\n return {\n body: parts.join('') + (budget.truncated ? '...' : ''),\n truncated: budget.truncated,\n attributes: attributeCollector?.result || {},\n }\n}\n\ntype ConsoleLevel = 'debug' | 'log' | 'warn' | 'error' | 'info'\n\n// Console method → OTLP severity level. `log` and `info` both map to `info`;\n// the originating method is preserved separately via the `log.source` attribute.\nconst LEVEL_MAP: Record<ConsoleLevel, LogSeverityLevel> = {\n debug: 'debug',\n log: 'info',\n warn: 'warn',\n error: 'error',\n info: 'info',\n}\n\nconst originalConsoleMethod = (method: any): any => {\n while (method?.__rrweb_original__) {\n method = method.__rrweb_original__\n }\n return method\n}\n\nconst initializeLogs = (posthog: PostHog) => {\n // `host` is carried here because the core SDK context has no equivalent. Session\n // attributes (window.id, sessionStartTimestamp, lastActivityTimestamp) are added\n // downstream by the core pipeline from the SDK context, alongside sessionId.\n const attributes: Record<string, string> = { host: assignableWindow.location.host }\n\n // Re-entrancy guard: the capture path itself logs — `_captureConsoleLog` calls into\n // session management, which emits internal debug lines through PostHog's own logger,\n // which in turn writes to the (now wrapped) console. Without this flag that would\n // re-enter capture and recurse until the stack overflows.\n let isCapturingLog = false\n\n for (const level of Object.keys(LEVEL_MAP) as ConsoleLevel[]) {\n const logWrapper =\n (originalConsoleLog: any) =>\n (...args: any[]) => {\n // Tracks whether *this* invocation acquired the re-entrancy guard, so that a\n // nested console call which skips capture doesn't release the guard early and\n // reopen the capture path while the outer invocation is still running.\n let acquiredGuard = false\n try {\n if (args.length > 0 && !isCapturingLog && posthog.is_capturing()) {\n isCapturingLog = true\n acquiredGuard = true\n const {\n body,\n truncated,\n attributes: flattenedAttributes,\n } = stringifyArgsSafely(args, LOG_BODY_SIZE_LIMIT)\n const logAttributes = {\n ...attributes,\n ...(truncated ? { body_truncated: 'true' } : {}),\n }\n // The core pipeline adds posthogDistinctId and url.full from the SDK context.\n posthog.logs?._captureConsoleLog({\n level: LEVEL_MAP[level],\n body,\n attributes: {\n 'log.source': `console.${level}`,\n ...logAttributes,\n ...flattenedAttributes,\n },\n })\n }\n } catch {\n // Capture must never break the page's own console output, so the\n // real console call below always runs even if capture throws.\n } finally {\n if (acquiredGuard) {\n isCapturingLog = false\n }\n originalConsoleLog.apply(assignableWindow.console, args)\n }\n }\n\n const originalConsoleLog = assignableWindow.console[level]\n const wrapped = logWrapper(originalConsoleLog)\n // Expose the original console method the same way rrweb's console plugin does, so\n // PostHog's internal logger (utils/logger.ts) writes to the real console instead of\n // re-entering this wrapper when it emits debug lines from inside the capture path.\n // Flatten an existing marker if another console plugin already wrapped this method.\n ;(wrapped as any).__rrweb_original__ = originalConsoleMethod(originalConsoleLog)\n assignableWindow.console[level] = wrapped\n }\n}\n\nassignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {}\nassignableWindow.__PosthogExtensions__.logs = { initializeLogs }\n"],"names":["win","window","undefined","global","globalThis","self","File","XMLHttpRequest","assignableWindow","type_utils_toString","Object","prototype","toString","isArray","Array","obj","call","isObject","x","appendWithLimit","parts","text","budget","remaining","length","push","slice","truncated","stringifyStringWithLimit","value","serialized","JSON","stringify","low","high","Math","min","mid","ceil","isJSONSerializablePrimitive","collectAttributeValue","key","collector","keysRemaining","sizeRemaining","String","result","collectFlattenedAttributes","seen","has","add","childKey","hasOwnProperty","_unused2","_unused3","stringifyValueWithLimit","inArray","attributeCollector","isBoolean","_unused","isNumberOrBoolean","toJSON","_unused4","objectTag","valueOf","_unused5","Error","errorObject","_unused6","name","_unused7","message","_unused8","stack","_unused9","i","item","_unused0","isFirst","propertyValue","_unused1","_unused10","propertyPrefix","partsBeforeProperty","remainingBeforeProperty","truncatedBeforeProperty","partsBeforeValue","truncatedAfterValue","_unused11","LEVEL_MAP","debug","log","warn","error","info","__PosthogExtensions__","logs","initializeLogs","posthog","attributes","host","location","isCapturingLog","_loop","level","originalConsoleLog","console","wrapped","acquiredGuard","_len","arguments","args","_key2","is_capturing","_posthog$logs","body","flattenedAttributes","stringifyArgsSafely","sizeLimit","WeakSet","join","logAttributes","_extends","body_truncated","_captureConsoleLog","_unused12","apply","logWrapper","__rrweb_original__","method","_method","originalConsoleMethod","keys"],"mappings":"iPAuCA,IAAMA,EAAkE,oB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