| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/elite-events-storybook/ |
Upload File : |
"use strict";(self.webpackChunkelite_events_nextjs=self.webpackChunkelite_events_nextjs||[]).push([[4110],{"./src/components/providers/RumProvider.stories.tsx":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Default:()=>Default,WithContent:()=>WithContent,__namedExportsOrder:()=>__namedExportsOrder,default:()=>RumProvider_stories});var jsx_runtime=__webpack_require__("./node_modules/next/dist/compiled/react/jsx-runtime.js"),react=__webpack_require__("./node_modules/next/dist/compiled/react/index.js"),navigation=__webpack_require__("./node_modules/@storybook/nextjs/dist/export-mocks/navigation/index.js");const rum=new class RealUserMonitoring{init(options){this.initialized||(this.enabled=options?.enabled??!0,this.enabled&&(this.endpoint=options?.endpoint||this.endpoint,this.sessionId=this.getOrCreateSessionId(),this.pageLoadId=this.generateId(),this.initialized=!0,this.observeWebVitals(),this.observeResourceTiming(),this.observeLongTasks(),this.observeErrors(),this.flushInterval=setInterval(()=>this.flush(),options?.flushIntervalMs||3e4),window.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&this.flush()}),window.addEventListener("beforeunload",()=>{this.flush()}),this.trackPageView(window.location.pathname)))}observeWebVitals(){try{new PerformanceObserver(entryList=>{const entries=entryList.getEntries(),lastEntry=entries[entries.length-1];lastEntry&&(this.vitals.LCP=lastEntry.startTime)}).observe({type:"largest-contentful-paint",buffered:!0})}catch{}try{new PerformanceObserver(entryList=>{const firstInput=entryList.getEntries()[0];firstInput&&(this.vitals.FID=firstInput.processingStart-firstInput.startTime)}).observe({type:"first-input",buffered:!0})}catch{}try{let clsValue=0;new PerformanceObserver(entryList=>{for(const entry of entryList.getEntries()){const layoutShift=entry;layoutShift.hadRecentInput||(clsValue+=layoutShift.value)}this.vitals.CLS=clsValue}).observe({type:"layout-shift",buffered:!0})}catch{}try{new PerformanceObserver(entryList=>{const fcpEntry=entryList.getEntries().find(e=>"first-contentful-paint"===e.name);fcpEntry&&(this.vitals.FCP=fcpEntry.startTime)}).observe({type:"paint",buffered:!0})}catch{}try{const navigationEntry=performance.getEntriesByType("navigation")[0];navigationEntry&&(this.vitals.TTFB=navigationEntry.responseStart-navigationEntry.requestStart)}catch{}}observeResourceTiming(){try{new PerformanceObserver(entryList=>{const entries=entryList.getEntries();for(const entry of entries)"fetch"!==entry.initiatorType&&"xmlhttprequest"!==entry.initiatorType||this.trackApiCall({url:this.sanitizeUrl(entry.name),duration:entry.duration,transferSize:entry.transferSize,encodedBodySize:entry.encodedBodySize})}).observe({type:"resource",buffered:!0})}catch{}}observeLongTasks(){try{new PerformanceObserver(entryList=>{for(const entry of entryList.getEntries())entry.duration>50&&this.trackLongTask({duration:entry.duration,startTime:entry.startTime})}).observe({type:"longtask",buffered:!0})}catch{}}observeErrors(){window.addEventListener("error",event=>{this.trackError({type:"error",message:event.message,filename:event.filename,lineno:event.lineno,colno:event.colno})}),window.addEventListener("unhandledrejection",event=>{this.trackError({type:"unhandledrejection",message:event.reason?.message||"Unhandled Promise Rejection",stack:event.reason?.stack})})}trackPageView(path){this.queueEvent("pageview",{path})}trackEvent(name,properties){this.queueEvent("event",{name,properties})}trackApiCall(data){this.queueEvent("api_call",data)}trackLongTask(data){this.queueEvent("long_task",data)}trackError(data){this.queueEvent("error",data)}queueEvent(type,data){if(!this.enabled)return;const event={type,sessionId:this.sessionId,pageLoadId:this.pageLoadId,timestamp:Date.now(),url:window.location.href,userAgent:navigator.userAgent,...data};this.eventQueue.push(event)}flush(){if(!this.enabled||0===this.eventQueue.length)return;Object.keys(this.vitals).length>0&&this.queueEvent("vitals",{...this.vitals});const events=[...this.eventQueue];this.eventQueue=[],navigator.sendBeacon?navigator.sendBeacon(this.endpoint,JSON.stringify({events})):fetch(this.endpoint,{method:"POST",body:JSON.stringify({events}),keepalive:!0,headers:{"Content-Type":"application/json"}}).catch(()=>{this.eventQueue.push(...events)})}getOrCreateSessionId(){const key="rum_session_id";let sessionId=sessionStorage.getItem(key);return sessionId||(sessionId=this.generateId(),sessionStorage.setItem(key,sessionId)),sessionId}generateId(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,c=>{const r=16*Math.random()|0;return("x"===c?r:3&r|8).toString(16)})}sanitizeUrl(url){try{const parsed=new URL(url);return parsed.searchParams.delete("token"),parsed.searchParams.delete("key"),parsed.searchParams.delete("password"),parsed.searchParams.delete("secret"),parsed.toString()}catch{return url}}destroy(){this.flushInterval&&clearInterval(this.flushInterval),this.flush(),this.initialized=!1}getVitals(){return{...this.vitals}}constructor(){this.sessionId="",this.pageLoadId="",this.vitals={},this.endpoint="/api/rum/collect",this.enabled=!1,this.initialized=!1,this.eventQueue=[],this.flushInterval=null}};function RumProvider({children}){const pathname=(0,navigation.usePathname)();return(0,react.useEffect)(()=>{rum.init()},[]),(0,react.useEffect)(()=>{pathname&&rum.trackPageView(pathname)},[pathname]),(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children})}const RumProvider_stories={title:"Providers/RumProvider",component:RumProvider,parameters:{layout:"centered",docs:{description:{component:"\nReal User Monitoring (RUM) Provider that initializes client-side performance monitoring.\n\n## Features\n- **Core Web Vitals**: LCP, FID, CLS, FCP, TTFB, INP\n- **API Monitoring**: Tracks fetch/XHR request durations\n- **Long Tasks**: Detects tasks blocking the main thread >50ms\n- **Error Tracking**: Captures JavaScript errors and unhandled rejections\n- **Page Views**: Automatically tracks route changes\n\n## Configuration\nSet `NEXT_PUBLIC_RUM_ENABLED=true` in your environment to enable RUM.\n\n## Usage\n```tsx\nimport { RumProvider } from '@/components/providers/RumProvider';\n\nfunction App() {\n return (\n <RumProvider>\n <YourApp />\n </RumProvider>\n );\n}\n```\n "}}},tags:["autodocs"]},Default={args:{children:(0,jsx_runtime.jsxs)("div",{className:"p-8 text-center",children:[(0,jsx_runtime.jsx)("h2",{className:"text-xl font-semibold mb-4",children:"RUM Provider Demo"}),(0,jsx_runtime.jsx)("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:"This component initializes Real User Monitoring in the background."}),(0,jsx_runtime.jsxs)("div",{className:"space-y-2 text-sm text-left max-w-md mx-auto bg-gray-100 dark:bg-gray-800 p-4 rounded",children:[(0,jsx_runtime.jsx)("p",{children:(0,jsx_runtime.jsx)("strong",{children:"Collecting:"})}),(0,jsx_runtime.jsxs)("ul",{className:"list-disc list-inside space-y-1",children:[(0,jsx_runtime.jsx)("li",{children:"Core Web Vitals (LCP, FID, CLS, FCP, TTFB, INP)"}),(0,jsx_runtime.jsx)("li",{children:"API call performance"}),(0,jsx_runtime.jsx)("li",{children:"Long tasks (>50ms)"}),(0,jsx_runtime.jsx)("li",{children:"JavaScript errors"}),(0,jsx_runtime.jsx)("li",{children:"Page views"})]})]})]})}},WithContent={args:{children:(0,jsx_runtime.jsxs)("div",{className:"p-8",children:[(0,jsx_runtime.jsx)("h1",{className:"text-2xl font-bold mb-4",children:"Sample Page Content"}),(0,jsx_runtime.jsx)("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:"RUM is silently collecting performance metrics in the background. Check the Network tab to see events being sent to /api/rum/collect."}),(0,jsx_runtime.jsx)("button",{className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700",onClick:()=>{const start=Date.now();for(;Date.now()-start<100;);alert("Long task completed! RUM will have captured this.")},children:"Trigger Long Task"})]})}},__namedExportsOrder=["Default","WithContent"]}}]);