@alwaysmeticulous/recorder-loader
Advanced tools
Comparing version 2.161.0 to 2.162.0
@@ -1,2 +0,2 @@ | ||
import { NetworkResponseSanitizer } from "@alwaysmeticulous/sdk-bundles-api"; | ||
import { NetworkResponseSanitizer, RecorderMiddleware } from "@alwaysmeticulous/sdk-bundles-api"; | ||
interface LoaderOptions { | ||
@@ -27,9 +27,27 @@ /** | ||
* Optional. Allows sanitizing network responses before they are sent to Meticulous's servers. | ||
* | ||
* @deprecated Please use `middleware` instead. | ||
*/ | ||
responseSanitizers?: NetworkResponseSanitizer[]; | ||
/** | ||
* Transform the recorded data before it is sent to Meticulous's servers. This is useful for redacting sensitive | ||
* information when recording production sessions. | ||
* | ||
* Please see JSDoc on {@link RecorderMiddleware} before implementing custom middleware. | ||
*/ | ||
middleware?: RecorderMiddleware[]; | ||
} | ||
interface Recorder { | ||
/** | ||
* Disables the recorder for the rest of the user session, and stops sending data to the Meticulous | ||
* servers. | ||
* | ||
* Once this method is called the recorder cannot be restarted (unless the page is reloaded). | ||
*/ | ||
stopRecording: () => Promise<void>; | ||
} | ||
/** | ||
* Load and start the Meticulous Recorder | ||
*/ | ||
export const tryLoadAndStartRecorder: (options: LoaderOptions) => Promise<void>; | ||
export const tryLoadAndStartRecorder: (options: LoaderOptions) => Promise<Recorder>; | ||
/** | ||
@@ -40,3 +58,3 @@ * @deprecated Use `tryLoadAndStartRecorder` instead. | ||
*/ | ||
export const loadAndStartRecorder: ({ projectId, recordingToken, uploadIntervalMs, snapshotLinkedStylesheets, commitHash, maxMsToBlockFor: maxMsToBlockFor_, snippetsBaseUrl, forceRecording, responseSanitizers, isProduction, }: LoaderOptions) => Promise<void>; | ||
export const loadAndStartRecorder: ({ projectId, recordingToken, uploadIntervalMs, snapshotLinkedStylesheets, commitHash, maxMsToBlockFor: maxMsToBlockFor_, snippetsBaseUrl, forceRecording, middleware, responseSanitizers, isProduction, }: LoaderOptions) => Promise<Recorder>; | ||
interface Interceptor { | ||
@@ -46,11 +64,2 @@ startRecordingSession: (options: LoaderOptions) => Promise<Recorder>; | ||
} | ||
interface Recorder { | ||
/** | ||
* Disables the recorder for the rest of the user session, and stops sending data to the Meticulous | ||
* servers. | ||
* | ||
* Once this method is called the recorder cannot be restarted (unless the page is reloaded). | ||
*/ | ||
stopRecording: () => Promise<void>; | ||
} | ||
/** | ||
@@ -90,3 +99,16 @@ * Stores a copy of network requests and responses in memory, but doesn't send them to the | ||
}) => Promise<Interceptor>; | ||
/** | ||
* If you add 'https://snippet.meticulous.ai/record/v1/network-recorder.bundle.js' as a script tag | ||
* then Meticulous will start off by recording any network requests in memory but not send the data to Meticulous’s | ||
* servers. Once you have the information to determine whether you want to record and persist the session | ||
* you can then call {@link tryLoadAndStartRecorder} if you do want to record, or this stopIntercepting method | ||
* if you do not want to record. When you call stopIntercepting any network requests/responses stored in memory | ||
* will be dropped and Meticulous will be deactivated. No data will be sent to Meticulous's servers. | ||
* | ||
* Please note that if you've already started recording and sending data to Meticulous's services i.e. | ||
* loaded the main meticulous recorder script or called tryLoadAndStartRecorder then this method will | ||
* not stop the recording. For that you need to call the stopRecording method returned by tryLoadAndStartRecorder. | ||
*/ | ||
export const stopIntercepting: () => Promise<void>; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,2 +8,3 @@ function $parcel$export(e, n, v, s) { | ||
$parcel$export(module.exports, "tryInstallMeticulousIntercepts", () => $f8da777fb815521f$export$c0c9d1ed5ecb2675); | ||
$parcel$export(module.exports, "stopIntercepting", () => $6795f29cc093eb86$export$e592d04d772ce0ec); | ||
const $d2f90b927d91d104$export$d16af6ab0c202bae = "https://snippet.meticulous.ai"; | ||
@@ -16,10 +17,19 @@ | ||
console.debug("Running as part of a Meticulous test case, so skipping loading the Meticulous recorder."); | ||
return; | ||
return { | ||
stopRecording: async ()=>{ | ||
// No op | ||
} | ||
}; | ||
} | ||
// Try to load the recorder and silence any initialisation error. | ||
await $c97024bcb09807fa$var$unsafeLoadAndStartRecorder(options).catch((error)=>{ | ||
return await $c97024bcb09807fa$var$unsafeLoadAndStartRecorder(options).catch((error)=>{ | ||
console.error(error); | ||
return { | ||
stopRecording: async ()=>{ | ||
// No op | ||
} | ||
}; | ||
}); | ||
}; | ||
const $c97024bcb09807fa$var$unsafeLoadAndStartRecorder = ({ projectId: projectId , recordingToken: recordingToken , uploadIntervalMs: uploadIntervalMs , snapshotLinkedStylesheets: snapshotLinkedStylesheets , commitHash: commitHash , maxMsToBlockFor: maxMsToBlockFor_ , snippetsBaseUrl: snippetsBaseUrl , forceRecording: forceRecording , responseSanitizers: responseSanitizers , isProduction: isProduction })=>{ | ||
const $c97024bcb09807fa$var$unsafeLoadAndStartRecorder = ({ projectId: projectId , recordingToken: recordingToken , uploadIntervalMs: uploadIntervalMs , snapshotLinkedStylesheets: snapshotLinkedStylesheets , commitHash: commitHash , maxMsToBlockFor: maxMsToBlockFor_ , snippetsBaseUrl: snippetsBaseUrl , forceRecording: forceRecording , middleware: middleware , responseSanitizers: responseSanitizers , isProduction: isProduction })=>{ | ||
let abandoned = false; | ||
@@ -30,3 +40,7 @@ return new Promise((resolve, reject)=>{ | ||
abandoned = true; | ||
resolve(); | ||
resolve({ | ||
stopRecording: async ()=>{ | ||
// No op: we never started recording | ||
} | ||
}); | ||
}, maxMsToBlockFor); | ||
@@ -46,2 +60,3 @@ const script = document.createElement("script"); | ||
if (responseSanitizers != null && responseSanitizers.length > 0) typedWindow.METICULOUS_NETWORK_RESPONSE_SANITIZERS = responseSanitizers; | ||
if (middleware != null && middleware.length > 0) typedWindow.METICULOUS_RECORDER_MIDDLEWARE_V1 = middleware; | ||
script.onload = function() { | ||
@@ -63,3 +78,10 @@ if (abandoned) { | ||
} | ||
resolve(); | ||
resolve({ | ||
stopRecording: async ()=>{ | ||
const stopRecording = window.__meticulous?.stopRecording; | ||
if (!stopRecording) throw new Error("Recorder not initialised: window.__meticulous.stopRecording is not defined."); | ||
await stopRecording(); | ||
return; | ||
} | ||
}); | ||
}; | ||
@@ -90,12 +112,4 @@ script.onerror = ()=>{ | ||
}; | ||
const startRecordingSession = (options)=>(0, $c97024bcb09807fa$export$f80553af9d70f9fd)(options).then(()=>({ | ||
stopRecording: async ()=>{ | ||
const stopRecording = window.__meticulous?.stopRecording; | ||
if (!stopRecording) throw new Error("Recorder not initialised: window.__meticulous.stopRecording is not defined."); | ||
await stopRecording(); | ||
return; | ||
} | ||
})); | ||
const interceptor = { | ||
startRecordingSession: startRecordingSession, | ||
startRecordingSession: (0, $c97024bcb09807fa$export$f80553af9d70f9fd), | ||
stopIntercepting: stopIntercepting | ||
@@ -130,4 +144,10 @@ }; | ||
const $6795f29cc093eb86$export$e592d04d772ce0ec = async ()=>{ | ||
const disposeFunction = window?.__meticulous?.earlyNetworkRecorder?.dispose; | ||
if (disposeFunction) await disposeFunction(); | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -8,10 +8,19 @@ const $7d7683134fbb8fec$export$d16af6ab0c202bae = "https://snippet.meticulous.ai"; | ||
console.debug("Running as part of a Meticulous test case, so skipping loading the Meticulous recorder."); | ||
return; | ||
return { | ||
stopRecording: async ()=>{ | ||
// No op | ||
} | ||
}; | ||
} | ||
// Try to load the recorder and silence any initialisation error. | ||
await $5d774bdb3a883001$var$unsafeLoadAndStartRecorder(options).catch((error)=>{ | ||
return await $5d774bdb3a883001$var$unsafeLoadAndStartRecorder(options).catch((error)=>{ | ||
console.error(error); | ||
return { | ||
stopRecording: async ()=>{ | ||
// No op | ||
} | ||
}; | ||
}); | ||
}; | ||
const $5d774bdb3a883001$var$unsafeLoadAndStartRecorder = ({ projectId: projectId , recordingToken: recordingToken , uploadIntervalMs: uploadIntervalMs , snapshotLinkedStylesheets: snapshotLinkedStylesheets , commitHash: commitHash , maxMsToBlockFor: maxMsToBlockFor_ , snippetsBaseUrl: snippetsBaseUrl , forceRecording: forceRecording , responseSanitizers: responseSanitizers , isProduction: isProduction })=>{ | ||
const $5d774bdb3a883001$var$unsafeLoadAndStartRecorder = ({ projectId: projectId , recordingToken: recordingToken , uploadIntervalMs: uploadIntervalMs , snapshotLinkedStylesheets: snapshotLinkedStylesheets , commitHash: commitHash , maxMsToBlockFor: maxMsToBlockFor_ , snippetsBaseUrl: snippetsBaseUrl , forceRecording: forceRecording , middleware: middleware , responseSanitizers: responseSanitizers , isProduction: isProduction })=>{ | ||
let abandoned = false; | ||
@@ -22,3 +31,7 @@ return new Promise((resolve, reject)=>{ | ||
abandoned = true; | ||
resolve(); | ||
resolve({ | ||
stopRecording: async ()=>{ | ||
// No op: we never started recording | ||
} | ||
}); | ||
}, maxMsToBlockFor); | ||
@@ -38,2 +51,3 @@ const script = document.createElement("script"); | ||
if (responseSanitizers != null && responseSanitizers.length > 0) typedWindow.METICULOUS_NETWORK_RESPONSE_SANITIZERS = responseSanitizers; | ||
if (middleware != null && middleware.length > 0) typedWindow.METICULOUS_RECORDER_MIDDLEWARE_V1 = middleware; | ||
script.onload = function() { | ||
@@ -55,3 +69,10 @@ if (abandoned) { | ||
} | ||
resolve(); | ||
resolve({ | ||
stopRecording: async ()=>{ | ||
const stopRecording = window.__meticulous?.stopRecording; | ||
if (!stopRecording) throw new Error("Recorder not initialised: window.__meticulous.stopRecording is not defined."); | ||
await stopRecording(); | ||
return; | ||
} | ||
}); | ||
}; | ||
@@ -82,12 +103,4 @@ script.onerror = ()=>{ | ||
}; | ||
const startRecordingSession = (options)=>(0, $5d774bdb3a883001$export$f80553af9d70f9fd)(options).then(()=>({ | ||
stopRecording: async ()=>{ | ||
const stopRecording = window.__meticulous?.stopRecording; | ||
if (!stopRecording) throw new Error("Recorder not initialised: window.__meticulous.stopRecording is not defined."); | ||
await stopRecording(); | ||
return; | ||
} | ||
})); | ||
const interceptor = { | ||
startRecordingSession: startRecordingSession, | ||
startRecordingSession: (0, $5d774bdb3a883001$export$f80553af9d70f9fd), | ||
stopIntercepting: stopIntercepting | ||
@@ -122,5 +135,11 @@ }; | ||
const $57efbd113493cb78$export$e592d04d772ce0ec = async ()=>{ | ||
const disposeFunction = window?.__meticulous?.earlyNetworkRecorder?.dispose; | ||
if (disposeFunction) await disposeFunction(); | ||
}; | ||
export {$5d774bdb3a883001$export$9da0cde53b499187 as loadAndStartRecorder, $5d774bdb3a883001$export$f80553af9d70f9fd as tryLoadAndStartRecorder, $d91c442ec5d010f4$export$c0c9d1ed5ecb2675 as tryInstallMeticulousIntercepts}; | ||
export {$5d774bdb3a883001$export$9da0cde53b499187 as loadAndStartRecorder, $5d774bdb3a883001$export$f80553af9d70f9fd as tryLoadAndStartRecorder, $d91c442ec5d010f4$export$c0c9d1ed5ecb2675 as tryInstallMeticulousIntercepts, $57efbd113493cb78$export$e592d04d772ce0ec as stopIntercepting}; | ||
//# sourceMappingURL=module.js.map |
{ | ||
"name": "@alwaysmeticulous/recorder-loader", | ||
"version": "2.161.0", | ||
"version": "2.162.0", | ||
"license": "ISC", | ||
@@ -24,3 +24,3 @@ "source": "src/index.ts", | ||
"devDependencies": { | ||
"@alwaysmeticulous/sdk-bundles-api": "^2.161.0" | ||
"@alwaysmeticulous/sdk-bundles-api": "^2.162.0" | ||
}, | ||
@@ -41,3 +41,3 @@ "author": { | ||
}, | ||
"gitHead": "64e42104344377fca631912b5447ec16a7b29d12" | ||
"gitHead": "d71c448c4d1856a0b62e13439d83bc8081c995b2" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48559
372