@workleap/logrocket 4.0.7 → 4.1.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @workleap/logrocket
2
2
 
3
+ ## 4.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#289](https://github.com/workleap/wl-telemetry/pull/289) [`a233944`](https://github.com/workleap/wl-telemetry/commit/a233944db31a52c20cfbe2d086dfa698e2a685b3) Thanks [@patricklafrance](https://github.com/patricklafrance)! - A name provided with the `privateQueryParameterNames` option is now matched literally, and is also matched in its percent-encoded form. Previously, a name was used as a regular expression without being escaped: a name such as `user[email]` was not redacted, and a name that is not a valid regular expression made the sanitizer throw. A name that relied on the regular expression syntax, such as `(sid|key)`, no longer matches and must be replaced by the actual names.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`a233944`](https://github.com/workleap/wl-telemetry/commit/a233944db31a52c20cfbe2d086dfa698e2a685b3)]:
12
+ - @workleap-telemetry/core@2.1.0
13
+
3
14
  ## 4.0.7
4
15
 
5
16
  ### Patch Changes
@@ -1,11 +1,11 @@
1
+ import { redactQueryParameters } from "@workleap-telemetry/core";
2
+
3
+
4
+
1
5
  function createUrlSanitizer(queryParametersToRemove) {
2
6
  return (url)=>{
3
7
  // A network request made with XMLHttpRequest can provide a URL object rather than a string.
4
- let sanitizedUrl = String(url);
5
- for (const x of queryParametersToRemove){
6
- sanitizedUrl = sanitizedUrl.replace(new RegExp(`${x}=([^&]*)`, "gi"), `${x}=**redacted**`);
7
- }
8
- return sanitizedUrl;
8
+ return redactQueryParameters(String(url), queryParametersToRemove);
9
9
  };
10
10
  }
11
11
 
@@ -1 +1 @@
1
- {"version":3,"file":"js/createUrlSanitizer.js","sources":["../../src/js/createUrlSanitizer.ts"],"sourcesContent":["export type UrlSanitizerFunction = (url: string) => string;\n\nexport function createUrlSanitizer(queryParametersToRemove: string[]) {\n return (url: string | URL) => {\n // A network request made with XMLHttpRequest can provide a URL object rather than a string.\n let sanitizedUrl = String(url);\n\n for (const x of queryParametersToRemove) {\n sanitizedUrl = sanitizedUrl.replace(new RegExp(`${x}=([^&]*)`, \"gi\"), `${x}=**redacted**`);\n }\n\n return sanitizedUrl;\n };\n}\n"],"names":["createUrlSanitizer","queryParametersToRemove","url","sanitizedUrl","String","x","RegExp"],"mappings":"AAEO,SAASA,mBAAmBC,uBAAiC;IAChE,OAAO,CAACC;QACJ,4FAA4F;QAC5F,IAAIC,eAAeC,OAAOF;QAE1B,KAAK,MAAMG,KAAKJ,wBAAyB;YACrCE,eAAeA,aAAa,OAAO,CAAC,IAAIG,OAAO,GAAGD,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAGA,EAAE,aAAa,CAAC;QAC7F;QAEA,OAAOF;IACX;AACJ"}
1
+ {"version":3,"file":"js/createUrlSanitizer.js","sources":["../../src/js/createUrlSanitizer.ts"],"sourcesContent":["import { redactQueryParameters } from \"@workleap-telemetry/core\";\n\nexport type UrlSanitizerFunction = (url: string) => string;\n\nexport function createUrlSanitizer(queryParametersToRemove: string[]) {\n return (url: string | URL) => {\n // A network request made with XMLHttpRequest can provide a URL object rather than a string.\n return redactQueryParameters(String(url), queryParametersToRemove);\n };\n}\n"],"names":["redactQueryParameters","createUrlSanitizer","queryParametersToRemove","url","String"],"mappings":";;;AAAiE;AAI1D,SAASC,mBAAmBC,uBAAiC;IAChE,OAAO,CAACC;QACJ,4FAA4F;QAC5F,OAAOH,qBAAqBA,CAACI,OAAOD,MAAMD;IAC9C;AACJ"}
@@ -1,4 +1,4 @@
1
- import { HasExecutedGuard } from "@workleap-telemetry/core";
1
+ import { DefaultPrivateQueryParameterNames, HasExecutedGuard } from "@workleap-telemetry/core";
2
2
  import { createCompositeLogger } from "@workleap/logging";
