@workleap/logrocket 1.0.0 → 1.0.1
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,11 @@
|
|
|
1
1
|
# @workleap/logrocket
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#36](https://github.com/workleap/wl-telemetry/pull/36) [`85f432b`](https://github.com/workleap/wl-telemetry/commit/85f432bb1c45433d24a765da7249fef4abb949d4) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Minor fixes to the API.
|
|
8
|
+
|
|
3
9
|
## 1.0.0
|
|
4
10
|
|
|
5
11
|
### Major Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type LogRocketSdkOptionsTransformer } from "./applyTransformers.ts";
|
|
2
2
|
import type { LogRocketSdkOptions } from "./logRocketTypes.ts";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const IsRegisteredVariableName = "__WLP_LOGROCKET_INSTRUMENTATION_IS_REGISTERED__";
|
|
4
4
|
export declare const RegisterGetSessionUrlFunctionName = "__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__";
|
|
5
5
|
/**
|
|
6
6
|
* @see https://workleap.github.io/wl-telemetry
|
|
@@ -36,7 +36,7 @@ import { HasExecutedGuard } from "./HasExecutedGuard.js";
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
const
|
|
39
|
+
const IsRegisteredVariableName = "__WLP_LOGROCKET_INSTRUMENTATION_IS_REGISTERED__";
|
|
40
40
|
const RegisterGetSessionUrlFunctionName = "__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__";
|
|
41
41
|
const DefaultPrivateFieldNames = [
|
|
42
42
|
"email",
|
|
@@ -124,7 +124,7 @@ function __resetRegistrationGuard() {
|
|
|
124
124
|
// which is great for DX.
|
|
125
125
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
126
126
|
// @ts-ignore
|
|
127
|
-
globalThis[
|
|
127
|
+
globalThis[IsRegisteredVariableName] = true;
|
|
128
128
|
// While consumers could directly call LogRocket.getSessionURL, by doing it this way,
|
|
129
129
|
// it allow consumers to not take a direct dependency on the "logrocket" package.
|
|
130
130
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -141,6 +141,6 @@ function __resetRegistrationGuard() {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
export {
|
|
144
|
+
export { IsRegisteredVariableName, RegisterGetSessionUrlFunctionName, __resetRegistrationGuard, getLogRocketSdkOptions, registerLogRocketInstrumentation };
|
|
145
145
|
|
|
146
146
|
//# sourceMappingURL=registerLogRocketInstrumentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerLogRocketInstrumentation.js","sources":["webpack://@workleap/logrocket/./src/registerLogRocketInstrumentation.ts"],"sourcesContent":["import { getBootstrappingStore, getTelemetryContext } from \"@workleap/telemetry\";\nimport LogRocket from \"logrocket\";\nimport LogrocketFuzzySanitizer from \"logrocket-fuzzy-search-sanitizer\";\nimport { applyTransformers, type LogRocketSdkOptionsTransformer } from \"./applyTransformers.ts\";\nimport { DeviceIdTrait, TelemetryIdTrait } from \"./createDefaultUserTraits.ts\";\nimport { createRequestSanitizer } from \"./createRequestSanitizer.ts\";\nimport { createResponseSanitizer } from \"./createResponseSanitizer.ts\";\nimport { createUrlSanitizer } from \"./createUrlSanitizer.ts\";\nimport { HasExecutedGuard } from \"./HasExecutedGuard.ts\";\nimport type { LogRocketSdkOptions } from \"./logRocketTypes.ts\";\n\nexport const
|
|
1
|
+
{"version":3,"file":"registerLogRocketInstrumentation.js","sources":["webpack://@workleap/logrocket/./src/registerLogRocketInstrumentation.ts"],"sourcesContent":["import { getBootstrappingStore, getTelemetryContext } from \"@workleap/telemetry\";\nimport LogRocket from \"logrocket\";\nimport LogrocketFuzzySanitizer from \"logrocket-fuzzy-search-sanitizer\";\nimport { applyTransformers, type LogRocketSdkOptionsTransformer } from \"./applyTransformers.ts\";\nimport { DeviceIdTrait, TelemetryIdTrait } from \"./createDefaultUserTraits.ts\";\nimport { createRequestSanitizer } from \"./createRequestSanitizer.ts\";\nimport { createResponseSanitizer } from \"./createResponseSanitizer.ts\";\nimport { createUrlSanitizer } from \"./createUrlSanitizer.ts\";\nimport { HasExecutedGuard } from \"./HasExecutedGuard.ts\";\nimport type { LogRocketSdkOptions } from \"./logRocketTypes.ts\";\n\nexport const IsRegisteredVariableName = \"__WLP_LOGROCKET_INSTRUMENTATION_IS_REGISTERED__\";\nexport const RegisterGetSessionUrlFunctionName = \"__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__\";\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 * @see https://workleap.github.io/wl-telemetry\n */\nexport interface RegisterLogRocketInstrumentationOptions {\n // Set to capture traffic from all subdomains under one session: https://docs.logrocket.com/reference/roothostname.\n rootHostname?: LogRocketSdkOptions[\"rootHostname\"];\n privateFieldNames?: string[];\n privateQueryParameterNames?: string[];\n verbose?: boolean;\n transformers?: LogRocketSdkOptionsTransformer[];\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function getLogRocketSdkOptions(options: RegisterLogRocketInstrumentationOptions): LogRocketSdkOptions {\n const {\n rootHostname = \"workleap.com\",\n privateFieldNames = [],\n privateQueryParameterNames = [],\n verbose = false,\n transformers = []\n } = options;\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 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 });\n}\n\nconst registrationGuard = new HasExecutedGuard();\n\n// This function should only be used by tests.\nexport function __resetRegistrationGuard() {\n registrationGuard.reset();\n}\n\n/**\n * @see https://workleap.github.io/wl-telemetry\n */\nexport function registerLogRocketInstrumentation(appId: string, options: RegisterLogRocketInstrumentationOptions = {}) {\n const {\n verbose = false\n } = options;\n\n registrationGuard.throw(\"[logrocket] The LogRocket instrumentation has already been registered. Did you call the \\\"registerLogRocketInstrumentation\\\" function twice?\");\n\n const sdkOptions = getLogRocketSdkOptions(options);\n\n // Session starts anonymously when LogRocket.init() is called.\n LogRocket.init(appId, sdkOptions);\n\n const telemetryContext = getTelemetryContext({ verbose });\n\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 if (verbose) {\n LogRocket.getSessionURL(url => {\n console.log(\"[logrocket] Session replay URL is now available:\", url);\n });\n }\n\n // Indicates to the host applications that logrocket has been initialized.\n // It's useful in cases where an \"add-on\", like the platform widgets needs\n // to know whether or not the host application is using LogRocket.\n // While there are ways that the host application could tell to an \"add-on\" if\n // it's using LogRocket or not, doing it this way is transparent for the consumer,\n // which is great for DX.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[IsRegisteredVariableName] = true;\n\n // While consumers could directly call LogRocket.getSessionURL, by doing it this way,\n // it allow consumers to not take a direct dependency on the \"logrocket\" package.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[RegisterGetSessionUrlFunctionName] = listener => {\n LogRocket.getSessionURL(listener);\n };\n\n // Let the other telemetry libraries know that LogRocket instrumentation is ready.\n getBootstrappingStore().dispatch({ type: \"logrocket-ready\" });\n\n if (verbose) {\n console.log(\"[logrocket] LogRocket instrumentation is registered.\");\n }\n}\n"],"names":["getBootstrappingStore","getTelemetryContext","LogRocket","LogrocketFuzzySanitizer","applyTransformers","DeviceIdTrait","TelemetryIdTrait","createRequestSanitizer","createResponseSanitizer","createUrlSanitizer","HasExecutedGuard","IsRegisteredVariableName","RegisterGetSessionUrlFunctionName","DefaultPrivateFieldNames","DefaultPrivateQueryParameterNames","getLogRocketSdkOptions","options","rootHostname","privateFieldNames","privateQueryParameterNames","verbose","transformers","mergedPrivateFieldNames","mergedPrivateQueryParameterNames","fuzzyRequestSanitizer","fuzzyResponseSanitizer","sdkOptions","registrationGuard","__resetRegistrationGuard","registerLogRocketInstrumentation","appId","telemetryContext","url","console","globalThis","listener"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAiF;AAC/C;AACqC;AACyB;AACjB;AACV;AACE;AACV;AACJ;AAGlD,MAAMW,2BAA2B,kDAAkD;AACnF,MAAMC,oCAAoC,sEAAsE;AAEvH,MAAMC,2BAA2B;IAC7B;IACA;IACA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AC6B,iBAAiB,QAAQ,EAAE;QAC1C,CAAC1B,aAAaA,CAAC,EAAE0B,iBAAiB,QAAQ;QAC1C,CAACzB,gBAAgBA,CAAC,EAAEyB,iBAAiB,WAAW;IACpD;IAEA,IAAIX,SAAS;QACTlB,uBAAuB,CAAC8B,CAAAA;YACpBC,QAAQ,GAAG,CAAC,oDAAoDD;QACpE;IACJ;IAEA,0EAA0E;IAC1E,0EAA0E;IAC1E,kEAAkE;IAClE,8EAA8E;IAC9E,kFAAkF;IAClF,yBAAyB;IACzB,6DAA6D;IAC7D,aAAa;IACbE,UAAU,CAACvB,yBAAyB,GAAG;IAEvC,qFAAqF;IACrF,iFAAiF;IACjF,6DAA6D;IAC7D,aAAa;IACbuB,UAAU,CAACtB,kCAAkC,GAAGuB,CAAAA;QAC5CjC,uBAAuB,CAACiC;IAC5B;IAEA,kFAAkF;IAClFnC,qBAAqBA,GAAG,QAAQ,CAAC;QAAE,MAAM;IAAkB;IAE3D,IAAIoB,SAAS;QACTa,QAAQ,GAAG,CAAC;IAChB;AACJ"}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ import { createUrlSanitizer } from "./createUrlSanitizer.ts";
|
|
|
9
9
|
import { HasExecutedGuard } from "./HasExecutedGuard.ts";
|
|
10
10
|
import type { LogRocketSdkOptions } from "./logRocketTypes.ts";
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const IsRegisteredVariableName = "__WLP_LOGROCKET_INSTRUMENTATION_IS_REGISTERED__";
|
|
13
13
|
export const RegisterGetSessionUrlFunctionName = "__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__";
|
|
14
14
|
|
|
15
15
|
const DefaultPrivateFieldNames = [
|
|
@@ -133,7 +133,7 @@ export function registerLogRocketInstrumentation(appId: string, options: Registe
|
|
|
133
133
|
// which is great for DX.
|
|
134
134
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
135
135
|
// @ts-ignore
|
|
136
|
-
globalThis[
|
|
136
|
+
globalThis[IsRegisteredVariableName] = true;
|
|
137
137
|
|
|
138
138
|
// While consumers could directly call LogRocket.getSessionURL, by doing it this way,
|
|
139
139
|
// it allow consumers to not take a direct dependency on the "logrocket" package.
|