@crimson-education/browser-logger 5.0.1-beta.2 → 5.0.1-beta.4
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 +63 -85
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +46 -22
- package/lib/index.js.map +1 -1
- package/lib/logger/consoleTransport.d.ts +1 -1
- package/lib/logger/consoleTransport.d.ts.map +1 -1
- package/lib/logger/consoleTransport.js +22 -16
- package/lib/logger/consoleTransport.js.map +1 -1
- package/lib/logger/datadogTransport.d.ts +1 -1
- package/lib/logger/datadogTransport.d.ts.map +1 -1
- package/lib/logger/datadogTransport.js +8 -4
- package/lib/logger/datadogTransport.js.map +1 -1
- package/lib/logger/index.js +49 -29
- package/lib/logger/index.js.map +1 -1
- package/lib/logger/index.test.js +18 -16
- package/lib/logger/index.test.js.map +1 -1
- package/lib/logger/utils.js +9 -4
- package/lib/logger/utils.js.map +1 -1
- package/lib/reporters/amplifyReporter.d.ts +4 -4
- package/lib/reporters/amplifyReporter.d.ts.map +1 -1
- package/lib/reporters/amplifyReporter.js +133 -230
- package/lib/reporters/amplifyReporter.js.map +1 -1
- package/lib/reporters/amplifyReporter.test.js +12 -9
- package/lib/reporters/amplifyReporter.test.js.map +1 -1
- package/lib/reporters/datadogReporter.d.ts +1 -13
- package/lib/reporters/datadogReporter.d.ts.map +1 -1
- package/lib/reporters/datadogReporter.js +49 -122
- package/lib/reporters/datadogReporter.js.map +1 -1
- package/lib/reporters/gtmReporter.d.ts +1 -1
- package/lib/reporters/gtmReporter.d.ts.map +1 -1
- package/lib/reporters/gtmReporter.js +5 -1
- package/lib/reporters/gtmReporter.js.map +1 -1
- package/lib/reporters/index.js +71 -46
- package/lib/reporters/index.js.map +1 -1
- package/lib/reporters/logReporter.js +34 -24
- package/lib/reporters/logReporter.js.map +1 -1
- package/lib/reporters/posthogReporter.d.ts +51 -0
- package/lib/reporters/posthogReporter.d.ts.map +1 -0
- package/lib/reporters/posthogReporter.js +254 -0
- package/lib/reporters/posthogReporter.js.map +1 -0
- package/lib/reporters/posthogReporter.test.d.ts +2 -0
- package/lib/reporters/posthogReporter.test.d.ts.map +1 -0
- package/lib/reporters/posthogReporter.test.js +197 -0
- package/lib/reporters/posthogReporter.test.js.map +1 -0
- package/lib/types/index.js +18 -2
- package/lib/types/index.js.map +1 -1
- package/lib/types/logger.d.ts +3 -3
- package/lib/types/logger.d.ts.map +1 -1
- package/lib/types/logger.js +5 -2
- package/lib/types/logger.js.map +1 -1
- package/lib/types/reporter.d.ts +14 -6
- package/lib/types/reporter.d.ts.map +1 -1
- package/lib/types/reporter.js +2 -1
- package/lib/utils.js +5 -1
- package/lib/utils.js.map +1 -1
- package/lib/utils.test.js +4 -2
- package/lib/utils.test.js.map +1 -1
- package/package.json +17 -15
- package/src/index.ts +6 -0
- package/src/reporters/amplifyReporter.ts +140 -264
- package/src/reporters/datadogReporter.ts +22 -133
- package/src/reporters/posthogReporter.test.ts +244 -0
- package/src/reporters/posthogReporter.ts +374 -0
- package/src/types/reporter.ts +9 -0
package/lib/logger/index.js
CHANGED
|
@@ -1,33 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.logger = exports.createLogger = exports.setLogLevel = exports.globalLogLevel = exports.logTransports = exports.globalMetadata = void 0;
|
|
1
18
|
/* eslint-disable prefer-rest-params */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export let globalLogLevel;
|
|
19
|
+
const types_1 = require("../types");
|
|
20
|
+
const utils_1 = require("../utils");
|
|
21
|
+
const consoleTransport_1 = require("./consoleTransport");
|
|
22
|
+
const utils_2 = require("./utils");
|
|
23
|
+
__exportStar(require("./consoleTransport"), exports);
|
|
24
|
+
__exportStar(require("./datadogTransport"), exports);
|
|
25
|
+
exports.globalMetadata = {};
|
|
26
|
+
exports.logTransports = [(0, consoleTransport_1.consoleTransport)()];
|
|
11
27
|
/**
|
|
12
28
|
* Sets the global log level.
|
|
13
29
|
*/
|
|
14
|
-
|
|
15
|
-
globalLogLevel = level
|
|
30
|
+
function setLogLevel(level) {
|
|
31
|
+
exports.globalLogLevel = level !== null && level !== void 0 ? level : undefined;
|
|
16
32
|
}
|
|
33
|
+
exports.setLogLevel = setLogLevel;
|
|
17
34
|
/**
|
|
18
35
|
* Creates a Logger Instance.
|
|
19
36
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
function createLogger(options = {}) {
|
|
38
|
+
var _a;
|
|
39
|
+
const rootMetadata = (_a = options.metadata) !== null && _a !== void 0 ? _a : {};
|
|
22
40
|
const logger = {
|
|
23
41
|
// impl loosely based on Winston Logger's dynamic log function
|
|
24
42
|
// https://github.com/winstonjs/winston/blob/master/lib/winston/logger.js
|
|
25
43
|
log() {
|
|
44
|
+
var _a, _b;
|
|
26
45
|
let logInfo;
|
|
27
46
|
// Optimize for the hotpath of logging JSON literals
|
|
28
47
|
if (arguments.length === 1) {
|
|
29
48
|
logInfo = {
|
|
30
|
-
level: LogLevel.Info,
|
|
49
|
+
level: types_1.LogLevel.Info,
|
|
31
50
|
...arguments[0],
|
|
32
51
|
};
|
|
33
52
|
}
|
|
@@ -37,7 +56,7 @@ export function createLogger(options = {}) {
|
|
|
37
56
|
if (message && typeof message === 'object') {
|
|
38
57
|
logInfo = {
|
|
39
58
|
...message,
|
|
40
|
-
level: message.level
|
|
59
|
+
level: (_a = message.level) !== null && _a !== void 0 ? _a : level,
|
|
41
60
|
};
|
|
42
61
|
}
|
|
43
62
|
else {
|
|
@@ -58,7 +77,7 @@ export function createLogger(options = {}) {
|
|
|
58
77
|
message,
|
|
59
78
|
};
|
|
60
79
|
if (meta.message) {
|
|
61
|
-
logInfo.message = `${getLogMessage(logInfo.message)} ${getLogMessage(meta.message)}`;
|
|
80
|
+
logInfo.message = `${(0, utils_2.getLogMessage)(logInfo.message)} ${(0, utils_2.getLogMessage)(meta.message)}`;
|
|
62
81
|
}
|
|
63
82
|
if (meta.stack) {
|
|
64
83
|
logInfo.stack = meta.stack;
|
|
@@ -73,27 +92,27 @@ export function createLogger(options = {}) {
|
|
|
73
92
|
}
|
|
74
93
|
}
|
|
75
94
|
// Check if we should log this message
|
|
76
|
-
const minLevel = globalLogLevel
|
|
77
|
-
if (minLevel && !isAboveLevel(logInfo.level, minLevel)) {
|
|
95
|
+
const minLevel = exports.globalLogLevel !== null && exports.globalLogLevel !== void 0 ? exports.globalLogLevel : options.logLevel;
|
|
96
|
+
if (minLevel && !(0, utils_2.isAboveLevel)(logInfo.level, minLevel)) {
|
|
78
97
|
return logger;
|
|
79
98
|
}
|
|
80
99
|
// Add timestamp and root metadata.
|
|
81
100
|
// Ensure there is a message property.
|
|
82
101
|
logInfo = {
|
|
83
|
-
...globalMetadata,
|
|
102
|
+
...exports.globalMetadata,
|
|
84
103
|
...rootMetadata,
|
|
85
104
|
timestamp: new Date().toISOString(),
|
|
86
105
|
...logInfo,
|
|
87
|
-
message: logInfo.message
|
|
106
|
+
message: (_b = logInfo.message) !== null && _b !== void 0 ? _b : '',
|
|
88
107
|
};
|
|
89
|
-
for (const transport of logTransports) {
|
|
108
|
+
for (const transport of exports.logTransports) {
|
|
90
109
|
if (transport.logLevel) {
|
|
91
|
-
if (!isAboveLevel(logInfo.level, transport.logLevel)) {
|
|
110
|
+
if (!(0, utils_2.isAboveLevel)(logInfo.level, transport.logLevel)) {
|
|
92
111
|
continue;
|
|
93
112
|
}
|
|
94
113
|
}
|
|
95
114
|
transport.log({
|
|
96
|
-
...filterReporterMetadata(logInfo, transport),
|
|
115
|
+
...(0, utils_1.filterReporterMetadata)(logInfo, transport),
|
|
97
116
|
// These would break the transport if excluded.
|
|
98
117
|
level: logInfo.level,
|
|
99
118
|
message: logInfo.message,
|
|
@@ -111,18 +130,19 @@ export function createLogger(options = {}) {
|
|
|
111
130
|
logger: this,
|
|
112
131
|
done: ({ message, level, metadata } = {}) => {
|
|
113
132
|
const duration = new Date().getTime() - start.getTime();
|
|
114
|
-
logger.log(level
|
|
133
|
+
logger.log(level !== null && level !== void 0 ? level : types_1.LogLevel.Info, message !== null && message !== void 0 ? message : 'Timer Completed', { duration, ...(metadata !== null && metadata !== void 0 ? metadata : {}) });
|
|
115
134
|
return true;
|
|
116
135
|
},
|
|
117
136
|
};
|
|
118
137
|
},
|
|
119
138
|
// Forward the log levels into the log function, essentially shortcuts.
|
|
120
|
-
debug: (...args) => logger.log(LogLevel.Debug, ...args),
|
|
121
|
-
info: (...args) => logger.log(LogLevel.Info, ...args),
|
|
122
|
-
warn: (...args) => logger.log(LogLevel.Warn, ...args),
|
|
123
|
-
error: (...args) => logger.log(LogLevel.Error, ...args),
|
|
139
|
+
debug: (...args) => logger.log(types_1.LogLevel.Debug, ...args),
|
|
140
|
+
info: (...args) => logger.log(types_1.LogLevel.Info, ...args),
|
|
141
|
+
warn: (...args) => logger.log(types_1.LogLevel.Warn, ...args),
|
|
142
|
+
error: (...args) => logger.log(types_1.LogLevel.Error, ...args),
|
|
124
143
|
};
|
|
125
144
|
return logger;
|
|
126
145
|
}
|
|
127
|
-
|
|
146
|
+
exports.createLogger = createLogger;
|
|
147
|
+
exports.logger = createLogger();
|
|
128
148
|
//# sourceMappingURL=index.js.map
|
package/lib/logger/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,oCAA8G;AAC9G,oCAAkD;AAClD,yDAAsD;AACtD,mCAAsD;AAEtD,qDAAmC;AACnC,qDAAmC;AAEtB,QAAA,cAAc,GAAa,EAAE,CAAC;AAE9B,QAAA,aAAa,GAAoB,CAAC,IAAA,mCAAgB,GAAE,CAAC,CAAC;AAGnE;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAsB;IAChD,sBAAc,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,SAAS,CAAC;AACtC,CAAC;AAFD,kCAEC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,UAAyB,EAAE;;IACtD,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,EAAE,CAAC;IAE5C,MAAM,MAAM,GAAY;QACtB,8DAA8D;QAC9D,yEAAyE;QACzE,GAAG;;YACD,IAAI,OAAsB,CAAC;YAE3B,oDAAoD;YACpD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC1B,OAAO,GAAG;oBACR,KAAK,EAAE,gBAAQ,CAAC,IAAI;oBACpB,GAAG,SAAS,CAAC,CAAC,CAAC;iBAChB,CAAC;aACH;YACD,mDAAmD;iBAC9C,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC/B,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,G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P,OAAO,cAAP,OAAO,GAAI,iBAAiB,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,EAAE,CAAC,CAAC;oBACpG,OAAO,IAAI,CAAC;gBACd,CAAC;aACF,CAAC;QACJ,CAAC;QACD,uEAAuE;QACvE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAQ,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC;QACvD,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAQ,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;QACrD,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAQ,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;QACrD,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAQ,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC;KACxD,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAhHD,oCAgHC;AAEY,QAAA,MAAM,GAAG,YAAY,EAAE,CAAC"}
|
package/lib/logger/index.test.js
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const _1 = require(".");
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
const reporters_1 = require("../reporters");
|
|
6
|
+
const types_1 = require("../types");
|
|
5
7
|
// This isn't actually asserting anything.
|
|
6
8
|
// But it ensures that the logs look correct, and no errors get thrown.
|
|
7
9
|
describe('logger', () => {
|
|
8
|
-
const logger = createLogger({
|
|
10
|
+
const logger = (0, _1.createLogger)({
|
|
9
11
|
metadata: {
|
|
10
12
|
service: 'test',
|
|
11
13
|
},
|
|
12
14
|
});
|
|
13
15
|
// Manually set the log transports.
|
|
14
|
-
logTransports.length = 0;
|
|
15
|
-
const transport = consoleTransport({
|
|
16
|
+
_1.logTransports.length = 0;
|
|
17
|
+
const transport = (0, _1.consoleTransport)({
|
|
16
18
|
// So we can see everything.
|
|
17
19
|
ignoreMetadataPatterns: [],
|
|
18
20
|
});
|
|
19
|
-
logTransports.push(transport);
|
|
21
|
+
_1.logTransports.push(transport);
|
|
20
22
|
it('should log', async () => {
|
|
21
23
|
logger.log({
|
|
22
24
|
level: 'info',
|
|
23
25
|
message: 'data',
|
|
24
26
|
});
|
|
25
27
|
logger.log({ data: 'obj' });
|
|
26
|
-
logger.log(LogLevel.Debug, 'level, message', { data: 'obj' });
|
|
27
|
-
logger.log(LogLevel.Debug, 'level, message, metadata', { data: 'obj' });
|
|
28
|
-
init({
|
|
28
|
+
logger.log(types_1.LogLevel.Debug, 'level, message', { data: 'obj' });
|
|
29
|
+
logger.log(types_1.LogLevel.Debug, 'level, message, metadata', { data: 'obj' });
|
|
30
|
+
(0, __1.init)({
|
|
29
31
|
service: 'test-service',
|
|
30
32
|
environment: 'test',
|
|
31
33
|
version: 'no-version',
|
|
@@ -39,17 +41,17 @@ describe('logger', () => {
|
|
|
39
41
|
const timer = logger.startTimer();
|
|
40
42
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
41
43
|
timer.done({ message: 'timer done', metadata: { id: 1 } });
|
|
42
|
-
|
|
43
|
-
addMetadata({ global: 'metadata' });
|
|
44
|
+
(0, _1.setLogLevel)(types_1.LogLevel.Info);
|
|
45
|
+
(0, reporters_1.addMetadata)({ global: 'metadata' });
|
|
44
46
|
logger.debug('You should not see this');
|
|
45
47
|
logger.info('You should see this with { global: "metadata" }');
|
|
46
|
-
|
|
47
|
-
setUser({
|
|
48
|
+
(0, _1.setLogLevel)(null);
|
|
49
|
+
(0, reporters_1.setUser)({
|
|
48
50
|
id: '123',
|
|
49
51
|
email: 'test@example.com',
|
|
50
52
|
});
|
|
51
53
|
logger.debug('debug call, user metadata');
|
|
52
|
-
transport.logLevel = LogLevel.Info;
|
|
54
|
+
transport.logLevel = types_1.LogLevel.Info;
|
|
53
55
|
logger.debug('You should not see this');
|
|
54
56
|
logger.info('You should see this');
|
|
55
57
|
transport.logLevel = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/logger/index.test.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/logger/index.test.ts"],"names":[],"mappings":";;AAAA,wBAAoG;AACpG,0BAA0B;AAC1B,4CAAoD;AACpD,oCAAoC;AAEpC,0CAA0C;AAC1C,uEAAuE;AACvE,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,MAAM,MAAM,GAAG,IAAA,eAAY,EAAC;QAC1B,QAAQ,EAAE;YACR,OAAO,EAAE,MAAM;SAChB;KACF,CAAC,CAAC;IAEH,mCAAmC;IACnC,gBAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,MAAM,SAAS,GAAG,IAAA,mBAAgB,EAAC;QACjC,4BAA4B;QAC5B,sBAAsB,EAAE,EAAE;KAC3B,CAAC,CAAC;IACH,gBAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE9B,EAAE,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC1B,MAAM,CAAC,GAAG,CAAC;YACT,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,MAAM;SAChB,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,gBAAQ,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9D,MAAM,CAAC,GA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AI,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACnC,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/logger/utils.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLogMessage = exports.isAboveLevel = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
2
5
|
/**
|
|
3
6
|
* Checks if a log level is above the global log level.
|
|
4
7
|
* @param level The log level to check
|
|
5
8
|
* @param checkLevel THe log level to check against
|
|
6
9
|
* @returns Is above the checkLevel?
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
const levels = [LogLevel.Debug, LogLevel.Info, LogLevel.Warn, LogLevel.Error];
|
|
11
|
+
function isAboveLevel(level, checkLevel) {
|
|
12
|
+
const levels = [types_1.LogLevel.Debug, types_1.LogLevel.Info, types_1.LogLevel.Warn, types_1.LogLevel.Error];
|
|
10
13
|
return levels.indexOf(level) >= levels.indexOf(checkLevel);
|
|
11
14
|
}
|
|
15
|
+
exports.isAboveLevel = isAboveLevel;
|
|
12
16
|
/**
|
|
13
17
|
* Ensures a message output is a string.
|
|
14
18
|
* @param message The message to assert is/convert to a string
|
|
15
19
|
* @returns The message as a string
|
|
16
20
|
*/
|
|
17
|
-
|
|
21
|
+
function getLogMessage(message) {
|
|
18
22
|
if (typeof message === 'string') {
|
|
19
23
|
return message;
|
|
20
24
|
}
|
|
@@ -24,4 +28,5 @@ export function getLogMessage(message) {
|
|
|
24
28
|
}
|
|
25
29
|
return String(message);
|
|
26
30
|
}
|
|
31
|
+
exports.getLogMessage = getLogMessage;
|
|
27
32
|
//# sourceMappingURL=utils.js.map
|
package/lib/logger/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/logger/utils.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/logger/utils.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AAEpC;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAe,EAAE,UAAoB;IAChE,MAAM,MAAM,GAAG,CAAC,gBAAQ,CAAC,KAAK,EAAE,gBAAQ,CAAC,IAAI,EAAE,gBAAQ,CAAC,IAAI,EAAE,gBAAQ,CAAC,KAAK,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAC7D,CAAC;AAHD,oCAGC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,OAAY;IACxC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,OAAO,CAAC;KAChB;IACD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE;QACnD,MAAM,IAAI,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;KAC7B;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC;AATD,sCASC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IReporter, Metadata, ReporterConfigBase, ServiceInfo } from '../types';
|
|
2
|
-
type AttributeMap = Record<string, string[] | string | null>;
|
|
3
|
-
type AmplifyAutoTrackSource = 'pageView' | 'event' | 'session';
|
|
2
|
+
declare type AttributeMap = Record<string, string[] | string | null>;
|
|
3
|
+
declare type AmplifyAutoTrackSource = 'pageView' | 'event' | 'session';
|
|
4
4
|
export interface AmplifyReporterConfig extends ReporterConfigBase {
|
|
5
5
|
/**
|
|
6
6
|
* AWS Region for Amplify.
|
|
@@ -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 | false;
|
|
14
14
|
/**
|
|
15
15
|
* The Pinpoint App Id to report to.
|
|
16
16
|
*/
|
|
@@ -61,7 +61,7 @@ export interface AmplifyReporterConfig extends ReporterConfigBase {
|
|
|
61
61
|
*
|
|
62
62
|
* @see https://docs.amplify.aws/lib/analytics/getting-started/q/platform/js/#set-up-existing-analytics-backend
|
|
63
63
|
*/
|
|
64
|
-
type AmplifyReporterBufferingConfig = {
|
|
64
|
+
declare type AmplifyReporterBufferingConfig = {
|
|
65
65
|
/** Number of items to buffer for sending. */
|
|
66
66
|
bufferSize?: number;
|
|
67
67
|
/** Number of events sent each time Pinpoint flushes. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplifyReporter.d.ts","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"amplifyReporter.d.ts","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,SAAS,EACT,QAAQ,EAER,kBAAkB,EAGlB,WAAW,EACZ,MAAM,UAAU,CAAC;AAIlB,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,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,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