3
3
  import logrocket from "logrocket";
4
4
  import logrocket_fuzzy_search_sanitizer from "logrocket-fuzzy-search-sanitizer";
@@ -39,11 +39,6 @@ const DefaultPrivateFieldNames = [
39
39
  "timeZone",
40
40
  "birthday"
41
41
  ];
42
- const DefaultPrivateQueryParameterNames = [
43
- "token",
44
- "email",
45
- "password"
46
- ];
47
42
  // The function return type is mandatory, otherwise we got an error TS4058.
48
43
  function getLogRocketSdkOptions(userOptions, logger) {
49
44
  const { rootHostname = "workleap.com", privateFieldNames = [], privateQueryParameterNames = [], verbose = false, transformers = [] } = userOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"js/registerLogRocketInstrumentation.js","sources":["../../src/js/registerLogRocketInstrumentation.ts"],"sourcesContent":["import { HasExecutedGuard, type TelemetryContext } from \"@workleap-telemetry/core\";\nimport { createCompositeLogger, type RootLogger } from \"@workleap/logging\";\nimport LogRocket from \"logrocket\";\nimport LogrocketFuzzySanitizer from \"logrocket-fuzzy-search-sanitizer\";\nimport { applyTransformers, type LogRocketSdkOptionsTransformer } from \"./applyTransformers.ts\";\nimport { createRequestSanitizer } from \"./createRequestSanitizer.ts\";\nimport { createResponseSanitizer } from \"./createResponseSanitizer.ts\";\nimport { createUrlSanitizer } from \"./createUrlSanitizer.ts\";\nimport { DeviceIdTrait, type LogRocketInstrumentationClient, LogRocketInstrumentationClientImpl, TelemetryIdTrait } from \"./LogRocketInstrumentationClient.ts\";\nimport type { LogRocketSdkOptions } from \"./logRocketTypes.ts\";\n\nconst DefaultPrivateFieldNames = [\"email\", \"personalEmail\", \"phoneNumber\", \"password\", \"firstName\", \"lastName\", \"givenName\", \"fullName\", \"gender\", \"timeZone\", \"birthday\"];\n\nconst DefaultPrivateQueryParameterNames = [\"token\", \"email\", \"password\"];\n\n///////////////////////////\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface RegisterLogRocketInstrumentationOptions {\n /**\n * A root hostname to track sessions across subdomains. Set this option to capture traffic from all subdomains under one session: https://docs.logrocket.com/reference/roothostname.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n rootHostname?: LogRocketSdkOptions[\"rootHostname\"];\n /**\n * Names of additional fields to exclude from session replays. These fields will be removed from network requests, responses using a fuzzy-matching algorithm.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n privateFieldNames?: string[];\n /**\n * Names of additional fields to exclude from session replays. These fields will be removed from query parameters using a fuzzy-matching algorithm.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n privateQueryParameterNames?: string[];\n /**\n * Context including telemetry correlation ids.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n telemetryContext?: TelemetryContext;\n /**\n * Hooks to transform the resulting LogRocket SDK options.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n transformers?: LogRocketSdkOptionsTransformer[];\n /**\n * Indicates whether or not debug information should be logged to the console.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n verbose?: boolean;\n /**\n * The logger instances that will output messages.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n loggers?: RootLogger[];\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function getLogRocketSdkOptions(userOptions: RegisterLogRocketInstrumentationOptions, logger: RootLogger): LogRocketSdkOptions {\n const { rootHostname = \"workleap.com\", privateFieldNames = [], privateQueryParameterNames = [], verbose = false, transformers = [] } = userOptions;\n\n const mergedPrivateFieldNames = DefaultPrivateFieldNames.concat(privateFieldNames);\n const mergedPrivateQueryParameterNames = DefaultPrivateQueryParameterNames.concat(privateQueryParameterNames);\n\n // The \"LogrocketFuzzySearch.setup\" code is awkward. For now, we prefer to play it safe and call it once here, then forward the sanitize functions\n // to the appropriate factories.\n // No clue why the \"setup\" method is not available. This package is shady.\n // @ts-ignore\n const { requestSanitizer: fuzzyRequestSanitizer, responseSanitizer: fuzzyResponseSanitizer } = LogrocketFuzzySanitizer.setup(mergedPrivateFieldNames);\n\n const urlSanitizer = createUrlSanitizer(mergedPrivateQueryParameterNames);\n\n const sdkOptions = {\n console: {\n // Prevent console logs from being visible in LogRocket session replays and leaking PII.\n // To capture logs in a session replay, use the LogRocketLogger class.\n isEnabled: false\n },\n rootHostname,\n dom: {\n textSanitizer: true,\n inputSanitizer: true\n },\n network: {\n requestSanitizer: createRequestSanitizer(fuzzyRequestSanitizer, urlSanitizer),\n responseSanitizer: createResponseSanitizer(fuzzyResponseSanitizer, urlSanitizer)\n },\n browser: {\n urlSanitizer\n },\n shouldDebugLog: verbose\n } satisfies LogRocketSdkOptions;\n\n return applyTransformers(sdkOptions, transformers, {\n verbose,\n logger\n });\n}\n\n///////////////////////////\n\nlet registrationGuardInstance: HasExecutedGuard | undefined;\n\n// It's important to use a lazy singleton instead of a singleton to avoid\n// any future probleme related to HMR, tree-shaking, SSR, etc..\nfunction getRegistrationGuard() {\n if (!registrationGuardInstance) {\n registrationGuardInstance = new HasExecutedGuard();\n }\n\n return registrationGuardInstance;\n}\n\n// This function should only be used by tests.\nexport function __resetRegistrationGuard() {\n if (registrationGuardInstance) {\n registrationGuardInstance.reset();\n }\n}\n\n///////////////////////////\n\nexport class LogRocketInstrumentationRegistrator {\n register(appId: string, options: RegisterLogRocketInstrumentationOptions = {}) {\n const { telemetryContext, verbose = false, loggers = [] } = options;\n\n const logger = createCompositeLogger(verbose, loggers);\n const sdkOptions = getLogRocketSdkOptions(options, logger);\n\n // Session starts anonymously when LogRocket.init() is called.\n LogRocket.init(appId, sdkOptions);\n\n // Identify the user with the correlation ids.\n if (telemetryContext) {\n // LogRocket maintains the same session even if the user starts as anonymous and later becomes identified via LogRocket.identify().\n // If LogRocket.identify is called multiple times during a recording, you can search for any of the identified users in the session.\n LogRocket.identify(telemetryContext.deviceId, {\n [DeviceIdTrait]: telemetryContext.deviceId,\n [TelemetryIdTrait]: telemetryContext.telemetryId\n });\n }\n\n LogRocket.getSessionURL(url => {\n logger.withText(\"[logrocket] Session replay URL is now available:\").withText(url).debug();\n });\n\n logger.information(\"[logrocket] LogRocket instrumentation is registered.\");\n\n const client = new LogRocketInstrumentationClientImpl(telemetryContext);\n\n // The cast is to normalize the inferred return type to the \"LogRocketInstrumentationClient\" type.\n return client as LogRocketInstrumentationClient;\n }\n}\n\n/**\n * Register the LogRocket instrumentation.\n * @param appId LogRocket application id.\n * @param options LogRocket instrumentation options.\n * @returns {LogRocketInstrumentationClient} A LogRocket instrumentation client instance.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function registerLogRocketInstrumentation(appId: string, options?: RegisterLogRocketInstrumentationOptions) {\n getRegistrationGuard().throw('[logrocket] The LogRocket instrumentation has already been registered. Did you call the \"registerLogRocketInstrumentation\" function twice?');\n\n return new LogRocketInstrumentationRegistrator().register(appId, options);\n}\n"],"names":["HasExecutedGuard","createCompositeLogger","LogRocket","LogrocketFuzzySanitizer","applyTransformers","createRequestSanitizer","createResponseSanitizer","createUrlSanitizer","DeviceIdTrait","LogRocketInstrumentationClientImpl","TelemetryIdTrait","DefaultPrivateFieldNames","DefaultPrivateQueryParameterNames","getLogRocketSdkOptions","userOptions","logger","rootHostname","privateFieldNames","privateQueryParameterNames","verbose","transformers","mergedPrivateFieldNames","mergedPrivateQueryParameterNames","fuzzyRequestSanitizer","fuzzyResponseSanitizer","urlSanitizer","sdkOptions","registrationGuardInstance","getRegistrationGuard","__resetRegistrationGuard","LogRocketInstrumentationRegistrator","appId","options","telemetryContext","loggers","url","client","registerLogRocketInstrumentation"],"mappings":";;;;;;;;;;;;;;;;;;;AAAmF;AACR;AACzC;AACqC;AACyB;AAC3B;AACE;AACV;AACkG;AAG/J,MAAMW,2BAA2B;IAAC;IAAS;IAAiB;IAAe;IAAY;IAAa;IAAY;IAAa;IAAY;IAAU;IAAY;CAAW;AAE1K,MAAMC,oCAAoC;IAAC;IAAS;IAAS;CAAW;AA6CxE,2EAA2E;AACpE,SAASC,uBAAuBC,WAAoD,EAAEC,MAAkB;IAC3G,MAAM,EAAEC,eAAe,cAAc,EAAEC,oBAAoB,EAAE,EAAEC,6BAA6B,EAAE,EAAEC,UAAU,KAAK,EAAEC,eAAe,EAAE,EAAE,GAAGN;IAEvI,MAAMO,0BAA0BV,yBAAyB,MAAM,CAACM;IACh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,EAAEyB,iBAAiB,QAAQ;gBAC1C,CAACvB,gBAAgBA,CAAC,EAAEuB,iBAAiB,WAAW;YACpD;QACJ;QAEA/B,uBAAuB,CAACiC,CAAAA;YACpBpB,OAAO,QAAQ,CAAC,oDAAoD,QAAQ,CAACoB,KAAK,KAAK;QAC3F;QAEApB,OAAO,WAAW,CAAC;QAEnB,MAAMqB,SAAS,IAAI3B,kCAAkCA,CAACwB;QAEtD,kGAAkG;QAClG,OAAOG;IACX;AACJ;AAEA;;;;;;CAMC,GACM,SAASC,iCAAiCN,KAAa,EAAEC,OAAiD;IAC7GJ,uBAAuB,KAAK,CAAC;IAE7B,OAAO,IAAIE,sCAAsC,QAAQ,CAACC,OAAOC;AACrE"}
