mitra-interactions-sdk 1.0.41 → 1.0.42
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/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +82 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -525,6 +525,11 @@ declare function getConfig(): MitraConfig;
|
|
|
525
525
|
*/
|
|
526
526
|
declare function resolveProjectId(projectId?: number): number;
|
|
527
527
|
|
|
528
|
+
/**
|
|
529
|
+
* Stop tracking user activity.
|
|
530
|
+
*/
|
|
531
|
+
declare function stopTracking(): void;
|
|
532
|
+
|
|
528
533
|
/**
|
|
529
534
|
* Mitra Interactions SDK - Autenticação
|
|
530
535
|
*
|
|
@@ -715,4 +720,4 @@ declare function setProfileScreensMitra(options: SetProfileScreensOptions): Prom
|
|
|
715
720
|
*/
|
|
716
721
|
declare function setProfileServerFunctionsMitra(options: SetProfileServerFunctionsOptions): Promise<SetProfilePermissionResponse>;
|
|
717
722
|
|
|
718
|
-
export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetRecordOptions, type GetVariableOptions, type GetVariableResponse, type IntegrationResponse, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type ListVariablesOptions, type ListVariablesResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type RunActionOptions, type RunActionResponse, type RunQueryOptions, type RunQueryResponse, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, callIntegrationMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteProfileMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDbActionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getProfileDetailsMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, runActionMitra, runQueryMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePublicMitra };
|
|
723
|
+
export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetRecordOptions, type GetVariableOptions, type GetVariableResponse, type IntegrationResponse, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type ListVariablesOptions, type ListVariablesResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type RunActionOptions, type RunActionResponse, type RunQueryOptions, type RunQueryResponse, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, callIntegrationMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteProfileMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDbActionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getProfileDetailsMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, runActionMitra, runQueryMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, stopTracking, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePublicMitra };
|
package/dist/index.d.ts
CHANGED
|
@@ -525,6 +525,11 @@ declare function getConfig(): MitraConfig;
|
|
|
525
525
|
*/
|
|
526
526
|
declare function resolveProjectId(projectId?: number): number;
|
|
527
527
|
|
|
528
|
+
/**
|
|
529
|
+
* Stop tracking user activity.
|
|
530
|
+
*/
|
|
531
|
+
declare function stopTracking(): void;
|
|
532
|
+
|
|
528
533
|
/**
|
|
529
534
|
* Mitra Interactions SDK - Autenticação
|
|
530
535
|
*
|
|
@@ -715,4 +720,4 @@ declare function setProfileScreensMitra(options: SetProfileScreensOptions): Prom
|
|
|
715
720
|
*/
|
|
716
721
|
declare function setProfileServerFunctionsMitra(options: SetProfileServerFunctionsOptions): Promise<SetProfilePermissionResponse>;
|
|
717
722
|
|
|
718
|
-
export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetRecordOptions, type GetVariableOptions, type GetVariableResponse, type IntegrationResponse, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type ListVariablesOptions, type ListVariablesResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type RunActionOptions, type RunActionResponse, type RunQueryOptions, type RunQueryResponse, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, callIntegrationMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteProfileMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDbActionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getProfileDetailsMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, runActionMitra, runQueryMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePublicMitra };
|
|
723
|
+
export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetRecordOptions, type GetVariableOptions, type GetVariableResponse, type IntegrationResponse, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type ListVariablesOptions, type ListVariablesResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type RunActionOptions, type RunActionResponse, type RunQueryOptions, type RunQueryResponse, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, callIntegrationMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteProfileMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDbActionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getProfileDetailsMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, runActionMitra, runQueryMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, stopTracking, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePublicMitra };
|
package/dist/index.js
CHANGED
|
@@ -554,10 +554,88 @@ function createMitraInstance(initialConfig) {
|
|
|
554
554
|
return instance;
|
|
555
555
|
}
|
|
556
556
|
|
|
557
|
+
// src/tracking.ts
|
|
558
|
+
var HEARTBEAT_INTERVAL_MS = 6e4;
|
|
559
|
+
var SESSION_KEY = "mitra-sdk-sid";
|
|
560
|
+
var tracker = null;
|
|
561
|
+
function getSessionId() {
|
|
562
|
+
if (typeof sessionStorage === "undefined") return "";
|
|
563
|
+
let sid = sessionStorage.getItem(SESSION_KEY);
|
|
564
|
+
if (!sid) {
|
|
565
|
+
sid = Math.floor(Math.random() * 1e15 + Date.now()).toString();
|
|
566
|
+
sessionStorage.setItem(SESSION_KEY, sid);
|
|
567
|
+
}
|
|
568
|
+
return sid;
|
|
569
|
+
}
|
|
570
|
+
function sendLog(event) {
|
|
571
|
+
if (!isConfigured() || !tracker) return;
|
|
572
|
+
let config;
|
|
573
|
+
try {
|
|
574
|
+
config = getConfig();
|
|
575
|
+
} catch (e) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
const { token, baseURL, projectId } = config;
|
|
579
|
+
if (!token || !baseURL || !projectId) return;
|
|
580
|
+
const formattedToken = token.startsWith("Bearer ") ? token : `Bearer ${token}`;
|
|
581
|
+
const qs = [
|
|
582
|
+
`sessionId=${tracker.sessionId}`,
|
|
583
|
+
"init=-998",
|
|
584
|
+
"accessOrigin=BUILD",
|
|
585
|
+
`buildPath=${encodeURIComponent(typeof location !== "undefined" ? location.pathname : "/")}`,
|
|
586
|
+
`buildEvent=${event}`
|
|
587
|
+
].join("&");
|
|
588
|
+
try {
|
|
589
|
+
fetch(`${baseURL}/userLog?${qs}`, {
|
|
590
|
+
method: "POST",
|
|
591
|
+
headers: {
|
|
592
|
+
"Content-Type": "application/json",
|
|
593
|
+
"Authorization": formattedToken,
|
|
594
|
+
"x-TenantID": `tenant_${projectId}`
|
|
595
|
+
},
|
|
596
|
+
keepalive: true
|
|
597
|
+
});
|
|
598
|
+
} catch (e) {
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
function startHeartbeat() {
|
|
602
|
+
if (!tracker || tracker.intervalId) return;
|
|
603
|
+
sendLog("pageview");
|
|
604
|
+
tracker.intervalId = setInterval(() => sendLog("heartbeat"), HEARTBEAT_INTERVAL_MS);
|
|
605
|
+
}
|
|
606
|
+
function stopHeartbeat() {
|
|
607
|
+
if (!(tracker == null ? void 0 : tracker.intervalId)) return;
|
|
608
|
+
clearInterval(tracker.intervalId);
|
|
609
|
+
tracker.intervalId = null;
|
|
610
|
+
}
|
|
611
|
+
function startTracking() {
|
|
612
|
+
if (typeof window === "undefined") return;
|
|
613
|
+
stopTracking();
|
|
614
|
+
const sessionId = getSessionId();
|
|
615
|
+
if (!sessionId) return;
|
|
616
|
+
const visibilityHandler = () => {
|
|
617
|
+
if (document.hidden) {
|
|
618
|
+
stopHeartbeat();
|
|
619
|
+
} else {
|
|
620
|
+
startHeartbeat();
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
tracker = { intervalId: null, sessionId, visibilityHandler };
|
|
624
|
+
document.addEventListener("visibilitychange", visibilityHandler);
|
|
625
|
+
startHeartbeat();
|
|
626
|
+
}
|
|
627
|
+
function stopTracking() {
|
|
628
|
+
if (!tracker) return;
|
|
629
|
+
stopHeartbeat();
|
|
630
|
+
if (tracker.visibilityHandler) {
|
|
631
|
+
document.removeEventListener("visibilitychange", tracker.visibilityHandler);
|
|
632
|
+
}
|
|
633
|
+
tracker = null;
|
|
634
|
+
}
|
|
635
|
+
|
|
557
636
|
// src/config.ts
|
|
558
637
|
var globalConfig = null;
|
|
559
638
|
function configureSdkMitra(config) {
|
|
560
|
-
var _a, _b;
|
|
561
639
|
if (!config.baseURL) {
|
|
562
640
|
throw new Error("baseURL \xE9 obrigat\xF3rio");
|
|
563
641
|
}
|
|
@@ -565,9 +643,8 @@ function configureSdkMitra(config) {
|
|
|
565
643
|
...config,
|
|
566
644
|
baseURL: config.baseURL.replace(/\/+$/, "")
|
|
567
645
|
};
|
|
568
|
-
if (config.token && typeof window !== "undefined"
|
|
569
|
-
(
|
|
570
|
-
(_b = window.__cbTracker) == null ? void 0 : _b.setBackUrl(config.baseURL);
|
|
646
|
+
if (config.token && typeof window !== "undefined") {
|
|
647
|
+
startTracking();
|
|
571
648
|
}
|
|
572
649
|
return createMitraInstance(config);
|
|
573
650
|
}
|
|
@@ -1034,6 +1111,7 @@ exports.setProfileServerFunctionsMitra = setProfileServerFunctionsMitra;
|
|
|
1034
1111
|
exports.setProfileUsersMitra = setProfileUsersMitra;
|
|
1035
1112
|
exports.setVariableMitra = setVariableMitra;
|
|
1036
1113
|
exports.stopServerFunctionExecutionMitra = stopServerFunctionExecutionMitra;
|
|
1114
|
+
exports.stopTracking = stopTracking;
|
|
1037
1115
|
exports.updateProfileMitra = updateProfileMitra;
|
|
1038
1116
|
exports.updateRecordMitra = updateRecordMitra;
|
|
1039
1117
|
exports.uploadFileLoadableMitra = uploadFileLoadableMitra;
|