Skip to content

Commit 2fc817e

Browse files
hardikmashruhani-iterablehardikmashrudarshan-iterablemprew97
authored
AUT Feature (#404)
* Integrate AUT feature (#301) * merge fork repo code and implement anon session * resolve test cases failure * call API for getting criteria * track anon event and purchase * track anon update cart and user * write test cases * resolve test cases failure for autjorization * modify anonymous manager class * modify test cases * update the lock files * implement criteria completion checker * implement user merge and set config * set config * Complete AUT feature * Resolve review comments * implement test case for merge user * unit test case for anon user event tracking * test case for criteria completion checker * resolve build failure * resolve build failure * resolve review comments * remove circular dependency * remove lock file * resolve review comments * Add user object to trackanonsession and create user after live/valid criteria met (#346) * aut changes * pushed files temporarily * some updates for AUT fixes * updates * Criteria bugs fixed * Criteria bugs fixed * Criteria bugs fixed * Criteria bugs fixed * event test undo * Update events.ts * updateuser changes * updates * more fixes and updates * Authorization test file fixed * Fixed destination email case * Sync events in case of anon user not created and developer tries to call setUserId/setEmail * Handle updateCart flow separately for Anon event and when syncing data * Fixed all the test file with authorixation and annon user event manager * Fixed JWT case * removed logs and did some improvements * fixed some circular dependencies * keep current identity of anon user if merge fails * logic changes for criteria * Simple min match works * Not check event again when matched criteria * Fixed event stored in local as it is and remove criteria id when sync * remove criteria id from events if not available in criteria list when refresh * JWT changes added in example * Authorization changes pushed * Authorization test fxed * Fixed comments * Create new AUT example * Update setUserId * webpack updated * Fixed test files * remove criteria from utils * Test file is fixed and criteria matched * Remove logs * Revert Users and Commerce changes * Fixed import circular dependency * Fixed circular dependancy * Update imports * Reverted eventform * Fixed circular dependency * more fixes * Update webpack.config.js * fixed some suggestions * Fixed comment * Fixed single item matches code (#410) * Fixed single item matches code * Fixed comments * added more unit tests, bug fixes --------- Co-authored-by: hardikmashru <[email protected]> * Add merge param (#414) * Fixed single item matches code * Fixed comments * Add merge parameter to the setEmail/setUserId function * added unit tests for merge and did some improvements * Fixed comments --------- Co-authored-by: hardikmashru <[email protected]> * MOB 8960 (#415) * Fixed single item matches code * Fixed comments * added more unit tests, bug fixes * Not combinator implemented * evaluateEvent added not combinator * minMatch changes revert * minMatch implemented * complex criteria tests, not combinator, evaluateFieldLogic fix --------- Co-authored-by: hardikmashru <[email protected]> * Isset purchase update fix (#416) * Fixed single item matches code * Fixed comments * added more unit tests, bug fixes * Not combinator implemented * evaluateEvent added not combinator * minMatch changes revert * minMatch implemented * complex criteria tests, not combinator, evaluateFieldLogic fix * Isset fix and unit tests * update cart and custom event fix, unit tests * little changes * doesItemMatchQueries fix * isset fail & min-max tests, * Replace for loop with array methods * added sampleTest1 * Set type annotations for issetCheck --------- Co-authored-by: hardikmashru <[email protected]> * Fixed bools needs to be string (#422) * MOB-9055: Resolve nested criteria match issue (#423) * MOB-9055: Resolve nested criteria match issue * converted an array operator as opposed to a for-loop * MOB-9138: Resolves DoesNotEqual criteria match issue (#426) * Merge branch 'main' into AUT_main 2606561 * revert back eslint rule * Resolve path related error * [MOB-9258] fixed nested IsSet matching (#427) * Fixed scenario where a IsSet criteria is on the object and there is also a IsSet criteria on the nested json * remove unnecessary method call for never happen scenario * revert back eslint rule --------- Co-authored-by: hani <[email protected]> * MOB-9305: fixed events createdAt timeStamps (#431) * MOB-9168: Written automated unit tests against Combination logic with Event Type (#429) * MOB-8824: Added limitation to event storage (#430) * MOB-8824: Added limitation to event storage * fix: build issue * Nested custom event check related change (#432) * MOB 9328 - Verify AUT works with JWT (#437) * implement code for generate JWT token * revert back the eslint rule * MOB 9149 - Sample app object updates not formatted properly (#438) * resolve nested criteria obj error * modify test case * MOB-9308: supports nested field types (#439) * MOB-9308: supports nested field types * fix: linting issue * MOB-9081: Written automated unit tests for different field types and … (#436) * MOB-9081: Written automated unit tests for different field types and comparator types * made criterias to be re-usable * fully supports comparison for data in Array data with all comparator types (#444) * MOB 9328 add JWT in response (#441) * added line for pass JWT to response * revert back code for server side revert back the code for generate JWT server side as per review comment * revert eslint rule * updated nested field logic (#445) * updated nested field logic * Resolved typo * resolved conflicts * MOB-9145: support isOneOf and isNotOneOf comparator (#446) * fully supports comparison for data in Array data with all comparator types * MOB-9145: support isOneOf and isNotOneOf comparator * fix: trailing spaces issue * [MOB-9522]: Fix JWT UserID Support (#452) * [DOCS-4818] EUDC instructions update (#428) * EUDC instructions update * Formatting * Bump braces from 3.0.2 to 3.0.3 (#406) Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3. - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md) - [Commits](micromatch/braces@3.0.2...3.0.3) --- updated-dependencies: - dependency-name: braces dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump ws from 7.5.9 to 7.5.10 (#409) Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](websockets/ws@7.5.9...7.5.10) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump axios from 1.6.2 to 1.7.4 (#433) Bumps [axios](https://github.com/axios/axios) from 1.6.2 to 1.7.4. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) - [Commits](axios/axios@v1.6.2...v1.7.4) --- updated-dependencies: - dependency-name: axios dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump postcss from 8.3.11 to 8.4.31 (#235) * Bump postcss from 8.3.11 to 8.4.31 Bumps [postcss](https://github.com/postcss/postcss) from 8.3.11 to 8.4.31. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](postcss/postcss@8.3.11...8.4.31) --- updated-dependencies: - dependency-name: postcss dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * fix spaces --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mitch Prewitt <[email protected]> * Bump braces from 3.0.2 to 3.0.3 in /example (#434) Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3. - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md) - [Commits](micromatch/braces@3.0.2...3.0.3) --- updated-dependencies: - dependency-name: braces dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump requirejs from 2.3.6 to 2.3.7 (#435) Bumps [requirejs](https://github.com/jrburke/r.js) from 2.3.6 to 2.3.7. - [Commits](requirejs/r.js@2.3.6...2.3.7) --- updated-dependencies: - dependency-name: requirejs dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump micromatch from 4.0.5 to 4.0.8 in /example (#447) Bumps [micromatch](https://github.com/micromatch/micromatch) from 4.0.5 to 4.0.8. - [Release notes](https://github.com/micromatch/micromatch/releases) - [Changelog](https://github.com/micromatch/micromatch/blob/master/CHANGELOG.md) - [Commits](micromatch/micromatch@4.0.5...4.0.8) --- updated-dependencies: - dependency-name: micromatch dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mitch Prewitt <[email protected]> * update version for release (#448) * Bump webpack from 5.76.0 to 5.94.0 (#443) Bumps [webpack](https://github.com/webpack/webpack) from 5.76.0 to 5.94.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](webpack/webpack@v5.76.0...v5.94.0) --- updated-dependencies: - dependency-name: webpack dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * EUDC -> EDC (#449) * fix jwt generator for userid * some cleanup and fixes * unused imports * fix build * revert, outside of scope * test not needed --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Brad Umbaugh <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * [MOB-9505] rename merge parameter (#450) * [MOB-9505] rename merge parameter * fix ci failure and resolved comment * fix: ci failure and merged AUT_main changes * MOB-9307 Add test to validate object created by custom event and user update api calls (#455) * [MOB-9402] update user should not be a separate call (#453) * [MOB-9402] update user should not be a separate call * feat: test cases update user should not be a separate call * [MOB-9568] update "criterias" to "criteriaSets" (#456) * [MOB-9578] implements identity resolution (#458) * MOB-9650 Added support for nested criteria match a.b.c (#457) * MOB-9650 Added support for nested criteria match a.b.c * fix: removed updatecart from nested criteria * [MOB-9652] support for nested JSON array (#459) * MOB-9650 Added support for nested criteria match a.b.c * fix: removed updatecart from nested criteria * [MOB-9652] support for nested JSON array * [MOB-9652] customEvent test case for nested JSON array * [MOB-9168] Automated unit tests against complex criteria (#461) * [MOB-9168] Automated unit tests against complex criteria * [MOB-9168] Automated unit tests against complex criteria * [MOB-9639] Added handler for notifying customer app of a newly created anon userid (#460) * [MOB-9578] implements identity resolution * [MOB-9639] Added handler for notifying customer app of a newly created anon userid * moved onAnonUserCreated in identityResolution * [MOB-9640] Keep AUT off until concent to track is granted (#462) * [MOB-9640] Keep AUT off until concent to track is granted * rename concent to consent * fixed eslint issue * added consent support for with-jwt config * [MOB-9899]: Add Auth Checks Before API Calls (#463) * AUT bug bash settings * block api calls if typeOfAuth not set * auth checks and tests * branch fix reversions * fix most of tests --------- Co-authored-by: jyu115 <[email protected]> * [MOB-9955]: Allow IdentityResolution Overrides and Move onAnonUserCreated in Config (#464) * shuffle onAnonUserCreated * allow identity resolution overrides on setEmail/setUserId * fix replay issue with JWT (#465) * [MOB-9954]: fix userMergeScenario test (#466) * fix replay issue with JWT * fix spec * [MOB-9954]: Fix Circular Dependency and Clean Up Auth Checks on API Calls (#467) * fix replay issue with JWT * fix spec * move initialize check over * add type of auth util * clean up auth checks and circular deps * add getter * fix * lets see * add additional endpoints * rename (#470) * [MOB-9703] Added support for fetching new JWT prior to calling merge (#468) * prettify code * [MOB-9703] Added support for fetching new JWT prior to calling merge * moved JWT to localstorage * fix circular deps * [MOB-9970] anonymous criteria should match for nested values (#472) * [MOB-10064] single primitive array bug fix (#473) * [MOB-9970] anonymous criteria should match for nested values * [MOB-10064] single primitive array bug fix * [MOB-10086]: Minor AUT Code Cleanup/Renaming (#474) * cleanup * rename * [MOB-10091]: AUT Pre-Bash Updates (#475) * update var, some error cleanup in sample app * remove endpoint from list * fix spec * remove md file (#477) * add method to clear anon data (#480) * add new messsage to rejection (#479) * [MOB-10123]: Clear Anon Data When Replay is False (#478) * clear anon data on user initialization * clear anon data even if replay is false * update tests * oop * Update authorization.ts * update release version (#481) * [MOB-9999] Aggregate user update event gets deleted (#469) * prettify code * [MOB-9703] Added support for fetching new JWT prior to calling merge * [MOB-9999] Aggregate user update event gets deleted * missed this * fix up tests and issues * update types * update types some more * forgot to commit this --------- Co-authored-by: mitch prewitt <[email protected]> * [MOB-11736]: UUA Test Cleanup (#519) * prettify code * [MOB-9703] Added support for fetching new JWT prior to calling merge * [MOB-9999] Aggregate user update event gets deleted * missed this * fix up tests and issues * update types * update types some more * forgot to commit this * update and cleanup UUA tests --------- Co-authored-by: Darshan Parmar <[email protected]> * [MOB-11714]: rename anonymous -> unknown (#520) * rename anonymous -> unknown * accidentally got deleted * Update authorization.ts * [MOB-11679]: consent logging implementation (#521) * consent loggimg impl draft * remove consent check and cleanup some * test fixes and additional cleanup * rework a bit * fix specs * [MOB-11737]: Resolve Main Branch Conflicts with UUA Branch (#522) * bump version (#482) * [MOB-11001] adding codecov to web-sdk (#487) * [MOB-11346] exposing baseIterableRequest (#489) * [MOB-11346] exposing baseIterableRequest * Update README.md Co-authored-by: lauren-mulkern <[email protected]> * Update README.md Co-authored-by: lauren-mulkern <[email protected]> * [MOB-11346] adding example for readme --------- Co-authored-by: lauren-mulkern <[email protected]> * [MOB-11441] Bump axios dependency version (#494) * [MOB-11441] Bump axios version * [MOB-11441] Bump axios version in react app * [MOB-11449] Upgrade jest dependency (#496) * [MOB-11449] Upgrade jest dependency in react sample app * [MOB-11449] Upgrade jest dependency in sample app * [MOB-11449] Upgrade jest dependency req * [MOB-11443] Bump express dependency version (#495) * [MOB-11443] Bump express dependency version * [MOB-11443] Bump express dependency version in sample app * [MOB-11443] Bump express dependency version in react sample app * [MOB-11443] Remove expess from package.json * [MOB-11427] Add maxWidth to getInAppMessages payload (#491) * [MOB-11427] Add maxWidth to getinappmessages payload * [MOB-11427] Include ESLint as workspace formatter * Revert "[MOB-11427] Include ESLint as workspace formatter" This reverts commit 63639ea. * [MOB-11427] Update tests and refactor * [MOB-11427] Add test * [MOB-11427] Update README * [MOB-11439] Upgrade Web SDK version to v1.2.0 (#499) * [MOB-11487] Upgrade webpack dependency (#500) * [MOB-11503] Fix eslint errors on vanilla JS sample app (#501) * [MOB-11503] Fix lint formatting errors on axios post request params * [MOB-11503] Cleanup * [MOB-11503] Reorder imports * [MOB-11503] Support login email in env * [MOB-11524] Support non-JWT requests in react sample app (#505) * [MOB-11524] Add USE_JWT to env example * [MOB-11524] Add lint exception for sample app * [MOB-11524] Support non-JWT requests in react sample app * [MOB-11524] Fix init * [MOB-11524] Use await * [MOB-11524] Set auth token for non-jwt logins after a logout * [MOB-11524] Set auth token for non-jwt logins after a logout * [MOB-11524] Create helper fn * [MOB-11524] Undo autoformat * [MOB-11524] Resolve linter error * [MOB-11507] Upgrade webpack-dev-server and node (#502) * [MOB-11507] Upgrade webpack-dev-server * [MOB-11507] Upgrade webpack-dev-server in /react-example * [MOB-11507] Upgrade webpack-dev-server in /example * [MOB-11507] Update env comments * [MOB-11507] Update node engine requirement * [MOB-11507] Upgrade webpack-cli * [MOB-11507] Upgrade webpack-cli in /example * [MOB-11507] Remove iterable from dependencies in /react-example * [MOB-11507] Upgrade webpack-cli in /react-example * [MOB-11507] Update node in ci config * [MOB-11507] Update lint config * [MOB-11507] Update README * [MOB-11616] Resolve Remaining Vulnerable Security Dependencies (#508) * [MOB-11616] Resolve braces vulnerability * [MOB-11616] Resolve micromatch vulnerability * [MOB-11616] Resolve babel runtime vulnerability * [MOB-11554] Resolve lint warnings (#506) * [MOB-11554] Resolve lint warnings in Users * [MOB-11554] Resolve lint warnings in Commerce * [MOB-11554] Resolve lint warnings in EventsForm * [MOB-11554] Resolve lint warnings in EmbeddedMsgsImpressionTracker * [MOB-11554] Resolve lint warnings in EmbeddedMsgs * [MOB-11554] Resolve lint warnings in EmbeddedForm * [MOB-11554] Clean up lint disables * [MOB-11618] Dedupe lockfiles (#509) * [MOB-11618] Dedupe lockfiles * [MOB-11618] Reinstall * [MOB-11575] Bump version to v2.0.0 (#510) * [MOB-11701] Test Publish (#514) * [MOB-11702] Add .nvmrc config to project (#513) * [MOB-11702] Add .nvmrc config to project * [MOB-11702] Add newline * [MOB-11702] Remove comments * [MOB-11716] Add build steps to publish workflow (#517) * [MOB-11717] Update version to v2.1.0 (#518) * fix UUA and base functionality * fix linting errors * fix up tests * update tests (WIP) * add new test suite to cover UUA logic on auth --------- Co-authored-by: Geoff Kim <[email protected]> Co-authored-by: lauren-mulkern <[email protected]> Co-authored-by: Paul Jung <[email protected]> * [MOB-11879]: export and readme updates for UUA (#523) * export and readme updates * remove comments * more updates * fix specs * prettier fix * fix comp errors * fix user profile updates for UUA (#525) --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Hani Vora <[email protected]> Co-authored-by: hardikmashru <[email protected]> Co-authored-by: darshan-iterable <[email protected]> Co-authored-by: hani <[email protected]> Co-authored-by: Mitch Prewitt <[email protected]> Co-authored-by: Brad Umbaugh <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jyu115 <[email protected]> Co-authored-by: mitch prewitt <[email protected]> Co-authored-by: Geoff Kim <[email protected]> Co-authored-by: lauren-mulkern <[email protected]> Co-authored-by: Paul Jung <[email protected]>
1 parent d24a4df commit 2fc817e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+13142
-672
lines changed

README.md

Lines changed: 121 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ Iterable's API, see the [API Overview](https://support.iterable.com/hc/articles/
131131
| [`updateSubscriptions`](#updateSubscriptions) | Updates the user's subscriptions by calling [`POST /api/users/updateSubscriptions`](https://support.iterable.com/hc/articles/204780579#post-api-users-updatesubscriptions). |
132132
| [`updateUser`](#updateUser) | Updates the data on a user's Iterable profile by calling [`POST /api/users/updateUser`](https://support.iterable.com/hc/articles/204780579#post-api-users-update). |
133133
| [`updateUserEmail`](#updateUserEmail) | Updates the current user's `email` by calling [`POST /api/users/updateEmail`](https://support.iterable.com/hc/articles/204780579#post-api-users-updateemail). Causes the SDK to fetch a JWT for the new email address. |
134+
| [`setVisitorUsageTracked`](#setVisitorUsageTracked) | Enables or disables unknown visitor tracking based on user consent (UUA). Returned by `initialize`/`initializeWithConfig`. |
135+
| [`clearVisitorEventsAndUserData`](#clearVisitorEventsAndUserData) | Clears unknown visitor session data and queued events (UUA). Returned by `initialize`/`initializeWithConfig`. |
134136

135137
Notes:
136138

@@ -152,7 +154,7 @@ function baseIterableRequest(
152154
```
153155

154156
Parameters:
155-
- `payload` - A request config see [`ExtendedRequestConfig`](#ExtendedRequestConfig)
157+
- `payload` - A request config see [`ExtendedRequestConfig`](#extendedrequestconfig)
156158

157159
Example:
158160
```ts
@@ -499,7 +501,7 @@ Parameters:
499501
import { IterableEmbeddedCard } from '@iterable/web-sdk';
500502
501503
const card = IterableEmbeddedCard({
502-
packageName,
504+
appPackageName,
503505
message,
504506
htmlElements,
505507
errorCallback: (error) => console.log('handleError: ', error)
@@ -563,7 +565,7 @@ For example:
563565
import { IterableEmbeddedBanner } from '@iterable/web-sdk';
564566
565567
const banner = IterableEmbeddedBanner({
566-
packageName,
568+
appPackageName,
567569
message,
568570
htmlElements,
569571
errorCallback: (error) => console.log('handleError: ', error)
@@ -623,7 +625,7 @@ Parameters:
623625
import { IterableEmbeddedNotification } from '@iterable/web-sdk';
624626
625627
const notification = IterableEmbeddedNotification({
626-
packageName,
628+
appPackageName,
627629
message,
628630
htmlElements,
629631
errorCallback: (error) => console.log('handleError: ', error)
@@ -702,13 +704,13 @@ const trackEmbeddedClick = (
702704
Example:
703705

704706
```js
705-
import { trackEmbeddedReceived } from '@iterable/web-sdk';
707+
import { trackEmbeddedClick } from '@iterable/web-sdk';
706708
707709
trackEmbeddedClick({
708-
messageId: message.metadata.messageId,
710+
messageId: message.metadata.messageId,
709711
buttonIdentifier: button.id,
710-
clickedUrl: defaultUrl,
711-
appPackageName: packageName
712+
targetUrl: defaultUrl,
713+
appPackageName
712714
}).then((response) => {
713715
if (response.status != 200) {
714716
console.log("Failure tracking embedded click")
@@ -999,7 +1001,7 @@ updateCart({
9991001

10001002
See also:
10011003

1002-
- [`UpdateCartRequestParams](#updatecartrequestparams)
1004+
- [`UpdateCartRequestParams`](#updatecartrequestparams)
10031005
- [`IterablePromise`](#iterablepromise)
10041006
- [`IterableResponse`](#iterableresponse)
10051007

@@ -1052,6 +1054,24 @@ See also:
10521054
- [`UpdateUserParams`](#updateuserparams)
10531055

10541056
## `updateUserEmail`
1057+
## `setVisitorUsageTracked`
1058+
1059+
Enables or disables unknown visitor tracking based on user consent (UUA). Returned by `initialize` and `initializeWithConfig`.
1060+
1061+
```ts
1062+
setVisitorUsageTracked: (consent: boolean) => void
1063+
```
1064+
1065+
- `true`: begin or continue collecting unknown events (and start/restore unknown session if enabled)
1066+
- `false`: stop collecting and clear unknown user data
1067+
1068+
## `clearVisitorEventsAndUserData`
1069+
1070+
Clears unknown visitor session data and queued events (UUA). Returned by `initialize` and `initializeWithConfig`.
1071+
1072+
```ts
1073+
clearVisitorEventsAndUserData: () => void
1074+
```
10551075

10561076
Updates the current user's `email` by calling [`POST /api/users/updateEmail`](https://support.iterable.com/hc/articles/204780579#post-api-users-updateemail).
10571077
Causes the SDK to fetch a JWT for the new email address.
@@ -1923,8 +1943,15 @@ Configuration options to pass to [`initializeWithConfig`](#initializewithconfig)
19231943
type Options = {
19241944
logLevel: 'none' | 'verbose';
19251945
baseURL: string;
1946+
enableUnknownActivation: boolean;
19261947
isEuIterableService: boolean;
19271948
dangerouslyAllowJsPopups: boolean;
1949+
eventThresholdLimit?: number;
1950+
onUnknownUserCreated?: (userId: string) => void;
1951+
identityResolution?: {
1952+
mergeOnUnknownToKnown?: boolean;
1953+
replayOnVisitorToKnown?: boolean;
1954+
};
19281955
};
19291956
```
19301957

@@ -1972,6 +1999,8 @@ interface SDKInAppMessagesParams {
19721999
// messageId of the latest (i.e., most recent) message in the device's
19732000
// local cache
19742001
latestCachedMessageId?: string;
2002+
// Set a default max-width style for message iframe. Applies to Center, TopRight, BottomRight
2003+
maxWidth?: string;
19752004
}
19762005
```
19772006

@@ -2075,6 +2104,8 @@ interface WithJWT {
20752104
setUserID: (userId: string) => Promise<string>;
20762105
logout: () => void;
20772106
refreshJwtToken: (authTypes: string) => Promise<string>;
2107+
setVisitorUsageTracked: (consent: boolean) => void;
2108+
clearVisitorEventsAndUserData: () => void;
20782109
}
20792110
```
20802111

@@ -2089,6 +2120,8 @@ Definitions:
20892120
or [`initializeWithConfig`](#initializeWithConfig).
20902121
- `refreshJwtToken` – Manually refreshes the JWT token for the signed-in user.
20912122
- `logout` – Signs the current user out of the SDK.
2123+
- `setVisitorUsageTracked` – Enables/disables unknown visitor tracking based on user consent.
2124+
- `clearVisitorEventsAndUserData` – Clears unknown visitor session data and queued events.
20922125

20932126
## `WithJWTParams`
20942127

@@ -2414,6 +2447,85 @@ At that point, further requests to Iterable's API will fail.
24142447
24152448
To perform a manual JWT token refresh, call [`refreshJwtToken`](#refreshjwttoken).
24162449
2450+
## UUA (Unknown User Activation)
2451+
2452+
Unknown User Activation (UUA) lets the SDK collect and queue events for unknown visitors and then transparently associate them to a known user once identified. The SDK handles session creation, consent, queuing, merge, and optional replay—out of the box.
2453+
2454+
### Enable UUA
2455+
2456+
```ts
2457+
import { initializeWithConfig } from '@iterable/web-sdk';
2458+
2459+
const { setEmail, setUserID, setVisitorUsageTracked, clearVisitorEventsAndUserData } = initializeWithConfig({
2460+
authToken: '<YOUR_API_KEY>',
2461+
configOptions: {
2462+
enableUnknownActivation: true,
2463+
identityResolution: {
2464+
mergeOnUnknownToKnown: true, // default
2465+
replayOnVisitorToKnown: true // default
2466+
},
2467+
onUnknownUserCreated: (userId) => {
2468+
console.log('unknown user created:', userId);
2469+
}
2470+
},
2471+
generateJWT: ({ email, userID }) => fetchJWT({ email, userID })
2472+
});
2473+
```
2474+
2475+
### Using UUA
2476+
2477+
- Consent control:
2478+
- `setVisitorUsageTracked(true)` to begin/continue collecting unknown events
2479+
- `setVisitorUsageTracked(false)` to stop collection and clear related local data
2480+
- `clearVisitorEventsAndUserData()` to purge queued unknown data explicitly
2481+
- Identification:
2482+
- Call `setEmail(email)` or `setUserID(userId)`
2483+
- SDK will merge unknown user → known user when `mergeOnUnknownToKnown` is true
2484+
- If `replayOnVisitorToKnown` is true, SDK will replay queued unknown events after identification
2485+
2486+
### Persistence and restoration across sessions
2487+
2488+
- Storage: the unknown user id is stored in `localStorage` under a project-scoped key. It has no TTL and persists across reloads and restarts until explicitly cleared.
2489+
- Automatic restoration: on initialize (with `enableUnknownActivation: true`), the SDK restores the unknown id from storage and automatically applies it to outgoing requests for supported endpoints.
2490+
- JWT mode: when using a JWT-enabled API key and consent is present, the SDK generates a JWT for the restored unknown id and attaches it so requests are authenticated.
2491+
- Lifecycle end: the unknown id is cleared when you identify (merge then clear), revoke consent via `setVisitorUsageTracked(false)`, call `clearVisitorEventsAndUserData()`, or when browser storage is cleared.
2492+
2493+
### Configuration options (UUA-specific)
2494+
2495+
```ts
2496+
type Options = {
2497+
enableUnknownActivation: boolean; // Enable UUA (default: false)
2498+
eventThresholdLimit?: number; // Queue flush threshold (default provided by SDK)
2499+
onUnknownUserCreated?: (userId: string) => void; // Callback when unknown user id is created
2500+
identityResolution?: {
2501+
mergeOnUnknownToKnown?: boolean; // Merge unknown → known on identify (default: true)
2502+
replayOnVisitorToKnown?: boolean; // Replay queued events after identify (default: true)
2503+
};
2504+
// ...plus general options like logLevel, baseURL, etc.
2505+
}
2506+
```
2507+
2508+
### Logic flow (what happens under the hood)
2509+
2510+
1. Initialization
2511+
- When `enableUnknownActivation` is true, SDK fetches unknown user criteria and starts an unknown session.
2512+
- If an unknown user id exists in storage, SDK restores it and authenticates appropriately.
2513+
2. Event collection (unknown)
2514+
- When consent is set via `setVisitorUsageTracked(true)`, SDK queues unknown events locally.
2515+
- Queue flush is governed by `eventThresholdLimit` and internal batching.
2516+
3. Identification
2517+
- App calls `setEmail` or `setUserID`.
2518+
- SDK authenticates the known identity and attempts to create the user (if needed).
2519+
- If `mergeOnUnknownToKnown` is true and an unknown id exists, SDK calls merge (unknown → known).
2520+
4. Replay (optional)
2521+
- If `replayOnVisitorToKnown` is true, SDK replays queued unknown events under the known identity and clears the unknown queue.
2522+
5. Cleanup
2523+
- After merge attempt (successful or skipped), SDK clears the stored unknown user id and related anonymous state.
2524+
2525+
Notes:
2526+
- UUA works for Events, In-App, Embedded, Commerce, and Users APIs; the SDK ensures requests are authenticated correctly pre/post identification.
2527+
- If consent is revoked (`setVisitorUsageTracked(false)`), the SDK clears unknown state and stops tracking until re-enabled.
2528+
24172529
# Iterable's European data center (EDC)
24182530
24192531
If your Iterable project is hosted on Iterable's [European data center (EDC)](https://support.iterable.com/hc/articles/17572750887444),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"@types/jest": "^27.0.2",
7575
"@types/node": "^12.7.1",
7676
"@types/throttle-debounce": "^2.1.0",
77-
"@types/uuid": "^9.0.2",
77+
"@types/uuid": "^9.0.8",
7878
"@typescript-eslint/eslint-plugin": "^5.38.1",
7979
"@typescript-eslint/parser": "^5.38.1",
8080
"@webpack-cli/serve": "^1.6.0",

react-example/.eslintrc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
{
2-
"extends": [
3-
"../.eslintrc",
4-
"plugin:react/recommended"
5-
],
2+
"extends": ["../.eslintrc", "plugin:react/recommended"],
63
"rules": {
74
"@typescript-eslint/no-empty-interface": "off",
85
"import/no-unresolved": "off",
96
"react/react-in-jsx-scope": "off"
107
},
11-
"ignorePatterns": [
12-
"node_modules/"
13-
]
14-
}
8+
"ignorePatterns": ["node_modules/"]
9+
}

react-example/src/components/EmbeddedForm.tsx

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
IterableEmbeddedMessageUpdateHandler,
55
IterableResponse,
66
trackEmbeddedClick,
7-
trackEmbeddedDismiss,
87
trackEmbeddedReceived,
98
trackEmbeddedSession
109
} from '@iterable/web-sdk';
@@ -126,34 +125,6 @@ export const EmbeddedForm: FC<Props> = ({
126125
});
127126
};
128127

129-
const submitEmbeddedMessagesDismissEvent = async (
130-
e: FormEvent<HTMLFormElement>
131-
) => {
132-
e.preventDefault();
133-
setTrackingEvent(true);
134-
135-
const sessionData = {
136-
messageId,
137-
buttonIdentifier: '123',
138-
deviceInfo: {
139-
deviceId: '123',
140-
platform: 'web',
141-
appPackageName: 'my-website'
142-
},
143-
createdAt: Date.now()
144-
};
145-
146-
trackEmbeddedDismiss(sessionData)
147-
.then((response: AxiosResponse<IterableResponse>) => {
148-
setTrackResponse(JSON.stringify(response.data));
149-
setTrackingEvent(false);
150-
})
151-
.catch((error: AxiosError<IterableResponse>) => {
152-
setTrackResponse(JSON.stringify(error.response.data));
153-
setTrackingEvent(false);
154-
});
155-
};
156-
157128
const submitEmbeddedSessionEvent = async (e: FormEvent<HTMLFormElement>) => {
158129
e.preventDefault();
159130
setTrackingEvent(true);
@@ -199,8 +170,6 @@ export const EmbeddedForm: FC<Props> = ({
199170
submitEmbeddedMessagesReceivedEvent(e);
200171
} else if (type === TYPE_CLICK) {
201172
submitEmbeddedMessagesClickEvent(e);
202-
} else if (type === TYPE_DISMISS) {
203-
submitEmbeddedMessagesDismissEvent(e);
204173
} else if (type === TYPE_SESSION) {
205174
submitEmbeddedSessionEvent(e);
206175
}

react-example/src/components/EventsForm.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ export const EventsForm: FC<Props> = ({
3636
);
3737

3838
const [trackEvent, setTrackEvent] = useState<string>('');
39-
4039
const [isTrackingEvent, setTrackingEvent] = useState<boolean>(false);
4140

42-
const handleTrack = (e: FormEvent<HTMLFormElement>) => {
41+
const handleTrack = async (e: FormEvent<HTMLFormElement>) => {
4342
e.preventDefault();
4443
setTrackingEvent(true);
4544

@@ -58,7 +57,6 @@ export const EventsForm: FC<Props> = ({
5857
})
5958
.catch((e: AxiosError<IterableResponse>) => {
6059
setTrackResponse(JSON.stringify(e.response.data));
61-
setTrackingEvent(false);
6260
});
6361
};
6462

react-example/src/components/LoginForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ const Error = styled.div`
3737
`;
3838

3939
interface Props {
40-
setEmail: (email: string) => Promise<string> | void;
41-
setUserId: (userId: string) => Promise<string | void>;
40+
setEmail: (email: string, identityResolution?: any) => Promise<string>;
41+
setUserId: (userId: string, identityResolution?: any) => Promise<string>;
4242
logout: () => void;
4343
refreshJwt?: (authTypes: string) => Promise<string>;
4444
}

0 commit comments

Comments
 (0)