@crimson-education/browser-logger 3.0.1 → 3.0.3-pinpoint-proxy.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/lib/reporters/amplifyReporter.d.ts +2 -0
- package/lib/reporters/amplifyReporter.d.ts.map +1 -1
- package/lib/reporters/amplifyReporter.js +14 -1
- package/lib/reporters/amplifyReporter.js.map +1 -1
- package/lib/reporters/datadogReporter.d.ts +10 -1
- package/lib/reporters/datadogReporter.d.ts.map +1 -1
- package/lib/reporters/datadogReporter.js +2 -0
- package/lib/reporters/datadogReporter.js.map +1 -1
- package/package.json +1 -1
- package/src/reporters/amplifyReporter.ts +19 -0
- package/src/reporters/datadogReporter.ts +12 -2
package/README.md
CHANGED
|
@@ -157,7 +157,7 @@ These will only send to the log reporter, it is recommended to use `toReporters`
|
|
|
157
157
|
|
|
158
158
|
#### Filtering out metadata
|
|
159
159
|
|
|
160
|
-
You can filter what metadata gets sent to each reporter in the reporter config.
|
|
160
|
+
You can filter what metadata gets sent to each reporter in the reporter config.
|
|
161
161
|
This accepts a string for exact match metadata keys, or a RegExp.
|
|
162
162
|
You can use `.` to traverse metadata.
|
|
163
163
|
|
|
@@ -199,6 +199,12 @@ Logger.addBreadcrumb({
|
|
|
199
199
|
|
|
200
200
|
### Configure Reporters
|
|
201
201
|
|
|
202
|
+
### Proxies
|
|
203
|
+
|
|
204
|
+
Some reporters support taking a `proxyUrl` parameter in their config. When provided, the reporter will send events to the `proxyUrl` instead of the default destination. This can be useful to get around ad blockers users might have installed. Typically, `proxyUrl` should point to our internal proxy service--a shared service that forwards requests it receives to a third-party system.
|
|
205
|
+
|
|
206
|
+
Our internal proxy service is defined in our [crimson-infrastructure](https://github.com/crimson-education/crimson-infrastructure) repository.
|
|
207
|
+
|
|
202
208
|
#### Log
|
|
203
209
|
|
|
204
210
|
By default, the log reporter is enabled. This adds all reporter functions to logs. Set `reporters.log` to `false` to disable reporter logging.
|
|
@@ -262,7 +268,7 @@ This automatically adds a Datadog Log Transport that transmits Log data to Datad
|
|
|
262
268
|
To configure Amplify, this requires at least `region`, `identityPoolId` and `analyticsAppId`.
|
|
263
269
|
|
|
264
270
|
> **Note**: If you are setting up Browser Logger in a project that uses AWS Cognito or other AWS Amplify Features, you will want to set `identityPoolId` to false. This disables the reporter's call to Auth.configure, as you will have used that to configure your App already.
|
|
265
|
-
>
|
|
271
|
+
>
|
|
266
272
|
> You will need to set identityPoolId in your Auth.configure function yourself, otherwise Pinpoint won't work.
|
|
267
273
|
|
|
268
274
|
Auto `Auth.configure`:
|
|
@@ -15,6 +15,8 @@ export interface AmplifyReporterConfig extends ReporterConfigBase {
|
|
|
15
15
|
* The Pinpoint App Id to report to.
|
|
16
16
|
*/
|
|
17
17
|
analyticsAppId: string;
|
|
18
|
+
/** Optional proxy URL */
|
|
19
|
+
proxyUrl?: string;
|
|
18
20
|
/**
|
|
19
21
|
* The Cognito User Pool to configure in Auth.configure.
|
|
20
22
|
* If you are using Cognito, it is better to set identityPoolId to false and configure Auth manually.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplifyReporter.d.ts","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EAER,kBAAkB,EAGlB,WAAW,EACZ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"amplifyReporter.d.ts","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EAER,kBAAkB,EAGlB,WAAW,EACZ,MAAM,UAAU,CAAC;AAQlB,aAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;AAE7D,aAAK,sBAAsB,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAE/D,MAAM,WAAW,qBAA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C3B,SAAS,GAAE,MAAM,GAAG,SAAqB,EACzC,WAAW,UAAO,GACjB,YAAY,CAsBd"}
|
|
@@ -5,7 +5,7 @@ const auth_1 = require("@aws-amplify/auth");
|
|
|
5
5
|
const analytics_1 = require("@aws-amplify/analytics");
|
|
6
6
|
const logger_1 = require("../logger");
|
|
7
7
|
function amplifyReporter(info, config) {
|
|
8
|
-
var _a;
|
|
8
|
+
var _a, _b;
|
|
9
9
|
if (config.identityPoolId !== false) {
|
|
10
10
|
auth_1.Auth.configure({
|
|
11
11
|
region: config.region,
|
|
@@ -56,6 +56,19 @@ function amplifyReporter(info, config) {
|
|
|
56
56
|
attributes: wrapAutoTrackMiddleware('event'),
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
+
if (config.proxyUrl) {
|
|
60
|
+
// No public API for overriding where the Pinpoint client sends events to... 🤮
|
|
61
|
+
const provider = (_b = analytics_1.Analytics.getPluggable('AWSPinpoint')) === null || _b === void 0 ? void 0 : _b.pinpointClient;
|
|
62
|
+
if (provider) {
|
|
63
|
+
const proxyUrl = new URL(config.proxyUrl);
|
|
64
|
+
provider.config.endpoint = () => Promise.resolve({
|
|
65
|
+
hostname: proxyUrl.hostname,
|
|
66
|
+
path: proxyUrl.pathname,
|
|
67
|
+
port: undefined,
|
|
68
|
+
protocol: proxyUrl.protocol,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
59
72
|
const reporter = {
|
|
60
73
|
trackEvent: function (event) {
|
|
61
74
|
analytics_1.Analytics.record({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplifyReporter.js","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":";;;AASA,4CAAyC;AACzC,sDAAmD;
|
|
1
|
+
{"version":3,"file":"amplifyReporter.js","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":";;;AASA,4CAAyC;AACzC,sDAAmD;AAGnD,sCAAmC;AAkFnC,S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CAAC,CAAC;IAEH,OAAO,sBAAsB,CAAC;AAChC,CAAC;AA1BD,8CA0BC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IReporter, ServiceInfo, ReporterConfigBase } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { LogsInitConfiguration } from '@datadog/browser-logs';
|
|
3
|
+
import { DefaultPrivacyLevel, RumInitConfiguration } from '@datadog/browser-rum';
|
|
3
4
|
import { DatadogLogTransportConfig } from '../logger/datadogTransport';
|
|
4
5
|
export interface DatadogReporterConfig extends ReporterConfigBase {
|
|
5
6
|
/** The RUM application ID. */
|
|
@@ -57,11 +58,19 @@ export interface DatadogReporterConfig extends ReporterConfigBase {
|
|
|
57
58
|
* Defaults to `data-analytics-name` to coincide with analytics attributes used across reporters.
|
|
58
59
|
*/
|
|
59
60
|
actionNameAttribute?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Allows you to modify RUM events before they are sent to Datadog.
|
|
63
|
+
*/
|
|
64
|
+
beforeSend?: RumInitConfiguration['beforeSend'];
|
|
60
65
|
/**
|
|
61
66
|
* Toggles/configures the Datadog Log Transport.
|
|
62
67
|
* Defaults to true.
|
|
63
68
|
*/
|
|
64
69
|
logTransport?: boolean | DatadogLogTransportConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Allows you to modify Log events before they are sent to Datadog (Can only be set at ).
|
|
72
|
+
*/
|
|
73
|
+
beforeLogsSend?: LogsInitConfiguration['beforeSend'];
|
|
65
74
|
/**
|
|
66
75
|
* By enabling Session Replay, you can automatically mask sensitive elements from being recorded through the RUM Browser SDK.
|
|
67
76
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datadogReporter.d.ts","sourceRoot":"","sources":["../../src/reporters/datadogReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMT,WAAW,EACX,kBAAkB,EACnB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"datadogReporter.d.ts","sourceRoot":"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EG;IACH,cAAc,CAAC,EAAE,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAErD;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C;;OAEG;IACH,qBAAqB,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAC7C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,qBAAqB,GAAG,SAAS,CA4H3F"}
|
|
@@ -22,6 +22,7 @@ function datadogReporter(info, config) {
|
|
|
22
22
|
env: info.environment,
|
|
23
23
|
version: (_b = config.version) !== null && _b !== void 0 ? _b : info.version,
|
|
24
24
|
sampleRate: (_c = config.sampleRate) !== null && _c !== void 0 ? _c : 100,
|
|
25
|
+
beforeSend: config.beforeLogsSend,
|
|
25
26
|
useSecureSessionCookie: (_d = config.useSecureSessionCookie) !== null && _d !== void 0 ? _d : !isLocalhost,
|
|
26
27
|
useCrossSiteSessionCookie: (_e = config.useCrossSiteSessionCookie) !== null && _e !== void 0 ? _e : false,
|
|
27
28
|
trackSessionAcrossSubdomains: config.trackSessionAcrossSubdomains,
|
|
@@ -50,6 +51,7 @@ function datadogReporter(info, config) {
|
|
|
50
51
|
trackFrustrations: (_m = config.trackFrustrations) !== null && _m !== void 0 ? _m : false,
|
|
51
52
|
trackViewsManually: (_o = config.trackViewsManually) !== null && _o !== void 0 ? _o : false,
|
|
52
53
|
actionNameAttribute: (_p = config.actionNameAttribute) !== null && _p !== void 0 ? _p : 'data-analytics-name',
|
|
54
|
+
beforeSend: config.beforeSend,
|
|
53
55
|
defaultPrivacyLevel: (_q = config.defaultPrivacyLevel) !== null && _q !== void 0 ? _q : 'mask-user-input',
|
|
54
56
|
allowedTracingOrigins: config.allowedTracingOrigins,
|
|
55
57
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datadogReporter.js","sourceRoot":"","sources":["../../src/reporters/datadogReporter.ts"],"names":[],"mappings":";;;A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;YACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACtC,CAAC;QACD,WAAW,EAAE,UAAU,QAAgB;YACrC,IAAI,MAAM,CAAC,kBAAkB,EAAE;gBAC7B,wBAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;aAChC;iBAAM;gBACL,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;aACpC;QACH,CAAC;QACD,WAAW,EAAE,UAAU,KAAkB,EAAE,QAAmB;YAC5D,wBAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACvC,CAAC;QACD,aAAa,EAAE;YACb,wBAAU,CAAC,2BAA2B,EAAE,CAAC;QAC3C,CAAC;QACD,iBAAiB,EAAE;YACjB,wBAAU,CAAC,0BAA0B,EAAE,CAAC;QAC1C,CAAC;KACF,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC;AA5HD,0CA4HC"}
|
package/package.json
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
} from '../types';
|
|
10
10
|
import { Auth } from '@aws-amplify/auth';
|
|
11
11
|
import { Analytics } from '@aws-amplify/analytics';
|
|
12
|
+
import { PinpointClient } from '@aws-sdk/client-pinpoint';
|
|
13
|
+
import { Endpoint } from '@aws-sdk/types';
|
|
12
14
|
import { logger } from '../logger';
|
|
13
15
|
|
|
14
16
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
@@ -30,6 +32,8 @@ export interface AmplifyReporterConfig extends ReporterConfigBase {
|
|
|
30
32
|
* The Pinpoint App Id to report to.
|
|
31
33
|
*/
|
|
32
34
|
analyticsAppId: string;
|
|
35
|
+
/** Optional proxy URL */
|
|
36
|
+
proxyUrl?: string;
|
|
33
37
|
/**
|
|
34
38
|
* The Cognito User Pool to configure in Auth.configure.
|
|
35
39
|
* If you are using Cognito, it is better to set identityPoolId to false and configure Auth manually.
|
|
@@ -147,6 +151,21 @@ export function amplifyReporter(info: ServiceInfo, config: AmplifyReporterConfig
|
|
|
147
151
|
});
|
|
148
152
|
}
|
|
149
153
|
|
|
154
|
+
if (config.proxyUrl) {
|
|
155
|
+
// No public API for overriding where the Pinpoint client sends events to... 🤮
|
|
156
|
+
const provider = (Analytics.getPluggable('AWSPinpoint') as any)?.pinpointClient as PinpointClient | undefined;
|
|
157
|
+
if (provider) {
|
|
158
|
+
const proxyUrl = new URL(config.proxyUrl);
|
|
159
|
+
provider.config.endpoint = (): Promise<Endpoint> =>
|
|
160
|
+
Promise.resolve({
|
|
161
|
+
hostname: proxyUrl.hostname,
|
|
162
|
+
path: proxyUrl.pathname,
|
|
163
|
+
port: undefined,
|
|
164
|
+
protocol: proxyUrl.protocol,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
150
169
|
const reporter: IReporter = {
|
|
151
170
|
trackEvent: function (event: ReporterEvent): void {
|
|
152
171
|
Analytics.record({
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
ServiceInfo,
|
|
9
9
|
ReporterConfigBase,
|
|
10
10
|
} from '../types';
|
|
11
|
-
import { datadogLogs, HandlerType } from '@datadog/browser-logs';
|
|
12
|
-
import { datadogRum, DefaultPrivacyLevel } from '@datadog/browser-rum';
|
|
11
|
+
import { datadogLogs, HandlerType, LogsInitConfiguration } from '@datadog/browser-logs';
|
|
12
|
+
import { datadogRum, DefaultPrivacyLevel, RumInitConfiguration } from '@datadog/browser-rum';
|
|
13
13
|
import { logTransports } from '../logger';
|
|
14
14
|
import { DatadogLogTransportConfig, datadogTransport } from '../logger/datadogTransport';
|
|
15
15
|
|
|
@@ -72,12 +72,20 @@ export interface DatadogReporterConfig extends ReporterConfigBase {
|
|
|
72
72
|
* Defaults to `data-analytics-name` to coincide with analytics attributes used across reporters.
|
|
73
73
|
*/
|
|
74
74
|
actionNameAttribute?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Allows you to modify RUM events before they are sent to Datadog.
|
|
77
|
+
*/
|
|
78
|
+
beforeSend?: RumInitConfiguration['beforeSend'];
|
|
75
79
|
|
|
76
80
|
/**
|
|
77
81
|
* Toggles/configures the Datadog Log Transport.
|
|
78
82
|
* Defaults to true.
|
|
79
83
|
*/
|
|
80
84
|
logTransport?: boolean | DatadogLogTransportConfig;
|
|
85
|
+
/**
|
|
86
|
+
* Allows you to modify Log events before they are sent to Datadog (Can only be set at ).
|
|
87
|
+
*/
|
|
88
|
+
beforeLogsSend?: LogsInitConfiguration['beforeSend'];
|
|
81
89
|
|
|
82
90
|
/**
|
|
83
91
|
* By enabling Session Replay, you can automatically mask sensitive elements from being recorded through the RUM Browser SDK.
|
|
@@ -110,6 +118,7 @@ export function datadogReporter(info: ServiceInfo, config: DatadogReporterConfig
|
|
|
110
118
|
version: config.version ?? info.version,
|
|
111
119
|
|
|
112
120
|
sampleRate: config.sampleRate ?? 100,
|
|
121
|
+
beforeSend: config.beforeLogsSend,
|
|
113
122
|
|
|
114
123
|
useSecureSessionCookie: config.useSecureSessionCookie ?? !isLocalhost,
|
|
115
124
|
useCrossSiteSessionCookie: config.useCrossSiteSessionCookie ?? false,
|
|
@@ -145,6 +154,7 @@ export function datadogReporter(info: ServiceInfo, config: DatadogReporterConfig
|
|
|
145
154
|
trackFrustrations: config.trackFrustrations ?? false,
|
|
146
155
|
trackViewsManually: config.trackViewsManually ?? false,
|
|
147
156
|
actionNameAttribute: config.actionNameAttribute ?? 'data-analytics-name',
|
|
157
|
+
beforeSend: config.beforeSend,
|
|
148
158
|
|
|
149
159
|
defaultPrivacyLevel: config.defaultPrivacyLevel ?? 'mask-user-input',
|
|
150
160
|
allowedTracingOrigins: config.allowedTracingOrigins,
|