@crimson-education/browser-logger 5.0.1-beta.2 → 5.0.1-beta.3

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 CHANGED
@@ -61,16 +61,6 @@ Logger.init({
61
61
  trackUserInteractions: true,
62
62
  allowedTrackingOrigins: ['https://my.api.domain'],
63
63
  },
64
-
65
- amplify: {
66
- region: config.awsRegion,
67
- identityPoolId: config.pinpointIdentityPoolId,
68
- analyticsAppId: config.pinpointAnalyticsAppId,
69
-
70
- autoTrackEvents: true,
71
- autoTrackPageViews: true,
72
- autoTrackSessions: true,
73
- },
74
64
  },
75
65
  });
76
66
 
@@ -262,66 +252,6 @@ Check out the [`DatadogReporterConfig`](https://github.com/crimson-education/bro
262
252
 
263
253
  This automatically adds a Datadog Log Transport that transmits Log data to Datadog, this can be customized in `DatadogReporterConfig` with `logTransport`, or disabled by setting `logTransport` to `false`.
264
254
 
265
- #### Amplify/Pinpoint
266
-
267
- To configure Amplify, this requires at least `region`, `identityPoolId` and `analyticsAppId`.
268
-
269
- > **Note**: If you are setting up Browser Logger in a project that uses AWS Cognito or other AWS Amplify Features, you will want to set `identityPoolId` to false. This disables the reporter's call to Auth.configure, as you will have used that to configure your App already.
270
- >
271
- > You will need to set identityPoolId in your Auth.configure function yourself, otherwise Pinpoint won't work.
272
-
273
- Auto `Auth.configure`:
274
-
275
- ```ts
276
- import { config } from '../configuration';
277
- import * as Logger from '@crimson-education/browser-logger';
278
-
279
- Logger.init({
280
- reporters: {
281
- amplify: {
282
- region: config.amplifyAwsRegion,
283
- analyticsAppId: config.pinpointAnalyticsAppId,
284
- identityPoolId: config.amplifyIdentityPoolId,
285
-
286
- autoTrackEvents: true,
287
- autoTrackPageViews: true,
288
- autoTrackSessions: true,
289
- },
290
- },
291
- });
292
- ```
293
-
294
- Manual `Auth.configure`:
295
-
296
- ```ts
297
- import { Auth } from '@aws-amplify/auth';
298
- import { config } from '../configuration';
299
- import * as Logger from '@crimson-education/browser-logger';
300
-
301
- Auth.configure({
302
- region: config.cognitoRegion,
303
- userPoolId: config.cognitoUserPoolId,
304
- userPoolWebClientId: config.cognitoClientId,
305
- identityPoolId: config.amplifyIdentityPoolId,
306
- });
307
-
308
- Logger.init({
309
- reporters: {
310
- amplify: {
311
- region: config.amplifyAwsRegion,
312
- analyticsAppId: config.pinpointAnalyticsAppId,
313
- identityPoolId: false,
314
-
315
- autoTrackEvents: true,
316
- autoTrackPageViews: true,
317
- autoTrackSessions: true,
318
- },
319
- },
320
- });
321
- ```
322
-
323
- Check out the [`AmplifyReporterConfig`](https://github.com/crimson-education/browser-logger/blob/main/src/reporters/amplifyReporter.ts) for all of the configuration you can apply to Amplify reporting.
324
-
325
255
  #### Google Tag Manager
326
256
 
327
257
  To configure GTM, you will need to have loaded the GTM script into your App.
@@ -357,7 +287,7 @@ See the [src/reporter/index.ts](./src/reporter/index.ts) file for all exported f
357
287
 
358
288
  ### Improve Session Tracking with Component names
359
289
 
360
- You can improve the name of components in analytics tools like Datadog and Amplify use, instead of the content of a component.
290
+ You can improve the name of components in analytics tools like Datadog, instead of using the content of a component.
361
291
  This is valuable if the content is dynamic, e.g. a user's name:
362
292
 
363
293
  ```jsx
@@ -378,12 +308,6 @@ This library has been upgraded to support Node.js 22. The following changes were
378
308
  - `trackFrustrations` → Removed (replaced with custom frustration detection implementation)
379
309
  - `allowedTracingOrigins` → `allowedTrackingOrigins` (corrected spelling)
380
310
 
381
- #### Amplify Reporter Changes
382
-
383
- - Updated to use Amplify Gen2 APIs (`@aws-amplify/analytics@7.x`, `@aws-amplify/auth@6.x`)
384
- - Enhanced auto-tracking capabilities for page views, user interactions, and session state
385
- - Improved error handling and configuration validation
386
-
387
311
  #### Removed Features
388
312
 
389
313
  The following features were removed during the upgrade and have been replaced with custom implementations:
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAQ9D,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AAEzB,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IAAE,SAAS,CAAC,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAIhF;;;GAGG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,YAAY,QA2CxC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAO9D,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AAEzB,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IAAE,SAAS,CAAC,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAIhF;;;GAGG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,YAAY,QAuCxC"}
package/lib/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { setLogLevel } from './logger';
2
2
  import { addMetadata, reporters, setEventLevel } from './reporters';
3
3
  import { gtmReporter } from './reporters/gtmReporter';
4
- import { amplifyReporter } from './reporters/amplifyReporter';
5
4
  import { datadogReporter } from './reporters/datadogReporter';
6
5
  import { logReporter } from './reporters/logReporter';
7
6
  export * from './types';
@@ -26,9 +25,6 @@ export function init(config) {
26
25
  if (config.reporters?.datadog) {
27
26
  reporters['datadog'] = datadogReporter(config, config.reporters.datadog);
28
27
  }
29
- if (config.reporters?.amplify) {
30
- reporters['amplify'] = amplifyReporter(config, config.reporters.amplify);
31
- }
32
28
  if (config.reporters?.gtm) {
33
29
  reporters['gtm'] = gtmReporter(config, typeof config.reporters.gtm === 'boolean' ? {} : config.reporters.gtm);
34
30
  }
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index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  import { DatadogReporterConfig } from '../reporters/datadogReporter';
3
2
  import { GTMReporterConfig } from '../reporters/gtmReporter';
4
3
  import { LogReporterConfig } from '../reporters/logReporter';
@@ -14,11 +13,6 @@ export type ReporterConfigurations = {
14
13
  * If not set, the datadog reporter will not be used.
15
14
  */
16
15
  datadog?: DatadogReporterConfig;
17
- /**
18
- * Amplify/Pinpoint reporter configuration.
19
- * If not set, the amplify reporter will not be used.
20
- */
21
- amplify?: AmplifyReporterConfig;
22
16
  /**
23
17
  * Google Tag Manager reporter configuration.
24
18
  * If not set, the gtm reporter will not be used.
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../src/types/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IAElC;;;OAGG;IACH,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAEhC;;;OAGG;IACH,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAEhC;;;OAGG;IACH,GAAG,CAAC,EAAE,IAAI,GAAG,iBAAiB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,sBAAsB,CAAC;AAExD,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE7C,MAAM,MAAM,WAAW,GAAG;IACxB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,WAAW,E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4
  "description": "An abstract logger and reporting utility for browser environments",
5
5
  "scripts": {
6
6
  "prepack": "npm run build",
@@ -28,10 +28,6 @@
28
28
  },
29
29
  "homepage": "https://github.com/crimson-education/browser-logger#readme",
30
30
  "dependencies": {
31
- "@aws-amplify/analytics": "7.0.90",
32
- "@aws-amplify/core": "6.15.0",
33
- "@aws-sdk/client-cognito-identity": "^3.844.0",
34
- "@aws-sdk/protocol-http": "^3.370.0",
35
31
  "@datadog/browser-logs": "^6.13.0",
36
32
  "@datadog/browser-rum": "^6.13.0"
37
33
  },
package/src/index.ts CHANGED
@@ -2,7 +2,6 @@ import { ReporterConfigurations, ServiceInfo } from './types';
2
2
  import { setLogLevel } from './logger';
3
3
  import { addMetadata, reporters, setEventLevel } from './reporters';
4
4
  import { gtmReporter } from './reporters/gtmReporter';
5
- import { amplifyReporter } from './reporters/amplifyReporter';
6
5
  import { datadogReporter } from './reporters/datadogReporter';
7
6
  import { logReporter } from './reporters/logReporter';
8
7
 
@@ -35,10 +34,6 @@ export function init(config: LoggerConfig) {
35
34
  reporters['datadog'] = datadogReporter(config, config.reporters.datadog);
36
35
  }
37
36
 
38
- if (config.reporters?.amplify) {
39
- reporters['amplify'] = amplifyReporter(config, config.reporters.amplify);
40
- }
41
-
42
37
  if (config.reporters?.gtm) {
43
38
  reporters['gtm'] = gtmReporter(config, typeof config.reporters.gtm === 'boolean' ? {} : config.reporters.gtm);
44
39
  }
@@ -1,4 +1,3 @@
1
- import { AmplifyReporterConfig } from '../reporters/amplifyReporter';
2
1
  import { DatadogReporterConfig } from '../reporters/datadogReporter';
3
2
  import { GTMReporterConfig } from '../reporters/gtmReporter';
4
3
  import { LogReporterConfig } from '../reporters/logReporter';
@@ -17,12 +16,6 @@ export type ReporterConfigurations = {
17
16
  */
18
17
  datadog?: DatadogReporterConfig;
19
18
 
20
- /**
21
- * Amplify/Pinpoint reporter configuration.
22
- * If not set, the amplify reporter will not be used.
23
- */
24
- amplify?: AmplifyReporterConfig;
25
-
26
19
  /**
27
20
  * Google Tag Manager reporter configuration.
28
21
  * If not set, the gtm reporter will not be used.
@@ -1,86 +0,0 @@
1
- import { IReporter, Metadata, ReporterConfigBase, ServiceInfo } from '../types';
2
- type AttributeMap = Record<string, string[] | string | null>;
3
- type AmplifyAutoTrackSource = 'pageView' | 'event' | 'session';
4
- export interface AmplifyReporterConfig extends ReporterConfigBase {
5
- /**
6
- * AWS Region for Amplify.
7
- */
8
- region: string;
9
- /**
10
- * The Identity Pool Id to use for reporting, if set to false, Auth.configure is not called.
11
- * This must be called manually for the reporter to work.
12
- */
13
- identityPoolId: string;
14
- /**
15
- * The Pinpoint App Id to report to.
16
- */
17
- analyticsAppId: string;
18
- /** Optional proxy URL */
19
- proxyUrl?: string;
20
- /**
21
- * The Cognito User Pool to configure in Auth.configure.
22
- * If you are using Cognito, it is better to set identityPoolId to false and configure Auth manually.
23
- */
24
- userPoolId?: string;
25
- /**
26
- * The Cognito Web Client Id to configure in Auth.configure.
27
- * If you are using Cognito, it is better to set identityPoolId to false and configure Auth manually.
28
- */
29
- userPoolWebClientId?: string;
30
- /**
31
- * If you want to track which page/url in your webapp is the most frequently viewed one, you can use this feature.
32
- * It will automatically send events containing url information when the page is visited.
33
- */
34
- autoTrackPageViews?: boolean;
35
- /**
36
- * If you want to track user interactions with elements on the page, you can use this feature.
37
- * All you need to do is attach the specified selectors to your dom element and turn on the auto tracking.
38
- */
39
- autoTrackEvents?: boolean;
40
- /**
41
- * A web session can be defined in different ways.
42
- * To keep it simple we define that the web session is active when the page is not hidden and inactive when the page is hidden.
43
- */
44
- autoTrackSessions?: boolean;
45
- /**
46
- * Optional function to run before autotracked analytics events are sent out.
47
- * The returned metadata is attached to the event.
48
- */
49
- beforeAutoTrack?(source: AmplifyAutoTrackSource): Metadata | undefined;
50
- /**
51
- * The data tag prefix to use for attributing HTML elements. Defaults to data-analytics-
52
- */
53
- selectorPrefix?: string;
54
- /**
55
- * Modify how the reporter sends events to Amplify.
56
- */
57
- buffering?: AmplifyReporterBufferingConfig;
58
- }
59
- /**
60
- * Configuration options for the buffering behavior of Pinpoint's event tracker.
61
- *
62
- * @see https://docs.amplify.aws/lib/analytics/getting-started/q/platform/js/#set-up-existing-analytics-backend
63
- */
64
- type AmplifyReporterBufferingConfig = {
65
- /** Number of items to buffer for sending. */
66
- bufferSize?: number;
67
- /** Number of events sent each time Pinpoint flushes. */
68
- flushSize?: number;
69
- /** Interval Pinpoint flushes analytics events. Measured in milliseconds. */
70
- flushInterval?: number;
71
- /** The maximum number of times Pinpoint will retry to send an event. */
72
- resendLimit?: number;
73
- };
74
- export declare function amplifyReporter(info: ServiceInfo, config: AmplifyReporterConfig): IReporter;
75
- /**
76
- * Pinpoint has strict attribute name and value length limits
77
- */
78
- export declare function asAttributeMap(values: Record<string, unknown>, groupValues?: boolean): AttributeMap;
79
- /**
80
- * Pinpoint expects `endpoint.attributes` and `endpoint.userAttributes` to have
81
- * values which are string arrays. This function takes in an object and ensures
82
- * all of its values are of type `string[]` to appease Pinpoint.
83
- */
84
- export declare function buildAttributeMap(values: Record<string, any>, parentKey?: string | undefined, groupValues?: boolean): AttributeMap;
85
- export {};
86
- //# sourceMappingURL=amplifyReporter.d.ts.map
@@ -1 +0,0 @@
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;AAwJ/D,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;O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ics';
2
- import { logger } from '../logger';
3
- // Note: fetchAuthSession was previously imported but unused; removing to satisfy linter
4
- import { Amplify } from '@aws-amplify/core';
5
- // Auto-tracking implementation for Gen2
6
- class AmplifyAutoTracker {
7
- config;
8
- allMetadata;
9
- currentUser = null;
10
- sessionStartTime = Date.now();
11
- pageViewCount = 0;
12
- lastPageUrl = window.location.href;
13
- isPageVisible = !document.hidden;
14
- constructor(config, allMetadata) {
15
- this.config = config;
16
- this.allMetadata = allMetadata;
17
- this.setupEventListeners();
18
- }
19
- setupEventListeners() {
20
- // Page visibility tracking
21
- document.addEventListener('visibilitychange', () => {
22
- this.isPageVisible = !document.hidden;
23
- if (this.config.autoTrackSessions) {
24
- this.trackSessionState();
25
- }
26
- });
27
- // Page view tracking
28
- if (this.config.autoTrackPageViews) {
29
- // Delay initial page view to ensure Amplify is fully configured
30
- // Using setTimeout(0) to defer to the next event loop tick
31
- setTimeout(() => {
32
- this.trackPageView();
33
- }, 0);
34
- // Track route changes for SPAs
35
- let currentUrl = window.location.href;
36
- const observer = new MutationObserver(() => {
37
- if (window.location.href !== currentUrl) {
38
- currentUrl = window.location.href;
39
- this.trackPageView();
40
- }
41
- });
42
- observer.observe(document.body, { childList: true, subtree: true });
43
- }
44
- // User interaction tracking
45
- if (this.config.autoTrackEvents) {
46
- this.setupInteractionTracking();
47
- }
48
- }
49
- trackPageView() {
50
- this.pageViewCount++;
51
- const pageViewEvent = {
52
- message: 'Page View',
53
- metadata: {
54
- url: window.location.href,
55
- title: document.title,
56
- referrer: document.referrer,
57
- pageViewCount: this.pageViewCount,
58
- ...this.getAutoTrackMetadata('pageView'),
59
- },
60
- };
61
- record({
62
- name: pageViewEvent.message,
63
- attributes: asAttributeMap({
64
- ...this.allMetadata,
65
- ...pageViewEvent.metadata,
66
- }, false),
67
- });
68
- }
69
- trackSessionState() {
70
- const sessionDuration = Date.now() - this.sessionStartTime;
71
- const sessionEvent = {
72
- message: this.isPageVisible ? 'Session Active' : 'Session Inactive',
73
- metadata: {
74
- sessionDuration,
75
- isVisible: this.isPageVisible,
76
- ...this.getAutoTrackMetadata('session'),
77
- },
78
- };
79
- record({
80
- name: sessionEvent.message,
81
- attributes: asAttributeMap({
82
- ...this.allMetadata,
83
- ...sessionEvent.metadata,
84
- }, false),
85
- });
86
- }
87
- setupInteractionTracking() {
88
- const selectorPrefix = this.config.selectorPrefix ?? 'data-analytics-';
89
- document.addEventListener('click', (event) => {
90
- const target = event.target;
91
- if (!target)
92
- return;
93
- // Find the closest element with analytics attributes
94
- const analyticsElement = target.closest(`[${selectorPrefix}name]`);
95
- if (!analyticsElement)
96
- return;
97
- const analyticsName = analyticsElement.getAttribute(`${selectorPrefix}name`);
98
- if (!analyticsName)
99
- return;
100
- const interactionEvent = {
101
- message: 'User Interaction',
102
- metadata: {
103
- elementName: analyticsName,
104
- elementType: target.tagName.toLowerCase(),
105
- elementText: target.textContent?.slice(0, 100),
106
- interactionType: 'click',
107
- ...this.getAutoTrackMetadata('event'),
108
- },
109
- };
110
- record({
111
- name: interactionEvent.message,
112
- attributes: asAttributeMap({
113
- ...this.allMetadata,
114
- ...interactionEvent.metadata,
115
- }, false),
116
- });
117
- });
118
- }
119
- getAutoTrackMetadata(source) {
120
- const { beforeAutoTrack } = this.config;
121
- return typeof beforeAutoTrack === 'function' ? (beforeAutoTrack(source) ?? {}) : {};
122
- }
123
- setUser(user) {
124
- this.currentUser = user;
125
- }
126
- updateMetadata(metadata) {
127
- Object.assign(this.allMetadata, metadata);
128
- }
129
- }
130
- export function amplifyReporter(info, config) {
131
- Amplify.configure({
132
- Auth: {
133
- Cognito: {
134
- identityPoolId: config.identityPoolId,
135
- allowGuestAccess: true,
136
- },
137
- },
138
- Analytics: {
139
- Pinpoint: {
140
- appId: config.analyticsAppId,
141
- region: config.region,
142
- ...config.buffering,
143
- },
144
- },
145
- });
146
- const allMetadata = asAttributeMap({
147
- appName: info.service,
148
- service: info.service,
149
- domain: window.location.host,
150
- environment: info.environment,
151
- version: info.version,
152
- });
153
- // Initialize auto-tracker for Gen2
154
- const autoTracker = new AmplifyAutoTracker(config, allMetadata);
155
- if (config.proxyUrl) {
156
- // installPinpointProxy(new URL(config.proxyUrl));
157
- }
158
- const reporter = {
159
- trackEvent: function (event) {
160
- record({
161
- name: event.message,
162
- attributes: asAttributeMap({
163
- ...allMetadata,
164
- ...event.metadata,
165
- ...event.tags,
166
- }, false),
167
- metrics: event.metrics,
168
- });
169
- },
170
- addBreadcrumb: function (breadcrumb) {
171
- reporter.trackEvent({
172
- message: breadcrumb.message,
173
- metadata: {
174
- category: breadcrumb.category,
175
- ...breadcrumb.metadata,
176
- },
177
- });
178
- },
179
- addMetadata: function (metadata) {
180
- Object.assign(allMetadata, asAttributeMap(metadata, true));
181
- autoTracker.updateMetadata(asAttributeMap(metadata, true));
182
- // Note: updateEndpoint is not available in Amplify v7
183
- // Metadata updates would need to be handled differently
184
- },
185
- setUser: function (user) {
186
- const userMetadata = user
187
- ? asAttributeMap({
188
- userId: user.id,
189
- })
190
- : {};
191
- Object.assign(allMetadata, asAttributeMap(userMetadata, true));
192
- autoTracker.setUser(user);
193
- // Only call identifyUser when we have a valid user ID
194
- // Calling with empty string can cause issues with Pinpoint USER_ID
195
- if (user?.id) {
196
- identifyUser({
197
- userId: user.id,
198
- userProfile: {
199
- email: user.email,
200
- },
201
- }).catch((error) => {
202
- // Credentials may not be ready yet, log warning and continue
203
- // The userId is still stored in allMetadata for event tracking
204
- logger.warn('Failed to identify user in Pinpoint', { error });
205
- });
206
- }
207
- },
208
- setRouteName: function (routeName) {
209
- reporter.addMetadata({ routeName });
210
- },
211
- setPageName: function (pageName) {
212
- reporter.addMetadata({ pageName });
213
- },
214
- };
215
- return reporter;
216
- }
217
- /**
218
- * Pinpoint has strict attribute name and value length limits
219
- */
220
- export function asAttributeMap(values, groupValues = true) {
221
- const attributeMap = buildAttributeMap(values, undefined, groupValues);
222
- const checkedEntries = Object.entries(attributeMap).map(([key, value]) => {
223
- const truncatedKey = key.length > 50 ? `___${key.slice(-47)}` : key;
224
- const truncatedValue = Array.isArray(value)
225
- ? (value?.map((val) => val.slice(0, 100)) ?? null)
226
- : (value?.slice(0, 100) ?? null);
227
- return [truncatedKey, truncatedValue];
228
- });
229
- // Pinpoint only accepts 40 attributes
230
- if (checkedEntries.length > 40) {
231
- logger.error(`Amplify only allows 40 attributes per event, truncating to 40 attributes`, {
232
- attributes: checkedEntries,
233
- });
234
- checkedEntries.length = 40;
235
- }
236
- return Object.fromEntries(checkedEntries);
237
- }
238
- /**
239
- * Pinpoint expects `endpoint.attributes` and `endpoint.userAttributes` to have
240
- * values which are string arrays. This function takes in an object and ensures
241
- * all of its values are of type `string[]` to appease Pinpoint.
242
- */
243
- export function buildAttributeMap(values, parentKey = undefined, groupValues = true) {
244
- const valuesWithStringArrays = {};
245
- Object.entries(values).forEach(([key, value]) => {
246
- const combinedKey = parentKey ? [parentKey, key].join('.') : key;
247
- // Only treat undefined or null as empty; avoid converting falsy values like ''/0/false to null
248
- if (value === undefined || value === null) {
249
- // For event attributes (groupValues === false), Pinpoint rejects null values.
250
- // In that case we omit the key entirely to avoid "Event attribute value can not be null".
251
- if (groupValues) {
252
- valuesWithStringArrays[combinedKey] = null;
253
- }
254
- }
255
- else if (groupValues && Array.isArray(value)) {
256
- valuesWithStringArrays[combinedKey] = value.map((element) => typeof element === 'string' ? element : JSON.stringify(element));
257
- }
258
- else if (typeof value === 'object') {
259
- const flattenedAttribute = buildAttributeMap(value, combinedKey, groupValues);
260
- Object.assign(valuesWithStringArrays, flattenedAttribute);
261
- }
262
- else {
263
- const stringValue = typeof value === 'string' ? value : JSON.stringify(value);
264
- valuesWithStringArrays[combinedKey] = groupValues ? [stringValue] : stringValue;
265
- }
266
- });
267
- return valuesWithStringArrays;
268
- }
269
- // function installPinpointProxy(proxyUrl: URL) {
270
- // // No public API for overriding where the Pinpoint client sends events to... 🤮
271
- // // In theory you can pass in an `endpoint` to the Pinpoint client's constructor like any other AWS
272
- // // client, but Amplify's analytics doesn't expose anything we can use to get an endpoint threaded
273
- // // down to the Pinpoint client's constructor.
274
- // //
275
- // // The Pinpoint client _also_ isn't available synchronously because it is instantiated when events
276
- // // get sent out, and then reconfigured whenever the API credentials change. We need to hook `_initClients`
277
- // // to ensure that the Pinpoint client being used is always patched with our custom endpoint.
278
- // const provider = (globalThis as any).Analytics?.getPluggable?.('AWSPinpoint') as any;
279
- // if (!provider || typeof provider._initClients !== 'function') {
280
- // logger.error(
281
- // 'Installation of the Pinpoint proxy failed. This likely means the internals of the @aws-amplify/analytics package have changed.',
282
- // );
283
- // return;
284
- // }
285
- // const originalInitClients = provider._initClients;
286
- // const requestMiddleware: FinalizeRequestMiddleware<ServiceInputTypes, ServiceOutputTypes> =
287
- // (next) => async (args) => {
288
- // const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
289
- // if (pinpointClient && proxyUrl.pathname !== '/' && HttpRequest.isInstance(args.request)) {
290
- // // Add proxyUrl.pathname to final request url if it was provided
291
- // const shouldStripSlash = proxyUrl.pathname.endsWith('/');
292
- // args.request.path = `${proxyUrl.pathname}${args.request.path.slice(shouldStripSlash ? 1 : 0)}`;
293
- // // Wrap request body so the proxy has signing info
294
- // if (typeof args.request.body === 'string') {
295
- // const credentials = await pinpointClient.config.credentials();
296
- // args.request.body = JSON.stringify({
297
- // credentials,
298
- // data: JSON.parse(args.request.body),
299
- // });
300
- // }
301
- // }
302
- // return next(args);
303
- // };
304
- // provider._initClients = async (credentials: unknown) => {
305
- // const result = await originalInitClients.call(provider, credentials);
306
- // const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
307
- // if (pinpointClient) {
308
- // pinpointClient.config.endpoint = (): Promise<Endpoint> =>
309
- // Promise.resolve({
310
- // hostname: proxyUrl.hostname,
311
- // // Passing proxyUrl.pathname here doesn't work; it gets overridden
312
- // path: '/',
313
- // port: undefined,
314
- // protocol: proxyUrl.protocol,
315
- // });
316
- // pinpointClient.middlewareStack.remove(requestMiddleware);
317
- // pinpointClient.middlewareStack.add(requestMiddleware, { step: 'finalizeRequest' });
318
- // }
319
- // return result;
320
- // };
321
- // }
322
- //# sourceMappingURL=amplifyReporter.js.map
@@ -1 +0,0 @@
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,wFAAwF;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAO5C,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,WAAW,CAAC;QAC/B,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;IAEO,mBAAmB;QACzB,2BAA2B;QAC3B,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,GAAG,EAAE;YACjD,IAAI,CAAC,aAAa,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACtC,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE;gBACjC,IAAI,CAAC,iBAAiB,EAAE,CAAC;aAC1B;QACH,CAAC,CAAC,CAAC;QAEH,qBAAqB;QACrB,IAAI,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE;YAClC,gEAAgE;YAChE,2DAA2D;YAC3D,UAAU,CAAC,GAAG,EAAE;gB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,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"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=amplifyReporter.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"amplifyReporter.test.d.ts","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.test.ts"],"names":[],"mappings":""}
@@ -1,48 +0,0 @@
1
- import { asAttributeMap } from './amplifyReporter';
2
- describe('amplifyReporter', () => {
3
- it('should convert all attribute values to arrays of strings', () => {
4
- const testMetadata = { a: 'a', d: ['e', 'f'] };
5
- const attributeMap = asAttributeMap(testMetadata);
6
- expect(attributeMap.a).toEqual(['a']);
7
- expect(attributeMap.d).toEqual(['e', 'f']);
8
- });
9
- it('should handle undefined / null attributes', () => {
10
- const testMetadata = { a: null, d: undefined };
11
- const attributeMap = asAttributeMap(testMetadata);
12
- expect(attributeMap.a).toBeNull();
13
- expect(attributeMap.d).toBeNull();
14
- });
15
- it('should flatten hierarchies', () => {
16
- const testMetadata = { foo: { bar: 'baz' } };
17
- const attributeMap = asAttributeMap(testMetadata);
18
- expect(attributeMap['foo.bar']).toEqual(['baz']);
19
- });
20
- it('should stringify non-string array members', () => {
21
- const testMetadata = { foo: 5, bar: [{ baz: 'maz' }] };
22
- const attributeMap = asAttributeMap(testMetadata);
23
- expect(attributeMap.foo).toEqual(['5']);
24
- expect(typeof attributeMap.bar?.[0]).toEqual('string');
25
- });
26
- it('should truncate attribute names', () => {
27
- const testMetadata = { thisIsAVeryVeryLongAttributeNameThatNeedsToBeTruncated: 5 };
28
- const attributeMap = asAttributeMap(testMetadata);
29
- expect(attributeMap.___VeryVeryLongAttributeNameThatNeedsToBeTruncated).toEqual(['5']);
30
- });
31
- it('should truncate attribute values', () => {
32
- const testMetadata = {
33
- a: 'ThisIsAVeryLongStringThatNeedsToBeTruncatedTo100CharsOrElseThereWillBeAProblemWithSendingTheBeautifulDataToPinpoint',
34
- };
35
- const attributeMap = asAttributeMap(testMetadata);
36
- expect(attributeMap.a).toEqual([
37
- 'ThisIsAVeryLongStringThatNeedsToBeTruncatedTo100CharsOrElseThereWillBeAProblemWithSendingTheBeautifu',
38
- ]);
39
- });
40
- it('should not group values into arrays when groupValues===false', () => {
41
- const testMetadata = {
42
- a: '5',
43
- };
44
- const attributeMap = asAttributeMap(testMetadata, false);
45
- expect(attributeMap.a).toEqual('5');
46
- });
47
- });
48
- //# sourceMappingURL=amplifyReporter.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"amplifyReporter.test.js","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,YAAY,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,YAAY,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;QAElD,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GA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C,YAAY,CAAC,kDAAkD,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,YAAY,GAAG;YACnB,CAAC,EAAE,qHAAqH;SACzH,CAAC;QACF,MAAM,YAAY,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;QAElD,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC7B,sGAAsG;SACvG,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,YAAY,GAAG;YACnB,CAAC,EAAE,GAAG;SACP,CAAC;QAEF,MAAM,YAAY,GAAG,cAAc,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QACzD,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,61 +0,0 @@
1
- import { asAttributeMap } from './amplifyReporter';
2
-
3
- describe('amplifyReporter', () => {
4
- it('should convert all attribute values to arrays of strings', () => {
5
- const testMetadata = { a: 'a', d: ['e', 'f'] };
6
- const attributeMap = asAttributeMap(testMetadata);
7
-
8
- expect(attributeMap.a).toEqual(['a']);
9
- expect(attributeMap.d).toEqual(['e', 'f']);
10
- });
11
-
12
- it('should handle undefined / null attributes', () => {
13
- const testMetadata = { a: null, d: undefined };
14
- const attributeMap = asAttributeMap(testMetadata);
15
-
16
- expect(attributeMap.a).toBeNull();
17
- expect(attributeMap.d).toBeNull();
18
- });
19
-
20
- it('should flatten hierarchies', () => {
21
- const testMetadata = { foo: { bar: 'baz' } };
22
- const attributeMap = asAttributeMap(testMetadata);
23
-
24
- expect(attributeMap['foo.bar']).toEqual(['baz']);
25
- });
26
-
27
- it('should stringify non-string array members', () => {
28
- const testMetadata = { foo: 5, bar: [{ baz: 'maz' }] };
29
- const attributeMap = asAttributeMap(testMetadata);
30
-
31
- expect(attributeMap.foo).toEqual(['5']);
32
- expect(typeof attributeMap.bar?.[0]).toEqual('string');
33
- });
34
-
35
- it('should truncate attribute names', () => {
36
- const testMetadata = { thisIsAVeryVeryLongAttributeNameThatNeedsToBeTruncated: 5 };
37
- const attributeMap = asAttributeMap(testMetadata);
38
-
39
- expect(attributeMap.___VeryVeryLongAttributeNameThatNeedsToBeTruncated).toEqual(['5']);
40
- });
41
-
42
- it('should truncate attribute values', () => {
43
- const testMetadata = {
44
- a: 'ThisIsAVeryLongStringThatNeedsToBeTruncatedTo100CharsOrElseThereWillBeAProblemWithSendingTheBeautifulDataToPinpoint',
45
- };
46
- const attributeMap = asAttributeMap(testMetadata);
47
-
48
- expect(attributeMap.a).toEqual([
49
- 'ThisIsAVeryLongStringThatNeedsToBeTruncatedTo100CharsOrElseThereWillBeAProblemWithSendingTheBeautifu',
50
- ]);
51
- });
52
-
53
- it('should not group values into arrays when groupValues===false', () => {
54
- const testMetadata = {
55
- a: '5',
56
- };
57
-
58
- const attributeMap = asAttributeMap(testMetadata, false);
59
- expect(attributeMap.a).toEqual('5');
60
- });
61
- });
@@ -1,468 +0,0 @@
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';
5
-
6
- import {
7
- IReporter,
8
- Metadata,
9
- ReporterBreadcrumb,
10
- ReporterConfigBase,
11
- ReporterEvent,
12
- ReportUser,
13
- ServiceInfo,
14
- } from '../types';
15
- import { logger } from '../logger';
16
- // Note: fetchAuthSession was previously imported but unused; removing to satisfy linter
17
- import { Amplify } from '@aws-amplify/core';
18
-
19
- /* eslint-disable @typescript-eslint/no-unused-vars */
20
- type AttributeMap = Record<string, string[] | string | null>;
21
-
22
- type AmplifyAutoTrackSource = 'pageView' | 'event' | 'session';
23
-
24
- // Auto-tracking implementation for Gen2
25
- class AmplifyAutoTracker {
26
- private config: AmplifyReporterConfig;
27
- private allMetadata: AttributeMap;
28
- private currentUser: ReportUser | null = null;
29
- private sessionStartTime: number = Date.now();
30
- private pageViewCount: number = 0;
31
- private lastPageUrl: string = window.location.href;
32
- private isPageVisible: boolean = !document.hidden;
33
-
34
- constructor(config: AmplifyReporterConfig, allMetadata: AttributeMap) {
35
- this.config = config;
36
- this.allMetadata = allMetadata;
37
- this.setupEventListeners();
38
- }
39
-
40
- private setupEventListeners() {
41
- // Page visibility tracking
42
- document.addEventListener('visibilitychange', () => {
43
- this.isPageVisible = !document.hidden;
44
- if (this.config.autoTrackSessions) {
45
- this.trackSessionState();
46
- }
47
- });
48
-
49
- // Page view tracking
50
- if (this.config.autoTrackPageViews) {
51
- // Delay initial page view to ensure Amplify is fully configured
52
- // Using setTimeout(0) to defer to the next event loop tick
53
- setTimeout(() => {
54
- this.trackPageView();
55
- }, 0);
56
-
57
- // Track route changes for SPAs
58
- let currentUrl = window.location.href;
59
- const observer = new MutationObserver(() => {
60
- if (window.location.href !== currentUrl) {
61
- currentUrl = window.location.href;
62
- this.trackPageView();
63
- }
64
- });
65
- observer.observe(document.body, { childList: true, subtree: true });
66
- }
67
-
68
- // User interaction tracking
69
- if (this.config.autoTrackEvents) {
70
- this.setupInteractionTracking();
71
- }
72
- }
73
-
74
- private trackPageView() {
75
- this.pageViewCount++;
76
- const pageViewEvent = {
77
- message: 'Page View',
78
- metadata: {
79
- url: window.location.href,
80
- title: document.title,
81
- referrer: document.referrer,
82
- pageViewCount: this.pageViewCount,
83
- ...this.getAutoTrackMetadata('pageView'),
84
- },
85
- };
86
-
87
- record({
88
- name: pageViewEvent.message,
89
- attributes: asAttributeMap(
90
- {
91
- ...this.allMetadata,
92
- ...pageViewEvent.metadata,
93
- },
94
- false,
95
- ) as Record<string, string>,
96
- });
97
- }
98
-
99
- private trackSessionState() {
100
- const sessionDuration = Date.now() - this.sessionStartTime;
101
- const sessionEvent = {
102
- message: this.isPageVisible ? 'Session Active' : 'Session Inactive',
103
- metadata: {
104
- sessionDuration,
105
- isVisible: this.isPageVisible,
106
- ...this.getAutoTrackMetadata('session'),
107
- },
108
- };
109
-
110
- record({
111
- name: sessionEvent.message,
112
- attributes: asAttributeMap(
113
- {
114
- ...this.allMetadata,
115
- ...sessionEvent.metadata,
116
- },
117
- false,
118
- ) as Record<string, string>,
119
- });
120
- }
121
-
122
- private setupInteractionTracking() {
123
- const selectorPrefix = this.config.selectorPrefix ?? 'data-analytics-';
124
-
125
- document.addEventListener('click', (event) => {
126
- const target = event.target as HTMLElement;
127
- if (!target) return;
128
-
129
- // Find the closest element with analytics attributes
130
- const analyticsElement = target.closest(`[${selectorPrefix}name]`);
131
- if (!analyticsElement) return;
132
-
133
- const analyticsName = analyticsElement.getAttribute(`${selectorPrefix}name`);
134
- if (!analyticsName) return;
135
-
136
- const interactionEvent = {
137
- message: 'User Interaction',
138
- metadata: {
139
- elementName: analyticsName,
140
- elementType: target.tagName.toLowerCase(),
141
- elementText: target.textContent?.slice(0, 100),
142
- interactionType: 'click',
143
- ...this.getAutoTrackMetadata('event'),
144
- },
145
- };
146
-
147
- record({
148
- name: interactionEvent.message,
149
- attributes: asAttributeMap(
150
- {
151
- ...this.allMetadata,
152
- ...interactionEvent.metadata,
153
- },
154
- false,
155
- ) as Record<string, string>,
156
- });
157
- });
158
- }
159
-
160
- private getAutoTrackMetadata(source: AmplifyAutoTrackSource): Metadata {
161
- const { beforeAutoTrack } = this.config;
162
- return typeof beforeAutoTrack === 'function' ? (beforeAutoTrack(source) ?? {}) : {};
163
- }
164
-
165
- public setUser(user: ReportUser | null) {
166
- this.currentUser = user;
167
- }
168
-
169
- public updateMetadata(metadata: AttributeMap) {
170
- Object.assign(this.allMetadata, metadata);
171
- }
172
- }
173
-
174
- export interface AmplifyReporterConfig extends ReporterConfigBase {
175
- /**
176
- * AWS Region for Amplify.
177
- */
178
- region: string;
179
- /**
180
- * The Identity Pool Id to use for reporting, if set to false, Auth.configure is not called.
181
- * This must be called manually for the reporter to work.
182
- */
183
- identityPoolId: string;
184
- /**
185
- * The Pinpoint App Id to report to.
186
- */
187
- analyticsAppId: string;
188
- /** Optional proxy URL */
189
- proxyUrl?: string;
190
- /**
191
- * The Cognito User Pool to configure in Auth.configure.
192
- * If you are using Cognito, it is better to set identityPoolId to false and configure Auth manually.
193
- */
194
- userPoolId?: string;
195
- /**
196
- * The Cognito Web Client Id to configure in Auth.configure.
197
- * If you are using Cognito, it is better to set identityPoolId to false and configure Auth manually.
198
- */
199
- userPoolWebClientId?: string;
200
-
201
- /**
202
- * If you want to track which page/url in your webapp is the most frequently viewed one, you can use this feature.
203
- * It will automatically send events containing url information when the page is visited.
204
- */
205
- autoTrackPageViews?: boolean;
206
- /**
207
- * If you want to track user interactions with elements on the page, you can use this feature.
208
- * All you need to do is attach the specified selectors to your dom element and turn on the auto tracking.
209
- */
210
- autoTrackEvents?: boolean;
211
- /**
212
- * A web session can be defined in different ways.
213
- * To keep it simple we define that the web session is active when the page is not hidden and inactive when the page is hidden.
214
- */
215
- autoTrackSessions?: boolean;
216
- /**
217
- * Optional function to run before autotracked analytics events are sent out.
218
- * The returned metadata is attached to the event.
219
- */
220
- beforeAutoTrack?(source: AmplifyAutoTrackSource): Metadata | undefined;
221
-
222
- /**
223
- * The data tag prefix to use for attributing HTML elements. Defaults to data-analytics-
224
- */
225
- selectorPrefix?: string;
226
-
227
- /**
228
- * Modify how the reporter sends events to Amplify.
229
- */
230
- buffering?: AmplifyReporterBufferingConfig;
231
- }
232
-
233
- /**
234
- * Configuration options for the buffering behavior of Pinpoint's event tracker.
235
- *
236
- * @see https://docs.amplify.aws/lib/analytics/getting-started/q/platform/js/#set-up-existing-analytics-backend
237
- */
238
- type AmplifyReporterBufferingConfig = {
239
- /** Number of items to buffer for sending. */
240
- bufferSize?: number;
241
- /** Number of events sent each time Pinpoint flushes. */
242
- flushSize?: number;
243
- /** Interval Pinpoint flushes analytics events. Measured in milliseconds. */
244
- flushInterval?: number;
245
- /** The maximum number of times Pinpoint will retry to send an event. */
246
- resendLimit?: number;
247
- };
248
-
249
- export function amplifyReporter(info: ServiceInfo, config: AmplifyReporterConfig): IReporter {
250
- Amplify.configure({
251
- Auth: {
252
- Cognito: {
253
- identityPoolId: config.identityPoolId,
254
- allowGuestAccess: true,
255
- },
256
- },
257
- Analytics: {
258
- Pinpoint: {
259
- appId: config.analyticsAppId,
260
- region: config.region,
261
- ...config.buffering,
262
- },
263
- },
264
- });
265
-
266
- const allMetadata = asAttributeMap({
267
- appName: info.service,
268
- service: info.service,
269
- domain: window.location.host,
270
- environment: info.environment,
271
- version: info.version,
272
- });
273
-
274
- // Initialize auto-tracker for Gen2
275
- const autoTracker = new AmplifyAutoTracker(config, allMetadata);
276
-
277
- if (config.proxyUrl) {
278
- // installPinpointProxy(new URL(config.proxyUrl));
279
- }
280
-
281
- const reporter: IReporter = {
282
- trackEvent: function (event: ReporterEvent): void {
283
- record({
284
- name: event.message,
285
- attributes: asAttributeMap(
286
- {
287
- ...allMetadata,
288
- ...event.metadata,
289
- ...event.tags,
290
- },
291
- false,
292
- ) as Record<string, string>,
293
- metrics: event.metrics,
294
- });
295
- },
296
- addBreadcrumb: function (breadcrumb: ReporterBreadcrumb): void {
297
- reporter.trackEvent({
298
- message: breadcrumb.message,
299
- metadata: {
300
- category: breadcrumb.category,
301
- ...breadcrumb.metadata,
302
- },
303
- });
304
- },
305
- addMetadata: function (metadata: Metadata): void {
306
- Object.assign(allMetadata, asAttributeMap(metadata, true));
307
- autoTracker.updateMetadata(asAttributeMap(metadata, true));
308
- // Note: updateEndpoint is not available in Amplify v7
309
- // Metadata updates would need to be handled differently
310
- },
311
- setUser: function (user: ReportUser | null): void {
312
- const userMetadata = user
313
- ? asAttributeMap({
314
- userId: user.id,
315
- })
316
- : {};
317
- Object.assign(allMetadata, asAttributeMap(userMetadata, true));
318
- autoTracker.setUser(user);
319
- // Only call identifyUser when we have a valid user ID
320
- // Calling with empty string can cause issues with Pinpoint USER_ID
321
- if (user?.id) {
322
- identifyUser({
323
- userId: user.id,
324
- userProfile: {
325
- email: user.email,
326
- },
327
- }).catch((error) => {
328
- // Credentials may not be ready yet, log warning and continue
329
- // The userId is still stored in allMetadata for event tracking
330
- logger.warn('Failed to identify user in Pinpoint', { error });
331
- });
332
- }
333
- },
334
- setRouteName: function (routeName: string): void {
335
- reporter.addMetadata({ routeName });
336
- },
337
- setPageName: function (pageName: string): void {
338
- reporter.addMetadata({ pageName });
339
- },
340
- };
341
-
342
- return reporter;
343
- }
344
-
345
- /**
346
- * Pinpoint has strict attribute name and value length limits
347
- */
348
- export function asAttributeMap(values: Record<string, unknown>, groupValues = true): AttributeMap {
349
- const attributeMap = buildAttributeMap(values, undefined, groupValues);
350
-
351
- const checkedEntries = Object.entries(attributeMap).map(([key, value]) => {
352
- const truncatedKey = key.length > 50 ? `___${key.slice(-47)}` : key;
353
- const truncatedValue = Array.isArray(value)
354
- ? (value?.map((val) => val.slice(0, 100)) ?? null)
355
- : (value?.slice(0, 100) ?? null);
356
-
357
- return [truncatedKey, truncatedValue];
358
- });
359
-
360
- // Pinpoint only accepts 40 attributes
361
- if (checkedEntries.length > 40) {
362
- logger.error(`Amplify only allows 40 attributes per event, truncating to 40 attributes`, {
363
- attributes: checkedEntries,
364
- });
365
- checkedEntries.length = 40;
366
- }
367
-
368
- return Object.fromEntries(checkedEntries);
369
- }
370
-
371
- /**
372
- * Pinpoint expects `endpoint.attributes` and `endpoint.userAttributes` to have
373
- * values which are string arrays. This function takes in an object and ensures
374
- * all of its values are of type `string[]` to appease Pinpoint.
375
- */
376
- export function buildAttributeMap(
377
- values: Record<string, any>,
378
- parentKey: string | undefined = undefined,
379
- groupValues = true,
380
- ): AttributeMap {
381
- const valuesWithStringArrays: AttributeMap = {};
382
-
383
- Object.entries(values).forEach(([key, value]) => {
384
- const combinedKey = parentKey ? [parentKey, key].join('.') : key;
385
-
386
- // Only treat undefined or null as empty; avoid converting falsy values like ''/0/false to null
387
- if (value === undefined || value === null) {
388
- // For event attributes (groupValues === false), Pinpoint rejects null values.
389
- // In that case we omit the key entirely to avoid "Event attribute value can not be null".
390
- if (groupValues) {
391
- valuesWithStringArrays[combinedKey] = null;
392
- }
393
- } else if (groupValues && Array.isArray(value)) {
394
- valuesWithStringArrays[combinedKey] = value.map((element) =>
395
- typeof element === 'string' ? element : JSON.stringify(element),
396
- );
397
- } else if (typeof value === 'object') {
398
- const flattenedAttribute = buildAttributeMap(value, combinedKey, groupValues);
399
- Object.assign(valuesWithStringArrays, flattenedAttribute);
400
- } else {
401
- const stringValue = typeof value === 'string' ? value : JSON.stringify(value);
402
- valuesWithStringArrays[combinedKey] = groupValues ? [stringValue] : stringValue;
403
- }
404
- });
405
-
406
- return valuesWithStringArrays;
407
- }
408
-
409
- // function installPinpointProxy(proxyUrl: URL) {
410
- // // No public API for overriding where the Pinpoint client sends events to... 🤮
411
- // // In theory you can pass in an `endpoint` to the Pinpoint client's constructor like any other AWS
412
- // // client, but Amplify's analytics doesn't expose anything we can use to get an endpoint threaded
413
- // // down to the Pinpoint client's constructor.
414
- // //
415
- // // The Pinpoint client _also_ isn't available synchronously because it is instantiated when events
416
- // // get sent out, and then reconfigured whenever the API credentials change. We need to hook `_initClients`
417
- // // to ensure that the Pinpoint client being used is always patched with our custom endpoint.
418
- // const provider = (globalThis as any).Analytics?.getPluggable?.('AWSPinpoint') as any;
419
- // if (!provider || typeof provider._initClients !== 'function') {
420
- // logger.error(
421
- // 'Installation of the Pinpoint proxy failed. This likely means the internals of the @aws-amplify/analytics package have changed.',
422
- // );
423
- // return;
424
- // }
425
-
426
- // const originalInitClients = provider._initClients;
427
- // const requestMiddleware: FinalizeRequestMiddleware<ServiceInputTypes, ServiceOutputTypes> =
428
- // (next) => async (args) => {
429
- // const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
430
-
431
- // if (pinpointClient && proxyUrl.pathname !== '/' && HttpRequest.isInstance(args.request)) {
432
- // // Add proxyUrl.pathname to final request url if it was provided
433
- // const shouldStripSlash = proxyUrl.pathname.endsWith('/');
434
- // args.request.path = `${proxyUrl.pathname}${args.request.path.slice(shouldStripSlash ? 1 : 0)}`;
435
-
436
- // // Wrap request body so the proxy has signing info
437
- // if (typeof args.request.body === 'string') {
438
- // const credentials = await pinpointClient.config.credentials();
439
- // args.request.body = JSON.stringify({
440
- // credentials,
441
- // data: JSON.parse(args.request.body),
442
- // });
443
- // }
444
- // }
445
-
446
- // return next(args);
447
- // };
448
-
449
- // provider._initClients = async (credentials: unknown) => {
450
- // const result = await originalInitClients.call(provider, credentials);
451
- // const pinpointClient = provider.pinpointClient as PinpointClient | undefined;
452
-
453
- // if (pinpointClient) {
454
- // pinpointClient.config.endpoint = (): Promise<Endpoint> =>
455
- // Promise.resolve({
456
- // hostname: proxyUrl.hostname,
457
- // // Passing proxyUrl.pathname here doesn't work; it gets overridden
458
- // path: '/',
459
- // port: undefined,
460
- // protocol: proxyUrl.protocol,
461
- // });
462
-
463
- // pinpointClient.middlewareStack.remove(requestMiddleware);
464
- // pinpointClient.middlewareStack.add(requestMiddleware, { step: 'finalizeRequest' });
465
- // }
466
- // return result;
467
- // };
468
- // }