1
+ {"version":3,"file":"js/registerLogRocketInstrumentation.js","sources":["../../src/js/registerLogRocketInstrumentation.ts"],"sourcesContent":["import { DefaultPrivateQueryParameterNames, HasExecutedGuard, type TelemetryContext } from \"@workleap-telemetry/core\";\nimport { createCompositeLogger, type RootLogger } from \"@workleap/logging\";\nimport LogRocket from \"logrocket\";\nimport LogrocketFuzzySanitizer from \"logrocket-fuzzy-search-sanitizer\";\nimport { applyTransformers, type LogRocketSdkOptionsTransformer } from \"./applyTransformers.ts\";\nimport { createRequestSanitizer } from \"./createRequestSanitizer.ts\";\nimport { createResponseSanitizer } from \"./createResponseSanitizer.ts\";\nimport { createUrlSanitizer } from \"./createUrlSanitizer.ts\";\nimport { DeviceIdTrait, type LogRocketInstrumentationClient, LogRocketInstrumentationClientImpl, TelemetryIdTrait } from \"./LogRocketInstrumentationClient.ts\";\nimport type { LogRocketSdkOptions } from \"./logRocketTypes.ts\";\n\nconst DefaultPrivateFieldNames = [\"email\", \"personalEmail\", \"phoneNumber\", \"password\", \"firstName\", \"lastName\", \"givenName\", \"fullName\", \"gender\", \"timeZone\", \"birthday\"];\n\n///////////////////////////\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface RegisterLogRocketInstrumentationOptions {\n /**\n * A root hostname to track sessions across subdomains. Set this option to capture traffic from all subdomains under one session: https://docs.logrocket.com/reference/roothostname.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n rootHostname?: LogRocketSdkOptions[\"rootHostname\"];\n /**\n * Names of additional fields to exclude from session replays. These fields will be removed from network requests, responses using a fuzzy-matching algorithm.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n privateFieldNames?: string[];\n /**\n * Names of additional fields to exclude from session replays. These fields will be removed from query parameters using a fuzzy-matching algorithm.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n privateQueryParameterNames?: string[];\n /**\n * Context including telemetry correlation ids.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n telemetryContext?: TelemetryContext;\n /**\n * Hooks to transform the resulting LogRocket SDK options.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n transformers?: LogRocketSdkOptionsTransformer[];\n /**\n * Indicates whether or not debug information should be logged to the console.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n verbose?: boolean;\n /**\n * The logger instances that will output messages.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n loggers?: RootLogger[];\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function getLogRocketSdkOptions(userOptions: RegisterLogRocketInstrumentationOptions, logger: RootLogger): LogRocketSdkOptions {\n const { rootHostname = \"workleap.com\", privateFieldNames = [], privateQueryParameterNames = [], verbose = false, transformers = [] } = userOptions;\n\n const mergedPrivateFieldNames = DefaultPrivateFieldNames.concat(privateFieldNames);\n const mergedPrivateQueryParameterNames = DefaultPrivateQueryParameterNames.concat(privateQueryParameterNames);\n\n // The \"LogrocketFuzzySearch.setup\" code is awkward. For now, we prefer to play it safe and call it once here, then forward the sanitize functions\n // to the appropriate factories.\n // No clue why the \"setup\" method is not available. This package is shady.\n // @ts-ignore\n const { requestSanitizer: fuzzyRequestSanitizer, responseSanitizer: fuzzyResponseSanitizer } = LogrocketFuzzySanitizer.setup(mergedPrivateFieldNames);\n\n const urlSanitizer = createUrlSanitizer(mergedPrivateQueryParameterNames);\n\n const sdkOptions = {\n console: {\n // Prevent console logs from being visible in LogRocket session replays and leaking PII.\n // To capture logs in a session replay, use the LogRocketLogger class.\n isEnabled: false\n },\n rootHostname,\n dom: {\n textSanitizer: true,\n inputSanitizer: true\n },\n network: {\n requestSanitizer: createRequestSanitizer(fuzzyRequestSanitizer, urlSanitizer),\n responseSanitizer: createResponseSanitizer(fuzzyResponseSanitizer, urlSanitizer)\n },\n browser: {\n urlSanitizer\n },\n shouldDebugLog: verbose\n } satisfies LogRocketSdkOptions;\n\n return applyTransformers(sdkOptions, transformers, {\n verbose,\n logger\n });\n}\n\n///////////////////////////\n\nlet registrationGuardInstance: HasExecutedGuard | undefined;\n\n// It's important to use a lazy singleton instead of a singleton to avoid\n// any future probleme related to HMR, tree-shaking, SSR, etc..\nfunction getRegistrationGuard() {\n if (!registrationGuardInstance) {\n registrationGuardInstance = new HasExecutedGuard();\n }\n\n return registrationGuardInstance;\n}\n\n// This function should only be used by tests.\nexport function __resetRegistrationGuard() {\n if (registrationGuardInstance) {\n registrationGuardInstance.reset();\n }\n}\n\n///////////////////////////\n\nexport class LogRocketInstrumentationRegistrator {\n register(appId: string, options: RegisterLogRocketInstrumentationOptions = {}) {\n const { telemetryContext, verbose = false, loggers = [] } = options;\n\n const logger = createCompositeLogger(verbose, loggers);\n const sdkOptions = getLogRocketSdkOptions(options, logger);\n\n // Session starts anonymously when LogRocket.init() is called.\n LogRocket.init(appId, sdkOptions);\n\n // Identify the user with the correlation ids.\n if (telemetryContext) {\n // LogRocket maintains the same session even if the user starts as anonymous and later becomes identified via LogRocket.identify().\n // If LogRocket.identify is called multiple times during a recording, you can search for any of the identified users in the session.\n LogRocket.identify(telemetryContext.deviceId, {\n [DeviceIdTrait]: telemetryContext.deviceId,\n [TelemetryIdTrait]: telemetryContext.telemetryId\n });\n }\n\n LogRocket.getSessionURL(url => {\n logger.withText(\"[logrocket] Session replay URL is now available:\").withText(url).debug();\n });\n\n logger.information(\"[logrocket] LogRocket instrumentation is registered.\");\n\n const client = new LogRocketInstrumentationClientImpl(telemetryContext);\n\n // The cast is to normalize the inferred return type to the \"LogRocketInstrumentationClient\" type.\n return client as LogRocketInstrumentationClient;\n }\n}\n\n/**\n * Register the LogRocket instrumentation.\n * @param appId LogRocket application id.\n * @param options LogRocket instrumentation options.\n * @returns {LogRocketInstrumentationClient} A LogRocket instrumentation client instance.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function registerLogRocketInstrumentation(appId: string, options?: RegisterLogRocketInstrumentationOptions) {\n getRegistrationGuard().throw('[logrocket] The LogRocket instrumentation has already been registered. Did you call the \"registerLogRocketInstrumentation\" function twice?');\n\n return new LogRocketInstrumentationRegistrator().register(appId, options);\n}\n"],"names":["DefaultPrivateQueryParameterNames","HasExecutedGuard","createCompositeLogger","LogRocket","LogrocketFuzzySanitizer","applyTransformers","createRequestSanitizer","createResponseSanitizer","createUrlSanitizer","DeviceIdTrait","LogRocketInstrumentationClientImpl","TelemetryIdTrait","DefaultPrivateFieldNames","getLogRocketSdkOptions","userOptions","logger","rootHostname","privateFieldNames","privateQueryParameterNames","verbose","transformers","mergedPrivateFieldNames","mergedPrivateQueryParameterNames","fuzzyRequestSanitizer","fuzzyResponseSanitizer","urlSanitizer","sdkOptions","registrationGuardInstance","getRegistrationGuard","__resetRegistrationGuard","LogRocketInstrumentationRegistrator","appId","options","telemetryContext","loggers","url","client","registerLogRocketInstrumentation"],"mappings":";;;;;;;;;;;;;;;;;;;AAAsH;AAC3C;AACzC;AACqC;AACyB;AAC3B;AACE;AACV;AACkG;AAG/J,MAAMY,2BAA2B;IAAC;IAAS;IAAiB;IAAe;IAAY;IAAa;IAAY;IAAa;IAAY;IAAU;IAAY;CAAW;AA6C1K,2EAA2E;AACpE,SAASC,uBAAuBC,WAAoD,EAAEC,MAAkB;IAC3G,MAAM,EAAEC,eAAe,cAAc,EAAEC,oBAAoB,EAAE,EAAEC,6BAA6B,E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AClB,mIAAmI;YACnI,oIAAoI;YACpI9B,kBAAkB,CAAC8B,iBAAiB,QAAQ,EAAE;gBAC1C,CAACxB,aAAaA,CAAC,EAAEwB,iBAAiB,QAAQ;gBAC1C,CAACtB,gBAAgBA,CAAC,EAAEsB,iBAAiB,WAAW;YACpD;QACJ;QAEA9B,uBAAuB,CAACgC,CAAAA;YACpBpB,OAAO,QAAQ,CAAC,oDAAoD,QAAQ,CAACoB,KAAK,KAAK;QAC3F;QAEApB,OAAO,WAAW,CAAC;QAEnB,MAAMqB,SAAS,IAAI1B,kCAAkCA,CAACuB;QAEtD,kGAAkG;QAClG,OAAOG;IACX;AACJ;AAEA;;;;;;CAMC,GACM,SAASC,iCAAiCN,KAAa,EAAEC,OAAiD;IAC7GJ,uBAAuB,KAAK,CAAC;IAE7B,OAAO,IAAIE,sCAAsC,QAAQ,CAACC,OAAOC;AACrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workleap/logrocket",
3
- "version": "4.0.7",
3
+ "version": "4.1.0",
4
4
  "description": "A package containing utilities for LogRocket.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Workleap",
@@ -33,7 +33,7 @@
33
33
  "provenance": true
34
34
  },
