@base44-preview/sdk 0.8.58-beta.0-pr.367.230725c → 0.8.58-pr.368.f587f1e
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.
|
@@ -6,6 +6,9 @@ export declare const ANALYTICS_INITIALIZATION_EVENT_NAME = "__initialization_eve
|
|
|
6
6
|
export declare const ANALYTICS_SESSION_DURATION_EVENT_NAME = "__session_duration_event__";
|
|
7
7
|
export declare const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
|
|
8
8
|
export declare const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
|
|
9
|
+
export declare const ANALYTICS_DENIED_LOCAL_STORAGE_KEY = "base44_analytics_denied";
|
|
10
|
+
/** Whether a page in this mode may track before any consent signal. */
|
|
11
|
+
export declare function initialConsentGranted(mode: string | null): boolean;
|
|
9
12
|
export declare const ANALYTICS_MODE_META_NAME = "base44-analytics";
|
|
10
13
|
/** Whether analytics may run and store the session id on this page. */
|
|
11
14
|
export declare function isAnalyticsAllowed(): boolean;
|
|
@@ -5,6 +5,37 @@ export const ANALYTICS_INITIALIZATION_EVENT_NAME = "__initialization_event__";
|
|
|
5
5
|
export const ANALYTICS_SESSION_DURATION_EVENT_NAME = "__session_duration_event__";
|
|
6
6
|
export const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
|
|
7
7
|
export const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
|
|
8
|
+
// Remembers a visitor's Decline across pages. On "on" pages the SDK starts
|
|
9
|
+
// before the app's banner replays the saved choice, so without it each new
|
|
10
|
+
// page would store the id and send one batch before the denial arrives.
|
|
11
|
+
export const ANALYTICS_DENIED_LOCAL_STORAGE_KEY = "base44_analytics_denied";
|
|
12
|
+
function readAnalyticsDenied() {
|
|
13
|
+
try {
|
|
14
|
+
return localStorage.getItem(ANALYTICS_DENIED_LOCAL_STORAGE_KEY) === "1";
|
|
15
|
+
}
|
|
16
|
+
catch (_a) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function writeAnalyticsDenied(denied) {
|
|
21
|
+
try {
|
|
22
|
+
if (denied)
|
|
23
|
+
localStorage.setItem(ANALYTICS_DENIED_LOCAL_STORAGE_KEY, "1");
|
|
24
|
+
else
|
|
25
|
+
localStorage.removeItem(ANALYTICS_DENIED_LOCAL_STORAGE_KEY);
|
|
26
|
+
}
|
|
27
|
+
catch (_a) {
|
|
28
|
+
// storage unavailable: the banner's replay still stops tracking
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Whether a page in this mode may track before any consent signal. */
|
|
32
|
+
export function initialConsentGranted(mode) {
|
|
33
|
+
if (mode === "consent")
|
|
34
|
+
return false;
|
|
35
|
+
if (mode === "on")
|
|
36
|
+
return !readAnalyticsDenied();
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
8
39
|
// Set by the Base44 server from the app owner's choice: "off" never tracks,
|
|
9
40
|
// "consent" waits for the page's Google Consent Mode `analytics_storage` grant,
|
|
10
41
|
// "on" tracks until that consent is denied. Absent: track as before.
|
|
@@ -61,7 +92,7 @@ const consentSharedState = getSharedInstance("analytics-consent", () => {
|
|
|
61
92
|
return {
|
|
62
93
|
analyticsMode,
|
|
63
94
|
// Whether the visitor may be tracked and the session id stored.
|
|
64
|
-
consentGranted: analyticsMode
|
|
95
|
+
consentGranted: initialConsentGranted(analyticsMode),
|
|
65
96
|
isWatchingConsent: false,
|
|
66
97
|
listeners: [],
|
|
67
98
|
};
|
|
@@ -73,6 +104,7 @@ export function isAnalyticsAllowed() {
|
|
|
73
104
|
}
|
|
74
105
|
function setConsentGranted(granted) {
|
|
75
106
|
var _a;
|
|
107
|
+
writeAnalyticsDenied(!granted);
|
|
76
108
|
if (consentSharedState.consentGranted === granted)
|
|
77
109
|
return;
|
|
78
110
|
consentSharedState.consentGranted = granted;
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface BrowserSessionOptions {
|
|
5
5
|
/**
|
|
6
|
-
* Whether
|
|
6
|
+
* Whether Base44's browser provider records the session and keeps its diagnostic logs.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* You can't retrieve the recordings or logs through the SDK. Set this to `false` when the session shows sensitive data that shouldn't be recorded. Defaults to `true`.
|
|
9
9
|
*/
|
|
10
10
|
captureDebugArtifacts?: boolean;
|
|
11
11
|
/**
|
|
12
12
|
* Maximum lifetime of the session, in whole seconds.
|
|
13
13
|
*
|
|
14
|
-
* The session ends when the timeout expires, even if it's still in use. Base44
|
|
14
|
+
* The session ends when the timeout expires, even if it's still in use. Base44 clamps the value to between `60` and `900` seconds. Defaults to `300`.
|
|
15
15
|
*/
|
|
16
16
|
sessionTimeoutSeconds?: number;
|
|
17
17
|
}
|
|
@@ -22,7 +22,7 @@ export interface BrowserSession {
|
|
|
22
22
|
/**
|
|
23
23
|
* Opaque session identifier issued to your app.
|
|
24
24
|
*
|
|
25
|
-
* Pass it unchanged to
|
|
25
|
+
* Pass it unchanged to [`endSession()`](#endsession) to end the session from a different request.
|
|
26
26
|
*/
|
|
27
27
|
sessionId: string;
|
|
28
28
|
/**
|
|
@@ -43,25 +43,30 @@ export interface BrowserSession {
|
|
|
43
43
|
/** ISO 8601 timestamp when the browser session expires. Omitted when the provider doesn't expose it. */
|
|
44
44
|
sessionExpiresAt?: string;
|
|
45
45
|
/**
|
|
46
|
-
* Ends the session. Equivalent to calling
|
|
46
|
+
* Ends the session. Equivalent to calling [`endSession()`](#endsession) with this session's ID.
|
|
47
47
|
*/
|
|
48
48
|
end: () => Promise<void>;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Browser module for running browser automation from your backend.
|
|
52
52
|
*
|
|
53
|
-
* This module creates remote browser sessions that you can control with a CDP client library such as Playwright or Puppeteer. Base44 doesn't store browser state, so each session is independent.
|
|
53
|
+
* This module creates remote browser sessions that you can control with a [Chrome DevTools Protocol (CDP)](https://chromedevtools.github.io/devtools-protocol/) client library such as [Playwright](https://playwright.dev/docs/api/class-browsertype#browser-type-connect-over-cdp) or [Puppeteer](https://pptr.dev/api/puppeteer.puppeteer.connect). Base44 doesn't store browser state, so each session is independent.
|
|
54
54
|
*
|
|
55
|
-
*
|
|
55
|
+
* ## Authentication modes
|
|
56
|
+
*
|
|
57
|
+
* This module is only available to use with a client in [service role authentication mode](/developers/references/sdk/getting-started/client#service-role) (`base44.asServiceRole.browser`), which means it can only be used in backend environments.
|
|
56
58
|
*/
|
|
57
59
|
export interface BrowserModule {
|
|
58
60
|
/**
|
|
59
61
|
* Creates a new remote browser session and returns its connection details.
|
|
60
62
|
*
|
|
61
|
-
* Each call creates a fresh session.
|
|
63
|
+
* Each call creates a fresh session, which uses credits from the workspace that owns the app. Each session is billed by the minute until it ends. An open session keeps running until its timeout expires. When you're done, call `end()` on the session. To end it from a different request, use {@linkcode endSession | endSession()}.
|
|
62
64
|
*
|
|
63
65
|
* @param options - Optional session settings.
|
|
64
|
-
* @returns Promise resolving to the new browser session.
|
|
66
|
+
* @returns Promise resolving to the new browser session. Rejects with a [`Base44Error`](/developers/references/sdk/getting-started/work-with-sdk#error-handling) whose `code` is one of the values under [Throws](#throws).
|
|
67
|
+
* @throws `insufficient_credits`: The workspace is out of credits.
|
|
68
|
+
* @throws `rate_limited`: You created more than 100 sessions in the last minute.
|
|
69
|
+
* @throws `browser_capacity_exceeded`: Browser capacity is temporarily unavailable.
|
|
65
70
|
*
|
|
66
71
|
* @example
|
|
67
72
|
* ```typescript
|
|
@@ -93,28 +98,27 @@ export interface BrowserModule {
|
|
|
93
98
|
* const session = await base44.asServiceRole.browser.getSession({
|
|
94
99
|
* captureDebugArtifacts: false,
|
|
95
100
|
* });
|
|
96
|
-
* ```
|
|
97
101
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* });
|
|
102
|
+
* try {
|
|
103
|
+
* // Connect to session.connectionUrl and run your automation
|
|
104
|
+
* } finally {
|
|
105
|
+
* await session.end();
|
|
106
|
+
* }
|
|
104
107
|
* ```
|
|
105
108
|
*/
|
|
106
109
|
getSession(options?: BrowserSessionOptions): Promise<BrowserSession>;
|
|
107
110
|
/**
|
|
108
111
|
* Ends a browser session created by your app.
|
|
109
112
|
*
|
|
110
|
-
* Use this when the session was created in a different request. Otherwise call `end()` on the session returned by {@linkcode getSession | getSession()}. Ending a session that has already ended succeeds, so it's safe to call more than once.
|
|
113
|
+
* Use this when the session was created in a different request. Otherwise call `end()` on the session returned by {@linkcode getSession | getSession()}. Ending a session that has already ended succeeds, so it's safe to call more than once.
|
|
111
114
|
*
|
|
112
|
-
* @param sessionId - The `sessionId` returned by {@linkcode getSession | getSession()}
|
|
113
|
-
* @returns Promise that resolves when the session has ended.
|
|
115
|
+
* @param sessionId - The `sessionId` returned by {@linkcode getSession | getSession()}.
|
|
116
|
+
* @returns Promise that resolves when the session has ended. Rejects with a [`Base44Error`](/developers/references/sdk/getting-started/work-with-sdk#error-handling) whose `code` is one of the values under [Throws](#throws-2).
|
|
117
|
+
* @throws `browser_session_not_found`: The session ID wasn't issued to your app.
|
|
114
118
|
*
|
|
115
119
|
* @example
|
|
116
120
|
* ```typescript
|
|
117
|
-
* // End a session
|
|
121
|
+
* // End a session from a later request, using the ID sent in the request body
|
|
118
122
|
* import { createClientFromRequest } from 'npm:@base44/sdk';
|
|
119
123
|
*
|
|
120
124
|
* Deno.serve(async (req) => {
|
|
@@ -11,7 +11,9 @@ export interface SsoAccessTokenResponse {
|
|
|
11
11
|
* tokens allow you to authenticate Base44 users with external systems or
|
|
12
12
|
* services.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* ## Authentication modes
|
|
15
|
+
*
|
|
16
|
+
* This module is only available to use with a client in [service role authentication mode](/developers/references/sdk/getting-started/client#service-role) (`base44.asServiceRole.sso`), which means it can only be used in backend environments.
|
|
15
17
|
*/
|
|
16
18
|
export interface SsoModule {
|
|
17
19
|
/**
|