@mparticle/web-sdk 2.26.6 → 2.26.7

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.
@@ -0,0 +1,25 @@
1
+ import { IMParticleUser, IdentityResultBody } from './identity-user-interfaces';
2
+
3
+ export function hasMPIDAndUserLoginChanged(
4
+ previousUser: IMParticleUser,
5
+ newUser: IMParticleUser
6
+ ): boolean {
7
+ return (
8
+ !previousUser ||
9
+ newUser.getMPID() !== previousUser.getMPID() ||
10
+ previousUser.isLoggedIn() !== newUser.isLoggedIn()
11
+ );
12
+ }
13
+
14
+ // https://go.mparticle.com/work/SQDSDKS-6504
15
+ export function hasMPIDChanged(
16
+ prevUser: IMParticleUser,
17
+ identityApiResult: IdentityResultBody
18
+ ): boolean {
19
+ return (
20
+ !prevUser ||
21
+ (prevUser.getMPID() &&
22
+ identityApiResult.mpid &&
23
+ identityApiResult.mpid !== prevUser.getMPID())
24
+ );
25
+ }
package/src/utils.ts CHANGED
@@ -229,6 +229,9 @@ const mergeObjects = <T extends object>(...objects: T[]): T => {
229
229
  return Object.assign({}, ...objects);
230
230
  };
231
231
 
232
+ const moveElementToEnd = <T>(array: T[], index: number): T[] =>
233
+ array.slice(0, index).concat(array.slice(index + 1), array[index]);
234
+
232
235
  export {
233
236
  createCookieString,
234
237
  revertCookieString,
@@ -258,4 +261,5 @@ export {
258
261
  isEmpty,
259
262
  isValidCustomFlagProperty,
260
263
  mergeObjects,
264
+ moveElementToEnd,
261
265
  };