@veroxm/sdk 1.0.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ - `tracker.identifyAccount(accessToken, traits?)`: links the visitor to a signed-in end user's account, checked
6
+ with their own access token, so segments can target `account.role` and `account.emailVerified`, which a page
7
+ can't fake. Needs a VeroXM with accounts linking (public API 2.2); an older one answers 400.
8
+ - `Schemas['IdentifyRequest']`: `userId` is optional, and `accountToken` is new.
9
+
3
10
  ## 1.0.0
4
11
 
5
12
  - Stable: from 1.0, breaking changes come only in a major version, after a deprecation period. What that covers
@@ -589,7 +589,7 @@ export interface paths {
589
589
  };
590
590
  get?: never;
591
591
  put?: never;
592
- /** Link a visitor to your user id */
592
+ /** Link a visitor to your user id, or to a signed-in end user with their accountToken */
593
593
  post: operations["identify"];
594
594
  delete?: never;
595
595
  options?: never;
@@ -998,7 +998,10 @@ export interface components {
998
998
  };
999
999
  IdentifyRequest: {
1000
1000
  visitorId: string;
1001
- userId: string;
1001
+ /** @description Your own id for this person. Not with accountToken; ids starting "account:" are refused. */
1002
+ userId?: string;
1003
+ /** @description A signed-in end user's access token: links the visitor to that account (the profile's user id is then "account:<id>"). */
1004
+ accountToken?: string;
1002
1005
  traits?: {
1003
1006
  [key: string]: unknown;
1004
1007
  };
package/dist/tracker.d.ts CHANGED
@@ -98,6 +98,13 @@ export declare class VeroxmTracker {
98
98
  consent(choices: ConsentChoices): Promise<void>;
99
99
  /** Links this visitor to your own user id (e.g. after sign-in) and updates their traits. Needs analytics consent. */
100
100
  identify(userId: string, traits?: Record<string, unknown>): Promise<void>;
101
+ /**
102
+ * Links this visitor to a signed-in end user's account (built-in accounts or your sign-in provider), checked with
103
+ * their own access token, so segments can target account roles that a page can't fake. Needs analytics consent.
104
+ * Call it after sign-in, e.g. `tracker.identifyAccount(await app.auth.getAccessToken())`.
105
+ * @since 1.1.0
106
+ */
107
+ identifyAccount(accessToken: string, traits?: Record<string, unknown>): Promise<void>;
101
108
  /** Call on sign-out: starts a new anonymous visitor on this device. Consent answers are kept. */
102
109
  reset(): void;
103
110
  /**
package/dist/tracker.js CHANGED
@@ -217,6 +217,19 @@ export class VeroxmTracker {
217
217
  await this.post('/identify', { visitorId: this.visitorId, userId, ...(traits ? { traits } : {}) }).catch((e) => this.onError(e));
218
218
  this.changed(); // traits can change which segment the visitor is in
219
219
  }
220
+ /**
221
+ * Links this visitor to a signed-in end user's account (built-in accounts or your sign-in provider), checked with
222
+ * their own access token, so segments can target account roles that a page can't fake. Needs analytics consent.
223
+ * Call it after sign-in, e.g. `tracker.identifyAccount(await app.auth.getAccessToken())`.
224
+ * @since 1.1.0
225
+ */
226
+ async identifyAccount(accessToken, traits) {
227
+ if (!this.canSend())
228
+ return;
229
+ await this.flush();
230
+ await this.post('/identify', { visitorId: this.visitorId, accountToken: accessToken, ...(traits ? { traits } : {}) }).catch((e) => this.onError(e));
231
+ this.changed();
232
+ }
220
233
  /** Call on sign-out: starts a new anonymous visitor on this device. Consent answers are kept. */
221
234
  reset() {
222
235
  this.queue = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veroxm/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "VeroXM client for JavaScript and TypeScript: content, media, experiences, events and the visitor tracker.",
5
5
  "keywords": [
6
6
  "veroxm",