@mparticle/web-sdk 2.75.0 → 2.76.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.js CHANGED
@@ -203,7 +203,7 @@ var mParticle = (function () {
203
203
  Base64: Base64$1
204
204
  };
205
205
 
206
- var version = "2.75.0";
206
+ var version = "2.76.0";
207
207
 
208
208
  var Constants = {
209
209
  sdkVersion: version,
@@ -2271,6 +2271,7 @@ var mParticle = (function () {
2271
2271
  location: convertSDKLocation(sdkEvent.Location),
2272
2272
  source_message_id: sdkEvent.SourceMessageId,
2273
2273
  active_time_on_site_ms: sdkEvent.ActiveTimeOnSite,
2274
+ total_time_on_site_ms: sdkEvent.TotalTimeOnSite,
2274
2275
  page_url: sdkEvent.PageUrl
2275
2276
  };
2276
2277
  return commonEventData;
@@ -2728,12 +2729,13 @@ var mParticle = (function () {
2728
2729
  };
2729
2730
  // https://go.mparticle.com/work/SQDSDKS-7133
2730
2731
  BatchUploader.prototype.createBackgroundASTEvent = function () {
2732
+ var _a;
2731
2733
  var now = Date.now();
2732
- var _a = this.mpInstance,
2733
- _Store = _a._Store,
2734
- Identity = _a.Identity,
2735
- _timeOnSiteTimer = _a._timeOnSiteTimer,
2736
- _Helpers = _a._Helpers;
2734
+ var _b = this.mpInstance,
2735
+ _Store = _b._Store,
2736
+ Identity = _b.Identity,
2737
+ _timeOnSiteTimer = _b._timeOnSiteTimer,
2738
+ _Helpers = _b._Helpers;
2737
2739
  var sessionId = _Store.sessionId,
2738
2740
  deviceId = _Store.deviceId,
2739
2741
  sessionStartDate = _Store.sessionStartDate,
@@ -2757,6 +2759,7 @@ var mParticle = (function () {
2757
2759
  SessionStartDate: (sessionStartDate === null || sessionStartDate === void 0 ? void 0 : sessionStartDate.getTime()) || now,
2758
2760
  Debug: SDKConfig.isDevelopmentMode,
2759
2761
  ActiveTimeOnSite: (_timeOnSiteTimer === null || _timeOnSiteTimer === void 0 ? void 0 : _timeOnSiteTimer.getTimeInForeground()) || 0,
2762
+ TotalTimeOnSite: ((_a = _Store.getTotalTimeOnSite) === null || _a === void 0 ? void 0 : _a.call(_Store)) || 0,
2760
2763
  PageUrl: getHref() || null,
2761
2764
  IsBackgroundAST: true
2762
2765
  };
@@ -4253,11 +4256,12 @@ var mParticle = (function () {
4253
4256
  return new Date().getTime() > new Date(lastSyncDate).getTime() + frequencyCap * DAYS_IN_MILLISECONDS;
4254
4257
  };
4255
4258
 
4256
- function logDeprecatedMethodUsage(usage, logger, loggingDispatcher) {
4259
+ function logDeprecatedMethodUsage(usage, logger, errorReporter) {
4257
4260
  logger.warning(usage.warningMessage);
4258
- loggingDispatcher === null || loggingDispatcher === void 0 ? void 0 : loggingDispatcher.log({
4261
+ errorReporter === null || errorReporter === void 0 ? void 0 : errorReporter.report({
4259
4262
  message: usage.methodName,
4260
- code: ErrorCodes.MP_DEPRECATED_METHOD_USAGE
4263
+ code: ErrorCodes.MP_DEPRECATED_METHOD_USAGE,
4264
+ severity: WSDKErrorSeverity.WARNING
4261
4265
  });
4262
4266
  }
4263
4267
 
@@ -4294,7 +4298,7 @@ var mParticle = (function () {
4294
4298
  logDeprecatedMethodUsage({
4295
4299
  methodName: 'SessionManager.getSession()',
4296
4300
  warningMessage: generateDeprecationMessage('SessionManager.getSession()', false, 'SessionManager.getSessionId()')
4297
- }, mpInstance.Logger, mpInstance._LoggingDispatcher);
4301
+ }, mpInstance.Logger, mpInstance._ErrorReportingDispatcher);
4298
4302
  return this.getSessionId();
4299
4303
  };
4300
4304
  this.getSessionId = function () {
@@ -5350,6 +5354,9 @@ var mParticle = (function () {
5350
5354
  var _a;
5351
5355
  return (_a = mpInstance._timeOnSiteTimer) === null || _a === void 0 ? void 0 : _a.getTimeInForeground();
5352
5356
  };
5357
+ this.getTotalTimeOnSite = function () {
5358
+ return _this.sessionStartDate ? Date.now() - _this.sessionStartDate.getTime() : undefined;
5359
+ };
5353
5360
  this.addMpidToSessionHistory = function (mpid, previousMPID) {
5354
5361
  var indexOfMPID = _this.currentSessionMPIDs.indexOf(mpid);
5355
5362
  if (mpid && previousMPID !== mpid && indexOfMPID < 0) {
@@ -7613,7 +7620,7 @@ var mParticle = (function () {
7613
7620
  return jsonObject;
7614
7621
  };
7615
7622
  this.createEventObject = function (event, user) {
7616
- var _a;
7623
+ var _a, _b, _c;
7617
7624
  var uploadObject = {};
7618
7625
  var eventObject = {};
7619
7626
  // The `optOut` variable is passed later in this method to the `uploadObject`
@@ -7651,6 +7658,7 @@ var mParticle = (function () {
7651
7658
  EventCategory: event.eventType,
7652
7659
  EventAttributes: mpInstance._Helpers.sanitizeAttributes(event.data, event.name),
7653
7660
  ActiveTimeOnSite: (_a = mpInstance._timeOnSiteTimer) === null || _a === void 0 ? void 0 : _a.getTimeInForeground(),
7661
+ TotalTimeOnSite: (_c = (_b = mpInstance._Store).getTotalTimeOnSite) === null || _c === void 0 ? void 0 : _c.call(_b),
7654
7662
  PageUrl: getHref() || null,
7655
7663
  SourceMessageId: event.sourceMessageId || mpInstance._Helpers.generateUniqueId(),
7656
7664
  EventDataType: event.messageType,
@@ -8781,7 +8789,7 @@ var mParticle = (function () {
8781
8789
  logDeprecatedMethodUsage({
8782
8790
  methodName: 'Identity.getCurrentUser().getCart()',
8783
8791
  warningMessage: 'Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases'
8784
- }, mpInstance.Logger, mpInstance._LoggingDispatcher);
8792
+ }, mpInstance.Logger, mpInstance._ErrorReportingDispatcher);
8785
8793
  return self.mParticleUserCart();
8786
8794
  },
8787
8795
  /**
@@ -8848,7 +8856,7 @@ var mParticle = (function () {
8848
8856
  logDeprecatedMethodUsage({
8849
8857
  methodName: 'Identity.getCurrentUser().getCart().add()',
8850
8858
  warningMessage: generateDeprecationMessage('Identity.getCurrentUser().getCart().add()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking')
8851
- }, mpInstance.Logger, mpInstance._LoggingDispatcher);
8859
+ }, mpInstance.Logger, mpInstance._ErrorReportingDispatcher);
8852
8860
  },
8853
8861
  /**
8854
8862
  * Removes a cart product from the current user cart
@@ -8859,7 +8867,7 @@ var mParticle = (function () {
8859
8867
  logDeprecatedMethodUsage({
8860
8868
  methodName: 'Identity.getCurrentUser().getCart().remove()',
8861
8869
  warningMessage: generateDeprecationMessage('Identity.getCurrentUser().getCart().remove()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking')
8862
- }, mpInstance.Logger, mpInstance._LoggingDispatcher);
8870
+ }, mpInstance.Logger, mpInstance._ErrorReportingDispatcher);
8863
8871
  },
8864
8872
  /**
8865
8873
  * Clears the user's cart
@@ -8870,7 +8878,7 @@ var mParticle = (function () {
8870
8878
  logDeprecatedMethodUsage({
8871
8879
  methodName: 'Identity.getCurrentUser().getCart().clear()',
8872
8880
  warningMessage: generateDeprecationMessage('Identity.getCurrentUser().getCart().clear()', true, '', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking')
8873
- }, mpInstance.Logger, mpInstance._LoggingDispatcher);
8881
+ }, mpInstance.Logger, mpInstance._ErrorReportingDispatcher);
8874
8882
  },
8875
8883
  /**
8876
8884
  * Returns all cart products
@@ -8882,7 +8890,7 @@ var mParticle = (function () {
8882
8890
  logDeprecatedMethodUsage({
8883
8891
  methodName: 'Identity.getCurrentUser().getCart().getCartProducts()',
8884
8892
  warningMessage: generateDeprecationMessage('Identity.getCurrentUser().getCart().getCartProducts()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking')
8885
- }, mpInstance.Logger, mpInstance._LoggingDispatcher);
8893
+ }, mpInstance.Logger, mpInstance._ErrorReportingDispatcher);
8886
8894
  return [];
8887
8895
  }
8888
8896
  };
@@ -8955,7 +8963,7 @@ var mParticle = (function () {
8955
8963
  newUser = mpInstance.Identity.getCurrentUser();
8956
8964
 
8957
8965
  // https://go.mparticle.com/work/SQDSDKS-6359
8958
- tryOnUserAlias(prevUser, newUser, identityApiData, mpInstance.Logger, mpInstance._LoggingDispatcher);
8966
+ tryOnUserAlias(prevUser, newUser, identityApiData, mpInstance.Logger, mpInstance._ErrorReportingDispatcher);
8959
8967
  var persistence = mpInstance._Persistence.getPersistence();
8960
8968
  if (newUser) {
8961
8969
  mpInstance._Persistence.storeDataInMemory(persistence, newUser.getMPID());
@@ -9088,13 +9096,13 @@ var mParticle = (function () {
9088
9096
  }
9089
9097
 
9090
9098
  // https://go.mparticle.com/work/SQDSDKS-6359
9091
- function tryOnUserAlias(previousUser, newUser, identityApiData, logger, loggingDispatcher) {
9099
+ function tryOnUserAlias(previousUser, newUser, identityApiData, logger, errorReporter) {
9092
9100
  if (identityApiData && identityApiData.onUserAlias && isFunction(identityApiData.onUserAlias)) {
9093
9101
  try {
9094
9102
  logDeprecatedMethodUsage({
9095
9103
  methodName: 'onUserAlias',
9096
9104
  warningMessage: generateDeprecationMessage('onUserAlias')
9097
- }, logger, loggingDispatcher);
9105
+ }, logger, errorReporter);
9098
9106
  identityApiData.onUserAlias(previousUser, newUser);
9099
9107
  } catch (e) {
9100
9108
  logger.error('There was an error with your onUserAlias function - ' + e);
@@ -9378,7 +9386,7 @@ var mParticle = (function () {
9378
9386
  logDeprecatedMethodUsage({
9379
9387
  methodName: 'Consent.removeCCPAState',
9380
9388
  warningMessage: 'removeCCPAState is deprecated and will be removed in a future release; use removeCCPAConsentState instead'
9381
- }, mpInstance.Logger, mpInstance._LoggingDispatcher);
9389
+ }, mpInstance.Logger, mpInstance._ErrorReportingDispatcher);
9382
9390
  // @ts-ignore
9383
9391
  return removeCCPAConsentState();
9384
9392
  }
@@ -10619,11 +10627,11 @@ var mParticle = (function () {
10619
10627
  * });
10620
10628
  */
10621
10629
  RoktManager.prototype.selectPlacements = function (options) {
10622
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
10630
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
10623
10631
  return __awaiter(this, void 0, void 0, function () {
10624
- var attributes, sandboxValue, mappedAttributes, attributesToLog, currentUserIdentities, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities, msg, msg, finalUserIdentities, timeOnSite, enrichedAttributes, hashedEmail, capturedAttrs, passbackId, enrichedOptions;
10632
+ var attributes, sandboxValue, mappedAttributes, attributesToLog, currentUserIdentities, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities, msg, msg, finalUserIdentities, timeOnSite, totalTimeOnSite, enrichedAttributes, hashedEmail, capturedAttrs, passbackId, enrichedOptions;
10625
10633
  var _this = this;
10626
- return __generator(this, function (_q) {
10634
+ return __generator(this, function (_s) {
10627
10635
  (_a = this.captureTiming) === null || _a === void 0 ? void 0 : _a.call(this, PerformanceMarkType.JointSdkSelectPlacements);
10628
10636
  // Queue if kit isn't ready OR if identity is in flight
10629
10637
  if (!this.isReady() || ((_b = this.store) === null || _b === void 0 ? void 0 : _b.identityCallInFlight)) {
@@ -10695,10 +10703,13 @@ var mParticle = (function () {
10695
10703
  finalUserIdentities = __assign(__assign({}, currentUserIdentities), newIdentities);
10696
10704
  this.setUserAttributes(mappedAttributes);
10697
10705
  timeOnSite = (_l = (_k = this.store) === null || _k === void 0 ? void 0 : _k.getTimeOnSite) === null || _l === void 0 ? void 0 : _l.call(_k);
10698
- enrichedAttributes = __assign(__assign(__assign({}, mappedAttributes), sandboxValue !== null ? {
10706
+ totalTimeOnSite = (_o = (_m = this.store) === null || _m === void 0 ? void 0 : _m.getTotalTimeOnSite) === null || _o === void 0 ? void 0 : _o.call(_m);
10707
+ enrichedAttributes = __assign(__assign(__assign(__assign({}, mappedAttributes), sandboxValue !== null ? {
10699
10708
  sandbox: sandboxValue
10700
10709
  } : {}), timeOnSite ? {
10701
10710
  active_time_on_site_ms: timeOnSite
10711
+ } : {}), totalTimeOnSite ? {
10712
+ total_time_on_site_ms: totalTimeOnSite
10702
10713
  } : {});
10703
10714
  // Propagate email from current user identities if not already in attributes
10704
10715
  if (finalUserIdentities.email && !enrichedAttributes.email) {
@@ -10712,9 +10723,9 @@ var mParticle = (function () {
10712
10723
  }
10713
10724
  }
10714
10725
  if (!enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID]) {
10715
- (_m = this.integrationCapture) === null || _m === void 0 ? void 0 : _m.capture();
10716
- capturedAttrs = (_o = this.integrationCapture) === null || _o === void 0 ? void 0 : _o.getClickIdsAsIntegrationAttributes();
10717
- passbackId = (_p = capturedAttrs === null || capturedAttrs === void 0 ? void 0 : capturedAttrs[PARTNER_MODULE_IDS.Rokt]) === null || _p === void 0 ? void 0 : _p[PASSBACK_CONVERSION_TRACKING_ID];
10726
+ (_p = this.integrationCapture) === null || _p === void 0 ? void 0 : _p.capture();
10727
+ capturedAttrs = (_q = this.integrationCapture) === null || _q === void 0 ? void 0 : _q.getClickIdsAsIntegrationAttributes();
10728
+ passbackId = (_r = capturedAttrs === null || capturedAttrs === void 0 ? void 0 : capturedAttrs[PARTNER_MODULE_IDS.Rokt]) === null || _r === void 0 ? void 0 : _r[PASSBACK_CONVERSION_TRACKING_ID];
10718
10729
  if (passbackId) {
10719
10730
  enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID] = passbackId;
10720
10731
  }
@@ -11688,7 +11699,7 @@ var mParticle = (function () {
11688
11699
  logDeprecatedMethodUsage({
11689
11700
  methodName: 'mPInstance.eCommerce.Cart.add()',
11690
11701
  warningMessage: generateDeprecationMessage('eCommerce.Cart.add()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking')
11691
- }, self.Logger, self._LoggingDispatcher);
11702
+ }, self.Logger, self._ErrorReportingDispatcher);
11692
11703
  },
11693
11704
  /**
11694
11705
  * Removes a product from the cart
@@ -11701,7 +11712,7 @@ var mParticle = (function () {
11701
11712
  logDeprecatedMethodUsage({
11702
11713
  methodName: 'mPInstance.eCommerce.Cart.remove()',
11703
11714
  warningMessage: generateDeprecationMessage('eCommerce.Cart.remove()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking')
11704
- }, self.Logger, self._LoggingDispatcher);
11715
+ }, self.Logger, self._ErrorReportingDispatcher);
11705
11716
  },
11706
11717
  /**
11707
11718
  * Clears the cart
@@ -11712,7 +11723,7 @@ var mParticle = (function () {
11712
11723
  logDeprecatedMethodUsage({
11713
11724
  methodName: 'mPInstance.eCommerce.Cart.clear()',
11714
11725
  warningMessage: generateDeprecationMessage('eCommerce.Cart.clear()', true, '', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking')
11715
- }, self.Logger, self._LoggingDispatcher);
11726
+ }, self.Logger, self._ErrorReportingDispatcher);
11716
11727
  }
11717
11728
  },
11718
11729
  /**
@@ -11801,7 +11812,7 @@ var mParticle = (function () {
11801
11812
  logDeprecatedMethodUsage({
11802
11813
  methodName: 'mParticle.logCheckout',
11803
11814
  warningMessage: 'mParticle.logCheckout is deprecated, please use mParticle.logProductAction instead'
11804
- }, self.Logger, self._LoggingDispatcher);
11815
+ }, self.Logger, self._ErrorReportingDispatcher);
11805
11816
  if (!self._Store.isInitialized) {
11806
11817
  self.ready(function () {
11807
11818
  self.eCommerce.logCheckout(step, option, attrs, customFlags);
@@ -11845,7 +11856,7 @@ var mParticle = (function () {
11845
11856
  logDeprecatedMethodUsage({
11846
11857
  methodName: 'mParticle.logPurchase',
11847
11858
  warningMessage: 'mParticle.logPurchase is deprecated, please use mParticle.logProductAction instead'
11848
- }, self.Logger, self._LoggingDispatcher);
11859
+ }, self.Logger, self._ErrorReportingDispatcher);
11849
11860
  if (!self._Store.isInitialized) {
11850
11861
  self.ready(function () {
11851
11862
  self.eCommerce.logPurchase(transactionAttributes, product, clearCart, attrs, customFlags);
@@ -11909,7 +11920,7 @@ var mParticle = (function () {
11909
11920
  logDeprecatedMethodUsage({
11910
11921
  methodName: 'mParticle.logRefund',
11911
11922
  warningMessage: 'mParticle.logRefund is deprecated, please use mParticle.logProductAction instead'
11912
- }, self.Logger, self._LoggingDispatcher);
11923
+ }, self.Logger, self._ErrorReportingDispatcher);
11913
11924
  if (!self._Store.isInitialized) {
11914
11925
  self.ready(function () {
11915
11926
  self.eCommerce.logRefund(transactionAttributes, product, clearCart, attrs, customFlags);
@@ -12460,7 +12471,8 @@ var mParticle = (function () {
12460
12471
  SDKConfig: {
12461
12472
  isDevelopmentMode: false,
12462
12473
  onCreateBatch: mockFunction
12463
- }
12474
+ },
12475
+ getTotalTimeOnSite: mockFunction
12464
12476
  },
12465
12477
  config: null,
12466
12478
  eCommerce: null,
@@ -66,6 +66,7 @@ export default class KitBlocker {
66
66
  LaunchReferral?: string;
67
67
  ExpandedEventCount: number;
68
68
  ActiveTimeOnSite: number;
69
+ TotalTimeOnSite: number;
69
70
  PageUrl?: string;
70
71
  IsBackgroundAST?: boolean;
71
72
  AlreadySentToForwarders?: boolean;
@@ -111,6 +112,7 @@ export default class KitBlocker {
111
112
  LaunchReferral?: string;
112
113
  ExpandedEventCount: number;
113
114
  ActiveTimeOnSite: number;
115
+ TotalTimeOnSite: number;
114
116
  PageUrl?: string;
115
117
  IsBackgroundAST?: boolean;
116
118
  AlreadySentToForwarders?: boolean;
@@ -1,8 +1,8 @@
1
- import { ILoggingService } from './types';
1
+ import { IErrorReportingService } from './types';
2
2
  import { SDKLoggerApi } from '../sdkRuntimeModels';
3
3
  interface DeprecatedMethodUsage {
4
4
  methodName: string;
5
5
  warningMessage: string;
6
6
  }
7
- export declare function logDeprecatedMethodUsage(usage: DeprecatedMethodUsage, logger: Pick<SDKLoggerApi, 'warning'>, loggingDispatcher: ILoggingService | undefined): void;
7
+ export declare function logDeprecatedMethodUsage(usage: DeprecatedMethodUsage, logger: Pick<SDKLoggerApi, 'warning'>, errorReporter: IErrorReportingService | undefined): void;
8
8
  export {};
@@ -60,6 +60,7 @@ export interface SDKEvent {
60
60
  LaunchReferral?: string;
61
61
  ExpandedEventCount: number;
62
62
  ActiveTimeOnSite: number;
63
+ TotalTimeOnSite: number;
63
64
  PageUrl?: string;
64
65
  IsBackgroundAST?: boolean;
65
66
  AlreadySentToForwarders?: boolean;
@@ -146,6 +146,7 @@ export interface IStore {
146
146
  getRoktAccountId?(): string;
147
147
  setRoktAccountId?(accountId: string): void;
148
148
  getTimeOnSite?(): number | undefined;
149
+ getTotalTimeOnSite?(): number | undefined;
149
150
  getIntegrationName?(): string;
150
151
  setIntegrationName?(integrationName: string): void;
151
152
  addMpidToSessionHistory?(mpid: MPID, previousMpid?: MPID): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.75.0",
3
+ "version": "2.76.0",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -103,7 +103,7 @@
103
103
  "@babel/preset-env": "^7.6.0",
104
104
  "@babel/preset-typescript": "^7.6.0",
105
105
  "@mparticle/data-planning-models": "^0.1.0",
106
- "@mparticle/event-models": "^1.3.0",
106
+ "@mparticle/event-models": "^1.3.1",
107
107
  "@rollup/plugin-babel": "6.0.3",
108
108
  "@rollup/plugin-commonjs": "25.0.4",
109
109
  "@rollup/plugin-json": "^5.0.2",
@@ -159,7 +159,7 @@
159
159
  "webpack-cli": "^5.0.2"
160
160
  },
161
161
  "peerDependencies": {
162
- "@mparticle/event-models": "^1.3.0"
162
+ "@mparticle/event-models": "^1.3.1"
163
163
  },
164
164
  "dependencies": {
165
165
  "@babel/runtime": "^7.23.2"
@@ -197,6 +197,7 @@ export class BatchUploader {
197
197
  SessionStartDate: sessionStartDate?.getTime() || now,
198
198
  Debug: SDKConfig.isDevelopmentMode,
199
199
  ActiveTimeOnSite: _timeOnSiteTimer?.getTimeInForeground() || 0,
200
+ TotalTimeOnSite: _Store.getTotalTimeOnSite?.() || 0,
200
201
  PageUrl: getHref() || null,
201
202
  IsBackgroundAST: true
202
203
  } as SDKEvent;
package/src/consent.ts CHANGED
@@ -512,7 +512,7 @@ export default function Consent(this: IConsent, mpInstance: IMParticleWebSDKInst
512
512
  warningMessage: 'removeCCPAState is deprecated and will be removed in a future release; use removeCCPAConsentState instead',
513
513
  },
514
514
  mpInstance.Logger,
515
- mpInstance._LoggingDispatcher
515
+ mpInstance._ErrorReportingDispatcher
516
516
  );
517
517
  // @ts-ignore
518
518
  return removeCCPAConsentState();
package/src/identity.js CHANGED
@@ -1260,7 +1260,7 @@ export default function Identity(mpInstance) {
1260
1260
  'Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases',
1261
1261
  },
1262
1262
  mpInstance.Logger,
1263
- mpInstance._LoggingDispatcher
1263
+ mpInstance._ErrorReportingDispatcher
1264
1264
  );
1265
1265
  return self.mParticleUserCart();
1266
1266
  },
@@ -1352,7 +1352,7 @@ export default function Identity(mpInstance) {
1352
1352
  ),
1353
1353
  },
1354
1354
  mpInstance.Logger,
1355
- mpInstance._LoggingDispatcher
1355
+ mpInstance._ErrorReportingDispatcher
1356
1356
  );
1357
1357
  },
1358
1358
  /**
@@ -1373,7 +1373,7 @@ export default function Identity(mpInstance) {
1373
1373
  ),
1374
1374
  },
1375
1375
  mpInstance.Logger,
1376
- mpInstance._LoggingDispatcher
1376
+ mpInstance._ErrorReportingDispatcher
1377
1377
  );
1378
1378
  },
1379
1379
  /**
@@ -1394,7 +1394,7 @@ export default function Identity(mpInstance) {
1394
1394
  ),
1395
1395
  },
1396
1396
  mpInstance.Logger,
1397
- mpInstance._LoggingDispatcher
1397
+ mpInstance._ErrorReportingDispatcher
1398
1398
  );
1399
1399
  },
1400
1400
  /**
@@ -1416,7 +1416,7 @@ export default function Identity(mpInstance) {
1416
1416
  ),
1417
1417
  },
1418
1418
  mpInstance.Logger,
1419
- mpInstance._LoggingDispatcher
1419
+ mpInstance._ErrorReportingDispatcher
1420
1420
  );
1421
1421
  return [];
1422
1422
  },
@@ -1571,7 +1571,7 @@ export default function Identity(mpInstance) {
1571
1571
  newUser,
1572
1572
  identityApiData,
1573
1573
  mpInstance.Logger,
1574
- mpInstance._LoggingDispatcher
1574
+ mpInstance._ErrorReportingDispatcher
1575
1575
  );
1576
1576
 
1577
1577
  const persistence = mpInstance._Persistence.getPersistence();
@@ -1812,7 +1812,7 @@ function tryOnUserAlias(
1812
1812
  newUser,
1813
1813
  identityApiData,
1814
1814
  logger,
1815
- loggingDispatcher
1815
+ errorReporter
1816
1816
  ) {
1817
1817
  if (
1818
1818
  identityApiData &&
@@ -1826,7 +1826,7 @@ function tryOnUserAlias(
1826
1826
  warningMessage: generateDeprecationMessage('onUserAlias'),
1827
1827
  },
1828
1828
  logger,
1829
- loggingDispatcher
1829
+ errorReporter
1830
1830
  );
1831
1831
  identityApiData.onUserAlias(previousUser, newUser);
1832
1832
  } catch (e) {
@@ -91,6 +91,7 @@ export default class _BatchValidator {
91
91
  isDevelopmentMode: false,
92
92
  onCreateBatch: mockFunction,
93
93
  },
94
+ getTotalTimeOnSite: mockFunction,
94
95
  },
95
96
  config: null,
96
97
  eCommerce: null,
@@ -792,7 +792,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
792
792
  ),
793
793
  },
794
794
  self.Logger,
795
- self._LoggingDispatcher
795
+ self._ErrorReportingDispatcher
796
796
  );
797
797
  },
798
798
  /**
@@ -814,7 +814,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
814
814
  ),
815
815
  },
816
816
  self.Logger,
817
- self._LoggingDispatcher
817
+ self._ErrorReportingDispatcher
818
818
  );
819
819
  },
820
820
  /**
@@ -834,7 +834,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
834
834
  ),
835
835
  },
836
836
  self.Logger,
837
- self._LoggingDispatcher
837
+ self._ErrorReportingDispatcher
838
838
  );
839
839
  },
840
840
  },
@@ -970,7 +970,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
970
970
  warningMessage: 'mParticle.logCheckout is deprecated, please use mParticle.logProductAction instead',
971
971
  },
972
972
  self.Logger,
973
- self._LoggingDispatcher
973
+ self._ErrorReportingDispatcher
974
974
  );
975
975
 
976
976
  if (!self._Store.isInitialized) {
@@ -1055,7 +1055,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
1055
1055
  warningMessage: 'mParticle.logPurchase is deprecated, please use mParticle.logProductAction instead',
1056
1056
  },
1057
1057
  self.Logger,
1058
- self._LoggingDispatcher
1058
+ self._ErrorReportingDispatcher
1059
1059
  );
1060
1060
  if (!self._Store.isInitialized) {
1061
1061
  self.ready(function() {
@@ -1172,7 +1172,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
1172
1172
  warningMessage: 'mParticle.logRefund is deprecated, please use mParticle.logProductAction instead',
1173
1173
  },
1174
1174
  self.Logger,
1175
- self._LoggingDispatcher
1175
+ self._ErrorReportingDispatcher
1176
1176
  );
1177
1177
  if (!self._Store.isInitialized) {
1178
1178
  self.ready(function() {
@@ -1,4 +1,4 @@
1
- import { ErrorCodes, ILoggingService } from './types';
1
+ import { ErrorCodes, IErrorReportingService, WSDKErrorSeverity } from './types';
2
2
  import { SDKLoggerApi } from '../sdkRuntimeModels';
3
3
 
4
4
  interface DeprecatedMethodUsage {
@@ -9,11 +9,12 @@ interface DeprecatedMethodUsage {
9
9
  export function logDeprecatedMethodUsage(
10
10
  usage: DeprecatedMethodUsage,
11
11
  logger: Pick<SDKLoggerApi, 'warning'>,
12
- loggingDispatcher: ILoggingService | undefined
12
+ errorReporter: IErrorReportingService | undefined
13
13
  ): void {
14
14
  logger.warning(usage.warningMessage);
15
- loggingDispatcher?.log({
15
+ errorReporter?.report({
16
16
  message: usage.methodName,
17
17
  code: ErrorCodes.MP_DEPRECATED_METHOD_USAGE,
18
+ severity: WSDKErrorSeverity.WARNING,
18
19
  });
19
20
  }
@@ -355,11 +355,13 @@ export default class RoktManager {
355
355
  this.setUserAttributes(mappedAttributes);
356
356
 
357
357
  const timeOnSite = this.store?.getTimeOnSite?.();
358
+ const totalTimeOnSite = this.store?.getTotalTimeOnSite?.();
358
359
 
359
360
  const enrichedAttributes: RoktAttributes = {
360
361
  ...mappedAttributes,
361
362
  ...(sandboxValue !== null ? { sandbox: sandboxValue } : {}),
362
363
  ...(timeOnSite ? { active_time_on_site_ms: timeOnSite } : {}),
364
+ ...(totalTimeOnSite ? { total_time_on_site_ms: totalTimeOnSite } : {}),
363
365
  };
364
366
 
365
367
  // Propagate email from current user identities if not already in attributes
@@ -94,6 +94,7 @@ export interface SDKEvent {
94
94
  LaunchReferral?: string;
95
95
  ExpandedEventCount: number;
96
96
  ActiveTimeOnSite: number;
97
+ TotalTimeOnSite: number;
97
98
  PageUrl?: string;
98
99
  IsBackgroundAST?: boolean;
99
100
  AlreadySentToForwarders?: boolean;
@@ -664,6 +664,7 @@ export function convertBaseEventData(
664
664
  location: convertSDKLocation(sdkEvent.Location),
665
665
  source_message_id: sdkEvent.SourceMessageId,
666
666
  active_time_on_site_ms: sdkEvent.ActiveTimeOnSite,
667
+ total_time_on_site_ms: sdkEvent.TotalTimeOnSite,
667
668
  page_url: sdkEvent.PageUrl,
668
669
  };
669
670
 
@@ -311,6 +311,7 @@ export default function ServerModel(
311
311
  event.name
312
312
  ),
313
313
  ActiveTimeOnSite: mpInstance._timeOnSiteTimer?.getTimeInForeground(),
314
+ TotalTimeOnSite: mpInstance._Store.getTotalTimeOnSite?.(),
314
315
  PageUrl: getHref() || null,
315
316
  SourceMessageId:
316
317
  event.sourceMessageId ||
@@ -78,7 +78,7 @@ export default function SessionManager(
78
78
  ),
79
79
  },
80
80
  mpInstance.Logger,
81
- mpInstance._LoggingDispatcher
81
+ mpInstance._ErrorReportingDispatcher
82
82
  );
83
83
  return this.getSessionId();
84
84
  };
package/src/store.ts CHANGED
@@ -233,6 +233,7 @@ export interface IStore {
233
233
  getRoktAccountId?(): string;
234
234
  setRoktAccountId?(accountId: string): void;
235
235
  getTimeOnSite?(): number | undefined;
236
+ getTotalTimeOnSite?(): number | undefined;
236
237
  getIntegrationName?(): string;
237
238
  setIntegrationName?(integrationName: string): void;
238
239
 
@@ -687,6 +688,11 @@ export default function Store(
687
688
  this.getTimeOnSite = () =>
688
689
  mpInstance._timeOnSiteTimer?.getTimeInForeground();
689
690
 
691
+ this.getTotalTimeOnSite = () =>
692
+ this.sessionStartDate
693
+ ? Date.now() - this.sessionStartDate.getTime()
694
+ : undefined;
695
+
690
696
  this.addMpidToSessionHistory = (mpid: MPID, previousMPID?: MPID): void => {
691
697
  const indexOfMPID = this.currentSessionMPIDs.indexOf(mpid);
692
698