@mparticle/web-sdk 2.73.0 → 2.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mparticle.common.js +32 -26
- package/dist/mparticle.esm.js +32 -26
- package/dist/mparticle.js +77 -38
- package/dist/types/src/constants.d.ts +1 -0
- package/dist/types/src/events.d.ts +1 -0
- package/dist/types/src/events.interfaces.d.ts +1 -0
- package/dist/types/src/pre-init-utils.d.ts +2 -1
- package/dist/types/src/store.d.ts +1 -0
- package/dist/types/src/utils.d.ts +2 -1
- package/package.json +1 -1
- package/src/constants.ts +1 -0
- package/src/events.interfaces.ts +1 -0
- package/src/events.js +12 -0
- package/src/identity/search.ts +3 -4
- package/src/identity-utils.ts +2 -3
- package/src/identity.js +2 -1
- package/src/identityApiClient.ts +3 -3
- package/src/mp-instance.ts +15 -3
- package/src/pre-init-utils.ts +32 -12
- package/src/roktManager.ts +20 -12
- package/src/store.ts +4 -1
- package/src/utils.ts +22 -0
package/src/roktManager.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
AttributeValue,
|
|
11
11
|
isEmpty,
|
|
12
12
|
obfuscateDevData,
|
|
13
|
+
getErrorMessage,
|
|
13
14
|
} from "./utils";
|
|
14
15
|
import { SDKIdentityApi } from "./identity.interfaces";
|
|
15
16
|
import { SDKLoggerApi } from "./sdkRuntimeModels";
|
|
@@ -338,8 +339,10 @@ export default class RoktManager {
|
|
|
338
339
|
}
|
|
339
340
|
);
|
|
340
341
|
} catch (error) {
|
|
341
|
-
|
|
342
|
-
|
|
342
|
+
this.logger.error(
|
|
343
|
+
'Background identify threw an error: ' +
|
|
344
|
+
getErrorMessage(error)
|
|
345
|
+
);
|
|
343
346
|
}
|
|
344
347
|
}
|
|
345
348
|
|
|
@@ -437,8 +440,9 @@ export default class RoktManager {
|
|
|
437
440
|
return hashedAttributes;
|
|
438
441
|
|
|
439
442
|
} catch (error) {
|
|
440
|
-
|
|
441
|
-
|
|
443
|
+
this.logger.error(
|
|
444
|
+
`Failed to hashAttributes, returning an empty object: ${getErrorMessage(error)}`
|
|
445
|
+
);
|
|
442
446
|
return {};
|
|
443
447
|
}
|
|
444
448
|
}
|
|
@@ -452,8 +456,9 @@ export default class RoktManager {
|
|
|
452
456
|
try {
|
|
453
457
|
this.kit.setExtensionData<T>(extensionData);
|
|
454
458
|
} catch (error) {
|
|
455
|
-
|
|
456
|
-
|
|
459
|
+
throw new Error(
|
|
460
|
+
'Error setting extension data: ' + getErrorMessage(error)
|
|
461
|
+
);
|
|
457
462
|
}
|
|
458
463
|
}
|
|
459
464
|
|
|
@@ -478,8 +483,9 @@ export default class RoktManager {
|
|
|
478
483
|
try {
|
|
479
484
|
this.kit.onShoppableAdsReady(callback);
|
|
480
485
|
} catch (error) {
|
|
481
|
-
|
|
482
|
-
|
|
486
|
+
this.logger.error(
|
|
487
|
+
`Failed to register onShoppableAdsReady callback: ${getErrorMessage(error)}`
|
|
488
|
+
);
|
|
483
489
|
}
|
|
484
490
|
}
|
|
485
491
|
|
|
@@ -517,8 +523,9 @@ export default class RoktManager {
|
|
|
517
523
|
const normalizedValue = String(attribute).trim().toLocaleLowerCase();
|
|
518
524
|
return await this.sha256Hex(normalizedValue);
|
|
519
525
|
} catch (error) {
|
|
520
|
-
|
|
521
|
-
|
|
526
|
+
this.logger.error(
|
|
527
|
+
`Failed to hashSha256, returning undefined: ${getErrorMessage(error)}`
|
|
528
|
+
);
|
|
522
529
|
return undefined;
|
|
523
530
|
}
|
|
524
531
|
}
|
|
@@ -607,8 +614,9 @@ export default class RoktManager {
|
|
|
607
614
|
const reject = message.reject;
|
|
608
615
|
|
|
609
616
|
const handleError = (error: unknown) => {
|
|
610
|
-
|
|
611
|
-
|
|
617
|
+
this.logger?.error(
|
|
618
|
+
`RoktManager: Error processing message '${message.methodName}': ${getErrorMessage(error)}`
|
|
619
|
+
);
|
|
612
620
|
if (reject) {
|
|
613
621
|
reject(error);
|
|
614
622
|
}
|
package/src/store.ts
CHANGED
|
@@ -151,6 +151,7 @@ export interface IFeatureFlags {
|
|
|
151
151
|
captureIntegrationSpecificIds?: boolean;
|
|
152
152
|
'captureIntegrationSpecificIds.V2'?: string;
|
|
153
153
|
astBackgroundEvents?: boolean;
|
|
154
|
+
autoLogPageView?: boolean;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
// Temporary Interface until Store can be refactored as a class
|
|
@@ -766,7 +767,8 @@ export function processFlags(config: SDKInitConfig): IFeatureFlags {
|
|
|
766
767
|
AudienceAPI,
|
|
767
768
|
CaptureIntegrationSpecificIds,
|
|
768
769
|
CaptureIntegrationSpecificIdsV2,
|
|
769
|
-
AstBackgroundEvents
|
|
770
|
+
AstBackgroundEvents,
|
|
771
|
+
AutoLogPageView
|
|
770
772
|
} = Constants.FeatureFlags;
|
|
771
773
|
|
|
772
774
|
if (!config.flags) {
|
|
@@ -787,6 +789,7 @@ export function processFlags(config: SDKInitConfig): IFeatureFlags {
|
|
|
787
789
|
flags[CaptureIntegrationSpecificIds] = config.flags[CaptureIntegrationSpecificIds] === 'True';
|
|
788
790
|
flags[CaptureIntegrationSpecificIdsV2] = (config.flags[CaptureIntegrationSpecificIdsV2] || 'none');
|
|
789
791
|
flags[AstBackgroundEvents] = config.flags[AstBackgroundEvents] === 'True';
|
|
792
|
+
flags[AutoLogPageView] = config.flags[AutoLogPageView] === 'True';
|
|
790
793
|
return flags;
|
|
791
794
|
}
|
|
792
795
|
|
package/src/utils.ts
CHANGED
|
@@ -625,6 +625,27 @@ function extend(...args: any[]): any {
|
|
|
625
625
|
return target;
|
|
626
626
|
}
|
|
627
627
|
|
|
628
|
+
const getErrorMessage = (
|
|
629
|
+
e: unknown,
|
|
630
|
+
fallback = 'unknown error'
|
|
631
|
+
): string => {
|
|
632
|
+
if (e instanceof Error) {
|
|
633
|
+
return e.message;
|
|
634
|
+
}
|
|
635
|
+
if (typeof e === 'string') {
|
|
636
|
+
return e;
|
|
637
|
+
}
|
|
638
|
+
// fetch-mock and some network libs reject with { message } rather than Error
|
|
639
|
+
if (
|
|
640
|
+
e &&
|
|
641
|
+
typeof e === 'object' &&
|
|
642
|
+
typeof (e as { message?: unknown }).message === 'string'
|
|
643
|
+
) {
|
|
644
|
+
return (e as { message: string }).message;
|
|
645
|
+
}
|
|
646
|
+
return fallback;
|
|
647
|
+
};
|
|
648
|
+
|
|
628
649
|
export {
|
|
629
650
|
createCookieString,
|
|
630
651
|
revertCookieString,
|
|
@@ -639,6 +660,7 @@ export {
|
|
|
639
660
|
generateDeprecationMessage,
|
|
640
661
|
generateHash,
|
|
641
662
|
generateUniqueId,
|
|
663
|
+
getErrorMessage,
|
|
642
664
|
getRampNumber,
|
|
643
665
|
inArray,
|
|
644
666
|
isObject,
|