@jitsu/js 1.9.0-canary.581.20240115194116 → 1.9.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.
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <title>Tracking page</title>
8
+ <script type="text/javascript" src="<%=trackingBase%>/p.js" defer></script>
9
+ <script>
10
+ (window.jitsuQ = window.jitsuQ || []).push(function (jitsu) {
11
+ jitsu.track("test-event1");
12
+ });
13
+
14
+ (window.jitsuQ = window.jitsuQ || []).push(["track", "test-event2"]);
15
+ </script>
16
+ </head>
17
+
18
+ <body>
19
+ <h1>Test</h1>
20
+ </body>
21
+ </html>
@@ -191,7 +191,31 @@ function describeEvent(type: string, body: any) {
191
191
  .join(", ");
192
192
  return `${type}${type === "track" ? `(${body.event})` : ""}[${params}]`;
193
193
  }
194
+
195
+ function clearRequestLog() {
196
+ requestLog.length = 0;
197
+ }
198
+
199
+ test("jitsu-queue-callbacks", async ({ browser }) => {
200
+ clearRequestLog();
201
+ const browserContext = await browser.newContext();
202
+ const { page, uncaughtErrors } = await createLoggingPage(browserContext);
203
+ const [pageResult] = await Promise.all([page.goto(`${server.baseUrl}/callbacks.html`)]);
204
+ await page.waitForFunction(() => window["jitsu"] !== undefined, undefined, {
205
+ timeout: 1000,
206
+ polling: 100,
207
+ });
208
+ //wait for some time since the server has an artificial latency of 30ms
209
+ await new Promise(resolve => setTimeout(resolve, 1000));
210
+ console.log(
211
+ `📝 Request log size of ${requestLog.length}`,
212
+ requestLog.map(x => describeEvent(x.type, x.body))
213
+ );
214
+ expect(requestLog.length).toBe(3);
215
+ });
216
+
194
217
  test("url-bug", async ({ browser }) => {
218
+ clearRequestLog();
195
219
  //tests a bug in getanalytics.io where the url without slash provided by
196
220
  //<link rel="canonical" ../> causes incorrect page path
197
221
  const browserContext = await browser.newContext();
@@ -221,7 +245,7 @@ test("url-bug", async ({ browser }) => {
221
245
  });
222
246
 
223
247
  test("basic", async ({ browser }) => {
224
- requestLog.length = 0;
248
+ clearRequestLog();
225
249
  const browserContext = await browser.newContext();
226
250
 
227
251
  const { page: firstPage, uncaughtErrors: firstPageErrors } = await createLoggingPage(browserContext);
@@ -290,7 +314,7 @@ test("basic", async ({ browser }) => {
290
314
  timeout: 1000,
291
315
  polling: 100,
292
316
  });
293
- requestLog.length = 0;
317
+ clearRequestLog();
294
318
 
295
319
  await secondPage.evaluate(generateTestEvents);
296
320
  expect(secondPageErrors.length).toBe(0);
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { JitsuOptions } from "./jitsu";
1
+ import type { JitsuOptions } from "./jitsu";
2
2
  export type JitsuBrowserOptions = {
3
3
  namespace?: string;
4
4
  userId?: string;