@traqio/web 0.5.0 → 0.6.1

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/build/index.d.ts CHANGED
@@ -59,6 +59,11 @@ export interface WebTrackProps {
59
59
  /** Where the payment went through — `"stripe"` for Stripe. */
60
60
  store?: "stripe" | "app_store" | "play_store" | "mac_app_store" | "amazon";
61
61
  }
62
+ /**
63
+ * `traqio_internal` in a URL's query: `1`/`true` → true, `0`/`false` → false, absent or
64
+ * anything else → null (left as it was).
65
+ */
66
+ export declare function internalParam(href: string): boolean | null;
62
67
  export declare class TraqioWeb {
63
68
  private readonly core;
64
69
  private store;
@@ -82,6 +87,10 @@ export declare class TraqioWeb {
82
87
  private groups;
83
88
  /** Group entries made before `init()` — replayed once the tracker exists. */
84
89
  private earlyGroups;
90
+ /** `alias()` calls made before `init()`: [userId, previousId]. */
91
+ private earlyAliases;
92
+ /** A `reset()` before `init()`: what earlier pages kept (super-properties, accounts) is dropped, not restored. */
93
+ private resetBeforeInit;
85
94
  /**
86
95
  * Call once, as early as possible on every page (or once in a single-page app).
87
96
  * Reads the trackID from the current URL first, synchronously, so even a visitor
@@ -89,6 +98,16 @@ export declare class TraqioWeb {
89
98
  * does nothing there.
90
99
  */
91
100
  init(opts: WebInitOptions): Promise<void>;
101
+ /**
102
+ * Mark this browser as the team's own (`true`) or as a visitor again (`false`) — what
103
+ * opening the site with `?traqio_internal=1` / `=0` does. Its analytics events are
104
+ * still sent, flagged: the console leaves them out of every figure by default and
105
+ * shows them under « Internal traffic only ». Conversions (`track()`) are not
106
+ * affected. Kept on the device, like the visitor id (and under the same consent).
107
+ */
108
+ setInternal(on: boolean): void;
109
+ /** True when this browser opted itself out as internal traffic — see `setInternal()`. */
110
+ get isInternal(): boolean;
92
111
  /** Whether this page runs in debug mode — see `WebInitOptions.debug`. Settled by `init()`. */
93
112
  get isDebug(): boolean;
94
113
  /** Record an event — `signup`, `purchase`, `add_to_cart`… Batched, retried, kept across page loads. */
@@ -149,6 +168,36 @@ export declare class TraqioWeb {
149
168
  resetGroups(): void;
150
169
  /** The accounts `group()` set, by type — a copy. */
151
170
  getGroups(): Groups;
171
+ /**
172
+ * Two ids, one person: the user known so far as `previousId` (a guest id, an id
173
+ * from before sign-up) IS the current user (`setUserId` / `identify`). Their
174
+ * analytics history and properties are merged under the current id — its own
175
+ * properties win. From the browser only what THIS visitor sent under `previousId`
176
+ * is merged; a backend (`@traqio/node`, secret key) merges everything.
177
+ *
178
+ * Traqio.identify("u_123");
179
+ * Traqio.alias("guest_8f2c");
180
+ *
181
+ * Ignored without a current user id, or when `previousId` is the current one. Needs `analytics` at init.
182
+ */
183
+ alias(previousId: string): void;
184
+ /**
185
+ * Sign-out: forget who the user was in this browser — the user id, the
186
+ * super-properties, the accounts — and end the analytics session, so the next
187
+ * person's visit starts clean. Events already queued keep the user they were
188
+ * captured under. The visitor id is KEPT: it carries the visitor's attribution
189
+ * (the click, the campaign) for the next sign-up.
190
+ */
191
+ reset(): void;
192
+ /**
193
+ * An experiment exposure: the visitor SAW `variant` of `experiment` — what the
194
+ * console's experiment analysis reads (uplift, significance per variant). Your site
195
+ * assigns the variant (its own flags, an edge split, a cookie); call this where the
196
+ * visitor first meets it. Sends `$exposure { experiment, variant, ...props }`.
197
+ *
198
+ * Traqio.exposure("pricing_page", "annual_first");
199
+ */
200
+ exposure(experiment: string, variant: string | number | boolean, props?: Record<string, unknown>): void;
152
201
  private persistGroups;
153
202
  private persistSuperProps;
154
203
  /**