35
35
  "dependencies": {
36
- "@workleap-telemetry/core": "^2.0.7",
36
+ "@workleap-telemetry/core": "^2.1.0",
37
37
  "@workleap/logging": "^2.1.0",
38
38
  "logrocket-fuzzy-search-sanitizer": "0.0.2"
39
39
  },
@@ -1,14 +1,10 @@
1
+ import { redactQueryParameters } from "@workleap-telemetry/core";
2
+
1
3
  export type UrlSanitizerFunction = (url: string) => string;
2
4
 
3
5
  export function createUrlSanitizer(queryParametersToRemove: string[]) {
4
6
  return (url: string | URL) => {
5
7
  // A network request made with XMLHttpRequest can provide a URL object rather than a string.
6
- let sanitizedUrl = String(url);
7
-
8
- for (const x of queryParametersToRemove) {
9
- sanitizedUrl = sanitizedUrl.replace(new RegExp(`${x}=([^&]*)`, "gi"), `${x}=**redacted**`);
10
- }
11
-
12
- return sanitizedUrl;
8
+ return redactQueryParameters(String(url), queryParametersToRemove);
13
9
  };
14
10
  }
@@ -1,4 +1,4 @@
1
- import { HasExecutedGuard, type TelemetryContext } from "@workleap-telemetry/core";
1
+ import { DefaultPrivateQueryParameterNames, HasExecutedGuard, type TelemetryContext } from "@workleap-telemetry/core";
2
2
  import { createCompositeLogger, type RootLogger } from "@workleap/logging";
3
3
  import LogRocket from "logrocket";
4
4
  import LogrocketFuzzySanitizer from "logrocket-fuzzy-search-sanitizer";
@@ -11,8 +11,6 @@ import type { LogRocketSdkOptions } from "./logRocketTypes.ts";
11
11
 
12
12
  const DefaultPrivateFieldNames = ["email", "personalEmail", "phoneNumber", "password", "firstName", "lastName", "givenName", "fullName", "gender", "timeZone", "birthday"];
13
13
 
14
- const DefaultPrivateQueryParameterNames = ["token", "email", "password"];
15
-
16
14
  ///////////////////////////
17
15
 
18
16
  /**