@workleap/logrocket 4.0.4 → 4.0.6

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,19 @@
1
1
  # @workleap/logrocket
2
2
 
3
+ ## 4.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#275](https://github.com/workleap/wl-telemetry/pull/275) [`0128608`](https://github.com/workleap/wl-telemetry/commit/012860830e4e4a17dc6960c9e3d310e7aac98b8e) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Redact the credential headers of the network requests and responses recorded in LogRocket session replays, regardless of the casing of the header name. A header is now redacted when its name contains `auth`, `cookie`, `token`, `session`, `secret`, `key`, `csrf`, `xsrf` or `x-honeycomb-team`. Previously, only a request header named exactly `Authorization` was redacted.
8
+
9
+ ## 4.0.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#269](https://github.com/workleap/wl-telemetry/pull/269) [`0a200c0`](https://github.com/workleap/wl-telemetry/commit/0a200c0dcbb3997a4cc3857836a4c4e269c41723) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Raise the minimum `@workleap/logging` version to `2.1.0`.
14
+ - Updated dependencies [[`0a200c0`](https://github.com/workleap/wl-telemetry/commit/0a200c0dcbb3997a4cc3857836a4c4e269c41723)]:
15
+ - @workleap-telemetry/core@2.0.7
16
+
3
17
  ## 4.0.4
4
18
 
5
19
  ### Patch Changes
@@ -131,32 +131,6 @@ export declare class LogRocketInstrumentationClientImpl implements LogRocketInst
131
131
  constructor(telemetryContext?: TelemetryContext);
132
132
  registerGetSessionUrlListener(listener: GetLogRocketSessionUrlListener): void;
133
133
  createWorkleapPlatformDefaultUserTraits(identification: LogRocketWorkleapPlatformIdentification): {
134
- "Plan Code - Compensation"?: string | undefined;
135
- "Plan Code - Pingboard"?: string | undefined;
136
- "Plan Code - Performance"?: string | undefined;
137
- "Plan Code - Skills"?: string | undefined;
138
- "Plan Code - Onboarding"?: string | undefined;
139
- "Plan Code - LMS"?: string | undefined;
140
- "Plan Code - Officevibe"?: string | undefined;
141
- "Is Team Manager"?: boolean | undefined;
142
- "Is Reporting Manager"?: boolean | undefined;
143
- "Is Collaborator - Compensation"?: boolean | undefined;
144
- "Is Collaborator - Pingboard"?: boolean | undefined;
145
- "Is Collaborator - Performance"?: boolean | undefined;
146
- "Is Collaborator - Skills"?: boolean | undefined;
147
- "Is Collaborator - Onboarding"?: boolean | undefined;
148
- "Is Collaborator - LMS"?: boolean | undefined;
149
- "Is Collaborator - Officevibe"?: boolean | undefined;
150
- "Is Collaborator"?: true | undefined;
151
- "Is Executive - Compensation"?: boolean | undefined;
152
- "Is Executive - Pingboard"?: boolean | undefined;
153
- "Is Executive - Performance"?: boolean | undefined;
154
- "Is Executive - Skills"?: boolean | undefined;
155
- "Is Executive - Onboarding"?: boolean | undefined;
156
- "Is Executive - LMS"?: boolean | undefined;
157
- "Is Executive - Officevibe"?: boolean | undefined;
158
- "Is Executive"?: true | undefined;
159
- "Is Organization Creator"?: boolean | undefined;
160
134
  "User Id": string;
161
135
  "Organization Id": string;
162
136
  "Organization Name": string;
@@ -164,6 +138,32 @@ export declare class LogRocketInstrumentationClientImpl implements LogRocketInst
164
138
  "Is Admin": boolean;
165
139
  "Device Id": string;
166
140
  "Telemetry Id": string;
141
+ "Is Organization Creator"?: boolean | undefined;
142
+ "Is Executive"?: true | undefined;
143
+ "Is Executive - Officevibe"?: boolean | undefined;
144
+ "Is Executive - LMS"?: boolean | undefined;
145
+ "Is Executive - Onboarding"?: boolean | undefined;
146
+ "Is Executive - Skills"?: boolean | undefined;
147
+ "Is Executive - Performance"?: boolean | undefined;
148
+ "Is Executive - Pingboard"?: boolean | undefined;
149
+ "Is Executive - Compensation"?: boolean | undefined;
150
+ "Is Collaborator"?: true | undefined;
151
+ "Is Collaborator - Officevibe"?: boolean | undefined;
152
+ "Is Collaborator - LMS"?: boolean | undefined;
153
+ "Is Collaborator - Onboarding"?: boolean | undefined;
154
+ "Is Collaborator - Skills"?: boolean | undefined;
155
+ "Is Collaborator - Performance"?: boolean | undefined;
156
+ "Is Collaborator - Pingboard"?: boolean | undefined;
157
+ "Is Collaborator - Compensation"?: boolean | undefined;
158
+ "Is Reporting Manager"?: boolean | undefined;
159
+ "Is Team Manager"?: boolean | undefined;
160
+ "Plan Code - Officevibe"?: string | undefined;
161
+ "Plan Code - LMS"?: string | undefined;
162
+ "Plan Code - Onboarding"?: string | undefined;
163
+ "Plan Code - Skills"?: string | undefined;
164
+ "Plan Code - Performance"?: string | undefined;
165
+ "Plan Code - Pingboard"?: string | undefined;
166
+ "Plan Code - Compensation"?: string | undefined;
167
167
  };
168
168
  createShareGateDefaultUserTraits(identification: LogRocketShareGateIdentification): {
169
169
  "ShareGate Account Id": string;
@@ -1 +1 @@
1
- {"version":3,"file":"js/LogRocketInstrumentationClient.js","sources":["../../src/js/LogRocketInstrumentationClient.ts"],"sourcesContent":["import type { LogRocketInstrumentationPartialClient, TelemetryContext } from \"@workleap-telemetry/core\";\nimport LogRocket from \"logrocket\";\nimport { isDefined } from \"./assertions.ts\";\n\nexport type GetLogRocketSessionUrlListener = (sessionURL: string) => void;\n\nexport const DeviceIdTrait = \"Device Id\";\nexport const TelemetryIdTrait = \"Telemetry Id\";\n\n///////////////////////////\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface LogRocketWorkleapPlatformIdentification {\n userId: string;\n organizationId: string;\n organizationName: string;\n isMigratedToWorkleap: boolean;\n isAdmin: boolean;\n isOrganizationCreator?: boolean;\n isExecutive?: {\n wov?: boolean;\n lms?: boolean;\n onb?: boolean;\n sks?: boolean;\n wpm?: boolean;\n pbd?: boolean;\n cmp?: boolean;\n };\n isCollaborator?: {\n wov?: boolean;\n lms?: boolean;\n onb?: boolean;\n sks?: boolean;\n wpm?: boolean;\n pbd?: boolean;\n cmp?: boolean;\n };\n isReportingManager?: boolean;\n isTeamManager?: boolean;\n planCode?: {\n wov?: string;\n lms?: string;\n onb?: string;\n sks?: string;\n wpm?: string;\n pbd?: string;\n cmp?: string;\n };\n}\n\n// Must remain assignable to the LogRocket \"IUserTraits\" type, otherwise the traits cannot be forwarded to\n// LogRocket.identify. Hence the type alias: an index signature would either widen the trait values beyond what\n// LogRocket accepts or forbid optional traits, while a plain interface has no implicit index signature.\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport type LogRocketWorkleapPlatformUserTraits = {\n \"User Id\": string;\n \"Organization Id\": string;\n \"Organization Name\": string;\n \"Is Migrated To Workleap\": boolean;\n \"Is Admin\": boolean;\n [DeviceIdTrait]: string;\n [TelemetryIdTrait]: string;\n \"Is Organization Creator\"?: boolean;\n \"Is Executive\"?: boolean;\n \"Is Executive - Officevibe\"?: boolean;\n \"Is Executive - LMS\"?: boolean;\n \"Is Executive - Onboarding\"?: boolean;\n \"Is Executive - Skills\"?: boolean;\n \"Is Executive - Performance\"?: boolean;\n \"Is Executive - Pingboard\"?: boolean;\n \"Is Executive - Compensation\"?: boolean;\n \"Is Collaborator\"?: boolean;\n \"Is Collaborator - Officevibe\"?: boolean;\n \"Is Collaborator - LMS\"?: boolean;\n \"Is Collaborator - Onboarding\"?: boolean;\n \"Is Collaborator - Skills\"?: boolean;\n \"Is Collaborator - Performance\"?: boolean;\n \"Is Collaborator - Pingboard\"?: boolean;\n \"Is Collaborator - Compensation\"?: boolean;\n \"Is Reporting Manager\"?: boolean;\n \"Is Team Manager\"?: boolean;\n \"Plan Code - Officevibe\"?: string;\n \"Plan Code - LMS\"?: string;\n \"Plan Code - Onboarding\"?: string;\n \"Plan Code - Skills\"?: string;\n \"Plan Code - Performance\"?: string;\n \"Plan Code - Pingboard\"?: string;\n \"Plan Code - Compensation\"?: string;\n};\n\n///////////////////////////\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface LogRocketShareGateIdentification {\n shareGateAccountId: string;\n microsoftUserId?: string;\n microsoftTenantId?: string;\n workspaceId?: string;\n}\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport type LogRocketShareGateUserTraits = {\n \"ShareGate Account Id\": string;\n \"Microsoft User Id\": string;\n \"Microsoft Tenant Id\": string;\n \"Workspace Id\": string;\n \"Device Id\": string;\n \"Telemetry Id\": string;\n};\n\n///////////////////////////\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface LogRocketInstrumentationClient extends LogRocketInstrumentationPartialClient {\n /**\n * Register a listener to receive the LogRocket session id when it's available.\n * This method is the equivalent of the LogRocket.getSessionURL function but is\n * particularly useful for third party libraries that doesn't want to take a dependency\n * on `logrocket`.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n registerGetSessionUrlListener: (listener: GetLogRocketSessionUrlListener) => void;\n\n /**\n * Create the default user traits for a Workleap Platform user.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n createWorkleapPlatformDefaultUserTraits: (identification: LogRocketWorkleapPlatformIdentification) => LogRocketWorkleapPlatformUserTraits;\n\n /**\n * Create the default user traits for a ShareGate user.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n createShareGateDefaultUserTraits: (identification: LogRocketShareGateIdentification) => LogRocketShareGateUserTraits;\n}\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketInstrumentationClientImpl implements LogRocketInstrumentationClient {\n readonly #telemetryContext?: TelemetryContext;\n\n constructor(telemetryContext?: TelemetryContext) {\n this.#telemetryContext = telemetryContext;\n }\n\n // IMPORTANT: If you update this method, make sure to update the LogRocketInstrumentationPartialClient\n // interface as well in @workleap-telemetry/core.\n registerGetSessionUrlListener(listener: GetLogRocketSessionUrlListener) {\n LogRocket.getSessionURL(listener);\n }\n\n createWorkleapPlatformDefaultUserTraits(identification: LogRocketWorkleapPlatformIdentification) {\n const {\n userId,\n organizationId,\n organizationName,\n isMigratedToWorkleap,\n isOrganizationCreator,\n isAdmin,\n isExecutive,\n isCollaborator,\n isReportingManager,\n isTeamManager,\n planCode\n } = identification;\n\n const isExecutiveInAnyProduct = Boolean(\n isExecutive?.wov ||\n isExecutive?.lms ||\n isExecutive?.onb ||\n isExecutive?.sks ||\n isExecutive?.wpm ||\n isExecutive?.pbd ||\n isExecutive?.cmp\n );\n\n const isCollaboratorInAnyProduct = Boolean(\n isCollaborator?.wov ||\n isCollaborator?.lms ||\n isCollaborator?.onb ||\n isCollaborator?.sks ||\n isCollaborator?.wpm ||\n isCollaborator?.pbd ||\n isCollaborator?.cmp\n );\n\n return {\n \"User Id\": userId,\n \"Organization Id\": organizationId,\n \"Organization Name\": organizationName,\n \"Is Migrated To Workleap\": isMigratedToWorkleap,\n \"Is Admin\": isAdmin,\n [DeviceIdTrait]: this.#telemetryContext?.deviceId ?? \"N/A\",\n [TelemetryIdTrait]: this.#telemetryContext?.telemetryId ?? \"N/A\",\n ...(isDefined(isOrganizationCreator) && { \"Is Organization Creator\": isOrganizationCreator }),\n ...(isExecutiveInAnyProduct && { \"Is Executive\": true }),\n ...(isDefined(isExecutive?.wov) && { \"Is Executive - Officevibe\": isExecutive.wov }),\n ...(isDefined(isExecutive?.lms) && { \"Is Executive - LMS\": isExecutive.lms }),\n ...(isDefined(isExecutive?.onb) && { \"Is Executive - Onboarding\": isExecutive.onb }),\n ...(isDefined(isExecutive?.sks) && { \"Is Executive - Skills\": isExecutive.sks }),\n ...(isDefined(isExecutive?.wpm) && { \"Is Executive - Performance\": isExecutive.wpm }),\n ...(isDefined(isExecutive?.pbd) && { \"Is Executive - Pingboard\": isExecutive.pbd }),\n ...(isDefined(isExecutive?.cmp) && { \"Is Executive - Compensation\": isExecutive.cmp }),\n ...(isCollaboratorInAnyProduct && { \"Is Collaborator\": isCollaboratorInAnyProduct }),\n ...(isDefined(isCollaborator?.wov) && { \"Is Collaborator - Officevibe\": isCollaborator.wov }),\n ...(isDefined(isCollaborator?.lms) && { \"Is Collaborator - LMS\": isCollaborator.lms }),\n ...(isDefined(isCollaborator?.onb) && { \"Is Collaborator - Onboarding\": isCollaborator.onb }),\n ...(isDefined(isCollaborator?.sks) && { \"Is Collaborator - Skills\": isCollaborator.sks }),\n ...(isDefined(isCollaborator?.wpm) && { \"Is Collaborator - Performance\": isCollaborator.wpm }),\n ...(isDefined(isCollaborator?.pbd) && { \"Is Collaborator - Pingboard\": isCollaborator.pbd }),\n ...(isDefined(isCollaborator?.cmp) && { \"Is Collaborator - Compensation\": isCollaborator.cmp }),\n ...(isDefined(isReportingManager) && { \"Is Reporting Manager\": isReportingManager }),\n ...(isDefined(isTeamManager) && { \"Is Team Manager\": isTeamManager }),\n ...(isDefined(planCode?.wov) && { \"Plan Code - Officevibe\": planCode.wov }),\n ...(isDefined(planCode?.lms) && { \"Plan Code - LMS\": planCode.lms }),\n ...(isDefined(planCode?.onb) && { \"Plan Code - Onboarding\": planCode.onb }),\n ...(isDefined(planCode?.sks) && { \"Plan Code - Skills\": planCode.sks }),\n ...(isDefined(planCode?.wpm) && { \"Plan Code - Performance\": planCode.wpm }),\n ...(isDefined(planCode?.pbd) && { \"Plan Code - Pingboard\": planCode.pbd }),\n ...(isDefined(planCode?.cmp) && { \"Plan Code - Compensation\": planCode.cmp })\n } satisfies LogRocketWorkleapPlatformUserTraits;\n }\n\n createShareGateDefaultUserTraits(identification: LogRocketShareGateIdentification) {\n return {\n \"ShareGate Account Id\": identification.shareGateAccountId,\n \"Microsoft User Id\": identification.microsoftUserId ?? \"N/A\",\n \"Microsoft Tenant Id\": identification.microsoftTenantId ?? \"N/A\",\n \"Workspace Id\": identification.workspaceId ?? \"N/A\",\n [DeviceIdTrait]: this.#telemetryContext?.deviceId ?? \"N/A\",\n [TelemetryIdTrait]: this.#telemetryContext?.telemetryId ?? \"N/A\"\n } satisfies LogRocketShareGateUserTraits;\n }\n}\n"],"names":["LogRocket","isDefined","DeviceIdTrait","TelemetryIdTrait","LogRocketInstrumentationClientImpl","telemetryContext","listener","identification","userId","organizationId","organizationName","isMigratedToWorkleap","isOrganizationCreator","isAdmin","isExecutive","isCollaborator","isReportingManager","isTe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ASA,CAACiB,UAAU,QAAQ;gBAAE,0BAA0BA,SAAS,GAAG;YAAC,CAAC;YAC1E,GAAIjB,SAASA,CAACiB,UAAU,QAAQ;gBAAE,mBAAmBA,SAAS,GAAG;YAAC,CAAC;YACnE,GAAIjB,SAASA,CAACiB,UAAU,QAAQ;gBAAE,0BAA0BA,SAAS,GAAG;YAAC,CAAC;YAC1E,GAAIjB,SAASA,CAACiB,UAAU,QAAQ;gBAAE,sBAAsBA,SAAS,GAAG;YAAC,CAAC;YACtE,GAAIjB,SAASA,CAACiB,UAAU,QAAQ;gBAAE,2BAA2BA,SAAS,GAAG;YAAC,CAAC;YAC3E,GAAIjB,SAASA,CAACiB,UAAU,QAAQ;gBAAE,yBAAyBA,SAAS,GAAG;YAAC,CAAC;YACzE,GAAIjB,SAASA,CAACiB,UAAU,QAAQ;gBAAE,4BAA4BA,SAAS,GAAG;YAAC,CAAC;QAChF;IACJ;IAEA,iCAAiCX,cAAgD,EAAE;QAC/E,OAAO;YACH,wBAAwBA,eAAe,kBAAkB;YACzD,qBAAqBA,eAAe,eAAe,IAAI;YACvD,uBAAuBA,eAAe,iBAAiB,IAAI;YAC3D,gBAAgBA,eAAe,WAAW,IAAI;YAC9C,CAACL,aAAaA,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY;YACrD,CAACC,gBAAgBA,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe;QAC/D;IACJ;AACJ"}
1
+ {"version":3,"file":"js/LogRocketInstrumentationClient.js","sources":["../../src/js/LogRocketInstrumentationClient.ts"],"sourcesContent":["import type { LogRocketInstrumentationPartialClient, TelemetryContext } from \"@workleap-telemetry/core\";\nimport LogRocket from \"logrocket\";\nimport { isDefined } from \"./assertions.ts\";\n\nexport type GetLogRocketSessionUrlListener = (sessionURL: string) => void;\n\nexport const DeviceIdTrait = \"Device Id\";\nexport const TelemetryIdTrait = \"Telemetry Id\";\n\n///////////////////////////\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface LogRocketWorkleapPlatformIdentification {\n userId: string;\n organizationId: string;\n organizationName: string;\n isMigratedToWorkleap: boolean;\n isAdmin: boolean;\n isOrganizationCreator?: boolean;\n isExecutive?: {\n wov?: boolean;\n lms?: boolean;\n onb?: boolean;\n sks?: boolean;\n wpm?: boolean;\n pbd?: boolean;\n cmp?: boolean;\n };\n isCollaborator?: {\n wov?: boolean;\n lms?: boolean;\n onb?: boolean;\n sks?: boolean;\n wpm?: boolean;\n pbd?: boolean;\n cmp?: boolean;\n };\n isReportingManager?: boolean;\n isTeamManager?: boolean;\n planCode?: {\n wov?: string;\n lms?: string;\n onb?: string;\n sks?: string;\n wpm?: string;\n pbd?: string;\n cmp?: string;\n };\n}\n\n// Must remain assignable to the LogRocket \"IUserTraits\" type, otherwise the traits cannot be forwarded to\n// LogRocket.identify. Hence the type alias: an index signature would either widen the trait values beyond what\n// LogRocket accepts or forbid optional traits, while a plain interface has no implicit index signature.\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport type LogRocketWorkleapPlatformUserTraits = {\n \"User Id\": string;\n \"Organization Id\": string;\n \"Organization Name\": string;\n \"Is Migrated To Workleap\": boolean;\n \"Is Admin\": boolean;\n [DeviceIdTrait]: string;\n [TelemetryIdTrait]: string;\n \"Is Organization Creator\"?: boolean;\n \"Is Executive\"?: boolean;\n \"Is Executive - Officevibe\"?: boolean;\n \"Is Executive - LMS\"?: boolean;\n \"Is Executive - Onboarding\"?: boolean;\n \"Is Executive - Skills\"?: boolean;\n \"Is Executive - Performance\"?: boolean;\n \"Is Executive - Pingboard\"?: boolean;\n \"Is Executive - Compensation\"?: boolean;\n \"Is Collaborator\"?: boolean;\n \"Is Collaborator - Officevibe\"?: boolean;\n \"Is Collaborator - LMS\"?: boolean;\n \"Is Collaborator - Onboarding\"?: boolean;\n \"Is Collaborator - Skills\"?: boolean;\n \"Is Collaborator - Performance\"?: boolean;\n \"Is Collaborator - Pingboard\"?: boolean;\n \"Is Collaborator - Compensation\"?: boolean;\n \"Is Reporting Manager\"?: boolean;\n \"Is Team Manager\"?: boolean;\n \"Plan Code - Officevibe\"?: string;\n \"Plan Code - LMS\"?: string;\n \"Plan Code - Onboarding\"?: string;\n \"Plan Code - Skills\"?: string;\n \"Plan Code - Performance\"?: string;\n \"Plan Code - Pingboard\"?: string;\n \"Plan Code - Compensation\"?: string;\n};\n\n///////////////////////////\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface LogRocketShareGateIdentification {\n shareGateAccountId: string;\n microsoftUserId?: string;\n microsoftTenantId?: string;\n workspaceId?: string;\n}\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport type LogRocketShareGateUserTraits = {\n \"ShareGate Account Id\": string;\n \"Microsoft User Id\": string;\n \"Microsoft Tenant Id\": string;\n \"Workspace Id\": string;\n \"Device Id\": string;\n \"Telemetry Id\": string;\n};\n\n///////////////////////////\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface LogRocketInstrumentationClient extends LogRocketInstrumentationPartialClient {\n /**\n * Register a listener to receive the LogRocket session id when it's available.\n * This method is the equivalent of the LogRocket.getSessionURL function but is\n * particularly useful for third party libraries that doesn't want to take a dependency\n * on `logrocket`.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n registerGetSessionUrlListener: (listener: GetLogRocketSessionUrlListener) => void;\n\n /**\n * Create the default user traits for a Workleap Platform user.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n createWorkleapPlatformDefaultUserTraits: (identification: LogRocketWorkleapPlatformIdentification) => LogRocketWorkleapPlatformUserTraits;\n\n /**\n * Create the default user traits for a ShareGate user.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n createShareGateDefaultUserTraits: (identification: LogRocketShareGateIdentification) => LogRocketShareGateUserTraits;\n}\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketInstrumentationClientImpl implements LogRocketInstrumentationClient {\n readonly #telemetryContext?: TelemetryContext;\n\n constructor(telemetryContext?: TelemetryContext) {\n this.#telemetryContext = telemetryContext;\n }\n\n // IMPORTANT: If you update this method, make sure to update the LogRocketInstrumentationPartialClient\n // interface as well in @workleap-telemetry/core.\n registerGetSessionUrlListener(listener: GetLogRocketSessionUrlListener) {\n LogRocket.getSessionURL(listener);\n }\n\n createWorkleapPlatformDefaultUserTraits(identification: LogRocketWorkleapPlatformIdentification) {\n const { userId, organizationId, organizationName, isMigratedToWorkleap, isOrganizationCreator, isAdmin, isExecutive, isCollaborator, isReportingManager, isTeamManager, planCode } = identification;\n\n const isExecutiveInAnyProduct = Boolean(isExecutive?.wov || isExecutive?.lms || isExecutive?.onb || isExecutive?.sks || isExecutive?.wpm || isExecutive?.pbd || isExecutive?.cmp);\n\n const isCollaboratorInAnyProduct = Boolean(isCollaborator?.wov || isCollaborator?.lms || isCollaborator?.onb || isCollaborator?.sks || isCollaborator?.wpm || isCollaborator?.pbd || isCollaborator?.cmp);\n\n return {\n \"User Id\": userId,\n \"Organization Id\": organizationId,\n \"Organization Name\": organizationName,\n \"Is Migrated To Workleap\": isMigratedToWorkleap,\n \"Is Admin\": isAdmin,\n [DeviceIdTrait]: this.#telemetryContext?.deviceId ?? \"N/A\",\n [TelemetryIdTrait]: this.#telemetryContext?.telemetryId ?? \"N/A\",\n ...(isDefined(isOrganizationCreator) && { \"Is Organization Creator\": isOrganizationCreator }),\n ...(isExecutiveInAnyProduct && { \"Is Executive\": true }),\n ...(isDefined(isExecutive?.wov) && { \"Is Executive - Officevibe\": isExecutive.wov }),\n ...(isDefined(isExecutive?.lms) && { \"Is Executive - LMS\": isExecutive.lms }),\n ...(isDefined(isExecutive?.onb) && { \"Is Executive - Onboarding\": isExecutive.onb }),\n ...(isDefined(isExecutive?.sks) && { \"Is Executive - Skills\": isExecutive.sks }),\n ...(isDefined(isExecutive?.wpm) && { \"Is Executive - Performance\": isExecutive.wpm }),\n ...(isDefined(isExecutive?.pbd) && { \"Is Executive - Pingboard\": isExecutive.pbd }),\n ...(isDefined(isExecutive?.cmp) && { \"Is Executive - Compensation\": isExecutive.cmp }),\n ...(isCollaboratorInAnyProduct && { \"Is Collaborator\": isCollaboratorInAnyProduct }),\n ...(isDefined(isCollaborator?.wov) && { \"Is Collaborator - Officevibe\": isCollaborator.wov }),\n ...(isDefined(isCollaborator?.lms) && { \"Is Collaborator - LMS\": isCollaborator.lms }),\n ...(isDefined(isCollaborator?.onb) && { \"Is Collaborator - Onboarding\": isCollaborator.onb }),\n ...(isDefined(isCollaborator?.sks) && { \"Is Collaborator - Skills\": isCollaborator.sks }),\n ...(isDefined(isCollaborator?.wpm) && { \"Is Collaborator - Performance\": isCollaborator.wpm }),\n ...(isDefined(isCollaborator?.pbd) && { \"Is Collaborator - Pingboard\": isCollaborator.pbd }),\n ...(isDefined(isCollaborator?.cmp) && { \"Is Collaborator - Compensation\": isCollaborator.cmp }),\n ...(isDefined(isReportingManager) && { \"Is Reporting Manager\": isReportingManager }),\n ...(isDefined(isTeamManager) && { \"Is Team Manager\": isTeamManager }),\n ...(isDefined(planCode?.wov) && { \"Plan Code - Officevibe\": planCode.wov }),\n ...(isDefined(planCode?.lms) && { \"Plan Code - LMS\": planCode.lms }),\n ...(isDefined(planCode?.onb) && { \"Plan Code - Onboarding\": planCode.onb }),\n ...(isDefined(planCode?.sks) && { \"Plan Code - Skills\": planCode.sks }),\n ...(isDefined(planCode?.wpm) && { \"Plan Code - Performance\": planCode.wpm }),\n ...(isDefined(planCode?.pbd) && { \"Plan Code - Pingboard\": planCode.pbd }),\n ...(isDefined(planCode?.cmp) && { \"Plan Code - Compensation\": planCode.cmp })\n } satisfies LogRocketWorkleapPlatformUserTraits;\n }\n\n createShareGateDefaultUserTraits(identification: LogRocketShareGateIdentification) {\n return {\n \"ShareGate Account Id\": identification.shareGateAccountId,\n \"Microsoft User Id\": identification.microsoftUserId ?? \"N/A\",\n \"Microsoft Tenant Id\": identification.microsoftTenantId ?? \"N/A\",\n \"Workspace Id\": identification.workspaceId ?? \"N/A\",\n [DeviceIdTrait]: this.#telemetryContext?.deviceId ?? \"N/A\",\n [TelemetryIdTrait]: this.#telemetryContext?.telemetryId ?? \"N/A\"\n } satisfies LogRocketShareGateUserTraits;\n }\n}\n"],"names":["LogRocket","isDefined","DeviceIdTrait","TelemetryIdTrait","LogRocketInstrumentationClientImpl","telemetryContext","listener","identification","userId","organizationId","organizationName","isMigratedToWorkleap","isOrganizationCreator","isAdmin","isExecutive","isCollaborator","isReportingManager","isTeamManager","planCode","isExecutiveInAnyProduct","Boolean","isCollaboratorInAnyProduct"],"mappings":";;;;;AACkC;AACU;AAIrC,MAAME,gBAAgB,YAAY;AAClC,MAAMC,mBAAmB,eAAe;AA2I/C;;CAEC,GACM,MAAMC;IACA,iBAAiB,CAAoB;IAE9C,YAAYC,gBAAmC,CAAE;QAC7C,IAAI,CAAC,iBAAiB,GAAGA;IAC7B;IAEA,sGAAsG;IACtG,iDAAiD;IACjD,8BAA8BC,QAAwC,EAAE;QACpEN,uBAAuB,CAACM;IAC5B;IAEA,wCAAwCC,cAAuD,EAAE;QAC7F,MAAM,EAAEC,MAAM,EAAEC,cAAc,EAAEC,gBAAgB,EAAEC,oBAAoB,EAAEC,qBAAqB,EAAEC,OAAO,EAAEC,WAAW,EAAEC,cAAc,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,EAAE,GAAGX;QAErL,MAAMY,0BAA0BC,QAAQN,aAAa,OAAOA,aAAa,OAAOA,aAAa,OAAOA,aAAa,OAAOA,aAAa,OAAOA,aAAa,OAAOA,aAAa;QAE7K,MAAMO,6BAA6BD,QAAQL,gBAAgB,OAAOA,gBAAgB,OAAOA,gBAAgB,OAAOA,gBAAgB,OAAOA,gBAAgB,OAAOA,gBAAgB,OAAOA,gBAAgB;QAErM,OAAO;YACH,WAAWP;YACX,mBAAmBC;YACnB,qBAAqBC;YACrB,2BAA2BC;YAC3B,YAAYE;YACZ,CAACX,cAAc,EAAE,IAAI,C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
130
130
  });
131
131
  }
132
- this.#log(logrocket.log, LogLevel.debug);
132
+ this.#log((...args)=>logrocket.log(...args), LogLevel.debug);
133
133
  }
134
134
  /**
135
135
  * Write an information log. The log will be processed only if the logger LogLevel is >= information.
@@ -141,7 +141,7 @@ function appendText(currentText, newText, options = {}) {
141
141
  value: log
142
142
  });
143
143
  }
144
- this.#log(logrocket.log, LogLevel.information);
144
+ this.#log((...args)=>logrocket.log(...args), LogLevel.information);
145
145
  }
146
146
  /**
147
147
  * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
@@ -153,7 +153,7 @@ function appendText(currentText, newText, options = {}) {
153
153
  value: log
154
154
  });
155
155
  }
156
- this.#log(logrocket.warn, LogLevel.warning);
156
+ this.#log((...args)=>logrocket.warn(...args), LogLevel.warning);
157
157
  }
158
158
  /**
159
159
  * Write an error log. The log will be processed only if the logger LogLevel is >= error.
@@ -165,7 +165,7 @@ function appendText(currentText, newText, options = {}) {
165
165
  value: log
166
166
  });
167
167
  }
168
- this.#log(logrocket.error, LogLevel.error);
168
+ this.#log((...args)=>logrocket.error(...args), LogLevel.error);
169
169
  }
170
170
  /**
171
171
  * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
@@ -177,7 +177,7 @@ function appendText(currentText, newText, options = {}) {
177
177
  value: log
178
178
  });
179
179
  }
180
- this.#log(logrocket.error, LogLevel.critical);
180
+ this.#log((...args)=>logrocket.error(...args), LogLevel.critical);
181
181
  }
182
182
  /**
183
183
  * @see {@link https://workleap.github.io/wl-logging}
@@ -279,7 +279,7 @@ function appendText(currentText, newText, options = {}) {
279
279
  value: log
280
280
  });
281
281
  }
282
- this.#log(logrocket.log, LogLevel.debug);
282
+ this.#log((...args)=>logrocket.log(...args), LogLevel.debug);
283
283
  }
284
284
  /**
285
285
  * Write an information log. The log will be processed only if the logger LogLevel is >= information.
@@ -291,7 +291,7 @@ function appendText(currentText, newText, options = {}) {
291
291
  value: log
292
292
  });
293
293
  }
294
- this.#log(logrocket.log, LogLevel.information);
294
+ this.#log((...args)=>logrocket.log(...args), LogLevel.information);
295
295
  }
296
296
  /**
297
297
  * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
@@ -303,7 +303,7 @@ function appendText(currentText, newText, options = {}) {
303
303
  value: log
304
304
  });
305
305
  }
306
- this.#log(logrocket.warn, LogLevel.warning);
306
+ this.#log((...args)=>logrocket.warn(...args), LogLevel.warning);
307
307
  }
308
308
  /**
309
309
  * Write an error log. The log will be processed only if the logger LogLevel is >= error.
@@ -315,7 +315,7 @@ function appendText(currentText, newText, options = {}) {
315
315
  value: log
316
316
  });
317
317
  }
318
- this.#log(logrocket.error, LogLevel.error);
318
+ this.#log((...args)=>logrocket.error(...args), LogLevel.error);
319
319
  }
320
320
  /**
321
321
  * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
@@ -327,7 +327,7 @@ function appendText(currentText, newText, options = {}) {
327
327
  value: log
328
328
  });
329
329
  }
330
- this.#log(logrocket.error, LogLevel.critical);
330
+ this.#log((...args)=>logrocket.error(...args), LogLevel.critical);
331
331
  }
332
332
  /**
333
333
  * Start a new logging scope. The scope will inherit the LogLevel of the root logger.
@@ -1 +1 @@
1
- {"version":3,"file":"js/LogRocketLogger.js","sources":["../../src/js/LogRocketLogger.ts"],"sourcesContent":["import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel, type LogOptions } from \"@workleap/logging\";\nimport LogRocket from \"logrocket\";\n\ninterface Segment {\n type: \"text\" | \"object\" | \"error\" | \"line-change\";\n value: unknown;\n options?: LogOptions;\n}\n\nfunction appendText(currentText: string, newText: string, options: { leadingSpace?: boolean } = {}) {\n const {\n leadingSpace = true\n } = options;\n\n if (currentText.length > 0) {\n return `${currentText}${leadingSpace ? \" \" : \"\"}${newText}`;\n }\n\n return newText;\n}\n\n/**\n * Formats an array of Segment objects into a list of log arguments.\n *\n * - Consecutive \"text\" segments are concatenated into a single string, separated by spaces (unless `leadingSpace` is false).\n * - Non-\"text\" segments (\"object\", \"error\", \"line-change\") are added directly to the output array.\n * - When a non-\"text\" segment is encountered, any buffered text is flushed to the output before adding the segment.\n * - At the end, any remaining buffered text is flushed.\n */\nfunction formatSegments(segments: Segment[]) {\n const logs: unknown[] = [];\n\n let textBuffer = \"\";\n\n const flushText = () => {\n if (textBuffer.length > 0) {\n logs.push(textBuffer);\n\n textBuffer = \"\";\n }\n };\n\n segments.forEach(x => {\n if (x.type === \"text\") {\n textBuffer = appendText(textBuffer, x.value as string, {\n leadingSpace: x.options?.leadingSpace\n });\n } else {\n flushText();\n\n logs.push(x.value);\n }\n });\n\n // If the last segment is text, the text buffer hasn't been flushed.\n flushText();\n\n return logs;\n}\n\ntype LogFunction = (...rest: unknown[]) => void;\ntype PendingLog = () => void;\n\n/**\n * An scope implementation for the LogRocket logger.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLoggerScope implements LoggerScope {\n readonly #logLevel: LogLevel;\n readonly #label: string;\n\n #segments: Segment[] = [];\n #pendingLogs: PendingLog[] = [];\n #hasEnded: boolean = false;\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(label: string, logLevel: LogLevel) {\n this.#logLevel = logLevel;\n this.#label = label;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n // Required closure to preserved the current log items for when they will be formatted when the scope is ended.\n const segments = this.#segments;\n\n this.#pendingLogs.push(() => {\n const formattedSegments = formatSegments(segments);\n // Since LogRocket session replay UI doesn't have a concept similar to console.group,\n // the logs of a group are indented by 4 spaces under the group label.\n formattedSegments.unshift(\" \");\n\n fct(...formattedSegments);\n });\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options?: Omit<LogOptions, \"style\">) {\n if (text) {\n this.#segments.push({\n type: \"text\",\n value: text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n type: \"error\",\n value: error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n type: \"object\",\n value: obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n type: \"line-change\",\n value: \"\\r\\n\"\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n end(options: LoggerScopeEndOptions = {}) {\n const {\n dismiss = false\n } = options;\n\n if (!this.#hasEnded) {\n this.#hasEnded = true;\n\n if (!dismiss) {\n if (this.#pendingLogs.length > 0) {\n LogRocket.log(this.#label);\n\n this.#pendingLogs.forEach(x => {\n x();\n });\n\n this.#pendingLogs = [];\n }\n }\n }\n }\n}\n\n/**\n * A logger implementation for LogRocket.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLogger implements Logger {\n readonly #logLevel: LogLevel;\n #segments: Segment[] = [];\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(options: LoggerOptions = {}) {\n const {\n logLevel = LogLevel.debug\n } = options;\n\n this.#logLevel = logLevel;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n const formattedSegments = formatSegments(this.#segments);\n\n fct(...formattedSegments);\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n getName() {\n return LogRocketLogger.name;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options?: Omit<LogOptions, \"style\">) {\n if (text) {\n this.#segments.push({\n type: \"text\",\n value: text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n type: \"error\",\n value: error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n type: \"object\",\n value: obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n type: \"line-change\",\n value: \"\\r\\n\"\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * Start a new logging scope. The scope will inherit the LogLevel of the root logger.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n startScope(label: string) {\n return new LogRocketLoggerScope(label, this.#logLevel);\n }\n}\n"],"names":["LogLevel","LogRocket","appendText","currentText","newText","options","leadingSpace","formatSegments","segments","logs","textBuffer","flushText","x","LogRocketLoggerScope","label","logLevel","fct","threshold","formattedSegments","text","error","obj","log","dismiss","LogRocketLogger"],"mappings":";;;;;AAA6I;AAC3G;AAQlC,SAASE,UAAUA,CAACC,WAAmB,EAAEC,OAAe,EAAEC,UAAsC,CAAC,CAAC;IAC9F,MAAM,EACFC,eAAe,IAAI,EACtB,GAAGD;IAEJ,IAAIF,YAAY,MAAM,GAAG,GAAG;QACxB,O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A,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAACrB,cAAc,EAAED,gBAAgB;IAC9C;IAEA;;;KAGC,GACD,MAAMsB,GAAY,EAAE;QAChB,IAAIA,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAACrB,eAAe,EAAED,cAAc;IAC7C;IAEA;;;KAGC,GACD,SAASsB,GAAY,EAAE;QACnB,IAAIA,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAACrB,eAAe,EAAED,iBAAiB;IAChD;IAEA;;;KAGC,GACD,WAAWc,KAAa,EAAE;QACtB,OAAO,IAAID,oBAAoBA,CAACC,OAAO,IAAI,CAAC,SAAS;IACzD;AACJ"}
1
+ {"version":3,"file":"js/LogRocketLogger.js","sources":["../../src/js/LogRocketLogger.ts"],"sourcesContent":["import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel, type LogOptions } from \"@workleap/logging\";\nimport LogRocket from \"logrocket\";\n\ninterface Segment {\n type: \"text\" | \"object\" | \"error\" | \"line-change\";\n value: unknown;\n options?: LogOptions;\n}\n\nfunction appendText(currentText: string, newText: string, options: { leadingSpace?: boolean } = {}) {\n const { leadingSpace = true } = options;\n\n if (currentText.length > 0) {\n return `${currentText}${leadingSpace ? \" \" : \"\"}${newText}`;\n }\n\n return newText;\n}\n\n/**\n * Formats an array of Segment objects into a list of log arguments.\n *\n * - Consecutive \"text\" segments are concatenated into a single string, separated by spaces (unless `leadingSpace` is false).\n * - Non-\"text\" segments (\"object\", \"error\", \"line-change\") are added directly to the output array.\n * - When a non-\"text\" segment is encountered, any buffered text is flushed to the output before adding the segment.\n * - At the end, any remaining buffered text is flushed.\n */\nfunction formatSegments(segments: Segment[]) {\n const logs: unknown[] = [];\n\n let textBuffer = \"\";\n\n const flushText = () => {\n if (textBuffer.length > 0) {\n logs.push(textBuffer);\n\n textBuffer = \"\";\n }\n };\n\n segments.forEach(x => {\n if (x.type === \"text\") {\n textBuffer = appendText(textBuffer, x.value as string, {\n leadingSpace: x.options?.leadingSpace\n });\n } else {\n flushText();\n\n logs.push(x.value);\n }\n });\n\n // If the last segment is text, the text buffer hasn't been flushed.\n flushText();\n\n return logs;\n}\n\ntype LogFunction = (...rest: unknown[]) => void;\ntype PendingLog = () => void;\n\n/**\n * An scope implementation for the LogRocket logger.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLoggerScope implements LoggerScope {\n readonly #logLevel: LogLevel;\n readonly #label: string;\n\n #segments: Segment[] = [];\n #pendingLogs: PendingLog[] = [];\n #hasEnded: boolean = false;\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(label: string, logLevel: LogLevel) {\n this.#logLevel = logLevel;\n this.#label = label;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n // Required closure to preserved the current log items for when they will be formatted when the scope is ended.\n const segments = this.#segments;\n\n this.#pendingLogs.push(() => {\n const formattedSegments = formatSegments(segments);\n // Since LogRocket session replay UI doesn't have a concept similar to console.group,\n // the logs of a group are indented by 4 spaces under the group label.\n formattedSegments.unshift(\" \");\n\n fct(...formattedSegments);\n });\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options?: Omit<LogOptions, \"style\">) {\n if (text) {\n this.#segments.push({\n type: \"text\",\n value: text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n type: \"error\",\n value: error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n type: \"object\",\n value: obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n type: \"line-change\",\n value: \"\\r\\n\"\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log((...args) => LogRocket.log(...args), LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log((...args) => LogRocket.log(...args), LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log((...args) => LogRocket.warn(...args), LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log((...args) => LogRocket.error(...args), LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log((...args) => LogRocket.error(...args), LogLevel.critical);\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n end(options: LoggerScopeEndOptions = {}) {\n const { dismiss = false } = options;\n\n if (!this.#hasEnded) {\n this.#hasEnded = true;\n\n if (!dismiss) {\n if (this.#pendingLogs.length > 0) {\n LogRocket.log(this.#label);\n\n this.#pendingLogs.forEach(x => {\n x();\n });\n\n this.#pendingLogs = [];\n }\n }\n }\n }\n}\n\n/**\n * A logger implementation for LogRocket.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLogger implements Logger {\n readonly #logLevel: LogLevel;\n #segments: Segment[] = [];\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(options: LoggerOptions = {}) {\n const { logLevel = LogLevel.debug } = options;\n\n this.#logLevel = logLevel;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n const formattedSegments = formatSegments(this.#segments);\n\n fct(...formattedSegments);\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n getName() {\n return LogRocketLogger.name;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options?: Omit<LogOptions, \"style\">) {\n if (text) {\n this.#segments.push({\n type: \"text\",\n value: text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n type: \"error\",\n value: error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n type: \"object\",\n value: obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n type: \"line-change\",\n value: \"\\r\\n\"\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log((...args) => LogRocket.log(...args), LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log((...args) => LogRocket.log(...args), LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log((...args) => LogRocket.warn(...args), LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log((...args) => LogRocket.error(...args), LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log((...args) => LogRocket.error(...args), LogLevel.critical);\n }\n\n /**\n * Start a new logging scope. The scope will inherit the LogLevel of the root logger.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n startScope(label: string) {\n return new LogRocketLoggerScope(label, this.#logLevel);\n }\n}\n"],"names":["LogLevel","LogRocket","appendText","currentText","newText","options","leadingSpace","formatSegments","segments","logs","textBuffer","flushText","x","LogRocketLoggerScope","label","logLevel","fct","threshold","formattedSegments","text","error","obj","log","args","dismiss","LogRocketLogger"],"mappings":";;;;;AAA6I;AAC3G;AAQlC,SAASE,WAAWC,WAAmB,EAAEC,OAAe,EAAEC,UAAsC,CAAC,CAAC;IAC9F,MAAM,EAAEC,eAAe,IAAI,EAAE,GAAGD;IAEhC,IAAIF,YAAY,MAAM,GAAG,GAAG;QACxB,OAAO,GAAGA,cA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QACJ;QAEA,IAAI,CAAC,IAAI,CAAC,CAAC,GAAGC,OAAStB,aAAa,IAAIsB,OAAOvB,oBAAoB;IACvE;IAEA;;;KAGC,GACD,QAAQsB,GAAY,EAAE;QAClB,IAAIA,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAAC,CAAC,GAAGC,OAAStB,cAAc,IAAIsB,OAAOvB,gBAAgB;IACpE;IAEA;;;KAGC,GACD,MAAMsB,GAAY,EAAE;QAChB,IAAIA,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAAC,CAAC,GAAGC,OAAStB,eAAe,IAAIsB,OAAOvB,cAAc;IACnE;IAEA;;;KAGC,GACD,SAASsB,GAAY,EAAE;QACnB,IAAIA,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAAC,CAAC,GAAGC,OAAStB,eAAe,IAAIsB,OAAOvB,iBAAiB;IACtE;IAEA;;;KAGC,GACD,WAAWc,KAAa,EAAE;QACtB,OAAO,IAAID,qBAAqBC,OAAO,IAAI,CAAC,SAAS;IACzD;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/NoopLogRocketInstrumentationClient.js","sources":["../../src/js/NoopLogRocketInstrumentationClient.ts"],"sourcesContent":["import type { LogRocketInstrumentationClient, LogRocketShareGateUserTraits, LogRocketWorkleapPlatformUserTraits } from \"./LogRocketInstrumentationClient.ts\";\n\nexport class NoopLogRocketInstrumentationClient implements LogRocketInstrumentationClient {\n createWorkleapPlatformDefaultUserTraits() {\n return {} as LogRocketWorkleapPlatformUserTraits;\n }\n\n createShareGateDefaultUserTraits() {\n return {} as LogRocketShareGateUserTraits;\n }\n\n registerGetSessionUrlListener() {}\n}\n"],"names":["NoopLogRocketInstrumentationClient"],"mappings":"AAEO,MAAMA,kCAAkCA;IAC3C,0CAA0C;QACtC,OAAO,CAAC;IACZ;IAEA,mCAAmC;QAC/B,OAAO,CAAC;IACZ;IAEA,gCAAgC,CAAC;AACrC"}
1
+ {"version":3,"file":"js/NoopLogRocketInstrumentationClient.js","sources":["../../src/js/NoopLogRocketInstrumentationClient.ts"],"sourcesContent":["import type { LogRocketInstrumentationClient, LogRocketShareGateUserTraits, LogRocketWorkleapPlatformUserTraits } from \"./LogRocketInstrumentationClient.ts\";\n\nexport class NoopLogRocketInstrumentationClient implements LogRocketInstrumentationClient {\n createWorkleapPlatformDefaultUserTraits() {\n return {} as LogRocketWorkleapPlatformUserTraits;\n }\n\n createShareGateDefaultUserTraits() {\n return {} as LogRocketShareGateUserTraits;\n }\n\n registerGetSessionUrlListener() {}\n}\n"],"names":["NoopLogRocketInstrumentationClient"],"mappings":"AAEO,MAAMA;IACT,0CAA0C;QACtC,OAAO,CAAC;IACZ;IAEA,mCAAmC;QAC/B,OAAO,CAAC;IACZ;IAEA,gCAAgC,CAAC;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/applyTransformers.js","sources":["../../src/js/applyTransformers.ts"],"sourcesContent":["import type { RootLogger } from \"@workleap/logging\";\nimport type { LogRocketSdkOptions } from \"./logRocketTypes.ts\";\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface LogRocketSdkOptionsTransformerContext {\n verbose: boolean;\n logger: RootLogger;\n}\n\n/**\n * Hook to transform the resulting LogRocket SDK options.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport type LogRocketSdkOptionsTransformer = (options: LogRocketSdkOptions, context: LogRocketSdkOptionsTransformerContext) => LogRocketSdkOptions;\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function applyTransformers(options: LogRocketSdkOptions, transformers: LogRocketSdkOptionsTransformer[], context: LogRocketSdkOptionsTransformerContext): LogRocketSdkOptions {\n return transformers.reduce((acc, transformer) => transformer(acc, context), options);\n}\n"],"names":["applyTransformers","options","transformers","context","acc","transformer"],"mappings":"AAiBA,2EAA2E;AACpE,SAASA,iBAAiBA,CAACC,OAA4B,EAAEC,YAA8C,EAAEC,OAA8C;IAC1J,OAAOD,aAAa,MAAM,CAAC,CAACE,KAAKC,cAAgBA,YAAYD,KAAKD,UAAUF;AAChF"}
1
+ {"version":3,"file":"js/applyTransformers.js","sources":["../../src/js/applyTransformers.ts"],"sourcesContent":["import type { RootLogger } from \"@workleap/logging\";\nimport type { LogRocketSdkOptions } from \"./logRocketTypes.ts\";\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface LogRocketSdkOptionsTransformerContext {\n verbose: boolean;\n logger: RootLogger;\n}\n\n/**\n * Hook to transform the resulting LogRocket SDK options.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport type LogRocketSdkOptionsTransformer = (options: LogRocketSdkOptions, context: LogRocketSdkOptionsTransformerContext) => LogRocketSdkOptions;\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function applyTransformers(options: LogRocketSdkOptions, transformers: LogRocketSdkOptionsTransformer[], context: LogRocketSdkOptionsTransformerContext): LogRocketSdkOptions {\n return transformers.reduce((acc, transformer) => transformer(acc, context), options);\n}\n"],"names":["applyTransformers","options","transformers","context","acc","transformer"],"mappings":"AAiBA,2EAA2E;AACpE,SAASA,kBAAkBC,OAA4B,EAAEC,YAA8C,EAAEC,OAA8C;IAC1J,OAAOD,aAAa,MAAM,CAAC,CAACE,KAAKC,cAAgBA,YAAYD,KAAKD,UAAUF;AAChF"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/assertions.js","sources":["../../src/js/assertions.ts"],"sourcesContent":["export function isDefined(value: unknown) {\n return typeof value !== \"undefined\" && value !== undefined;\n}\n"],"names":["isDefined","value","undefined"],"mappings":"AAAO,SAASA,SAASA,CAACC,KAAc;IACpC,OAAO,OAAOA,UAAU,eAAeA,UAAUC;AACrD"}
1
+ {"version":3,"file":"js/assertions.js","sources":["../../src/js/assertions.ts"],"sourcesContent":["export function isDefined(value: unknown) {\n return typeof value !== \"undefined\" && value !== undefined;\n}\n"],"names":["isDefined","value","undefined"],"mappings":"AAAO,SAASA,UAAUC,KAAc;IACpC,OAAO,OAAOA,UAAU,eAAeA,UAAUC;AACrD"}
@@ -1,8 +1,10 @@
1
+ import { sanitizeHeaders } from "./sanitizeHeaders.js";
2
+
3
+
4
+
1
5
  function createRequestSanitizer(fuzzyRequestSanitizer) {
2
6
  return (req)=>{
3
- if (req.headers["Authorization"]) {
4
- req.headers["Authorization"] = "**redacted**";
5
- }
7
+ req.headers = sanitizeHeaders(req.headers);
6
8
  if (req.body) {
7
9
  // Do not return the request body, which could contain sensitive information.
8
10
  req.body = "**redacted**";
@@ -1 +1 @@
1
- {"version":3,"file":"js/createRequestSanitizer.js","sources":["../../src/js/createRequestSanitizer.ts"],"sourcesContent":["import type { LogRocketRequest } from \"./logRocketTypes.ts\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RequestSanitizerFunction = (req: LogRocketRequest) => any;\n\nexport function createRequestSanitizer(fuzzyRequestSanitizer: RequestSanitizerFunction) {\n return (req: LogRocketRequest) => {\n if (req.headers[\"Authorization\"]) {\n req.headers[\"Authorization\"] = \"**redacted**\";\n }\n\n if (req.body) {\n // Do not return the request body, which could contain sensitive information.\n req.body = \"**redacted**\";\n }\n\n return fuzzyRequestSanitizer(req);\n };\n}\n"],"names":["createRequestSanitizer","fuzzyRequestSanitizer","req"],"mappings":"AAKO,SAASA,sBAAsBA,CAACC,qBAA+C;IAClF,OAAO,CAACC;QACJ,IAAIA,IAAI,OAAO,CAAC,gBAAgB,EAAE;YAC9BA,IAAI,OAAO,CAAC,gBAAgB,GAAG;QACnC;QAEA,IAAIA,IAAI,IAAI,EAAE;YACV,6EAA6E;YAC7EA,IAAI,IAAI,GAAG;QACf;QAEA,OAAOD,sBAAsBC;IACjC;AACJ"}
1
+ {"version":3,"file":"js/createRequestSanitizer.js","sources":["../../src/js/createRequestSanitizer.ts"],"sourcesContent":["import type { LogRocketRequest } from \"./logRocketTypes.ts\";\nimport { sanitizeHeaders } from \"./sanitizeHeaders.ts\";\n\n// oxlint-disable-next-line typescript/no-explicit-any\nexport type RequestSanitizerFunction = (req: LogRocketRequest) => any;\n\nexport function createRequestSanitizer(fuzzyRequestSanitizer: RequestSanitizerFunction) {\n return (req: LogRocketRequest) => {\n req.headers = sanitizeHeaders(req.headers);\n\n if (req.body) {\n // Do not return the request body, which could contain sensitive information.\n req.body = \"**redacted**\";\n }\n\n return fuzzyRequestSanitizer(req);\n };\n}\n"],"names":["sanitizeHeaders","createRequestSanitizer","fuzzyRequestSanitizer","req"],"mappings":";;;AACuD;AAKhD,SAASC,uBAAuBC,qBAA+C;IAClF,OAAO,CAACC;QACJA,IAAI,OAAO,GAAGH,eAAeA,CAACG,IAAI,OAAO;QAEzC,IAAIA,IAAI,IAAI,EAAE;YACV,6EAA6E;YAC7EA,IAAI,IAAI,GAAG;QACf;QAEA,OAAOD,sBAAsBC;IACjC;AACJ"}
@@ -1,5 +1,10 @@
1
+ import { sanitizeHeaders } from "./sanitizeHeaders.js";
2
+
3
+
4
+
1
5
  function createResponseSanitizer(fuzzyResponseSanitizer) {
2
6
  return (res)=>{
7
+ res.headers = sanitizeHeaders(res.headers);
3
8
  if (res.body) {
4
9
  // Do not return the response body, which could contain sensitive information.
5
10
  res.body = "**redacted**";
@@ -1 +1 @@
1
- {"version":3,"file":"js/createResponseSanitizer.js","sources":["../../src/js/createResponseSanitizer.ts"],"sourcesContent":["import type { LogRocketResponse } from \"./logRocketTypes.ts\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ResponseSanitizerFunction = (res: LogRocketResponse) => any;\n\nexport function createResponseSanitizer(fuzzyResponseSanitizer: ResponseSanitizerFunction) {\n return (res: LogRocketResponse) => {\n if (res.body) {\n // Do not return the response body, which could contain sensitive information.\n res.body = \"**redacted**\";\n }\n\n return fuzzyResponseSanitizer(res);\n };\n}\n"],"names":["createResponseSanitizer","fuzzyResponseSanitizer","res"],"mappings":"AAKO,SAASA,uBAAuBA,CAACC,sBAAiD;IACrF,OAAO,CAACC;QACJ,IAAIA,IAAI,IAAI,EAAE;YACV,8EAA8E;YAC9EA,IAAI,IAAI,GAAG;QACf;QAEA,OAAOD,uBAAuBC;IAClC;AACJ"}
1
+ {"version":3,"file":"js/createResponseSanitizer.js","sources":["../../src/js/createResponseSanitizer.ts"],"sourcesContent":["import type { LogRocketResponse } from \"./logRocketTypes.ts\";\nimport { sanitizeHeaders } from \"./sanitizeHeaders.ts\";\n\n// oxlint-disable-next-line typescript/no-explicit-any\nexport type ResponseSanitizerFunction = (res: LogRocketResponse) => any;\n\nexport function createResponseSanitizer(fuzzyResponseSanitizer: ResponseSanitizerFunction) {\n return (res: LogRocketResponse) => {\n res.headers = sanitizeHeaders(res.headers);\n\n if (res.body) {\n // Do not return the response body, which could contain sensitive information.\n res.body = \"**redacted**\";\n }\n\n return fuzzyResponseSanitizer(res);\n };\n}\n"],"names":["sanitizeHeaders","createResponseSanitizer","fuzzyResponseSanitizer","res"],"mappings":";;;AACuD;AAKhD,SAASC,wBAAwBC,sBAAiD;IACrF,OAAO,CAACC;QACJA,IAAI,OAAO,GAAGH,eAAeA,CAACG,IAAI,OAAO;QAEzC,IAAIA,IAAI,IAAI,EAAE;YACV,8EAA8E;YAC9EA,IAAI,IAAI,GAAG;QACf;QAEA,OAAOD,uBAAuBC;IAClC;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/createUrlSanitizer.js","sources":["../../src/js/createUrlSanitizer.ts"],"sourcesContent":["export function createUrlSanitizer(queryParametersToRemove: string[]) {\n return (url: string) => {\n let sanitizedUrl = url;\n\n for (const x of queryParametersToRemove) {\n sanitizedUrl = sanitizedUrl.replace(new RegExp(`${x}=([^&]*)`, \"i\"), `${x}=**redacted**`);\n }\n\n return sanitizedUrl;\n };\n}\n"],"names":["createUrlSanitizer","queryParametersToRemove","url","sanitizedUrl","x","RegExp"],"mappings":"AAAO,SAASA,kBAAkBA,CAACC,uBAAiC;IAChE,OAAO,CAACC;QACJ,IAAIC,eAAeD;QAEnB,KAAK,MAAME,KAAKH,wBAAyB;YACrCE,eAAeA,aAAa,OAAO,CAAC,IAAIE,OAAO,GAAGD,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAGA,EAAE,aAAa,CAAC;QAC5F;QAEA,OAAOD;IACX;AACJ"}
1
+ {"version":3,"file":"js/createUrlSanitizer.js","sources":["../../src/js/createUrlSanitizer.ts"],"sourcesContent":["export function createUrlSanitizer(queryParametersToRemove: string[]) {\n return (url: string) => {\n let sanitizedUrl = url;\n\n for (const x of queryParametersToRemove) {\n sanitizedUrl = sanitizedUrl.replace(new RegExp(`${x}=([^&]*)`, \"i\"), `${x}=**redacted**`);\n }\n\n return sanitizedUrl;\n };\n}\n"],"names":["createUrlSanitizer","queryParametersToRemove","url","sanitizedUrl","x","RegExp"],"mappings":"AAAO,SAASA,mBAAmBC,uBAAiC;IAChE,OAAO,CAACC;QACJ,IAAIC,eAAeD;QAEnB,KAAK,MAAME,KAAKH,wBAAyB;YACrCE,eAAeA,aAAa,OAAO,CAAC,IAAIE,OAAO,GAAGD,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAGA,EAAE,aAAa,CAAC;QAC5F;QAEA,OAAOD;IACX;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/index.js","sources":["../../src/js/index.ts"],"sourcesContent":["export { createTelemetryContext, type CreateTelemetryContextOptions, type TelemetryContext } from \"@workleap-telemetry/core\";\nexport type { LogRocketSdkOptionsTransformer } from \"./applyTransformers.ts\";\nexport type {\n GetLogRocketSessionUrlListener,\n LogRocketInstrumentationClient,\n LogRocketShareGateIdentification,\n LogRocketShareGateUserTraits,\n LogRocketWorkleapPlatformIdentification,\n LogRocketWorkleapPlatformUserTraits\n} from \"./LogRocketInstrumentationClient.ts\";\nexport { LogRocketLogger, LogRocketLoggerScope } from \"./LogRocketLogger.ts\";\nexport type * from \"./logRocketTypes.ts\";\nexport { NoopLogRocketInstrumentationClient } from \"./NoopLogRocketInstrumentationClient.ts\";\nexport { registerLogRocketInstrumentation, type RegisterLogRocketInstrumentationOptions } from \"./registerLogRocketInstrumentation.ts\";\n\n"],"names":["createTelemetryContext","LogRocketLogger","LogRocketLoggerScope","NoopLogRocketInstrumentationClient","registerLogRocketInstrumentation"],"mappings":";;;;AAA6H;AAUhD;AAEgB;AAC0C"}
1
+ {"version":3,"file":"js/index.js","sources":["../../src/js/index.ts"],"sourcesContent":["export { createTelemetryContext, type CreateTelemetryContextOptions, type TelemetryContext } from \"@workleap-telemetry/core\";\nexport type { LogRocketSdkOptionsTransformer } from \"./applyTransformers.ts\";\nexport type { GetLogRocketSessionUrlListener, LogRocketInstrumentationClient, LogRocketShareGateIdentification, LogRocketShareGateUserTraits, LogRocketWorkleapPlatformIdentification, LogRocketWorkleapPlatformUserTraits } from \"./LogRocketInstrumentationClient.ts\";\nexport { LogRocketLogger, LogRocketLoggerScope } from \"./LogRocketLogger.ts\";\nexport type * from \"./logRocketTypes.ts\";\nexport { NoopLogRocketInstrumentationClient } from \"./NoopLogRocketInstrumentationClient.ts\";\nexport { registerLogRocketInstrumentation, type RegisterLogRocketInstrumentationOptions } from \"./registerLogRocketInstrumentation.ts\";\n"],"names":["createTelemetryContext","LogRocketLogger","LogRocketLoggerScope","NoopLogRocketInstrumentationClient","registerLogRocketInstrumentation"],"mappings":";;;;AAA6H;AAGhD;AAEgB;AAC0C"}
@@ -52,7 +52,6 @@ function getLogRocketSdkOptions(userOptions, logger) {
52
52
  // The "LogrocketFuzzySearch.setup" code is awkward. For now, we prefer to play it safe and call it once here, then forward the sanitize functions
53
53
  // to the appropriate factories.
54
54
  // No clue why the "setup" method is not available. This package is shady.
55
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
56
55
  // @ts-ignore
57
56
  const { requestSanitizer: fuzzyRequestSanitizer, responseSanitizer: fuzzyResponseSanitizer } = logrocket_fuzzy_search_sanitizer.setup(mergedPrivateFieldNames);
58
57
  const sdkOptions = {
@@ -129,7 +128,7 @@ class LogRocketInstrumentationRegistrator {
129
128
  * @returns {LogRocketInstrumentationClient} A LogRocket instrumentation client instance.
130
129
  * @see {@link https://workleap.github.io/wl-telemetry}
131
130
  */ function registerLogRocketInstrumentation(appId, options) {
132
- getRegistrationGuard().throw("[logrocket] The LogRocket instrumentation has already been registered. Did you call the \"registerLogRocketInstrumentation\" function twice?");
131
+ getRegistrationGuard().throw('[logrocket] The LogRocket instrumentation has already been registered. Did you call the "registerLogRocketInstrumentation" function twice?');
133
132
  return new LogRocketInstrumentationRegistrator().register(appId, options);
134
133
  }
135
134
 
@@ -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 = [\n \"email\",\n \"personalEmail\",\n \"phoneNumber\",\n \"password\",\n \"firstName\",\n \"lastName\",\n \"givenName\",\n \"fullName\",\n \"gender\",\n \"timeZone\",\n \"birthday\"\n];\n\nconst DefaultPrivateQueryParameterNames = [\n \"token\",\n \"email\",\n \"password\"\n];\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 {\n rootHostname = \"workleap.com\",\n privateFieldNames = [],\n privateQueryParameterNames = [],\n verbose = false,\n transformers = []\n } = 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 // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const { requestSanitizer: fuzzyRequestSanitizer, responseSanitizer: fuzzyResponseSanitizer } = LogrocketFuzzySanitizer.setup(mergedPrivateFieldNames);\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),\n responseSanitizer: createResponseSanitizer(fuzzyResponseSanitizer)\n },\n browser: {\n urlSanitizer: createUrlSanitizer(mergedPrivateQueryParameterNames)\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(\n appId: string,\n options: RegisterLogRocketInstrumentationOptions = {}\n ) {\n const {\n telemetryContext,\n verbose = false,\n loggers = []\n } = 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\n .withText(\"[logrocket] Session replay URL is now available:\")\n .withText(url)\n .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(\n appId: string,\n options?: RegisterLogRocketInstrumentationOptions\n) {\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","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,wBAAwBA,GAAG;IAC7B;IACA;IACA;IACA;IACA;IACA;IACA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ACIC,KAAa,EACbC,UAAmD,CAAC,CAAC,EACvD;QACE,MAAM,EACFC,gBAAgB,EAChBb,UAAU,KAAK,EACfc,UAAU,EAAE,EACf,GAAGF;QAEJ,MAAMhB,SAASd,qBAAqBA,CAACkB,SAASc;QAC9C,MAAMR,aAAaZ,sBAAsBA,CAACkB,SAAShB;QAEnD,8DAA8D;QAC9Db,cAAc,CAAC4B,OAAOL;QAEtB,8CAA8C;QAC9C,IAAIO,kBAAkB;YAClB,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;YACpBnB,OACK,QAAQ,CAAC,oDACT,QAAQ,CAACmB,KACT,KAAK;QACd;QAEAnB,OAAO,WAAW,CAAC;QAEnB,MAAMoB,SAAS,IAAI1B,kCAAkCA,CAACuB;QAEtD,kGAAkG;QAClG,OAAOG;IACX;AACJ;AAEA;;;;;;CAMC,GACM,SAASC,gCAAgCA,CAC5CN,KAAa,EACbC,OAAiD;IAEjDJ,oBAAoBA,GAAG,KAAK,CAAC;IAE7B,OAAO,IAAIE,mCAAmCA,GAAG,QAAQ,CAACC,OAAOC;AACrE"}
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 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),\n responseSanitizer: createResponseSanitizer(fuzzyResponseSanitizer)\n },\n browser: {\n urlSanitizer: createUrlSanitizer(mergedPrivateQueryParameterNames)\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","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;IAChE,MAAMK,mCAAmCV,kCAAkC,MAAM,CAACM;IAElF,kJAAkJ;IAClJ,gCAAgC;IAChC,0EAA0E;IAC1E,aAAa;IACb,MAAM,EAAE,kBAAkBK,qBAAqB,EAAE,mBAAmBC,sBAAsB,EAAE,GAAGrB,sCAA6B,CAACkB;IAE7H,MAAMI,aAAa;QACf,SAAS;YACL,wFAAwF;YACxF,sEAAsE;YACtE,WAAW;QACf;QACAT;QACA,KAAK;YACD,eAAe;YACf,gBAAgB;QACpB;QACA,SAAS;YACL,kBAAkBX,sBAAsBA,CAACkB;YACzC,mBAAmBjB,uBAAuBA,CAACkB;QAC/C;QACA,SAAS;YACL,cAAcjB,kBAAkBA,CAACe;QACrC;QACA,gBAAgBH;IACpB;IAEA,OAAOf,iBAAiBA,CAACqB,YAAYL,cAAc;QAC/CD;QACAJ;IACJ;AACJ;AAEA,2BAA2B;AAE3B,IAAIW;AAEJ,yEAAyE;AACzE,+DAA+D;AAC/D,SAASC;IACL,IAAI,CAACD,2BAA2B;QAC5BA,4BAA4B,IAAI1B,gBAAgBA;IACpD;IAEA,OAAO0B;AACX;AAEA,8CAA8C;AACvC,SAASE;IACZ,IAAIF,2BAA2B;QAC3BA,0BAA0B,KAAK;IACnC;AACJ;AAEA,2BAA2B;AAEpB,MAAMG;IACT,SAASC,KAAa,EAAEC,UAAmD,CAAC,CAAC,EAAE;QAC3E,MAAM,EAAEC,gBAAgB,EAAEb,UAAU,KAAK,EAAEc,UAAU,EAAE,EAAE,GAAGF;QAE5D,MAAMhB,SAASd,qBAAqBA,CAACkB,SAASc;QAC9C,MAAMR,aAAaZ,uBAAuBkB,SAAShB;QAEnD,8DAA8D;QAC9Db,cAAc,CAAC4B,OAAOL;QAEtB,8CAA8C;QAC9C,IAAIO,kBAAkB;YAClB,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;YACpBnB,OAAO,QAAQ,CAAC,oDAAoD,QAAQ,CAACmB,KAAK,KAAK;QAC3F;QAEAnB,OAAO,WAAW,CAAC;QAEnB,MAAMoB,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"}
@@ -0,0 +1,3 @@
1
+ export declare function sanitizeHeaders(headers: unknown): {
2
+ [key: string]: string | null | undefined;
3
+ };
@@ -0,0 +1,32 @@
1
+ // A header is redacted when its lowercased name contains one of the following values.
2
+ const PrivateHeaderNames = [
3
+ "auth",
4
+ "cookie",
5
+ "token",
6
+ "session",
7
+ "secret",
8
+ "key",
9
+ "csrf",
10
+ "xsrf",
11
+ "x-honeycomb-team"
12
+ ];
13
+ // When the headers of a fetch request are provided as an array of tuples, LogRocket indexes the headers by their position
14
+ // and the header name ends up in the value, e.g. { "0": "Authorization,Bearer 123" }.
15
+ const IndexedHeaderNameRegEx = /^\d+$/;
16
+ function isPrivateHeader(name) {
17
+ const lowercasedName = name.toLowerCase();
18
+ return IndexedHeaderNameRegEx.test(name) || PrivateHeaderNames.some((x)=>lowercasedName.includes(x));
19
+ }
20
+ function sanitizeHeaders(headers) {
21
+ const sanitizedHeaders = {};
22
+ if (headers !== null && typeof headers === "object") {
23
+ for (const [name, value] of Object.entries(headers)){
24
+ sanitizedHeaders[name] = isPrivateHeader(name) ? "**redacted**" : value;
25
+ }
26
+ }
27
+ return sanitizedHeaders;
28
+ }
29
+
30
+ export { sanitizeHeaders };
31
+
32
+ //# sourceMappingURL=sanitizeHeaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"js/sanitizeHeaders.js","sources":["../../src/js/sanitizeHeaders.ts"],"sourcesContent":["import type { LogRocketRequest } from \"./logRocketTypes.ts\";\n\n// A header is redacted when its lowercased name contains one of the following values.\nconst PrivateHeaderNames = [\"auth\", \"cookie\", \"token\", \"session\", \"secret\", \"key\", \"csrf\", \"xsrf\", \"x-honeycomb-team\"];\n\n// When the headers of a fetch request are provided as an array of tuples, LogRocket indexes the headers by their position\n// and the header name ends up in the value, e.g. { \"0\": \"Authorization,Bearer 123\" }.\nconst IndexedHeaderNameRegEx = /^\\d+$/;\n\nfunction isPrivateHeader(name: string) {\n const lowercasedName = name.toLowerCase();\n\n return IndexedHeaderNameRegEx.test(name) || PrivateHeaderNames.some(x => lowercasedName.includes(x));\n}\n\nexport function sanitizeHeaders(headers: unknown) {\n const sanitizedHeaders: LogRocketRequest[\"headers\"] = {};\n\n if (headers !== null && typeof headers === \"object\") {\n for (const [name, value] of Object.entries(headers)) {\n sanitizedHeaders[name] = isPrivateHeader(name) ? \"**redacted**\" : value;\n }\n }\n\n return sanitizedHeaders;\n}\n"],"names":["PrivateHeaderNames","IndexedHeaderNameRegEx","isPrivateHeader","name","lowercasedName","x","sanitizeHeaders","headers","sanitizedHeaders","value","Object"],"mappings":"AAEA,sFAAsF;AACtF,MAAMA,qBAAqB;IAAC;IAAQ;IAAU;IAAS;IAAW;IAAU;IAAO;IAAQ;IAAQ;CAAmB;AAEtH,0HAA0H;AAC1H,sFAAsF;AACtF,MAAMC,yBAAyB;AAE/B,SAASC,gBAAgBC,IAAY;IACjC,MAAMC,iBAAiBD,KAAK,WAAW;IAEvC,OAAOF,uBAAuB,IAAI,CAACE,SAASH,mBAAmB,IAAI,CAACK,CAAAA,IAAKD,eAAe,QAAQ,CAACC;AACrG;AAEO,SAASC,gBAAgBC,OAAgB;IAC5C,MAAMC,mBAAgD,CAAC;IAEvD,IAAID,YAAY,QAAQ,OAAOA,YAAY,UAAU;QACjD,KAAK,MAAM,CAACJ,MAAMM,MAAM,IAAIC,OAAO,OAAO,CAACH,SAAU;YACjDC,gBAAgB,CAACL,KAAK,GAAGD,gBAAgBC,QAAQ,iBAAiBM;QACtE;IACJ;IAEA,OAAOD;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"react/LogRocketInstrumentationContext.js","sources":["../../src/react/LogRocketInstrumentationContext.tsx"],"sourcesContent":["import { createContext, type PropsWithChildren, useContext } from \"react\";\nimport type { LogRocketInstrumentationClient } from \"../js/LogRocketInstrumentationClient.ts\";\n\nconst LogRocketInstrumentationContext = createContext<LogRocketInstrumentationClient | undefined>(undefined);\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface LogRocketInstrumentationProviderProps extends PropsWithChildren {\n client: LogRocketInstrumentationClient;\n}\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function LogRocketInstrumentationProvider(props: LogRocketInstrumentationProviderProps) {\n const {\n client,\n children\n } = props;\n\n return (\n <LogRocketInstrumentationContext.Provider value={client}>\n {children}\n </LogRocketInstrumentationContext.Provider>\n );\n}\n\nexport interface UseLogRocketInstrumentationClientOptions {\n /**\n * Whether or not an exception should be thrown if the client hasn't been provided.\n */\n throwOnUndefined?: boolean;\n}\n\nexport function useLogRocketInstrumentationClient(options?: { throwOnUndefined?: true }): LogRocketInstrumentationClient;\nexport function useLogRocketInstrumentationClient(options: { throwOnUndefined: false }): LogRocketInstrumentationClient | undefined;\n\n/**\n * Retrieve the LogRocket instrumentation client.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function useLogRocketInstrumentationClient(options: UseLogRocketInstrumentationClientOptions = {}) {\n const {\n throwOnUndefined = true\n } = options;\n\n const client = useContext(LogRocketInstrumentationContext);\n\n if (!client && throwOnUndefined) {\n throw new Error(\"[logrocket] The useLogRocketInstrumentationClient function is called before an LogRocketInstrumentationClient instance has been provided.\");\n }\n\n return client;\n}\n"],"names":["createContext","useContext","LogRocketInstrumentationContext","undefined","LogRocketInstrumentationProvider","props","client","children","useLogRocketInstrumentationClient","options","throwOnUndefined","Error"],"mappings":";;;;;;AAA0E;AAG1E,MAAME,+BAA+BA,iBAAGF,aAAaA,CAA6CG;AASlG;;CAEC,GACM,SAASC,gCAAgCA,CAACC,KAA4C;IACzF,MAAM,EACFC,MAAM,EACNC,QAAQ,EACX,GAAGF;IAEJ,qBACI,IAACH,+BAA+BA,CAAC,QAAQ;QAAC,OAAOI;kBAC5CC;;AAGb;AAYA;;;CAGC,GACM,SAASC,iCAAiCA,CAACC,UAAoD,CAAC,CAAC;IACpG,MAAM,EACFC,mBAAmB,IAAI,EAC1B,GAAGD;IAEJ,MAAMH,SAASL,UAAUA,CAACC,+BAA+BA;IAEzD,IAAI,CAACI,UAAUI,kBAAkB;QAC7B,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOL;AACX"}
1
+ {"version":3,"file":"react/LogRocketInstrumentationContext.js","sources":["../../src/react/LogRocketInstrumentationContext.tsx"],"sourcesContent":["import { createContext, type PropsWithChildren, useContext } from \"react\";\nimport type { LogRocketInstrumentationClient } from \"../js/LogRocketInstrumentationClient.ts\";\n\nconst LogRocketInstrumentationContext = createContext<LogRocketInstrumentationClient | undefined>(undefined);\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface LogRocketInstrumentationProviderProps extends PropsWithChildren {\n client: LogRocketInstrumentationClient;\n}\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function LogRocketInstrumentationProvider(props: LogRocketInstrumentationProviderProps) {\n const { client, children } = props;\n\n return <LogRocketInstrumentationContext.Provider value={client}>{children}</LogRocketInstrumentationContext.Provider>;\n}\n\nexport interface UseLogRocketInstrumentationClientOptions {\n /**\n * Whether or not an exception should be thrown if the client hasn't been provided.\n */\n throwOnUndefined?: boolean;\n}\n\nexport function useLogRocketInstrumentationClient(options?: { throwOnUndefined?: true }): LogRocketInstrumentationClient;\nexport function useLogRocketInstrumentationClient(options: { throwOnUndefined: false }): LogRocketInstrumentationClient | undefined;\n\n/**\n * Retrieve the LogRocket instrumentation client.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function useLogRocketInstrumentationClient(options: UseLogRocketInstrumentationClientOptions = {}) {\n const { throwOnUndefined = true } = options;\n\n const client = useContext(LogRocketInstrumentationContext);\n\n if (!client && throwOnUndefined) {\n throw new Error(\"[logrocket] The useLogRocketInstrumentationClient function is called before an LogRocketInstrumentationClient instance has been provided.\");\n }\n\n return client;\n}\n"],"names":["createContext","useContext","LogRocketInstrumentationContext","undefined","LogRocketInstrumentationProvider","props","client","children","useLogRocketInstrumentationClient","options","throwOnUndefined","Error"],"mappings":";;;;;;AAA0E;AAG1E,MAAME,gDAAkCF,aAAaA,CAA6CG;AASlG;;CAEC,GACM,SAASC,iCAAiCC,KAA4C;IACzF,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGF;IAE7B,qBAAO,IAACH,gCAAgC,QAAQ;QAAC,OAAOI;kBAASC;;AACrE;AAYA;;;CAGC,GACM,SAASC,kCAAkCC,UAAoD,CAAC,CAAC;IACpG,MAAM,EAAEC,mBAAmB,IAAI,EAAE,GAAGD;IAEpC,MAAMH,SAASL,UAAUA,CAACC;IAE1B,IAAI,CAACI,UAAUI,kBAAkB;QAC7B,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOL;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"react/index.js","sources":["../../src/react/index.ts"],"sourcesContent":["export * from \"../js/index.ts\";\nexport { LogRocketInstrumentationProvider, useLogRocketInstrumentationClient, type UseLogRocketInstrumentationClientOptions } from \"./LogRocketInstrumentationContext.tsx\";\n\n"],"names":["LogRocketInstrumentationProvider","useLogRocketInstrumentationClient"],"mappings":";;AAA+B;AAC4I"}
1
+ {"version":3,"file":"react/index.js","sources":["../../src/react/index.ts"],"sourcesContent":["export * from \"../js/index.ts\";\nexport { LogRocketInstrumentationProvider, useLogRocketInstrumentationClient, type UseLogRocketInstrumentationClientOptions } from \"./LogRocketInstrumentationContext.tsx\";\n"],"names":["LogRocketInstrumentationProvider","useLogRocketInstrumentationClient"],"mappings":";;AAA+B;AAC4I"}
package/package.json CHANGED
@@ -1,19 +1,21 @@
1
1
  {
2
2
  "name": "@workleap/logrocket",
3
- "author": "Workleap",
4
- "version": "4.0.4",
3
+ "version": "4.0.6",
5
4
  "description": "A package containing utilities for LogRocket.",
6
5
  "license": "Apache-2.0",
6
+ "author": "Workleap",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/workleap/wl-telemetry.git",
10
10
  "directory": "packages/logrocket"
11
11
  },
12
+ "files": [
13
+ "src",
14
+ "dist",
15
+ "CHANGELOG.md"
16
+ ],
12
17
  "type": "module",
13
- "publishConfig": {
14
- "access": "public",
15
- "provenance": true
16
- },
18
+ "sideEffects": false,
17
19
  "exports": {
18
20
  ".": {
19
21
  "types": "./dist/js/index.d.ts",
@@ -26,11 +28,26 @@
26
28
  "default": "./dist/react/index.js"
27
29
  }
28
30
  },
29
- "files": [
30
- "src",
31
- "dist",
32
- "CHANGELOG.md"
33
- ],
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "provenance": true
34
+ },
35
+ "dependencies": {
36
+ "@workleap-telemetry/core": "^2.0.7",
37
+ "@workleap/logging": "^2.1.0",
38
+ "logrocket-fuzzy-search-sanitizer": "0.0.2"
39
+ },
40
+ "devDependencies": {
41
+ "@rsbuild/core": "2.3.1",
42
+ "@rslib/core": "1.0.6",
43
+ "@types/node": "26.6.6",
44
+ "@types/react": "19.3.0",
45
+ "@workleap/rslib-configs": "2.1.1",
46
+ "@workleap/typescript-configs": "5.1.0",
47
+ "happy-dom": "21.0.4",
48
+ "typescript": "7.0.2",
49
+ "vitest": "5.1.0"
50
+ },
34
51
  "peerDependencies": {
35
52
  "@types/react": "^18.0.0 || ^19.0.0",
36
53
  "logrocket": "^12.4.0",
@@ -48,33 +65,9 @@
48
65
  "optional": true
49
66
  }
50
67
  },
51
- "dependencies": {
52
- "@workleap-telemetry/core": "^2.0.6",
53
- "@workleap/logging": "^2.0.1",
54
- "logrocket-fuzzy-search-sanitizer": "0.0.2"
55
- },
56
- "devDependencies": {
57
- "@eslint/js": "9.39.2",
58
- "@rsbuild/core": "2.2.14",
59
- "@rslib/core": "1.0.3",
60
- "@types/node": "26.6.5",
61
- "@types/react": "19.3.0",
62
- "@typescript-eslint/parser": "8.72.0",
63
- "@typescript/native-preview": "7.0.0-dev.20260707.2",
64
- "@workleap/eslint-configs": "2.0.6",
65
- "@workleap/rslib-configs": "2.0.0",
66
- "@workleap/typescript-configs": "5.0.0",
67
- "eslint": "9.39.2",
68
- "happy-dom": "21.0.4",
69
- "typescript": "6.0.3",
70
- "typescript-eslint": "8.72.0",
71
- "vitest": "5.0.5"
72
- },
73
- "sideEffects": false,
74
68
  "scripts": {
75
69
  "build": "rslib build --config ./rslib.build.ts",
76
- "eslint": "eslint . --max-warnings=0 --cache --cache-location node_modules/.cache/eslint",
77
- "typecheck": "tsgo",
70
+ "typecheck": "tsc",
78
71
  "test": "vitest --config vitest.config.ts --no-watch"
79
72
  }
80
73
  }
@@ -161,39 +161,11 @@ export class LogRocketInstrumentationClientImpl implements LogRocketInstrumentat
161
161
  }
162
162
 
163
163
  createWorkleapPlatformDefaultUserTraits(identification: LogRocketWorkleapPlatformIdentification) {
164
- const {
165
- userId,
166
- organizationId,
167
- organizationName,
168
- isMigratedToWorkleap,
169
- isOrganizationCreator,
170
- isAdmin,
171
- isExecutive,
172
- isCollaborator,
173
- isReportingManager,
174
- isTeamManager,
175
- planCode
176
- } = identification;
177
-
178
- const isExecutiveInAnyProduct = Boolean(
179
- isExecutive?.wov ||
180
- isExecutive?.lms ||
181
- isExecutive?.onb ||
182
- isExecutive?.sks ||
183
- isExecutive?.wpm ||
184
- isExecutive?.pbd ||
185
- isExecutive?.cmp
186
- );
187
-
188
- const isCollaboratorInAnyProduct = Boolean(
189
- isCollaborator?.wov ||
190
- isCollaborator?.lms ||
191
- isCollaborator?.onb ||
192
- isCollaborator?.sks ||
193
- isCollaborator?.wpm ||
194
- isCollaborator?.pbd ||
195
- isCollaborator?.cmp
196
- );
164
+ const { userId, organizationId, organizationName, isMigratedToWorkleap, isOrganizationCreator, isAdmin, isExecutive, isCollaborator, isReportingManager, isTeamManager, planCode } = identification;
165
+
166
+ const isExecutiveInAnyProduct = Boolean(isExecutive?.wov || isExecutive?.lms || isExecutive?.onb || isExecutive?.sks || isExecutive?.wpm || isExecutive?.pbd || isExecutive?.cmp);
167
+
168
+ const isCollaboratorInAnyProduct = Boolean(isCollaborator?.wov || isCollaborator?.lms || isCollaborator?.onb || isCollaborator?.sks || isCollaborator?.wpm || isCollaborator?.pbd || isCollaborator?.cmp);
197
169
 
198
170
  return {
199
171
  "User Id": userId,
@@ -8,9 +8,7 @@ interface Segment {
8
8
  }
9
9
 
10
10
  function appendText(currentText: string, newText: string, options: { leadingSpace?: boolean } = {}) {
11
- const {
12
- leadingSpace = true
13
- } = options;
11
+ const { leadingSpace = true } = options;
14
12
 
15
13
  if (currentText.length > 0) {
16
14
  return `${currentText}${leadingSpace ? " " : ""}${newText}`;
@@ -172,7 +170,7 @@ export class LogRocketLoggerScope implements LoggerScope {
172
170
  });
173
171
  }
174
172
 
175
- this.#log(LogRocket.log, LogLevel.debug);
173
+ this.#log((...args) => LogRocket.log(...args), LogLevel.debug);
176
174
  }
177
175
 
178
176
  /**
@@ -187,7 +185,7 @@ export class LogRocketLoggerScope implements LoggerScope {
187
185
  });
188
186
  }
189
187
 
190
- this.#log(LogRocket.log, LogLevel.information);
188
+ this.#log((...args) => LogRocket.log(...args), LogLevel.information);
191
189
  }
192
190
 
193
191
  /**
@@ -202,7 +200,7 @@ export class LogRocketLoggerScope implements LoggerScope {
202
200
  });
203
201
  }
204
202
 
205
- this.#log(LogRocket.warn, LogLevel.warning);
203
+ this.#log((...args) => LogRocket.warn(...args), LogLevel.warning);
206
204
  }
207
205
 
208
206
  /**
@@ -217,7 +215,7 @@ export class LogRocketLoggerScope implements LoggerScope {
217
215
  });
218
216
  }
219
217
 
220
- this.#log(LogRocket.error, LogLevel.error);
218
+ this.#log((...args) => LogRocket.error(...args), LogLevel.error);
221
219
  }
222
220
 
223
221
  /**
@@ -232,16 +230,14 @@ export class LogRocketLoggerScope implements LoggerScope {
232
230
  });
233
231
  }
234
232
 
235
- this.#log(LogRocket.error, LogLevel.critical);
233
+ this.#log((...args) => LogRocket.error(...args), LogLevel.critical);
236
234
  }
237
235
 
238
236
  /**
239
237
  * @see {@link https://workleap.github.io/wl-logging}
240
238
  */
241
239
  end(options: LoggerScopeEndOptions = {}) {
242
- const {
243
- dismiss = false
244
- } = options;
240
+ const { dismiss = false } = options;
245
241
 
246
242
  if (!this.#hasEnded) {
247
243
  this.#hasEnded = true;
@@ -273,9 +269,7 @@ export class LogRocketLogger implements Logger {
273
269
  * @see {@link https://workleap.github.io/wl-logging}
274
270
  */
275
271
  constructor(options: LoggerOptions = {}) {
276
- const {
277
- logLevel = LogLevel.debug
278
- } = options;
272
+ const { logLevel = LogLevel.debug } = options;
279
273
 
280
274
  this.#logLevel = logLevel;
281
275
  }
@@ -370,7 +364,7 @@ export class LogRocketLogger implements Logger {
370
364
  });
371
365
  }
372
366
 
373
- this.#log(LogRocket.log, LogLevel.debug);
367
+ this.#log((...args) => LogRocket.log(...args), LogLevel.debug);
374
368
  }
375
369
 
376
370
  /**
@@ -385,7 +379,7 @@ export class LogRocketLogger implements Logger {
385
379
  });
386
380
  }
387
381
 
388
- this.#log(LogRocket.log, LogLevel.information);
382
+ this.#log((...args) => LogRocket.log(...args), LogLevel.information);
389
383
  }
390
384
 
391
385
  /**
@@ -400,7 +394,7 @@ export class LogRocketLogger implements Logger {
400
394
  });
401
395
  }
402
396
 
403
- this.#log(LogRocket.warn, LogLevel.warning);
397
+ this.#log((...args) => LogRocket.warn(...args), LogLevel.warning);
404
398
  }
405
399
 
406
400
  /**
@@ -415,7 +409,7 @@ export class LogRocketLogger implements Logger {
415
409
  });
416
410
  }
417
411
 
418
- this.#log(LogRocket.error, LogLevel.error);
412
+ this.#log((...args) => LogRocket.error(...args), LogLevel.error);
419
413
  }
420
414
 
421
415
  /**
@@ -430,7 +424,7 @@ export class LogRocketLogger implements Logger {
430
424
  });
431
425
  }
432
426
 
433
- this.#log(LogRocket.error, LogLevel.critical);
427
+ this.#log((...args) => LogRocket.error(...args), LogLevel.critical);
434
428
  }
435
429
 
436
430
  /**
@@ -1,13 +1,12 @@
1
1
  import type { LogRocketRequest } from "./logRocketTypes.ts";
2
+ import { sanitizeHeaders } from "./sanitizeHeaders.ts";
2
3
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ // oxlint-disable-next-line typescript/no-explicit-any
4
5
  export type RequestSanitizerFunction = (req: LogRocketRequest) => any;
5
6
 
6
7
  export function createRequestSanitizer(fuzzyRequestSanitizer: RequestSanitizerFunction) {
7
8
  return (req: LogRocketRequest) => {
8
- if (req.headers["Authorization"]) {
9
- req.headers["Authorization"] = "**redacted**";
10
- }
9
+ req.headers = sanitizeHeaders(req.headers);
11
10
 
12
11
  if (req.body) {
13
12
  // Do not return the request body, which could contain sensitive information.
@@ -1,10 +1,13 @@
1
1
  import type { LogRocketResponse } from "./logRocketTypes.ts";
2
+ import { sanitizeHeaders } from "./sanitizeHeaders.ts";
2
3
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ // oxlint-disable-next-line typescript/no-explicit-any
4
5
  export type ResponseSanitizerFunction = (res: LogRocketResponse) => any;
5
6
 
6
7
  export function createResponseSanitizer(fuzzyResponseSanitizer: ResponseSanitizerFunction) {
7
8
  return (res: LogRocketResponse) => {
9
+ res.headers = sanitizeHeaders(res.headers);
10
+
8
11
  if (res.body) {
9
12
  // Do not return the response body, which could contain sensitive information.
10
13
  res.body = "**redacted**";
package/src/js/index.ts CHANGED
@@ -1,15 +1,7 @@
1
1
  export { createTelemetryContext, type CreateTelemetryContextOptions, type TelemetryContext } from "@workleap-telemetry/core";
2
2
  export type { LogRocketSdkOptionsTransformer } from "./applyTransformers.ts";
3
- export type {
4
- GetLogRocketSessionUrlListener,
5
- LogRocketInstrumentationClient,
6
- LogRocketShareGateIdentification,
7
- LogRocketShareGateUserTraits,
8
- LogRocketWorkleapPlatformIdentification,
9
- LogRocketWorkleapPlatformUserTraits
10
- } from "./LogRocketInstrumentationClient.ts";
3
+ export type { GetLogRocketSessionUrlListener, LogRocketInstrumentationClient, LogRocketShareGateIdentification, LogRocketShareGateUserTraits, LogRocketWorkleapPlatformIdentification, LogRocketWorkleapPlatformUserTraits } from "./LogRocketInstrumentationClient.ts";
11
4
  export { LogRocketLogger, LogRocketLoggerScope } from "./LogRocketLogger.ts";
12
5
  export type * from "./logRocketTypes.ts";
13
6
  export { NoopLogRocketInstrumentationClient } from "./NoopLogRocketInstrumentationClient.ts";
14
7
  export { registerLogRocketInstrumentation, type RegisterLogRocketInstrumentationOptions } from "./registerLogRocketInstrumentation.ts";
15
-
@@ -9,25 +9,9 @@ import { createUrlSanitizer } from "./createUrlSanitizer.ts";
9
9
  import { DeviceIdTrait, type LogRocketInstrumentationClient, LogRocketInstrumentationClientImpl, TelemetryIdTrait } from "./LogRocketInstrumentationClient.ts";
10
10
  import type { LogRocketSdkOptions } from "./logRocketTypes.ts";
11
11
 
12
- const DefaultPrivateFieldNames = [
13
- "email",
14
- "personalEmail",
15
- "phoneNumber",
16
- "password",
17
- "firstName",
18
- "lastName",
19
- "givenName",
20
- "fullName",
21
- "gender",
22
- "timeZone",
23
- "birthday"
24
- ];
25
-
26
- const DefaultPrivateQueryParameterNames = [
27
- "token",
28
- "email",
29
- "password"
30
- ];
12
+ const DefaultPrivateFieldNames = ["email", "personalEmail", "phoneNumber", "password", "firstName", "lastName", "givenName", "fullName", "gender", "timeZone", "birthday"];
13
+
14
+ const DefaultPrivateQueryParameterNames = ["token", "email", "password"];
31
15
 
32
16
  ///////////////////////////
33
17
 
@@ -74,13 +58,7 @@ export interface RegisterLogRocketInstrumentationOptions {
74
58
 
75
59
  // The function return type is mandatory, otherwise we got an error TS4058.
76
60
  export function getLogRocketSdkOptions(userOptions: RegisterLogRocketInstrumentationOptions, logger: RootLogger): LogRocketSdkOptions {
77
- const {
78
- rootHostname = "workleap.com",
79
- privateFieldNames = [],
80
- privateQueryParameterNames = [],
81
- verbose = false,
82
- transformers = []
83
- } = userOptions;
61
+ const { rootHostname = "workleap.com", privateFieldNames = [], privateQueryParameterNames = [], verbose = false, transformers = [] } = userOptions;
84
62
 
85
63
  const mergedPrivateFieldNames = DefaultPrivateFieldNames.concat(privateFieldNames);
86
64
  const mergedPrivateQueryParameterNames = DefaultPrivateQueryParameterNames.concat(privateQueryParameterNames);
@@ -88,7 +66,6 @@ export function getLogRocketSdkOptions(userOptions: RegisterLogRocketInstrumenta
88
66
  // The "LogrocketFuzzySearch.setup" code is awkward. For now, we prefer to play it safe and call it once here, then forward the sanitize functions
89
67
  // to the appropriate factories.
90
68
  // No clue why the "setup" method is not available. This package is shady.
91
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
92
69
  // @ts-ignore
93
70
  const { requestSanitizer: fuzzyRequestSanitizer, responseSanitizer: fuzzyResponseSanitizer } = LogrocketFuzzySanitizer.setup(mergedPrivateFieldNames);
94
71
 
@@ -143,15 +120,8 @@ export function __resetRegistrationGuard() {
143
120
  ///////////////////////////
144
121
 
145
122
  export class LogRocketInstrumentationRegistrator {
146
- register(
147
- appId: string,
148
- options: RegisterLogRocketInstrumentationOptions = {}
149
- ) {
150
- const {
151
- telemetryContext,
152
- verbose = false,
153
- loggers = []
154
- } = options;
123
+ register(appId: string, options: RegisterLogRocketInstrumentationOptions = {}) {
124
+ const { telemetryContext, verbose = false, loggers = [] } = options;
155
125
 
156
126
  const logger = createCompositeLogger(verbose, loggers);
157
127
  const sdkOptions = getLogRocketSdkOptions(options, logger);
@@ -170,10 +140,7 @@ export class LogRocketInstrumentationRegistrator {
170
140
  }
171
141
 
172
142
  LogRocket.getSessionURL(url => {
173
- logger
174
- .withText("[logrocket] Session replay URL is now available:")
175
- .withText(url)
176
- .debug();
143
+ logger.withText("[logrocket] Session replay URL is now available:").withText(url).debug();
177
144
  });
178
145
 
179
146
  logger.information("[logrocket] LogRocket instrumentation is registered.");
@@ -192,11 +159,8 @@ export class LogRocketInstrumentationRegistrator {
192
159
  * @returns {LogRocketInstrumentationClient} A LogRocket instrumentation client instance.
193
160
  * @see {@link https://workleap.github.io/wl-telemetry}
194
161
  */
195
- export function registerLogRocketInstrumentation(
196
- appId: string,
197
- options?: RegisterLogRocketInstrumentationOptions
198
- ) {
199
- getRegistrationGuard().throw("[logrocket] The LogRocket instrumentation has already been registered. Did you call the \"registerLogRocketInstrumentation\" function twice?");
162
+ export function registerLogRocketInstrumentation(appId: string, options?: RegisterLogRocketInstrumentationOptions) {
163
+ getRegistrationGuard().throw('[logrocket] The LogRocket instrumentation has already been registered. Did you call the "registerLogRocketInstrumentation" function twice?');
200
164
 
201
165
  return new LogRocketInstrumentationRegistrator().register(appId, options);
202
166
  }
@@ -0,0 +1,26 @@
1
+ import type { LogRocketRequest } from "./logRocketTypes.ts";
2
+
3
+ // A header is redacted when its lowercased name contains one of the following values.
4
+ const PrivateHeaderNames = ["auth", "cookie", "token", "session", "secret", "key", "csrf", "xsrf", "x-honeycomb-team"];
5
+
6
+ // When the headers of a fetch request are provided as an array of tuples, LogRocket indexes the headers by their position
7
+ // and the header name ends up in the value, e.g. { "0": "Authorization,Bearer 123" }.
8
+ const IndexedHeaderNameRegEx = /^\d+$/;
9
+
10
+ function isPrivateHeader(name: string) {
11
+ const lowercasedName = name.toLowerCase();
12
+
13
+ return IndexedHeaderNameRegEx.test(name) || PrivateHeaderNames.some(x => lowercasedName.includes(x));
14
+ }
15
+
16
+ export function sanitizeHeaders(headers: unknown) {
17
+ const sanitizedHeaders: LogRocketRequest["headers"] = {};
18
+
19
+ if (headers !== null && typeof headers === "object") {
20
+ for (const [name, value] of Object.entries(headers)) {
21
+ sanitizedHeaders[name] = isPrivateHeader(name) ? "**redacted**" : value;
22
+ }
23
+ }
24
+
25
+ return sanitizedHeaders;
26
+ }
@@ -14,16 +14,9 @@ export interface LogRocketInstrumentationProviderProps extends PropsWithChildren
14
14
  * @see {@link https://workleap.github.io/wl-telemetry}
15
15
  */
16
16
  export function LogRocketInstrumentationProvider(props: LogRocketInstrumentationProviderProps) {
17
- const {
18
- client,
19
- children
20
- } = props;
21
-
22
- return (
23
- <LogRocketInstrumentationContext.Provider value={client}>
24
- {children}
25
- </LogRocketInstrumentationContext.Provider>
26
- );
17
+ const { client, children } = props;
18
+
19
+ return <LogRocketInstrumentationContext.Provider value={client}>{children}</LogRocketInstrumentationContext.Provider>;
27
20
  }
28
21
 
29
22
  export interface UseLogRocketInstrumentationClientOptions {
@@ -41,9 +34,7 @@ export function useLogRocketInstrumentationClient(options: { throwOnUndefined: f
41
34
  * @see {@link https://workleap.github.io/wl-telemetry}
42
35
  */
43
36
  export function useLogRocketInstrumentationClient(options: UseLogRocketInstrumentationClientOptions = {}) {
44
- const {
45
- throwOnUndefined = true
46
- } = options;
37
+ const { throwOnUndefined = true } = options;
47
38
 
48
39
  const client = useContext(LogRocketInstrumentationContext);
49
40
 
@@ -1,3 +1,2 @@
1
1
  export * from "../js/index.ts";
2
2
  export { LogRocketInstrumentationProvider, useLogRocketInstrumentationClient, type UseLogRocketInstrumentationClientOptions } from "./LogRocketInstrumentationContext.tsx";
3
-