@outlit/browser 1.4.3 → 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 +69 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -6
- 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 +72 -5
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +75 -7
- package/dist/react/index.mjs.map +1 -1
- package/dist/{tracker-CzhtZoOC.d.mts → tracker-DlHUyaah.d.mts} +3 -5
- package/dist/{tracker-CzhtZoOC.d.ts → tracker-DlHUyaah.d.ts} +3 -5
- package/dist/vue/index.d.mts +46 -46
- package/dist/vue/index.d.ts +46 -46
- package/dist/vue/index.js +72 -5
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/index.mjs +75 -7
- package/dist/vue/index.mjs.map +1 -1
- package/package.json +32 -18
package/dist/vue/index.d.mts
CHANGED
|
@@ -1,50 +1,6 @@
|
|
|
1
|
-
import { ShallowRef, Ref, InjectionKey, App } from 'vue';
|
|
2
|
-
import { O as Outlit, U as UserIdentity, h as OutlitOptions, B as BillingOptions } from '../tracker-CzhtZoOC.mjs';
|
|
3
1
|
import { BrowserIdentifyOptions, BrowserTrackOptions } from '@outlit/core';
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
};
|
|
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 { ShallowRef, Ref, InjectionKey, App } from 'vue';
|
|
2
|
-
import { O as Outlit, U as UserIdentity, h as OutlitOptions, B as BillingOptions } from '../tracker-CzhtZoOC.js';
|
|
3
1
|
import { BrowserIdentifyOptions, BrowserTrackOptions } from '@outlit/core';
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
};
|
|
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
|
|
|
@@ -817,11 +820,19 @@ var Outlit = class {
|
|
|
817
820
|
console.warn("[Outlit] Tracking not enabled. Call enableTracking() first.");
|
|
818
821
|
return;
|
|
819
822
|
}
|
|
823
|
+
if (!options.email && !options.userId) {
|
|
824
|
+
console.warn("[Outlit] identify requires email or userId");
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
820
827
|
if (options.email || options.userId) {
|
|
821
828
|
const hadNoUser = !this.currentUser;
|
|
822
829
|
this.currentUser = {
|
|
823
830
|
email: options.email,
|
|
824
|
-
userId: options.userId
|
|
831
|
+
userId: options.userId,
|
|
832
|
+
customerId: options.customerId,
|
|
833
|
+
customerDomain: options.customerDomain,
|
|
834
|
+
customerTraits: options.customerTraits,
|
|
835
|
+
traits: options.traits
|
|
825
836
|
};
|
|
826
837
|
if (hadNoUser) {
|
|
827
838
|
this.flushPendingStageEvents();
|
|
@@ -832,6 +843,9 @@ var Outlit = class {
|
|
|
832
843
|
referrer: document.referrer,
|
|
833
844
|
email: options.email,
|
|
834
845
|
userId: options.userId,
|
|
846
|
+
customerId: options.customerId,
|
|
847
|
+
customerDomain: options.customerDomain,
|
|
848
|
+
customerTraits: options.customerTraits,
|
|
835
849
|
traits: options.traits
|
|
836
850
|
});
|
|
837
851
|
this.enqueue(event);
|
|
@@ -873,7 +887,14 @@ var Outlit = class {
|
|
|
873
887
|
*/
|
|
874
888
|
applyUser(identity) {
|
|
875
889
|
this.currentUser = identity;
|
|
876
|
-
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
|
+
});
|
|
877
898
|
this.flushPendingStageEvents();
|
|
878
899
|
}
|
|
879
900
|
/**
|
|
@@ -941,11 +962,23 @@ var Outlit = class {
|
|
|
941
962
|
console.warn("[Outlit] Tracking not enabled. Call enableTracking() first.");
|
|
942
963
|
return;
|
|
943
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
|
+
}
|
|
944
976
|
const event = (0, import_core3.buildBillingEvent)({
|
|
945
977
|
url: window.location.href,
|
|
946
978
|
referrer: document.referrer,
|
|
947
979
|
status,
|
|
948
980
|
customerId: options.customerId,
|
|
981
|
+
customerDomain: options.customerDomain,
|
|
949
982
|
stripeCustomerId: options.stripeCustomerId,
|
|
950
983
|
domain: options.domain,
|
|
951
984
|
properties: options.properties
|
|
@@ -1063,12 +1096,47 @@ var Outlit = class {
|
|
|
1063
1096
|
this.flush();
|
|
1064
1097
|
}, this.flushInterval);
|
|
1065
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
|
+
}
|
|
1066
1125
|
async sendEvents(events) {
|
|
1067
1126
|
if (events.length === 0) return;
|
|
1068
1127
|
if (!this.visitorId) return;
|
|
1069
|
-
const userIdentity = this.
|
|
1128
|
+
const userIdentity = this.getPayloadUserIdentity();
|
|
1129
|
+
const customerIdentity = this.getPayloadCustomerIdentity();
|
|
1070
1130
|
const sessionId = this.sessionTracker?.getSessionId();
|
|
1071
|
-
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
|
+
);
|
|
1072
1140
|
const url = `${this.apiHost}/api/i/v1/${this.publicKey}/events`;
|
|
1073
1141
|
try {
|
|
1074
1142
|
if (typeof navigator !== "undefined" && navigator.sendBeacon) {
|
|
@@ -1162,7 +1230,6 @@ var OutlitPlugin = {
|
|
|
1162
1230
|
};
|
|
1163
1231
|
|
|
1164
1232
|
// src/vue/composables.ts
|
|
1165
|
-
var import_vue2 = require("vue");
|
|
1166
1233
|
function useOutlit() {
|
|
1167
1234
|
const instance = (0, import_vue2.inject)(OutlitKey);
|
|
1168
1235
|
if (!instance) {
|