@blinkdotnew/sdk 0.18.3 → 0.18.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/README.md +2 -2
- package/dist/index.d.mts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +40 -18
- package/dist/index.mjs +40 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
**The full-stack TypeScript SDK that powers Blink AI-generated apps**
|
|
7
7
|
|
|
8
|
-
Blink is an AI App
|
|
8
|
+
Blink is an AI App Builder that builds fully functional apps in seconds. This SDK (`@blinkdotnew/sdk`) is the TypeScript foundation that powers every Blink app natively, providing zero-boilerplate authentication, database operations, AI capabilities, and file storage. Works seamlessly on both client-side (React, Vue, etc.) and server-side (Node.js, Deno, Edge functions).
|
|
9
9
|
|
|
10
10
|
## 🚀 Quick Start
|
|
11
11
|
|
|
@@ -133,7 +133,7 @@ const { publicUrl } = await blink.storage.upload(
|
|
|
133
133
|
|
|
134
134
|
## 🤖 What is Blink?
|
|
135
135
|
|
|
136
|
-
**Blink is an AI App
|
|
136
|
+
**Blink is an AI App Builder** that creates fully functional applications in seconds. Simply describe what you want to build, and Blink's AI agent will:
|
|
137
137
|
|
|
138
138
|
- 🏗️ **Generate complete apps** with React + TypeScript + Vite
|
|
139
139
|
- 🔧 **Auto-install this SDK** with zero configuration
|
package/dist/index.d.mts
CHANGED
|
@@ -826,6 +826,18 @@ declare class BlinkAuth {
|
|
|
826
826
|
private initializationPromise;
|
|
827
827
|
private isInitialized;
|
|
828
828
|
constructor(config: BlinkClientConfig);
|
|
829
|
+
/**
|
|
830
|
+
* Generate project-scoped storage key
|
|
831
|
+
*/
|
|
832
|
+
private getStorageKey;
|
|
833
|
+
/**
|
|
834
|
+
* Migrate existing global tokens to project-scoped storage
|
|
835
|
+
* DISABLED: We don't migrate global blink_tokens anymore because:
|
|
836
|
+
* 1. Platform uses blink_tokens for platform auth (different user)
|
|
837
|
+
* 2. Migrating platform tokens would cause project to show wrong user
|
|
838
|
+
* 3. Projects should always authenticate fresh via their own flow
|
|
839
|
+
*/
|
|
840
|
+
private migrateExistingTokens;
|
|
829
841
|
/**
|
|
830
842
|
* Wait for authentication initialization to complete
|
|
831
843
|
*/
|
|
@@ -1238,6 +1250,10 @@ declare class BlinkAnalyticsImpl implements BlinkAnalytics {
|
|
|
1238
1250
|
private utmParams;
|
|
1239
1251
|
private persistedAttribution;
|
|
1240
1252
|
constructor(httpClient: HttpClient, projectId: string);
|
|
1253
|
+
/**
|
|
1254
|
+
* Generate project-scoped storage key for analytics
|
|
1255
|
+
*/
|
|
1256
|
+
private getStorageKey;
|
|
1241
1257
|
/**
|
|
1242
1258
|
* Log a custom analytics event
|
|
1243
1259
|
*/
|
|
@@ -1477,7 +1493,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1477
1493
|
* // With options
|
|
1478
1494
|
* const { text, usage } = await blink.ai.generateText({
|
|
1479
1495
|
* prompt: "Summarize this article",
|
|
1480
|
-
* model: "gpt-
|
|
1496
|
+
* model: "gpt-4.1-mini",
|
|
1481
1497
|
* maxTokens: 150,
|
|
1482
1498
|
* temperature: 0.7
|
|
1483
1499
|
* });
|
|
@@ -1485,7 +1501,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1485
1501
|
* // With web search (OpenAI models only)
|
|
1486
1502
|
* const { text, sources } = await blink.ai.generateText({
|
|
1487
1503
|
* prompt: "What are the latest developments in AI?",
|
|
1488
|
-
* model: "gpt-
|
|
1504
|
+
* model: "gpt-4.1-mini",
|
|
1489
1505
|
* search: true // Enables web search
|
|
1490
1506
|
* });
|
|
1491
1507
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -826,6 +826,18 @@ declare class BlinkAuth {
|
|
|
826
826
|
private initializationPromise;
|
|
827
827
|
private isInitialized;
|
|
828
828
|
constructor(config: BlinkClientConfig);
|
|
829
|
+
/**
|
|
830
|
+
* Generate project-scoped storage key
|
|
831
|
+
*/
|
|
832
|
+
private getStorageKey;
|
|
833
|
+
/**
|
|
834
|
+
* Migrate existing global tokens to project-scoped storage
|
|
835
|
+
* DISABLED: We don't migrate global blink_tokens anymore because:
|
|
836
|
+
* 1. Platform uses blink_tokens for platform auth (different user)
|
|
837
|
+
* 2. Migrating platform tokens would cause project to show wrong user
|
|
838
|
+
* 3. Projects should always authenticate fresh via their own flow
|
|
839
|
+
*/
|
|
840
|
+
private migrateExistingTokens;
|
|
829
841
|
/**
|
|
830
842
|
* Wait for authentication initialization to complete
|
|
831
843
|
*/
|
|
@@ -1238,6 +1250,10 @@ declare class BlinkAnalyticsImpl implements BlinkAnalytics {
|
|
|
1238
1250
|
private utmParams;
|
|
1239
1251
|
private persistedAttribution;
|
|
1240
1252
|
constructor(httpClient: HttpClient, projectId: string);
|
|
1253
|
+
/**
|
|
1254
|
+
* Generate project-scoped storage key for analytics
|
|
1255
|
+
*/
|
|
1256
|
+
private getStorageKey;
|
|
1241
1257
|
/**
|
|
1242
1258
|
* Log a custom analytics event
|
|
1243
1259
|
*/
|
|
@@ -1477,7 +1493,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1477
1493
|
* // With options
|
|
1478
1494
|
* const { text, usage } = await blink.ai.generateText({
|
|
1479
1495
|
* prompt: "Summarize this article",
|
|
1480
|
-
* model: "gpt-
|
|
1496
|
+
* model: "gpt-4.1-mini",
|
|
1481
1497
|
* maxTokens: 150,
|
|
1482
1498
|
* temperature: 0.7
|
|
1483
1499
|
* });
|
|
@@ -1485,7 +1501,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
1485
1501
|
* // With web search (OpenAI models only)
|
|
1486
1502
|
* const { text, sources } = await blink.ai.generateText({
|
|
1487
1503
|
* prompt: "What are the latest developments in AI?",
|
|
1488
|
-
* model: "gpt-
|
|
1504
|
+
* model: "gpt-4.1-mini",
|
|
1489
1505
|
* search: true // Enables web search
|
|
1490
1506
|
* });
|
|
1491
1507
|
*
|
package/dist/index.js
CHANGED
|
@@ -916,6 +916,9 @@ var BlinkAuth = class {
|
|
|
916
916
|
isInitialized = false;
|
|
917
917
|
constructor(config) {
|
|
918
918
|
this.config = config;
|
|
919
|
+
if (!config.projectId) {
|
|
920
|
+
throw new Error("projectId is required for authentication");
|
|
921
|
+
}
|
|
919
922
|
this.authConfig = {
|
|
920
923
|
mode: "managed",
|
|
921
924
|
// Default mode
|
|
@@ -946,6 +949,21 @@ var BlinkAuth = class {
|
|
|
946
949
|
this.isInitialized = true;
|
|
947
950
|
}
|
|
948
951
|
}
|
|
952
|
+
/**
|
|
953
|
+
* Generate project-scoped storage key
|
|
954
|
+
*/
|
|
955
|
+
getStorageKey(suffix) {
|
|
956
|
+
return `blink_${suffix}_${this.config.projectId}`;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Migrate existing global tokens to project-scoped storage
|
|
960
|
+
* DISABLED: We don't migrate global blink_tokens anymore because:
|
|
961
|
+
* 1. Platform uses blink_tokens for platform auth (different user)
|
|
962
|
+
* 2. Migrating platform tokens would cause project to show wrong user
|
|
963
|
+
* 3. Projects should always authenticate fresh via their own flow
|
|
964
|
+
*/
|
|
965
|
+
migrateExistingTokens() {
|
|
966
|
+
}
|
|
949
967
|
/**
|
|
950
968
|
* Wait for authentication initialization to complete
|
|
951
969
|
*/
|
|
@@ -996,6 +1014,7 @@ var BlinkAuth = class {
|
|
|
996
1014
|
console.log("\u{1F680} Initializing Blink Auth...");
|
|
997
1015
|
this.setLoading(true);
|
|
998
1016
|
try {
|
|
1017
|
+
this.migrateExistingTokens();
|
|
999
1018
|
if (this.isIframe) {
|
|
1000
1019
|
console.log("\u{1F50D} Detected iframe environment, waiting for parent tokens...");
|
|
1001
1020
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -2068,7 +2087,7 @@ var BlinkAuth = class {
|
|
|
2068
2087
|
});
|
|
2069
2088
|
if (persist && typeof window !== "undefined") {
|
|
2070
2089
|
try {
|
|
2071
|
-
localStorage.setItem("
|
|
2090
|
+
localStorage.setItem(this.getStorageKey("tokens"), JSON.stringify(tokensWithTimestamp));
|
|
2072
2091
|
console.log("\u{1F4BE} Tokens persisted to localStorage");
|
|
2073
2092
|
} catch (error) {
|
|
2074
2093
|
console.log("\u{1F4A5} Error persisting tokens to localStorage:", error);
|
|
@@ -2119,7 +2138,7 @@ var BlinkAuth = class {
|
|
|
2119
2138
|
clearTokens() {
|
|
2120
2139
|
if (typeof window !== "undefined") {
|
|
2121
2140
|
try {
|
|
2122
|
-
localStorage.removeItem("
|
|
2141
|
+
localStorage.removeItem(this.getStorageKey("tokens"));
|
|
2123
2142
|
} catch (error) {
|
|
2124
2143
|
console.log("\u{1F4A5} Error clearing tokens from localStorage:", error);
|
|
2125
2144
|
}
|
|
@@ -2137,7 +2156,7 @@ var BlinkAuth = class {
|
|
|
2137
2156
|
return this.parentWindowTokens;
|
|
2138
2157
|
}
|
|
2139
2158
|
try {
|
|
2140
|
-
const stored = localStorage.getItem("
|
|
2159
|
+
const stored = localStorage.getItem(this.getStorageKey("tokens"));
|
|
2141
2160
|
console.log("\u{1F50D} Checking localStorage for tokens:", {
|
|
2142
2161
|
hasStoredData: !!stored,
|
|
2143
2162
|
storedLength: stored?.length || 0,
|
|
@@ -2307,7 +2326,7 @@ var BlinkAuth = class {
|
|
|
2307
2326
|
setupCrossTabSync() {
|
|
2308
2327
|
if (typeof window === "undefined") return;
|
|
2309
2328
|
window.addEventListener("storage", (e) => {
|
|
2310
|
-
if (e.key === "
|
|
2329
|
+
if (e.key === this.getStorageKey("tokens")) {
|
|
2311
2330
|
const newTokens = e.newValue ? JSON.parse(e.newValue) : null;
|
|
2312
2331
|
if (newTokens && newTokens !== this.authState.tokens) {
|
|
2313
2332
|
this.setTokens(newTokens, false).catch((error) => {
|
|
@@ -3054,7 +3073,7 @@ var BlinkAIImpl = class {
|
|
|
3054
3073
|
* // With options
|
|
3055
3074
|
* const { text, usage } = await blink.ai.generateText({
|
|
3056
3075
|
* prompt: "Summarize this article",
|
|
3057
|
-
* model: "gpt-
|
|
3076
|
+
* model: "gpt-4.1-mini",
|
|
3058
3077
|
* maxTokens: 150,
|
|
3059
3078
|
* temperature: 0.7
|
|
3060
3079
|
* });
|
|
@@ -3062,7 +3081,7 @@ var BlinkAIImpl = class {
|
|
|
3062
3081
|
* // With web search (OpenAI models only)
|
|
3063
3082
|
* const { text, sources } = await blink.ai.generateText({
|
|
3064
3083
|
* prompt: "What are the latest developments in AI?",
|
|
3065
|
-
* model: "gpt-
|
|
3084
|
+
* model: "gpt-4.1-mini",
|
|
3066
3085
|
* search: true // Enables web search
|
|
3067
3086
|
* });
|
|
3068
3087
|
*
|
|
@@ -4456,9 +4475,6 @@ var SESSION_DURATION = 30 * 60 * 1e3;
|
|
|
4456
4475
|
var MAX_BATCH_SIZE = 10;
|
|
4457
4476
|
var BATCH_TIMEOUT = 3e3;
|
|
4458
4477
|
var MAX_STRING_LENGTH = 256;
|
|
4459
|
-
var STORAGE_KEY_QUEUE = "blinkAnalyticsQueue";
|
|
4460
|
-
var STORAGE_KEY_SESSION = "blinkAnalyticsSession";
|
|
4461
|
-
var STORAGE_KEY_ATTRIBUTION = "blinkAnalyticsAttribution";
|
|
4462
4478
|
var BlinkAnalyticsImpl = class {
|
|
4463
4479
|
httpClient;
|
|
4464
4480
|
projectId;
|
|
@@ -4487,6 +4503,12 @@ var BlinkAnalyticsImpl = class {
|
|
|
4487
4503
|
this.setupRouteChangeListener();
|
|
4488
4504
|
this.setupUnloadListener();
|
|
4489
4505
|
}
|
|
4506
|
+
/**
|
|
4507
|
+
* Generate project-scoped storage key for analytics
|
|
4508
|
+
*/
|
|
4509
|
+
getStorageKey(suffix) {
|
|
4510
|
+
return `blinkAnalytics${suffix}_${this.projectId}`;
|
|
4511
|
+
}
|
|
4490
4512
|
/**
|
|
4491
4513
|
* Log a custom analytics event
|
|
4492
4514
|
*/
|
|
@@ -4543,7 +4565,7 @@ var BlinkAnalyticsImpl = class {
|
|
|
4543
4565
|
clearAttribution() {
|
|
4544
4566
|
this.persistedAttribution = {};
|
|
4545
4567
|
try {
|
|
4546
|
-
localStorage.removeItem(
|
|
4568
|
+
localStorage.removeItem(this.getStorageKey("Attribution"));
|
|
4547
4569
|
} catch {
|
|
4548
4570
|
}
|
|
4549
4571
|
}
|
|
@@ -4619,7 +4641,7 @@ var BlinkAnalyticsImpl = class {
|
|
|
4619
4641
|
}
|
|
4620
4642
|
getOrCreateSessionId() {
|
|
4621
4643
|
try {
|
|
4622
|
-
const stored = localStorage.getItem(
|
|
4644
|
+
const stored = localStorage.getItem(this.getStorageKey("Session"));
|
|
4623
4645
|
if (stored) {
|
|
4624
4646
|
const session = JSON.parse(stored);
|
|
4625
4647
|
const now = Date.now();
|
|
@@ -4627,7 +4649,7 @@ var BlinkAnalyticsImpl = class {
|
|
|
4627
4649
|
return this.createNewSession();
|
|
4628
4650
|
}
|
|
4629
4651
|
session.lastActivityAt = now;
|
|
4630
|
-
localStorage.setItem(
|
|
4652
|
+
localStorage.setItem(this.getStorageKey("Session"), JSON.stringify(session));
|
|
4631
4653
|
return session.id;
|
|
4632
4654
|
}
|
|
4633
4655
|
return this.createNewSession();
|
|
@@ -4644,14 +4666,14 @@ var BlinkAnalyticsImpl = class {
|
|
|
4644
4666
|
lastActivityAt: now
|
|
4645
4667
|
};
|
|
4646
4668
|
try {
|
|
4647
|
-
localStorage.setItem(
|
|
4669
|
+
localStorage.setItem(this.getStorageKey("Session"), JSON.stringify(session));
|
|
4648
4670
|
} catch {
|
|
4649
4671
|
}
|
|
4650
4672
|
return session.id;
|
|
4651
4673
|
}
|
|
4652
4674
|
loadQueue() {
|
|
4653
4675
|
try {
|
|
4654
|
-
const stored = localStorage.getItem(
|
|
4676
|
+
const stored = localStorage.getItem(this.getStorageKey("Queue"));
|
|
4655
4677
|
if (stored) {
|
|
4656
4678
|
this.queue = JSON.parse(stored);
|
|
4657
4679
|
if (this.queue.length > 0) {
|
|
@@ -4665,9 +4687,9 @@ var BlinkAnalyticsImpl = class {
|
|
|
4665
4687
|
persistQueue() {
|
|
4666
4688
|
try {
|
|
4667
4689
|
if (this.queue.length === 0) {
|
|
4668
|
-
localStorage.removeItem(
|
|
4690
|
+
localStorage.removeItem(this.getStorageKey("Queue"));
|
|
4669
4691
|
} else {
|
|
4670
|
-
localStorage.setItem(
|
|
4692
|
+
localStorage.setItem(this.getStorageKey("Queue"), JSON.stringify(this.queue));
|
|
4671
4693
|
}
|
|
4672
4694
|
} catch {
|
|
4673
4695
|
}
|
|
@@ -4735,7 +4757,7 @@ var BlinkAnalyticsImpl = class {
|
|
|
4735
4757
|
}
|
|
4736
4758
|
loadPersistedAttribution() {
|
|
4737
4759
|
try {
|
|
4738
|
-
const stored = localStorage.getItem(
|
|
4760
|
+
const stored = localStorage.getItem(this.getStorageKey("Attribution"));
|
|
4739
4761
|
if (stored) {
|
|
4740
4762
|
this.persistedAttribution = JSON.parse(stored);
|
|
4741
4763
|
}
|
|
@@ -4751,7 +4773,7 @@ var BlinkAnalyticsImpl = class {
|
|
|
4751
4773
|
Object.entries(this.utmParams).filter(([_, v]) => v !== null)
|
|
4752
4774
|
)
|
|
4753
4775
|
};
|
|
4754
|
-
localStorage.setItem(
|
|
4776
|
+
localStorage.setItem(this.getStorageKey("Attribution"), JSON.stringify(attribution));
|
|
4755
4777
|
this.persistedAttribution = attribution;
|
|
4756
4778
|
} catch {
|
|
4757
4779
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -914,6 +914,9 @@ var BlinkAuth = class {
|
|
|
914
914
|
isInitialized = false;
|
|
915
915
|
constructor(config) {
|
|
916
916
|
this.config = config;
|
|
917
|
+
if (!config.projectId) {
|
|
918
|
+
throw new Error("projectId is required for authentication");
|
|
919
|
+
}
|
|
917
920
|
this.authConfig = {
|
|
918
921
|
mode: "managed",
|
|
919
922
|
// Default mode
|
|
@@ -944,6 +947,21 @@ var BlinkAuth = class {
|
|
|
944
947
|
this.isInitialized = true;
|
|
945
948
|
}
|
|
946
949
|
}
|
|
950
|
+
/**
|
|
951
|
+
* Generate project-scoped storage key
|
|
952
|
+
*/
|
|
953
|
+
getStorageKey(suffix) {
|
|
954
|
+
return `blink_${suffix}_${this.config.projectId}`;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Migrate existing global tokens to project-scoped storage
|
|
958
|
+
* DISABLED: We don't migrate global blink_tokens anymore because:
|
|
959
|
+
* 1. Platform uses blink_tokens for platform auth (different user)
|
|
960
|
+
* 2. Migrating platform tokens would cause project to show wrong user
|
|
961
|
+
* 3. Projects should always authenticate fresh via their own flow
|
|
962
|
+
*/
|
|
963
|
+
migrateExistingTokens() {
|
|
964
|
+
}
|
|
947
965
|
/**
|
|
948
966
|
* Wait for authentication initialization to complete
|
|
949
967
|
*/
|
|
@@ -994,6 +1012,7 @@ var BlinkAuth = class {
|
|
|
994
1012
|
console.log("\u{1F680} Initializing Blink Auth...");
|
|
995
1013
|
this.setLoading(true);
|
|
996
1014
|
try {
|
|
1015
|
+
this.migrateExistingTokens();
|
|
997
1016
|
if (this.isIframe) {
|
|
998
1017
|
console.log("\u{1F50D} Detected iframe environment, waiting for parent tokens...");
|
|
999
1018
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -2066,7 +2085,7 @@ var BlinkAuth = class {
|
|
|
2066
2085
|
});
|
|
2067
2086
|
if (persist && typeof window !== "undefined") {
|
|
2068
2087
|
try {
|
|
2069
|
-
localStorage.setItem("
|
|
2088
|
+
localStorage.setItem(this.getStorageKey("tokens"), JSON.stringify(tokensWithTimestamp));
|
|
2070
2089
|
console.log("\u{1F4BE} Tokens persisted to localStorage");
|
|
2071
2090
|
} catch (error) {
|
|
2072
2091
|
console.log("\u{1F4A5} Error persisting tokens to localStorage:", error);
|
|
@@ -2117,7 +2136,7 @@ var BlinkAuth = class {
|
|
|
2117
2136
|
clearTokens() {
|
|
2118
2137
|
if (typeof window !== "undefined") {
|
|
2119
2138
|
try {
|
|
2120
|
-
localStorage.removeItem("
|
|
2139
|
+
localStorage.removeItem(this.getStorageKey("tokens"));
|
|
2121
2140
|
} catch (error) {
|
|
2122
2141
|
console.log("\u{1F4A5} Error clearing tokens from localStorage:", error);
|
|
2123
2142
|
}
|
|
@@ -2135,7 +2154,7 @@ var BlinkAuth = class {
|
|
|
2135
2154
|
return this.parentWindowTokens;
|
|
2136
2155
|
}
|
|
2137
2156
|
try {
|
|
2138
|
-
const stored = localStorage.getItem("
|
|
2157
|
+
const stored = localStorage.getItem(this.getStorageKey("tokens"));
|
|
2139
2158
|
console.log("\u{1F50D} Checking localStorage for tokens:", {
|
|
2140
2159
|
hasStoredData: !!stored,
|
|
2141
2160
|
storedLength: stored?.length || 0,
|
|
@@ -2305,7 +2324,7 @@ var BlinkAuth = class {
|
|
|
2305
2324
|
setupCrossTabSync() {
|
|
2306
2325
|
if (typeof window === "undefined") return;
|
|
2307
2326
|
window.addEventListener("storage", (e) => {
|
|
2308
|
-
if (e.key === "
|
|
2327
|
+
if (e.key === this.getStorageKey("tokens")) {
|
|
2309
2328
|
const newTokens = e.newValue ? JSON.parse(e.newValue) : null;
|
|
2310
2329
|
if (newTokens && newTokens !== this.authState.tokens) {
|
|
2311
2330
|
this.setTokens(newTokens, false).catch((error) => {
|
|
@@ -3052,7 +3071,7 @@ var BlinkAIImpl = class {
|
|
|
3052
3071
|
* // With options
|
|
3053
3072
|
* const { text, usage } = await blink.ai.generateText({
|
|
3054
3073
|
* prompt: "Summarize this article",
|
|
3055
|
-
* model: "gpt-
|
|
3074
|
+
* model: "gpt-4.1-mini",
|
|
3056
3075
|
* maxTokens: 150,
|
|
3057
3076
|
* temperature: 0.7
|
|
3058
3077
|
* });
|
|
@@ -3060,7 +3079,7 @@ var BlinkAIImpl = class {
|
|
|
3060
3079
|
* // With web search (OpenAI models only)
|
|
3061
3080
|
* const { text, sources } = await blink.ai.generateText({
|
|
3062
3081
|
* prompt: "What are the latest developments in AI?",
|
|
3063
|
-
* model: "gpt-
|
|
3082
|
+
* model: "gpt-4.1-mini",
|
|
3064
3083
|
* search: true // Enables web search
|
|
3065
3084
|
* });
|
|
3066
3085
|
*
|
|
@@ -4454,9 +4473,6 @@ var SESSION_DURATION = 30 * 60 * 1e3;
|
|
|
4454
4473
|
var MAX_BATCH_SIZE = 10;
|
|
4455
4474
|
var BATCH_TIMEOUT = 3e3;
|
|
4456
4475
|
var MAX_STRING_LENGTH = 256;
|
|
4457
|
-
var STORAGE_KEY_QUEUE = "blinkAnalyticsQueue";
|
|
4458
|
-
var STORAGE_KEY_SESSION = "blinkAnalyticsSession";
|
|
4459
|
-
var STORAGE_KEY_ATTRIBUTION = "blinkAnalyticsAttribution";
|
|
4460
4476
|
var BlinkAnalyticsImpl = class {
|
|
4461
4477
|
httpClient;
|
|
4462
4478
|
projectId;
|
|
@@ -4485,6 +4501,12 @@ var BlinkAnalyticsImpl = class {
|
|
|
4485
4501
|
this.setupRouteChangeListener();
|
|
4486
4502
|
this.setupUnloadListener();
|
|
4487
4503
|
}
|
|
4504
|
+
/**
|
|
4505
|
+
* Generate project-scoped storage key for analytics
|
|
4506
|
+
*/
|
|
4507
|
+
getStorageKey(suffix) {
|
|
4508
|
+
return `blinkAnalytics${suffix}_${this.projectId}`;
|
|
4509
|
+
}
|
|
4488
4510
|
/**
|
|
4489
4511
|
* Log a custom analytics event
|
|
4490
4512
|
*/
|
|
@@ -4541,7 +4563,7 @@ var BlinkAnalyticsImpl = class {
|
|
|
4541
4563
|
clearAttribution() {
|
|
4542
4564
|
this.persistedAttribution = {};
|
|
4543
4565
|
try {
|
|
4544
|
-
localStorage.removeItem(
|
|
4566
|
+
localStorage.removeItem(this.getStorageKey("Attribution"));
|
|
4545
4567
|
} catch {
|
|
4546
4568
|
}
|
|
4547
4569
|
}
|
|
@@ -4617,7 +4639,7 @@ var BlinkAnalyticsImpl = class {
|
|
|
4617
4639
|
}
|
|
4618
4640
|
getOrCreateSessionId() {
|
|
4619
4641
|
try {
|
|
4620
|
-
const stored = localStorage.getItem(
|
|
4642
|
+
const stored = localStorage.getItem(this.getStorageKey("Session"));
|
|
4621
4643
|
if (stored) {
|
|
4622
4644
|
const session = JSON.parse(stored);
|
|
4623
4645
|
const now = Date.now();
|
|
@@ -4625,7 +4647,7 @@ var BlinkAnalyticsImpl = class {
|
|
|
4625
4647
|
return this.createNewSession();
|
|
4626
4648
|
}
|
|
4627
4649
|
session.lastActivityAt = now;
|
|
4628
|
-
localStorage.setItem(
|
|
4650
|
+
localStorage.setItem(this.getStorageKey("Session"), JSON.stringify(session));
|
|
4629
4651
|
return session.id;
|
|
4630
4652
|
}
|
|
4631
4653
|
return this.createNewSession();
|
|
@@ -4642,14 +4664,14 @@ var BlinkAnalyticsImpl = class {
|
|
|
4642
4664
|
lastActivityAt: now
|
|
4643
4665
|
};
|
|
4644
4666
|
try {
|
|
4645
|
-
localStorage.setItem(
|
|
4667
|
+
localStorage.setItem(this.getStorageKey("Session"), JSON.stringify(session));
|
|
4646
4668
|
} catch {
|
|
4647
4669
|
}
|
|
4648
4670
|
return session.id;
|
|
4649
4671
|
}
|
|
4650
4672
|
loadQueue() {
|
|
4651
4673
|
try {
|
|
4652
|
-
const stored = localStorage.getItem(
|
|
4674
|
+
const stored = localStorage.getItem(this.getStorageKey("Queue"));
|
|
4653
4675
|
if (stored) {
|
|
4654
4676
|
this.queue = JSON.parse(stored);
|
|
4655
4677
|
if (this.queue.length > 0) {
|
|
@@ -4663,9 +4685,9 @@ var BlinkAnalyticsImpl = class {
|
|
|
4663
4685
|
persistQueue() {
|
|
4664
4686
|
try {
|
|
4665
4687
|
if (this.queue.length === 0) {
|
|
4666
|
-
localStorage.removeItem(
|
|
4688
|
+
localStorage.removeItem(this.getStorageKey("Queue"));
|
|
4667
4689
|
} else {
|
|
4668
|
-
localStorage.setItem(
|
|
4690
|
+
localStorage.setItem(this.getStorageKey("Queue"), JSON.stringify(this.queue));
|
|
4669
4691
|
}
|
|
4670
4692
|
} catch {
|
|
4671
4693
|
}
|
|
@@ -4733,7 +4755,7 @@ var BlinkAnalyticsImpl = class {
|
|
|
4733
4755
|
}
|
|
4734
4756
|
loadPersistedAttribution() {
|
|
4735
4757
|
try {
|
|
4736
|
-
const stored = localStorage.getItem(
|
|
4758
|
+
const stored = localStorage.getItem(this.getStorageKey("Attribution"));
|
|
4737
4759
|
if (stored) {
|
|
4738
4760
|
this.persistedAttribution = JSON.parse(stored);
|
|
4739
4761
|
}
|
|
@@ -4749,7 +4771,7 @@ var BlinkAnalyticsImpl = class {
|
|
|
4749
4771
|
Object.entries(this.utmParams).filter(([_, v]) => v !== null)
|
|
4750
4772
|
)
|
|
4751
4773
|
};
|
|
4752
|
-
localStorage.setItem(
|
|
4774
|
+
localStorage.setItem(this.getStorageKey("Attribution"), JSON.stringify(attribution));
|
|
4753
4775
|
this.persistedAttribution = attribution;
|
|
4754
4776
|
} catch {
|
|
4755
4777
|
}
|
package/package.json
CHANGED