@outlit/browser 1.4.1 → 1.4.5
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +96 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -8
- package/dist/index.mjs.map +1 -1
- package/dist/outlit.global.js +1 -1
- package/dist/outlit.global.js.map +1 -1
- package/dist/react/index.d.mts +116 -116
- package/dist/react/index.d.ts +116 -116
- package/dist/react/index.js +100 -8
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +103 -10
- package/dist/react/index.mjs.map +1 -1
- package/dist/{tracker-OMgVDwlV.d.mts → tracker-DlHUyaah.d.mts} +5 -6
- package/dist/{tracker-OMgVDwlV.d.ts → tracker-DlHUyaah.d.ts} +5 -6
- package/dist/vue/index.d.mts +47 -47
- package/dist/vue/index.d.ts +47 -47
- package/dist/vue/index.js +99 -7
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/index.mjs +102 -9
- package/dist/vue/index.mjs.map +1 -1
- package/package.json +32 -32
- package/LICENSE +0 -201
package/dist/vue/index.d.mts
CHANGED
|
@@ -1,50 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
interface OutlitPluginOptions extends Omit<OutlitOptions, "trackPageviews"> {
|
|
6
|
-
/**
|
|
7
|
-
* Whether to automatically track pageviews.
|
|
8
|
-
* @default true
|
|
9
|
-
*/
|
|
10
|
-
trackPageviews?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Whether to start tracking automatically.
|
|
13
|
-
* Set to false if you need to wait for user consent.
|
|
14
|
-
* @default true
|
|
15
|
-
*/
|
|
16
|
-
autoTrack?: boolean;
|
|
17
|
-
}
|
|
18
|
-
interface OutlitInstance {
|
|
19
|
-
outlit: ShallowRef<Outlit | null>;
|
|
20
|
-
isInitialized: Readonly<Ref<boolean>>;
|
|
21
|
-
isTrackingEnabled: Readonly<Ref<boolean>>;
|
|
22
|
-
enableTracking: () => void;
|
|
23
|
-
disableTracking: () => void;
|
|
24
|
-
/**
|
|
25
|
-
* Set the current user. Automatically calls identify when user changes.
|
|
26
|
-
* Pass null to clear the user (logout).
|
|
27
|
-
*/
|
|
28
|
-
setUser: (user: UserIdentity | null) => void;
|
|
29
|
-
}
|
|
30
|
-
declare const OutlitKey: InjectionKey<OutlitInstance>;
|
|
31
|
-
/**
|
|
32
|
-
* Vue plugin to install Outlit.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* // main.ts
|
|
37
|
-
* import { createApp } from 'vue'
|
|
38
|
-
* import { OutlitPlugin } from '@outlit/browser/vue'
|
|
39
|
-
*
|
|
40
|
-
* const app = createApp(App)
|
|
41
|
-
* app.use(OutlitPlugin, { publicKey: 'pk_xxx' })
|
|
42
|
-
* app.mount('#app')
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
declare const OutlitPlugin: {
|
|
46
|
-
install(app: App, options: OutlitPluginOptions): void;
|
|
47
|
-
};
|
|
1
|
+
import { BrowserIdentifyOptions, BrowserTrackOptions } from '@outlit/core';
|
|
2
|
+
import { Ref, ShallowRef, InjectionKey, App } from 'vue';
|
|
3
|
+
import { U as UserIdentity, B as BillingOptions, O as Outlit, h as OutlitOptions } from '../tracker-DlHUyaah.mjs';
|
|
48
4
|
|
|
49
5
|
interface UseOutlitReturn {
|
|
50
6
|
/**
|
|
@@ -201,4 +157,48 @@ type UseTrackReturn = ReturnType<typeof useTrack>;
|
|
|
201
157
|
*/
|
|
202
158
|
type UseIdentifyReturn = ReturnType<typeof useIdentify>;
|
|
203
159
|
|
|
160
|
+
interface OutlitPluginOptions extends Omit<OutlitOptions, "trackPageviews"> {
|
|
161
|
+
/**
|
|
162
|
+
* Whether to automatically track pageviews.
|
|
163
|
+
* @default true
|
|
164
|
+
*/
|
|
165
|
+
trackPageviews?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Whether to start tracking automatically.
|
|
168
|
+
* Set to false if you need to wait for user consent.
|
|
169
|
+
* @default true
|
|
170
|
+
*/
|
|
171
|
+
autoTrack?: boolean;
|
|
172
|
+
}
|
|
173
|
+
interface OutlitInstance {
|
|
174
|
+
outlit: ShallowRef<Outlit | null>;
|
|
175
|
+
isInitialized: Readonly<Ref<boolean>>;
|
|
176
|
+
isTrackingEnabled: Readonly<Ref<boolean>>;
|
|
177
|
+
enableTracking: () => void;
|
|
178
|
+
disableTracking: () => void;
|
|
179
|
+
/**
|
|
180
|
+
* Set the current user. Automatically calls identify when user changes.
|
|
181
|
+
* Pass null to clear the user (logout).
|
|
182
|
+
*/
|
|
183
|
+
setUser: (user: UserIdentity | null) => void;
|
|
184
|
+
}
|
|
185
|
+
declare const OutlitKey: InjectionKey<OutlitInstance>;
|
|
186
|
+
/**
|
|
187
|
+
* Vue plugin to install Outlit.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* // main.ts
|
|
192
|
+
* import { createApp } from 'vue'
|
|
193
|
+
* import { OutlitPlugin } from '@outlit/browser/vue'
|
|
194
|
+
*
|
|
195
|
+
* const app = createApp(App)
|
|
196
|
+
* app.use(OutlitPlugin, { publicKey: 'pk_xxx' })
|
|
197
|
+
* app.mount('#app')
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
declare const OutlitPlugin: {
|
|
201
|
+
install(app: App, options: OutlitPluginOptions): void;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
204
|
export { type OutlitInstance, OutlitKey, OutlitPlugin, type OutlitPluginOptions, type UseIdentifyReturn, type UseOutlitReturn, type UseTrackReturn, useIdentify, useOutlit, useOutlitUser, useTrack };
|
package/dist/vue/index.d.ts
CHANGED
|
@@ -1,50 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
interface OutlitPluginOptions extends Omit<OutlitOptions, "trackPageviews"> {
|
|
6
|
-
/**
|
|
7
|
-
* Whether to automatically track pageviews.
|
|
8
|
-
* @default true
|
|
9
|
-
*/
|
|
10
|
-
trackPageviews?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Whether to start tracking automatically.
|
|
13
|
-
* Set to false if you need to wait for user consent.
|
|
14
|
-
* @default true
|
|
15
|
-
*/
|
|
16
|
-
autoTrack?: boolean;
|
|
17
|
-
}
|
|
18
|
-
interface OutlitInstance {
|
|
19
|
-
outlit: ShallowRef<Outlit | null>;
|
|
20
|
-
isInitialized: Readonly<Ref<boolean>>;
|
|
21
|
-
isTrackingEnabled: Readonly<Ref<boolean>>;
|
|
22
|
-
enableTracking: () => void;
|
|
23
|
-
disableTracking: () => void;
|
|
24
|
-
/**
|
|
25
|
-
* Set the current user. Automatically calls identify when user changes.
|
|
26
|
-
* Pass null to clear the user (logout).
|
|
27
|
-
*/
|
|
28
|
-
setUser: (user: UserIdentity | null) => void;
|
|
29
|
-
}
|
|
30
|
-
declare const OutlitKey: InjectionKey<OutlitInstance>;
|
|
31
|
-
/**
|
|
32
|
-
* Vue plugin to install Outlit.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* // main.ts
|
|
37
|
-
* import { createApp } from 'vue'
|
|
38
|
-
* import { OutlitPlugin } from '@outlit/browser/vue'
|
|
39
|
-
*
|
|
40
|
-
* const app = createApp(App)
|
|
41
|
-
* app.use(OutlitPlugin, { publicKey: 'pk_xxx' })
|
|
42
|
-
* app.mount('#app')
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
declare const OutlitPlugin: {
|
|
46
|
-
install(app: App, options: OutlitPluginOptions): void;
|
|
47
|
-
};
|
|
1
|
+
import { BrowserIdentifyOptions, BrowserTrackOptions } from '@outlit/core';
|
|
2
|
+
import { Ref, ShallowRef, InjectionKey, App } from 'vue';
|
|
3
|
+
import { U as UserIdentity, B as BillingOptions, O as Outlit, h as OutlitOptions } from '../tracker-DlHUyaah.js';
|
|
48
4
|
|
|
49
5
|
interface UseOutlitReturn {
|
|
50
6
|
/**
|
|
@@ -201,4 +157,48 @@ type UseTrackReturn = ReturnType<typeof useTrack>;
|
|
|
201
157
|
*/
|
|
202
158
|
type UseIdentifyReturn = ReturnType<typeof useIdentify>;
|
|
203
159
|
|
|
160
|
+
interface OutlitPluginOptions extends Omit<OutlitOptions, "trackPageviews"> {
|
|
161
|
+
/**
|
|
162
|
+
* Whether to automatically track pageviews.
|
|
163
|
+
* @default true
|
|
164
|
+
*/
|
|
165
|
+
trackPageviews?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Whether to start tracking automatically.
|
|
168
|
+
* Set to false if you need to wait for user consent.
|
|
169
|
+
* @default true
|
|
170
|
+
*/
|
|
171
|
+
autoTrack?: boolean;
|
|
172
|
+
}
|
|
173
|
+
interface OutlitInstance {
|
|
174
|
+
outlit: ShallowRef<Outlit | null>;
|
|
175
|
+
isInitialized: Readonly<Ref<boolean>>;
|
|
176
|
+
isTrackingEnabled: Readonly<Ref<boolean>>;
|
|
177
|
+
enableTracking: () => void;
|
|
178
|
+
disableTracking: () => void;
|
|
179
|
+
/**
|
|
180
|
+
* Set the current user. Automatically calls identify when user changes.
|
|
181
|
+
* Pass null to clear the user (logout).
|
|
182
|
+
*/
|
|
183
|
+
setUser: (user: UserIdentity | null) => void;
|
|
184
|
+
}
|
|
185
|
+
declare const OutlitKey: InjectionKey<OutlitInstance>;
|
|
186
|
+
/**
|
|
187
|
+
* Vue plugin to install Outlit.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* // main.ts
|
|
192
|
+
* import { createApp } from 'vue'
|
|
193
|
+
* import { OutlitPlugin } from '@outlit/browser/vue'
|
|
194
|
+
*
|
|
195
|
+
* const app = createApp(App)
|
|
196
|
+
* app.use(OutlitPlugin, { publicKey: 'pk_xxx' })
|
|
197
|
+
* app.mount('#app')
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
declare const OutlitPlugin: {
|
|
201
|
+
install(app: App, options: OutlitPluginOptions): void;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
204
|
export { type OutlitInstance, OutlitKey, OutlitPlugin, type OutlitPluginOptions, type UseIdentifyReturn, type UseOutlitReturn, type UseTrackReturn, useIdentify, useOutlit, useOutlitUser, useTrack };
|
package/dist/vue/index.js
CHANGED
|
@@ -29,6 +29,9 @@ __export(vue_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(vue_exports);
|
|
31
31
|
|
|
32
|
+
// src/vue/composables.ts
|
|
33
|
+
var import_vue2 = require("vue");
|
|
34
|
+
|
|
32
35
|
// src/vue/plugin.ts
|
|
33
36
|
var import_vue = require("vue");
|
|
34
37
|
|
|
@@ -676,11 +679,23 @@ var Outlit = class {
|
|
|
676
679
|
currentUser = null;
|
|
677
680
|
pendingUser = null;
|
|
678
681
|
pendingStageEvents = [];
|
|
682
|
+
exitCleanups = [];
|
|
679
683
|
constructor(options) {
|
|
680
684
|
this.publicKey = options.publicKey;
|
|
681
685
|
this.apiHost = options.apiHost ?? import_core3.DEFAULT_API_HOST;
|
|
682
686
|
this.flushInterval = options.flushInterval ?? 5e3;
|
|
683
687
|
this.options = options;
|
|
688
|
+
const isDev = typeof window !== "undefined" && typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
689
|
+
if (isDev) {
|
|
690
|
+
const key = `__outlit_${options.publicKey}`;
|
|
691
|
+
if (window[key]) {
|
|
692
|
+
console.warn(
|
|
693
|
+
"[Outlit] Multiple instances created with the same key. If using HMR, this is expected. Otherwise, use init() for singleton behavior or call shutdown() on the previous instance."
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
;
|
|
697
|
+
window[key] = true;
|
|
698
|
+
}
|
|
684
699
|
if (typeof window !== "undefined") {
|
|
685
700
|
const handleExit = () => {
|
|
686
701
|
if (this.hasHandledExit) return;
|
|
@@ -688,15 +703,21 @@ var Outlit = class {
|
|
|
688
703
|
this.sessionTracker?.emitEngagement();
|
|
689
704
|
this.flush();
|
|
690
705
|
};
|
|
691
|
-
|
|
706
|
+
const visibilityHandler = () => {
|
|
692
707
|
if (document.visibilityState === "hidden") {
|
|
693
708
|
handleExit();
|
|
694
709
|
} else {
|
|
695
710
|
this.hasHandledExit = false;
|
|
696
711
|
}
|
|
697
|
-
}
|
|
712
|
+
};
|
|
713
|
+
document.addEventListener("visibilitychange", visibilityHandler);
|
|
698
714
|
window.addEventListener("pagehide", handleExit);
|
|
699
715
|
window.addEventListener("beforeunload", handleExit);
|
|
716
|
+
this.exitCleanups = [
|
|
717
|
+
() => document.removeEventListener("visibilitychange", visibilityHandler),
|
|
718
|
+
() => window.removeEventListener("pagehide", handleExit),
|
|
719
|
+
() => window.removeEventListener("beforeunload", handleExit)
|
|
720
|
+
];
|
|
700
721
|
}
|
|
701
722
|
this.isInitialized = true;
|
|
702
723
|
const consent = getConsentState();
|
|
@@ -799,11 +820,19 @@ var Outlit = class {
|
|
|
799
820
|
console.warn("[Outlit] Tracking not enabled. Call enableTracking() first.");
|
|
800
821
|
return;
|
|
801
822
|
}
|
|
823
|
+
if (!options.email && !options.userId) {
|
|
824
|
+
console.warn("[Outlit] identify requires email or userId");
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
802
827
|
if (options.email || options.userId) {
|
|
803
828
|
const hadNoUser = !this.currentUser;
|
|
804
829
|
this.currentUser = {
|
|
805
830
|
email: options.email,
|
|
806
|
-
userId: options.userId
|
|
831
|
+
userId: options.userId,
|
|
832
|
+
customerId: options.customerId,
|
|
833
|
+
customerDomain: options.customerDomain,
|
|
834
|
+
customerTraits: options.customerTraits,
|
|
835
|
+
traits: options.traits
|
|
807
836
|
};
|
|
808
837
|
if (hadNoUser) {
|
|
809
838
|
this.flushPendingStageEvents();
|
|
@@ -814,6 +843,9 @@ var Outlit = class {
|
|
|
814
843
|
referrer: document.referrer,
|
|
815
844
|
email: options.email,
|
|
816
845
|
userId: options.userId,
|
|
846
|
+
customerId: options.customerId,
|
|
847
|
+
customerDomain: options.customerDomain,
|
|
848
|
+
customerTraits: options.customerTraits,
|
|
817
849
|
traits: options.traits
|
|
818
850
|
});
|
|
819
851
|
this.enqueue(event);
|
|
@@ -855,7 +887,14 @@ var Outlit = class {
|
|
|
855
887
|
*/
|
|
856
888
|
applyUser(identity) {
|
|
857
889
|
this.currentUser = identity;
|
|
858
|
-
this.identify({
|
|
890
|
+
this.identify({
|
|
891
|
+
email: identity.email,
|
|
892
|
+
userId: identity.userId,
|
|
893
|
+
traits: identity.traits,
|
|
894
|
+
customerId: identity.customerId,
|
|
895
|
+
customerDomain: identity.customerDomain,
|
|
896
|
+
customerTraits: identity.customerTraits
|
|
897
|
+
});
|
|
859
898
|
this.flushPendingStageEvents();
|
|
860
899
|
}
|
|
861
900
|
/**
|
|
@@ -923,11 +962,23 @@ var Outlit = class {
|
|
|
923
962
|
console.warn("[Outlit] Tracking not enabled. Call enableTracking() first.");
|
|
924
963
|
return;
|
|
925
964
|
}
|
|
965
|
+
try {
|
|
966
|
+
(0, import_core3.validateCustomerIdentity)(
|
|
967
|
+
options.customerId,
|
|
968
|
+
options.customerDomain,
|
|
969
|
+
options.domain,
|
|
970
|
+
options.stripeCustomerId
|
|
971
|
+
);
|
|
972
|
+
} catch (error) {
|
|
973
|
+
console.warn("[Outlit]", error instanceof Error ? error.message : error);
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
926
976
|
const event = (0, import_core3.buildBillingEvent)({
|
|
927
977
|
url: window.location.href,
|
|
928
978
|
referrer: document.referrer,
|
|
929
979
|
status,
|
|
930
980
|
customerId: options.customerId,
|
|
981
|
+
customerDomain: options.customerDomain,
|
|
931
982
|
stripeCustomerId: options.stripeCustomerId,
|
|
932
983
|
domain: options.domain,
|
|
933
984
|
properties: options.properties
|
|
@@ -962,6 +1013,13 @@ var Outlit = class {
|
|
|
962
1013
|
stopCalendarTracking();
|
|
963
1014
|
stopSessionTracking();
|
|
964
1015
|
this.sessionTracker = null;
|
|
1016
|
+
for (const cleanup of this.exitCleanups) {
|
|
1017
|
+
cleanup();
|
|
1018
|
+
}
|
|
1019
|
+
this.exitCleanups = [];
|
|
1020
|
+
if (typeof window !== "undefined" && typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
|
|
1021
|
+
delete window[`__outlit_${this.publicKey}`];
|
|
1022
|
+
}
|
|
965
1023
|
await this.flush();
|
|
966
1024
|
}
|
|
967
1025
|
// ============================================
|
|
@@ -1038,12 +1096,47 @@ var Outlit = class {
|
|
|
1038
1096
|
this.flush();
|
|
1039
1097
|
}, this.flushInterval);
|
|
1040
1098
|
}
|
|
1099
|
+
getPayloadUserIdentity() {
|
|
1100
|
+
if (!this.currentUser) {
|
|
1101
|
+
return void 0;
|
|
1102
|
+
}
|
|
1103
|
+
const { email, userId } = this.currentUser;
|
|
1104
|
+
if (!email && !userId) {
|
|
1105
|
+
return void 0;
|
|
1106
|
+
}
|
|
1107
|
+
return {
|
|
1108
|
+
...email && { email },
|
|
1109
|
+
...userId && { userId }
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
getPayloadCustomerIdentity() {
|
|
1113
|
+
if (!this.currentUser) {
|
|
1114
|
+
return void 0;
|
|
1115
|
+
}
|
|
1116
|
+
const { customerId, customerDomain } = this.currentUser;
|
|
1117
|
+
if (!customerId && !customerDomain) {
|
|
1118
|
+
return void 0;
|
|
1119
|
+
}
|
|
1120
|
+
return {
|
|
1121
|
+
...customerId && { customerId },
|
|
1122
|
+
...customerDomain && { customerDomain }
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1041
1125
|
async sendEvents(events) {
|
|
1042
1126
|
if (events.length === 0) return;
|
|
1043
1127
|
if (!this.visitorId) return;
|
|
1044
|
-
const userIdentity = this.
|
|
1128
|
+
const userIdentity = this.getPayloadUserIdentity();
|
|
1129
|
+
const customerIdentity = this.getPayloadCustomerIdentity();
|
|
1045
1130
|
const sessionId = this.sessionTracker?.getSessionId();
|
|
1046
|
-
const payload = (0, import_core3.buildIngestPayload)(
|
|
1131
|
+
const payload = (0, import_core3.buildIngestPayload)(
|
|
1132
|
+
this.visitorId,
|
|
1133
|
+
"client",
|
|
1134
|
+
events,
|
|
1135
|
+
userIdentity,
|
|
1136
|
+
sessionId,
|
|
1137
|
+
void 0,
|
|
1138
|
+
customerIdentity
|
|
1139
|
+
);
|
|
1047
1140
|
const url = `${this.apiHost}/api/i/v1/${this.publicKey}/events`;
|
|
1048
1141
|
try {
|
|
1049
1142
|
if (typeof navigator !== "undefined" && navigator.sendBeacon) {
|
|
@@ -1137,7 +1230,6 @@ var OutlitPlugin = {
|
|
|
1137
1230
|
};
|
|
1138
1231
|
|
|
1139
1232
|
// src/vue/composables.ts
|
|
1140
|
-
var import_vue2 = require("vue");
|
|
1141
1233
|
function useOutlit() {
|
|
1142
1234
|
const instance = (0, import_vue2.inject)(OutlitKey);
|
|
1143
1235
|
if (!instance) {
|