@crimson-education/browser-logger 3.0.2 → 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/index.d.ts +12 -12
- package/lib/index.js +69 -69
- package/lib/logger/consoleTransport.d.ts +36 -36
- package/lib/logger/consoleTransport.js +80 -80
- package/lib/logger/datadogTransport.d.ts +7 -7
- package/lib/logger/datadogTransport.js +20 -20
- package/lib/logger/index.d.ts +15 -15
- package/lib/logger/index.js +147 -147
- package/lib/logger/index.test.d.ts +1 -1
- package/lib/logger/index.test.js +59 -59
- package/lib/logger/utils.d.ts +14 -14
- package/lib/logger/utils.js +31 -31
- package/lib/reporters/amplifyReporter.d.ts +85 -83
- package/lib/reporters/amplifyReporter.d.ts.map +1 -1
- package/lib/reporters/amplifyReporter.js +175 -162
- package/lib/reporters/amplifyReporter.js.map +1 -1
- package/lib/reporters/amplifyReporter.test.d.ts +1 -1
- package/lib/reporters/amplifyReporter.test.js +50 -50
- package/lib/reporters/datadogReporter.d.ts +85 -85
- package/lib/reporters/datadogReporter.js +124 -124
- package/lib/reporters/gtmReporter.d.ts +8 -8
- package/lib/reporters/gtmReporter.js +56 -56
- package/lib/reporters/index.d.ts +66 -66
- package/lib/reporters/index.js +212 -212
- package/lib/reporters/logReporter.d.ts +34 -34
- package/lib/reporters/logReporter.js +61 -61
- package/lib/types/index.d.ts +2 -2
- package/lib/types/index.js +18 -18
- package/lib/types/logger.d.ts +77 -77
- package/lib/types/logger.js +10 -10
- package/lib/types/reporter.d.ts +154 -154
- package/lib/types/reporter.js +2 -2
- package/lib/utils.d.ts +9 -9
- package/lib/utils.js +31 -31
- package/lib/utils.test.d.ts +1 -1
- package/lib/utils.test.js +31 -31
- package/package.json +1 -1
- package/src/reporters/amplifyReporter.ts +19 -0
package/lib/utils.test.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("./utils");
|
|
4
|
-
describe('utils', () => {
|
|
5
|
-
describe('filterReporterMetadata', () => {
|
|
6
|
-
it('should remove attributes which match the ignore patterns', () => {
|
|
7
|
-
const inputAttributeMap = {
|
|
8
|
-
includeme: '5',
|
|
9
|
-
excludeme: 'false',
|
|
10
|
-
differentProp: 'boo',
|
|
11
|
-
deep: {
|
|
12
|
-
includeme: '5',
|
|
13
|
-
excludeme: 'false',
|
|
14
|
-
deepExcludeStr: 'boo',
|
|
15
|
-
deepExcludeRegex: 'boo',
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
const filtered = (0, utils_1.filterReporterMetadata)(inputAttributeMap, {
|
|
19
|
-
ignoreMetadataPatterns: [/excludeme/g, /Prop/g, 'deep.deepExcludeStr', /deep\.deepExcludeRegex/g],
|
|
20
|
-
});
|
|
21
|
-
expect(filtered.includeme).toBeTruthy();
|
|
22
|
-
expect(filtered.excludeme).toBeFalsy();
|
|
23
|
-
expect(filtered.differentProp).toBeFalsy();
|
|
24
|
-
// deep
|
|
25
|
-
expect(filtered.deep.includeme).toBeTruthy();
|
|
26
|
-
expect(filtered.deep.excludeme).toBeFalsy();
|
|
27
|
-
expect(filtered.deep.deepExcludeStr).toBeFalsy();
|
|
28
|
-
expect(filtered.deep.deepExcludeRegex).toBeFalsy();
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("./utils");
|
|
4
|
+
describe('utils', () => {
|
|
5
|
+
describe('filterReporterMetadata', () => {
|
|
6
|
+
it('should remove attributes which match the ignore patterns', () => {
|
|
7
|
+
const inputAttributeMap = {
|
|
8
|
+
includeme: '5',
|
|
9
|
+
excludeme: 'false',
|
|
10
|
+
differentProp: 'boo',
|
|
11
|
+
deep: {
|
|
12
|
+
includeme: '5',
|
|
13
|
+
excludeme: 'false',
|
|
14
|
+
deepExcludeStr: 'boo',
|
|
15
|
+
deepExcludeRegex: 'boo',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const filtered = (0, utils_1.filterReporterMetadata)(inputAttributeMap, {
|
|
19
|
+
ignoreMetadataPatterns: [/excludeme/g, /Prop/g, 'deep.deepExcludeStr', /deep\.deepExcludeRegex/g],
|
|
20
|
+
});
|
|
21
|
+
expect(filtered.includeme).toBeTruthy();
|
|
22
|
+
expect(filtered.excludeme).toBeFalsy();
|
|
23
|
+
expect(filtered.differentProp).toBeFalsy();
|
|
24
|
+
// deep
|
|
25
|
+
expect(filtered.deep.includeme).toBeTruthy();
|
|
26
|
+
expect(filtered.deep.excludeme).toBeFalsy();
|
|
27
|
+
expect(filtered.deep.deepExcludeStr).toBeFalsy();
|
|
28
|
+
expect(filtered.deep.deepExcludeRegex).toBeFalsy();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
32
|
//# sourceMappingURL=utils.test.js.map
|
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({
|