@crimson-education/browser-logger 5.0.0-beta.7 → 5.0.0-beta.8.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplifyReporter.d.ts","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":"AAKA,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":"AAKA,OAAO,EACL,SAAS,EACT,QAAQ,EAER,kBAAkB,EAGlB,WAAW,EACZ,MAAM,UAAU,CAAC;AAMlB,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;AAE7D,KAAK,sBAAsB,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAkI/D,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,cAAc,EAAE,MAAM,GAAG,KAAK,CAAC;IAC/B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,eAAe,CAAC,CAAC,MAAM,EAAE,sBAAsB,GAAG,QAAQ,GAAG,SAAS,CAAC;IAEvE;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,SAAS,CAAC,EAAE,8BAA8B,CAAC;CAC5C;AAED;;;;GAIG;AACH,KAAK,8BAA8B,GAAG;IACpC,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,qBAAqB,GAAG,SAAS,CAoF3F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,UAAO,GAAG,YAAY,CAqBhG;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,SAAS,GAAE,MAAM,GAAG,SAAqB,EACzC,WAAW,UAAO,GACjB,YAAY,CAsBd"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { identifyUser, record } from '@aws-amplify/analytics';
|
|
2
|
-
import { HttpRequest } from '@aws-sdk/protocol-http';
|
|
3
2
|
import { logger } from '../logger';
|
|
4
3
|
import { initAmplifyAnalytics } from './amplifyUtils';
|
|
4
|
+
import { fetchAuthSession } from '@aws-amplify/auth';
|
|
5
5
|
// Auto-tracking implementation for Gen2
|
|
6
6
|
class AmplifyAutoTracker {
|
|
7
7
|
config;
|
|
@@ -130,6 +130,10 @@ export function amplifyReporter(info, config) {
|
|
|
130
130
|
environment: info.environment,
|
|
131
131
|
version: info.version,
|
|
132
132
|
});
|
|
133
|
+
fetchAuthSession({ forceRefresh: true }).then((session) => {
|
|
134
|
+
console.log('Auth session fetched successfully');
|
|
135
|
+
console.log('Session:', session);
|
|
136
|
+
});
|
|
133
137
|
// Initialize auto-tracker for Gen2
|
|
134
138
|
const autoTracker = new AmplifyAutoTracker(config, allMetadata);
|
|
135
139
|
if (config.proxyUrl) {
|
|
@@ -234,53 +238,57 @@ export function buildAttributeMap(values, parentKey = undefined, groupValues = t
|
|
|
234
238
|
});
|
|
235
239
|
return valuesWithStringArrays;
|
|
236
240
|
}
|
|
237
|
-
function installPinpointProxy(proxyUrl) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
241
|
+
// function installPinpointProxy(proxyUrl: URL) {
|
|
242
|
+
// // No public API for overriding where the Pinpoint client sends events to... 🤮
|
|
243
|
+
// // In theory you can pass in an `endpoint` to the Pinpoint client's constructor like any other AWS
|
|
244
|
+
// // client, but Amplify's analytics doesn't expose anything we can use to get an endpoint threaded
|
|
245
|
+
// // down to the Pinpoint client's constructor.
|
|
246
|
+
// //
|
|
247
|
+
// // The Pinpoint client _also_ isn't available synchronously because it is instantiated when events
|
|
248
|
+
// // get sent out, and then reconfigured whenever the API credentials change. We need to hook `_initClients`
|
|
249
|
+
// // to ensure that the Pinpoint client being used is always patched with our custom endpoint.
|
|
250
|
+
// const provider = (globalThis as any).Analytics?.getPluggable?.('AWSPinpoint') as any;
|
|
251
|
+
// if (!provider || typeof provider._initClients !== 'function') {
|
|
252
|
+
// logger.error(
|
|
253
|
+
// 'Installation of the Pinpoint proxy failed. This likely means the internals of the @aws-amplify/analytics package have changed.',
|
|
254
|
+
// );
|
|
255
|
+
// return;
|
|
256
|
+
// }
|
|
257
|
+
// const originalInitClients = provider._initClients;
|
|
258
|
+
// const requestMiddleware: FinalizeRequestMiddleware<ServiceInputTypes, ServiceOutputTypes> =
|
|
259
|
+
// (next) => async (args) => {
|
|
260
|
+
// const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
|
|
261
|
+
// if (pinpointClient && proxyUrl.pathname !== '/' && HttpRequest.isInstance(args.request)) {
|
|
262
|
+
// // Add proxyUrl.pathname to final request url if it was provided
|
|
263
|
+
// const shouldStripSlash = proxyUrl.pathname.endsWith('/');
|
|
264
|
+
// args.request.path = `${proxyUrl.pathname}${args.request.path.slice(shouldStripSlash ? 1 : 0)}`;
|
|
265
|
+
// // Wrap request body so the proxy has signing info
|
|
266
|
+
// if (typeof args.request.body === 'string') {
|
|
267
|
+
// const credentials = await pinpointClient.config.credentials();
|
|
268
|
+
// args.request.body = JSON.stringify({
|
|
269
|
+
// credentials,
|
|
270
|
+
// data: JSON.parse(args.request.body),
|
|
271
|
+
// });
|
|
272
|
+
// }
|
|
273
|
+
// }
|
|
274
|
+
// return next(args);
|
|
275
|
+
// };
|
|
276
|
+
// provider._initClients = async (credentials: unknown) => {
|
|
277
|
+
// const result = await originalInitClients.call(provider, credentials);
|
|
278
|
+
// const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
|
|
279
|
+
// if (pinpointClient) {
|
|
280
|
+
// pinpointClient.config.endpoint = (): Promise<Endpoint> =>
|
|
281
|
+
// Promise.resolve({
|
|
282
|
+
// hostname: proxyUrl.hostname,
|
|
283
|
+
// // Passing proxyUrl.pathname here doesn't work; it gets overridden
|
|
284
|
+
// path: '/',
|
|
285
|
+
// port: undefined,
|
|
286
|
+
// protocol: proxyUrl.protocol,
|
|
287
|
+
// });
|
|
288
|
+
// pinpointClient.middlewareStack.remove(requestMiddleware);
|
|
289
|
+
// pinpointClient.middlewareStack.add(requestMiddleware, { step: 'finalizeRequest' });
|
|
290
|
+
// }
|
|
291
|
+
// return result;
|
|
292
|
+
// };
|
|
293
|
+
// }
|
|
286
294
|
//# sourceMappingURL=amplifyReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplifyReporter.js","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"amplifyReporter.js","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAc9D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOrD,wCAAwC;AACxC,MAAM,kBAAkB;IACd,MAAM,CAAwB;IAC9B,WAAW,CAAe;IAC1B,WAAW,GAAsB,IAAI,CAAC;IACtC,gBAAgB,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;IACtC,aAAa,GAAW,CAAC,CAAC;IAC1B,WAAW,GAAW,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC3C,aAAa,GAAY,CAAC,QAAQ,CAAC,MAAM,CAAC;IAElD,YAAY,MAA6B,EAAE,WAAyB;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAA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N,uDAAuD;AACvD,gGAAgG;AAChG,kCAAkC;AAClC,sFAAsF;AAEtF,mGAAmG;AACnG,2EAA2E;AAC3E,oEAAoE;AACpE,0GAA0G;AAE1G,6DAA6D;AAC7D,uDAAuD;AACvD,2EAA2E;AAC3E,iDAAiD;AACjD,2BAA2B;AAC3B,mDAAmD;AACnD,gBAAgB;AAChB,YAAY;AACZ,UAAU;AAEV,2BAA2B;AAC3B,SAAS;AAET,8DAA8D;AAC9D,4EAA4E;AAC5E,oFAAoF;AAEpF,4BAA4B;AAC5B,kEAAkE;AAClE,4BAA4B;AAC5B,yCAAyC;AACzC,+EAA+E;AAC/E,uBAAuB;AACvB,6BAA6B;AAC7B,yCAAyC;AACzC,cAAc;AAEd,kEAAkE;AAClE,4FAA4F;AAC5F,QAAQ;AACR,qBAAqB;AACrB,OAAO;AACP,IAAI"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crimson-education/browser-logger",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.8.1",
|
|
4
4
|
"description": "An abstract logger and reporting utility for browser environments",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepack": "npm run build",
|
|
@@ -45,12 +45,6 @@
|
|
|
45
45
|
"ts-jest": "^29.1.2",
|
|
46
46
|
"typescript": "^5.4.3"
|
|
47
47
|
},
|
|
48
|
-
"peerDependencies": {
|
|
49
|
-
"@aws-amplify/analytics": ">=7.0.0",
|
|
50
|
-
"@aws-amplify/auth": ">=6.0.0",
|
|
51
|
-
"@aws-amplify/core": ">=6.0.0",
|
|
52
|
-
"@aws-sdk/client-pinpoint": ">=3.370.0"
|
|
53
|
-
},
|
|
54
48
|
"files": [
|
|
55
49
|
"lib",
|
|
56
50
|
"src"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { identifyUser, record } from '@aws-amplify/analytics';
|
|
2
|
-
import { Endpoint, FinalizeRequestMiddleware } from '@aws-sdk/types';
|
|
3
|
-
import { HttpRequest } from '@aws-sdk/protocol-http';
|
|
4
|
-
import { PinpointClient, ServiceInputTypes, ServiceOutputTypes } from '@aws-sdk/client-pinpoint';
|
|
2
|
+
// import { Endpoint, FinalizeRequestMiddleware } from '@aws-sdk/types';
|
|
3
|
+
// import { HttpRequest } from '@aws-sdk/protocol-http';
|
|
4
|
+
// import { PinpointClient, ServiceInputTypes, ServiceOutputTypes } from '@aws-sdk/client-pinpoint';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
IReporter,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from '../types';
|
|
15
15
|
import { logger } from '../logger';
|
|
16
16
|
import { initAmplifyAnalytics } from './amplifyUtils';
|
|
17
|
+
import { fetchAuthSession } from '@aws-amplify/auth';
|
|
17
18
|
|
|
18
19
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
19
20
|
type AttributeMap = Record<string, string[] | string | null>;
|
|
@@ -240,6 +241,10 @@ export function amplifyReporter(info: ServiceInfo, config: AmplifyReporterConfig
|
|
|
240
241
|
environment: info.environment,
|
|
241
242
|
version: info.version,
|
|
242
243
|
});
|
|
244
|
+
fetchAuthSession({ forceRefresh: true }).then((session) => {
|
|
245
|
+
console.log('Auth session fetched successfully');
|
|
246
|
+
console.log('Session:', session);
|
|
247
|
+
});
|
|
243
248
|
|
|
244
249
|
// Initialize auto-tracker for Gen2
|
|
245
250
|
const autoTracker = new AmplifyAutoTracker(config, allMetadata);
|
|
@@ -364,63 +369,63 @@ export function buildAttributeMap(
|
|
|
364
369
|
return valuesWithStringArrays;
|
|
365
370
|
}
|
|
366
371
|
|
|
367
|
-
function installPinpointProxy(proxyUrl: URL) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
372
|
+
// function installPinpointProxy(proxyUrl: URL) {
|
|
373
|
+
// // No public API for overriding where the Pinpoint client sends events to... 🤮
|
|
374
|
+
// // In theory you can pass in an `endpoint` to the Pinpoint client's constructor like any other AWS
|
|
375
|
+
// // client, but Amplify's analytics doesn't expose anything we can use to get an endpoint threaded
|
|
376
|
+
// // down to the Pinpoint client's constructor.
|
|
377
|
+
// //
|
|
378
|
+
// // The Pinpoint client _also_ isn't available synchronously because it is instantiated when events
|
|
379
|
+
// // get sent out, and then reconfigured whenever the API credentials change. We need to hook `_initClients`
|
|
380
|
+
// // to ensure that the Pinpoint client being used is always patched with our custom endpoint.
|
|
381
|
+
// const provider = (globalThis as any).Analytics?.getPluggable?.('AWSPinpoint') as any;
|
|
382
|
+
// if (!provider || typeof provider._initClients !== 'function') {
|
|
383
|
+
// logger.error(
|
|
384
|
+
// 'Installation of the Pinpoint proxy failed. This likely means the internals of the @aws-amplify/analytics package have changed.',
|
|
385
|
+
// );
|
|
386
|
+
// return;
|
|
387
|
+
// }
|
|
388
|
+
|
|
389
|
+
// const originalInitClients = provider._initClients;
|
|
390
|
+
// const requestMiddleware: FinalizeRequestMiddleware<ServiceInputTypes, ServiceOutputTypes> =
|
|
391
|
+
// (next) => async (args) => {
|
|
392
|
+
// const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
|
|
393
|
+
|
|
394
|
+
// if (pinpointClient && proxyUrl.pathname !== '/' && HttpRequest.isInstance(args.request)) {
|
|
395
|
+
// // Add proxyUrl.pathname to final request url if it was provided
|
|
396
|
+
// const shouldStripSlash = proxyUrl.pathname.endsWith('/');
|
|
397
|
+
// args.request.path = `${proxyUrl.pathname}${args.request.path.slice(shouldStripSlash ? 1 : 0)}`;
|
|
398
|
+
|
|
399
|
+
// // Wrap request body so the proxy has signing info
|
|
400
|
+
// if (typeof args.request.body === 'string') {
|
|
401
|
+
// const credentials = await pinpointClient.config.credentials();
|
|
402
|
+
// args.request.body = JSON.stringify({
|
|
403
|
+
// credentials,
|
|
404
|
+
// data: JSON.parse(args.request.body),
|
|
405
|
+
// });
|
|
406
|
+
// }
|
|
407
|
+
// }
|
|
408
|
+
|
|
409
|
+
// return next(args);
|
|
410
|
+
// };
|
|
411
|
+
|
|
412
|
+
// provider._initClients = async (credentials: unknown) => {
|
|
413
|
+
// const result = await originalInitClients.call(provider, credentials);
|
|
414
|
+
// const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
|
|
415
|
+
|
|
416
|
+
// if (pinpointClient) {
|
|
417
|
+
// pinpointClient.config.endpoint = (): Promise<Endpoint> =>
|
|
418
|
+
// Promise.resolve({
|
|
419
|
+
// hostname: proxyUrl.hostname,
|
|
420
|
+
// // Passing proxyUrl.pathname here doesn't work; it gets overridden
|
|
421
|
+
// path: '/',
|
|
422
|
+
// port: undefined,
|
|
423
|
+
// protocol: proxyUrl.protocol,
|
|
424
|
+
// });
|
|
425
|
+
|
|
426
|
+
// pinpointClient.middlewareStack.remove(requestMiddleware);
|
|
427
|
+
// pinpointClient.middlewareStack.add(requestMiddleware, { step: 'finalizeRequest' });
|
|
428
|
+
// }
|
|
429
|
+
// return result;
|
|
430
|
+
// };
|
|
431
|
+
// }
|