@crimson-education/browser-logger 5.0.0-beta.8.0 → 5.0.0-beta.9
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/lib/reporters/amplifyReporter.d.ts +1 -1
- package/lib/reporters/amplifyReporter.d.ts.map +1 -1
- package/lib/reporters/amplifyReporter.js +68 -63
- package/lib/reporters/amplifyReporter.js.map +1 -1
- package/package.json +1 -7
- package/src/reporters/amplifyReporter.ts +79 -76
- package/lib/reporters/amplifyUtils.d.ts +0 -15
- package/lib/reporters/amplifyUtils.d.ts.map +0 -1
- package/lib/reporters/amplifyUtils.js +0 -27
- package/lib/reporters/amplifyUtils.js.map +0 -1
- package/src/reporters/amplifyUtils.ts +0 -41
|
@@ -10,7 +10,7 @@ export interface AmplifyReporterConfig extends ReporterConfigBase {
|
|
|
10
10
|
* The Identity Pool Id to use for reporting, if set to false, Auth.configure is not called.
|
|
11
11
|
* This must be called manually for the reporter to work.
|
|
12
12
|
*/
|
|
13
|
-
identityPoolId: string
|
|
13
|
+
identityPoolId: string;
|
|
14
14
|
/**
|
|
15
15
|
* The Pinpoint App Id to report to.
|
|
16
16
|
*/
|
|
@@ -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;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,
|
|
1
|
+
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EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,qBAAqB,GAAG,SAAS,CAuF3F;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,8 +1,6 @@
|
|
|
1
1
|
import { identifyUser, record } from '@aws-amplify/analytics';
|
|
2
|
-
import { HttpRequest } from '@aws-sdk/protocol-http';
|
|
3
2
|
import { logger } from '../logger';
|
|
4
|
-
import {
|
|
5
|
-
import { fetchAuthSession } from '@aws-amplify/auth';
|
|
3
|
+
import { Amplify } from 'aws-amplify';
|
|
6
4
|
// Auto-tracking implementation for Gen2
|
|
7
5
|
class AmplifyAutoTracker {
|
|
8
6
|
config;
|
|
@@ -116,13 +114,20 @@ class AmplifyAutoTracker {
|
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
export function amplifyReporter(info, config) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
Amplify.configure({
|
|
118
|
+
Auth: {
|
|
119
|
+
Cognito: {
|
|
120
|
+
identityPoolId: config.identityPoolId,
|
|
121
|
+
allowGuestAccess: true,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
Analytics: {
|
|
125
|
+
Pinpoint: {
|
|
126
|
+
appId: config.analyticsAppId,
|
|
127
|
+
region: config.region,
|
|
128
|
+
...config.buffering,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
126
131
|
});
|
|
127
132
|
const allMetadata = asAttributeMap({
|
|
128
133
|
appName: info.service,
|
|
@@ -131,10 +136,6 @@ export function amplifyReporter(info, config) {
|
|
|
131
136
|
environment: info.environment,
|
|
132
137
|
version: info.version,
|
|
133
138
|
});
|
|
134
|
-
fetchAuthSession({ forceRefresh: true }).then((session) => {
|
|
135
|
-
console.log('Auth session fetched successfully');
|
|
136
|
-
console.log('Session:', session);
|
|
137
|
-
});
|
|
138
139
|
// Initialize auto-tracker for Gen2
|
|
139
140
|
const autoTracker = new AmplifyAutoTracker(config, allMetadata);
|
|
140
141
|
if (config.proxyUrl) {
|
|
@@ -239,53 +240,57 @@ export function buildAttributeMap(values, parentKey = undefined, groupValues = t
|
|
|
239
240
|
});
|
|
240
241
|
return valuesWithStringArrays;
|
|
241
242
|
}
|
|
242
|
-
function installPinpointProxy(proxyUrl) {
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
243
|
+
// function installPinpointProxy(proxyUrl: URL) {
|
|
244
|
+
// // No public API for overriding where the Pinpoint client sends events to... 🤮
|
|
245
|
+
// // In theory you can pass in an `endpoint` to the Pinpoint client's constructor like any other AWS
|
|
246
|
+
// // client, but Amplify's analytics doesn't expose anything we can use to get an endpoint threaded
|
|
247
|
+
// // down to the Pinpoint client's constructor.
|
|
248
|
+
// //
|
|
249
|
+
// // The Pinpoint client _also_ isn't available synchronously because it is instantiated when events
|
|
250
|
+
// // get sent out, and then reconfigured whenever the API credentials change. We need to hook `_initClients`
|
|
251
|
+
// // to ensure that the Pinpoint client being used is always patched with our custom endpoint.
|
|
252
|
+
// const provider = (globalThis as any).Analytics?.getPluggable?.('AWSPinpoint') as any;
|
|
253
|
+
// if (!provider || typeof provider._initClients !== 'function') {
|
|
254
|
+
// logger.error(
|
|
255
|
+
// 'Installation of the Pinpoint proxy failed. This likely means the internals of the @aws-amplify/analytics package have changed.',
|
|
256
|
+
// );
|
|
257
|
+
// return;
|
|
258
|
+
// }
|
|
259
|
+
// const originalInitClients = provider._initClients;
|
|
260
|
+
// const requestMiddleware: FinalizeRequestMiddleware<ServiceInputTypes, ServiceOutputTypes> =
|
|
261
|
+
// (next) => async (args) => {
|
|
262
|
+
// const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
|
|
263
|
+
// if (pinpointClient && proxyUrl.pathname !== '/' && HttpRequest.isInstance(args.request)) {
|
|
264
|
+
// // Add proxyUrl.pathname to final request url if it was provided
|
|
265
|
+
// const shouldStripSlash = proxyUrl.pathname.endsWith('/');
|
|
266
|
+
// args.request.path = `${proxyUrl.pathname}${args.request.path.slice(shouldStripSlash ? 1 : 0)}`;
|
|
267
|
+
// // Wrap request body so the proxy has signing info
|
|
268
|
+
// if (typeof args.request.body === 'string') {
|
|
269
|
+
// const credentials = await pinpointClient.config.credentials();
|
|
270
|
+
// args.request.body = JSON.stringify({
|
|
271
|
+
// credentials,
|
|
272
|
+
// data: JSON.parse(args.request.body),
|
|
273
|
+
// });
|
|
274
|
+
// }
|
|
275
|
+
// }
|
|
276
|
+
// return next(args);
|
|
277
|
+
// };
|
|
278
|
+
// provider._initClients = async (credentials: unknown) => {
|
|
279
|
+
// const result = await originalInitClients.call(provider, credentials);
|
|
280
|
+
// const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
|
|
281
|
+
// if (pinpointClient) {
|
|
282
|
+
// pinpointClient.config.endpoint = (): Promise<Endpoint> =>
|
|
283
|
+
// Promise.resolve({
|
|
284
|
+
// hostname: proxyUrl.hostname,
|
|
285
|
+
// // Passing proxyUrl.pathname here doesn't work; it gets overridden
|
|
286
|
+
// path: '/',
|
|
287
|
+
// port: undefined,
|
|
288
|
+
// protocol: proxyUrl.protocol,
|
|
289
|
+
// });
|
|
290
|
+
// pinpointClient.middlewareStack.remove(requestMiddleware);
|
|
291
|
+
// pinpointClient.middlewareStack.add(requestMiddleware, { step: 'finalizeRequest' });
|
|
292
|
+
// }
|
|
293
|
+
// return result;
|
|
294
|
+
// };
|
|
295
|
+
// }
|
|
291
296
|
//# 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;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAOtC,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,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AClC,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.9",
|
|
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,
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
ServiceInfo,
|
|
14
14
|
} from '../types';
|
|
15
15
|
import { logger } from '../logger';
|
|
16
|
-
import { initAmplifyAnalytics } from './amplifyUtils';
|
|
17
16
|
import { fetchAuthSession } from '@aws-amplify/auth';
|
|
17
|
+
import { Amplify } from 'aws-amplify';
|
|
18
18
|
|
|
19
19
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
20
20
|
type AttributeMap = Record<string, string[] | string | null>;
|
|
@@ -158,7 +158,7 @@ export interface AmplifyReporterConfig extends ReporterConfigBase {
|
|
|
158
158
|
* The Identity Pool Id to use for reporting, if set to false, Auth.configure is not called.
|
|
159
159
|
* This must be called manually for the reporter to work.
|
|
160
160
|
*/
|
|
161
|
-
identityPoolId: string
|
|
161
|
+
identityPoolId: string;
|
|
162
162
|
/**
|
|
163
163
|
* The Pinpoint App Id to report to.
|
|
164
164
|
*/
|
|
@@ -225,13 +225,20 @@ type AmplifyReporterBufferingConfig = {
|
|
|
225
225
|
};
|
|
226
226
|
|
|
227
227
|
export function amplifyReporter(info: ServiceInfo, config: AmplifyReporterConfig): IReporter {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
228
|
+
Amplify.configure({
|
|
229
|
+
Auth: {
|
|
230
|
+
Cognito: {
|
|
231
|
+
identityPoolId: config.identityPoolId,
|
|
232
|
+
allowGuestAccess: true,
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
Analytics: {
|
|
236
|
+
Pinpoint: {
|
|
237
|
+
appId: config.analyticsAppId,
|
|
238
|
+
region: config.region,
|
|
239
|
+
...config.buffering,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
235
242
|
});
|
|
236
243
|
|
|
237
244
|
const allMetadata = asAttributeMap({
|
|
@@ -241,10 +248,6 @@ export function amplifyReporter(info: ServiceInfo, config: AmplifyReporterConfig
|
|
|
241
248
|
environment: info.environment,
|
|
242
249
|
version: info.version,
|
|
243
250
|
});
|
|
244
|
-
fetchAuthSession({ forceRefresh: true }).then((session) => {
|
|
245
|
-
console.log('Auth session fetched successfully');
|
|
246
|
-
console.log('Session:', session);
|
|
247
|
-
});
|
|
248
251
|
|
|
249
252
|
// Initialize auto-tracker for Gen2
|
|
250
253
|
const autoTracker = new AmplifyAutoTracker(config, allMetadata);
|
|
@@ -369,63 +372,63 @@ export function buildAttributeMap(
|
|
|
369
372
|
return valuesWithStringArrays;
|
|
370
373
|
}
|
|
371
374
|
|
|
372
|
-
function installPinpointProxy(proxyUrl: URL) {
|
|
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
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
375
|
+
// function installPinpointProxy(proxyUrl: URL) {
|
|
376
|
+
// // No public API for overriding where the Pinpoint client sends events to... 🤮
|
|
377
|
+
// // In theory you can pass in an `endpoint` to the Pinpoint client's constructor like any other AWS
|
|
378
|
+
// // client, but Amplify's analytics doesn't expose anything we can use to get an endpoint threaded
|
|
379
|
+
// // down to the Pinpoint client's constructor.
|
|
380
|
+
// //
|
|
381
|
+
// // The Pinpoint client _also_ isn't available synchronously because it is instantiated when events
|
|
382
|
+
// // get sent out, and then reconfigured whenever the API credentials change. We need to hook `_initClients`
|
|
383
|
+
// // to ensure that the Pinpoint client being used is always patched with our custom endpoint.
|
|
384
|
+
// const provider = (globalThis as any).Analytics?.getPluggable?.('AWSPinpoint') as any;
|
|
385
|
+
// if (!provider || typeof provider._initClients !== 'function') {
|
|
386
|
+
// logger.error(
|
|
387
|
+
// 'Installation of the Pinpoint proxy failed. This likely means the internals of the @aws-amplify/analytics package have changed.',
|
|
388
|
+
// );
|
|
389
|
+
// return;
|
|
390
|
+
// }
|
|
391
|
+
|
|
392
|
+
// const originalInitClients = provider._initClients;
|
|
393
|
+
// const requestMiddleware: FinalizeRequestMiddleware<ServiceInputTypes, ServiceOutputTypes> =
|
|
394
|
+
// (next) => async (args) => {
|
|
395
|
+
// const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
|
|
396
|
+
|
|
397
|
+
// if (pinpointClient && proxyUrl.pathname !== '/' && HttpRequest.isInstance(args.request)) {
|
|
398
|
+
// // Add proxyUrl.pathname to final request url if it was provided
|
|
399
|
+
// const shouldStripSlash = proxyUrl.pathname.endsWith('/');
|
|
400
|
+
// args.request.path = `${proxyUrl.pathname}${args.request.path.slice(shouldStripSlash ? 1 : 0)}`;
|
|
401
|
+
|
|
402
|
+
// // Wrap request body so the proxy has signing info
|
|
403
|
+
// if (typeof args.request.body === 'string') {
|
|
404
|
+
// const credentials = await pinpointClient.config.credentials();
|
|
405
|
+
// args.request.body = JSON.stringify({
|
|
406
|
+
// credentials,
|
|
407
|
+
// data: JSON.parse(args.request.body),
|
|
408
|
+
// });
|
|
409
|
+
// }
|
|
410
|
+
// }
|
|
411
|
+
|
|
412
|
+
// return next(args);
|
|
413
|
+
// };
|
|
414
|
+
|
|
415
|
+
// provider._initClients = async (credentials: unknown) => {
|
|
416
|
+
// const result = await originalInitClients.call(provider, credentials);
|
|
417
|
+
// const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
|
|
418
|
+
|
|
419
|
+
// if (pinpointClient) {
|
|
420
|
+
// pinpointClient.config.endpoint = (): Promise<Endpoint> =>
|
|
421
|
+
// Promise.resolve({
|
|
422
|
+
// hostname: proxyUrl.hostname,
|
|
423
|
+
// // Passing proxyUrl.pathname here doesn't work; it gets overridden
|
|
424
|
+
// path: '/',
|
|
425
|
+
// port: undefined,
|
|
426
|
+
// protocol: proxyUrl.protocol,
|
|
427
|
+
// });
|
|
428
|
+
|
|
429
|
+
// pinpointClient.middlewareStack.remove(requestMiddleware);
|
|
430
|
+
// pinpointClient.middlewareStack.add(requestMiddleware, { step: 'finalizeRequest' });
|
|
431
|
+
// }
|
|
432
|
+
// return result;
|
|
433
|
+
// };
|
|
434
|
+
// }
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface AmplifyAnalyticsConfig {
|
|
2
|
-
region: string;
|
|
3
|
-
analyticsAppId: string;
|
|
4
|
-
identityPoolId?: string | false;
|
|
5
|
-
userPoolId?: string;
|
|
6
|
-
userPoolWebClientId?: string;
|
|
7
|
-
buffering?: {
|
|
8
|
-
bufferSize?: number;
|
|
9
|
-
flushSize?: number;
|
|
10
|
-
flushInterval?: number;
|
|
11
|
-
resendLimit?: number;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export declare function initAmplifyAnalytics(config: AmplifyAnalyticsConfig): Promise<void>;
|
|
15
|
-
//# sourceMappingURL=amplifyUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"amplifyUtils.d.ts","sourceRoot":"","sources":["../../src/reporters/amplifyUtils.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE;QACV,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,sBAAsB,iBAwBxE"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Amplify } from '@aws-amplify/core';
|
|
2
|
-
export async function initAmplifyAnalytics(config) {
|
|
3
|
-
if (config.identityPoolId !== false && config.identityPoolId) {
|
|
4
|
-
// if (config.userPoolId && config.userPoolWebClientId) {
|
|
5
|
-
// authConfig.Cognito.userPoolId = config.userPoolId;
|
|
6
|
-
// authConfig.Cognito.userPoolClientId = config.userPoolWebClientId;
|
|
7
|
-
// }
|
|
8
|
-
Amplify.configure({
|
|
9
|
-
Auth: {
|
|
10
|
-
Cognito: {
|
|
11
|
-
identityPoolId: config.identityPoolId,
|
|
12
|
-
allowGuestAccess: true,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
Amplify.configure({
|
|
18
|
-
Analytics: {
|
|
19
|
-
Pinpoint: {
|
|
20
|
-
appId: config.analyticsAppId,
|
|
21
|
-
region: config.region,
|
|
22
|
-
...config.buffering,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=amplifyUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"amplifyUtils.js","sourceRoot":"","sources":["../../src/reporters/amplifyUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAgB5C,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAA8B;IACvE,IAAI,MAAM,CAAC,cAAc,KAAK,KAAK,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QAC7D,yDAAyD;QACzD,uDAAuD;QACvD,sEAAsE;QACtE,IAAI;QACJ,OAAO,CAAC,SAAS,CAAC;YAChB,IAAI,EAAE;gBACJ,OAAO,EAAE;oBACP,cAAc,EAAE,MAAM,CAAC,cAAc;oBACrC,gBAAgB,EAAE,IAAI;iBACvB;aACF;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,CAAC,SAAS,CAAC;QAChB,SAAS,EAAE;YACT,QAAQ,EAAE;gBACR,KAAK,EAAE,MAAM,CAAC,cAAc;gBAC5B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,MAAM,CAAC,SAAS;aACpB;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Amplify } from '@aws-amplify/core';
|
|
2
|
-
|
|
3
|
-
export interface AmplifyAnalyticsConfig {
|
|
4
|
-
region: string;
|
|
5
|
-
analyticsAppId: string;
|
|
6
|
-
identityPoolId?: string | false;
|
|
7
|
-
userPoolId?: string;
|
|
8
|
-
userPoolWebClientId?: string;
|
|
9
|
-
buffering?: {
|
|
10
|
-
bufferSize?: number;
|
|
11
|
-
flushSize?: number;
|
|
12
|
-
flushInterval?: number;
|
|
13
|
-
resendLimit?: number;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function initAmplifyAnalytics(config: AmplifyAnalyticsConfig) {
|
|
18
|
-
if (config.identityPoolId !== false && config.identityPoolId) {
|
|
19
|
-
// if (config.userPoolId && config.userPoolWebClientId) {
|
|
20
|
-
// authConfig.Cognito.userPoolId = config.userPoolId;
|
|
21
|
-
// authConfig.Cognito.userPoolClientId = config.userPoolWebClientId;
|
|
22
|
-
// }
|
|
23
|
-
Amplify.configure({
|
|
24
|
-
Auth: {
|
|
25
|
-
Cognito: {
|
|
26
|
-
identityPoolId: config.identityPoolId,
|
|
27
|
-
allowGuestAccess: true,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
Amplify.configure({
|
|
33
|
-
Analytics: {
|
|
34
|
-
Pinpoint: {
|
|
35
|
-
appId: config.analyticsAppId,
|
|
36
|
-
region: config.region,
|
|
37
|
-
...config.buffering,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
}
|