@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.
Files changed (39) hide show
  1. package/README.md +8 -2
  2. package/lib/index.d.ts +12 -12
  3. package/lib/index.js +69 -69
  4. package/lib/logger/consoleTransport.d.ts +36 -36
  5. package/lib/logger/consoleTransport.js +80 -80
  6. package/lib/logger/datadogTransport.d.ts +7 -7
  7. package/lib/logger/datadogTransport.js +20 -20
  8. package/lib/logger/index.d.ts +15 -15
  9. package/lib/logger/index.js +147 -147
  10. package/lib/logger/index.test.d.ts +1 -1
  11. package/lib/logger/index.test.js +59 -59
  12. package/lib/logger/utils.d.ts +14 -14
  13. package/lib/logger/utils.js +31 -31
  14. package/lib/reporters/amplifyReporter.d.ts +85 -83
  15. package/lib/reporters/amplifyReporter.d.ts.map +1 -1
  16. package/lib/reporters/amplifyReporter.js +175 -162
  17. package/lib/reporters/amplifyReporter.js.map +1 -1
  18. package/lib/reporters/amplifyReporter.test.d.ts +1 -1
  19. package/lib/reporters/amplifyReporter.test.js +50 -50
  20. package/lib/reporters/datadogReporter.d.ts +85 -85
  21. package/lib/reporters/datadogReporter.js +124 -124
  22. package/lib/reporters/gtmReporter.d.ts +8 -8
  23. package/lib/reporters/gtmReporter.js +56 -56
  24. package/lib/reporters/index.d.ts +66 -66
  25. package/lib/reporters/index.js +212 -212
  26. package/lib/reporters/logReporter.d.ts +34 -34
  27. package/lib/reporters/logReporter.js +61 -61
  28. package/lib/types/index.d.ts +2 -2
  29. package/lib/types/index.js +18 -18
  30. package/lib/types/logger.d.ts +77 -77
  31. package/lib/types/logger.js +10 -10
  32. package/lib/types/reporter.d.ts +154 -154
  33. package/lib/types/reporter.js +2 -2
  34. package/lib/utils.d.ts +9 -9
  35. package/lib/utils.js +31 -31
  36. package/lib/utils.test.d.ts +1 -1
  37. package/lib/utils.test.js +31 -31
  38. package/package.json +1 -1
  39. 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crimson-education/browser-logger",
3
- "version": "3.0.2",
3
+ "version": "3.0.3-pinpoint-proxy.0",
4
4
  "description": "An abstract logger and reporting utility for browser environments",
5
5
  "scripts": {
6
6
  "prepack": "npm run build",
@@ -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({