@amplifyup/sdk 0.1.0 → 0.1.2
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 +23 -3
- package/dist/AmplifyRenderer.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +123 -37
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +123 -37
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.js +128 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +124 -38
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +155 -50
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +155 -50
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +6 -2
- package/dist/server.d.ts +6 -2
- package/dist/server.js +77 -1375
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +76 -1376
- package/dist/server.mjs.map +1 -1
- package/dist/{types-B9nHG2Cl.d.mts → types-Xv9P55Dj.d.mts} +51 -1
- package/dist/{types-B9nHG2Cl.d.ts → types-Xv9P55Dj.d.ts} +51 -1
- package/package.json +4 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CDPAdapter, A as AmplifyUpConfig, E as EventProperties, I as IdentifyTraits, a as EventTrackingConfig$1 } from './types-
|
|
2
|
-
export { P as PageConfig, Z as ZoneConfig } from './types-
|
|
1
|
+
import { C as CDPAdapter, A as AmplifyUpConfig, E as EventProperties, I as IdentifyTraits, a as AmplifyUpTarget, b as EventTrackingConfig$1 } from './types-Xv9P55Dj.mjs';
|
|
2
|
+
export { P as PageConfig, Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, c as resolveAmplifyUpUrls } from './types-Xv9P55Dj.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* AmplifyUp Tracking SDK
|
|
@@ -24,7 +24,12 @@ declare class AmplifyUpSDK {
|
|
|
24
24
|
private apiGatewayUrl;
|
|
25
25
|
private orchestratorUrl;
|
|
26
26
|
private decisionApiUrl;
|
|
27
|
+
private target;
|
|
27
28
|
private initialized;
|
|
29
|
+
/** Prevents overlapping init() from React Strict Mode double-mount */
|
|
30
|
+
private initPromise;
|
|
31
|
+
/** Ensures auto page() on init fires once per page load */
|
|
32
|
+
private initialPageSent;
|
|
28
33
|
private highlightingEnabled;
|
|
29
34
|
private componentRegistry;
|
|
30
35
|
private messageListener;
|
|
@@ -49,22 +54,12 @@ declare class AmplifyUpSDK {
|
|
|
49
54
|
* Check if we're in preview/composer mode (should disable tracking)
|
|
50
55
|
*/
|
|
51
56
|
private isPreviewMode;
|
|
52
|
-
/**
|
|
53
|
-
* Get production URLs
|
|
54
|
-
*
|
|
55
|
-
* URLs are baked in at build time via tsup.config.ts
|
|
56
|
-
*
|
|
57
|
-
* API Gateway endpoints:
|
|
58
|
-
* - /v1/track - Event tracking (ingestion)
|
|
59
|
-
* - /v1/page - Page view tracking (ingestion)
|
|
60
|
-
* - /v1/personalize - Decision engine (personalization)
|
|
61
|
-
*/
|
|
62
|
-
private getProductionUrls;
|
|
63
57
|
/**
|
|
64
58
|
* Initialize the SDK
|
|
65
|
-
*
|
|
59
|
+
* Resolves local | dev | production targets for ingestion + personalization URLs.
|
|
66
60
|
*/
|
|
67
61
|
init(config: AmplifyUpConfig): Promise<void>;
|
|
62
|
+
private performInit;
|
|
68
63
|
/**
|
|
69
64
|
* Check if SDK is initialized
|
|
70
65
|
*/
|
|
@@ -130,6 +125,7 @@ declare class AmplifyUpSDK {
|
|
|
130
125
|
instanceId: string;
|
|
131
126
|
userId: string | null;
|
|
132
127
|
trackingId: string | undefined;
|
|
128
|
+
target: AmplifyUpTarget;
|
|
133
129
|
config: {
|
|
134
130
|
apiGatewayUrl?: string;
|
|
135
131
|
decisionApiUrl?: string;
|
|
@@ -137,6 +133,7 @@ declare class AmplifyUpSDK {
|
|
|
137
133
|
debug?: boolean;
|
|
138
134
|
};
|
|
139
135
|
};
|
|
136
|
+
getTarget(): AmplifyUpTarget;
|
|
140
137
|
/**
|
|
141
138
|
* Test tracking by sending a test event
|
|
142
139
|
*/
|
|
@@ -266,6 +263,7 @@ declare const reset: () => void;
|
|
|
266
263
|
declare const getInstanceId: () => string;
|
|
267
264
|
declare const getUserId: () => string | null;
|
|
268
265
|
declare const getTrackingId: () => string | undefined;
|
|
266
|
+
declare const getTarget: () => AmplifyUpTarget;
|
|
269
267
|
declare const getOrchestratorUrl: () => string | undefined;
|
|
270
268
|
declare const buildLayoutProviderUrl: (route: string, preview?: boolean) => string;
|
|
271
269
|
declare const buildPageRenderUrl: (route: string, preview?: boolean) => string;
|
|
@@ -278,6 +276,7 @@ declare const getDiagnostics: () => {
|
|
|
278
276
|
instanceId: string;
|
|
279
277
|
userId: string | null;
|
|
280
278
|
trackingId: string | undefined;
|
|
279
|
+
target: AmplifyUpTarget;
|
|
281
280
|
config: {
|
|
282
281
|
apiGatewayUrl?: string;
|
|
283
282
|
decisionApiUrl?: string;
|
|
@@ -290,6 +289,7 @@ declare const getStatus: () => {
|
|
|
290
289
|
instanceId: string;
|
|
291
290
|
userId: string | null;
|
|
292
291
|
trackingId: string | undefined;
|
|
292
|
+
target: AmplifyUpTarget;
|
|
293
293
|
config: {
|
|
294
294
|
apiGatewayUrl?: string;
|
|
295
295
|
decisionApiUrl?: string;
|
|
@@ -306,4 +306,4 @@ declare const verifyAWSConnection: () => {
|
|
|
306
306
|
|
|
307
307
|
declare const _default: AmplifyUpSDK;
|
|
308
308
|
|
|
309
|
-
export { AmplifyUpConfig, AmplifyUpSDK, CDPAdapter, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, IdentifyTraits, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchPageConfig, getDiagnostics, getInstanceId, getOrchestratorUrl, getSDK, getStatus, getTrackingId, getUserId, identify, init, page, refreshEventTracking, reset, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
309
|
+
export { AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, IdentifyTraits, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchPageConfig, getDiagnostics, getInstanceId, getOrchestratorUrl, getSDK, getStatus, getTarget, getTrackingId, getUserId, identify, init, page, refreshEventTracking, reset, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CDPAdapter, A as AmplifyUpConfig, E as EventProperties, I as IdentifyTraits, a as EventTrackingConfig$1 } from './types-
|
|
2
|
-
export { P as PageConfig, Z as ZoneConfig } from './types-
|
|
1
|
+
import { C as CDPAdapter, A as AmplifyUpConfig, E as EventProperties, I as IdentifyTraits, a as AmplifyUpTarget, b as EventTrackingConfig$1 } from './types-Xv9P55Dj.js';
|
|
2
|
+
export { P as PageConfig, Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, c as resolveAmplifyUpUrls } from './types-Xv9P55Dj.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* AmplifyUp Tracking SDK
|
|
@@ -24,7 +24,12 @@ declare class AmplifyUpSDK {
|
|
|
24
24
|
private apiGatewayUrl;
|
|
25
25
|
private orchestratorUrl;
|
|
26
26
|
private decisionApiUrl;
|
|
27
|
+
private target;
|
|
27
28
|
private initialized;
|
|
29
|
+
/** Prevents overlapping init() from React Strict Mode double-mount */
|
|
30
|
+
private initPromise;
|
|
31
|
+
/** Ensures auto page() on init fires once per page load */
|
|
32
|
+
private initialPageSent;
|
|
28
33
|
private highlightingEnabled;
|
|
29
34
|
private componentRegistry;
|
|
30
35
|
private messageListener;
|
|
@@ -49,22 +54,12 @@ declare class AmplifyUpSDK {
|
|
|
49
54
|
* Check if we're in preview/composer mode (should disable tracking)
|
|
50
55
|
*/
|
|
51
56
|
private isPreviewMode;
|
|
52
|
-
/**
|
|
53
|
-
* Get production URLs
|
|
54
|
-
*
|
|
55
|
-
* URLs are baked in at build time via tsup.config.ts
|
|
56
|
-
*
|
|
57
|
-
* API Gateway endpoints:
|
|
58
|
-
* - /v1/track - Event tracking (ingestion)
|
|
59
|
-
* - /v1/page - Page view tracking (ingestion)
|
|
60
|
-
* - /v1/personalize - Decision engine (personalization)
|
|
61
|
-
*/
|
|
62
|
-
private getProductionUrls;
|
|
63
57
|
/**
|
|
64
58
|
* Initialize the SDK
|
|
65
|
-
*
|
|
59
|
+
* Resolves local | dev | production targets for ingestion + personalization URLs.
|
|
66
60
|
*/
|
|
67
61
|
init(config: AmplifyUpConfig): Promise<void>;
|
|
62
|
+
private performInit;
|
|
68
63
|
/**
|
|
69
64
|
* Check if SDK is initialized
|
|
70
65
|
*/
|
|
@@ -130,6 +125,7 @@ declare class AmplifyUpSDK {
|
|
|
130
125
|
instanceId: string;
|
|
131
126
|
userId: string | null;
|
|
132
127
|
trackingId: string | undefined;
|
|
128
|
+
target: AmplifyUpTarget;
|
|
133
129
|
config: {
|
|
134
130
|
apiGatewayUrl?: string;
|
|
135
131
|
decisionApiUrl?: string;
|
|
@@ -137,6 +133,7 @@ declare class AmplifyUpSDK {
|
|
|
137
133
|
debug?: boolean;
|
|
138
134
|
};
|
|
139
135
|
};
|
|
136
|
+
getTarget(): AmplifyUpTarget;
|
|
140
137
|
/**
|
|
141
138
|
* Test tracking by sending a test event
|
|
142
139
|
*/
|
|
@@ -266,6 +263,7 @@ declare const reset: () => void;
|
|
|
266
263
|
declare const getInstanceId: () => string;
|
|
267
264
|
declare const getUserId: () => string | null;
|
|
268
265
|
declare const getTrackingId: () => string | undefined;
|
|
266
|
+
declare const getTarget: () => AmplifyUpTarget;
|
|
269
267
|
declare const getOrchestratorUrl: () => string | undefined;
|
|
270
268
|
declare const buildLayoutProviderUrl: (route: string, preview?: boolean) => string;
|
|
271
269
|
declare const buildPageRenderUrl: (route: string, preview?: boolean) => string;
|
|
@@ -278,6 +276,7 @@ declare const getDiagnostics: () => {
|
|
|
278
276
|
instanceId: string;
|
|
279
277
|
userId: string | null;
|
|
280
278
|
trackingId: string | undefined;
|
|
279
|
+
target: AmplifyUpTarget;
|
|
281
280
|
config: {
|
|
282
281
|
apiGatewayUrl?: string;
|
|
283
282
|
decisionApiUrl?: string;
|
|
@@ -290,6 +289,7 @@ declare const getStatus: () => {
|
|
|
290
289
|
instanceId: string;
|
|
291
290
|
userId: string | null;
|
|
292
291
|
trackingId: string | undefined;
|
|
292
|
+
target: AmplifyUpTarget;
|
|
293
293
|
config: {
|
|
294
294
|
apiGatewayUrl?: string;
|
|
295
295
|
decisionApiUrl?: string;
|
|
@@ -306,4 +306,4 @@ declare const verifyAWSConnection: () => {
|
|
|
306
306
|
|
|
307
307
|
declare const _default: AmplifyUpSDK;
|
|
308
308
|
|
|
309
|
-
export { AmplifyUpConfig, AmplifyUpSDK, CDPAdapter, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, IdentifyTraits, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchPageConfig, getDiagnostics, getInstanceId, getOrchestratorUrl, getSDK, getStatus, getTrackingId, getUserId, identify, init, page, refreshEventTracking, reset, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
309
|
+
export { AmplifyUpConfig, AmplifyUpSDK, AmplifyUpTarget, CDPAdapter, EventProperties, EventTrackingConfig$1 as EventTrackingConfig, IdentifyTraits, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, _default as default, fetchPageConfig, getDiagnostics, getInstanceId, getOrchestratorUrl, getSDK, getStatus, getTarget, getTrackingId, getUserId, identify, init, page, refreshEventTracking, reset, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
package/dist/index.js
CHANGED
|
@@ -171,6 +171,16 @@ var AWSAdapter = class {
|
|
|
171
171
|
// src/storage.ts
|
|
172
172
|
var INSTANCE_ID_KEY = "amplifyup_instance_id";
|
|
173
173
|
var USER_ID_KEY = "amplifyup_user_id";
|
|
174
|
+
function generateGuid() {
|
|
175
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
176
|
+
return crypto.randomUUID();
|
|
177
|
+
}
|
|
178
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
179
|
+
const r = Math.random() * 16 | 0;
|
|
180
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
181
|
+
return v.toString(16);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
174
184
|
function getInstanceId() {
|
|
175
185
|
if (typeof window === "undefined") {
|
|
176
186
|
return "";
|
|
@@ -179,7 +189,7 @@ function getInstanceId() {
|
|
|
179
189
|
if (stored) {
|
|
180
190
|
return stored;
|
|
181
191
|
}
|
|
182
|
-
const instanceId = `
|
|
192
|
+
const instanceId = `browser_${generateGuid()}`;
|
|
183
193
|
localStorage.setItem(INSTANCE_ID_KEY, instanceId);
|
|
184
194
|
return instanceId;
|
|
185
195
|
}
|
|
@@ -203,9 +213,69 @@ function clearIds() {
|
|
|
203
213
|
localStorage.removeItem(USER_ID_KEY);
|
|
204
214
|
}
|
|
205
215
|
|
|
216
|
+
// src/targets.ts
|
|
217
|
+
var AWS_DEV_API = "https://api-dev.amplifyup.ai";
|
|
218
|
+
var AWS_PROD_API = "https://api.amplifyup.ai";
|
|
219
|
+
var PROD_ORCHESTRATOR = "https://amplifyup.ai";
|
|
220
|
+
function isAmplifyUpTarget(value) {
|
|
221
|
+
return value === "local" || value === "dev" || value === "production";
|
|
222
|
+
}
|
|
223
|
+
function normalizeAmplifyUpTarget(value) {
|
|
224
|
+
return value === "dev" ? "local" : value;
|
|
225
|
+
}
|
|
226
|
+
function resolveAmplifyUpTarget(options) {
|
|
227
|
+
if (options?.configTarget && isAmplifyUpTarget(options.configTarget)) {
|
|
228
|
+
return normalizeAmplifyUpTarget(options.configTarget);
|
|
229
|
+
}
|
|
230
|
+
if (options?.configDev === true) {
|
|
231
|
+
return "local";
|
|
232
|
+
}
|
|
233
|
+
const envTarget = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_AMPLIFYUP_TARGET : void 0;
|
|
234
|
+
if (isAmplifyUpTarget(envTarget)) {
|
|
235
|
+
return normalizeAmplifyUpTarget(envTarget);
|
|
236
|
+
}
|
|
237
|
+
if (typeof window !== "undefined") {
|
|
238
|
+
const host = window.location.hostname;
|
|
239
|
+
if (host === "localhost" || host === "127.0.0.1") {
|
|
240
|
+
return "local";
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return "production";
|
|
244
|
+
}
|
|
245
|
+
function localOrchestratorUrl() {
|
|
246
|
+
const fromEnv = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_ORCHESTRATOR_URL : void 0;
|
|
247
|
+
return (fromEnv || "http://localhost:5001").replace(/\/$/, "");
|
|
248
|
+
}
|
|
249
|
+
function localAwsApiUrl() {
|
|
250
|
+
const fromEnv = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_AMPLIFYUP_API_URL : void 0;
|
|
251
|
+
return (fromEnv || AWS_DEV_API).replace(/\/$/, "");
|
|
252
|
+
}
|
|
253
|
+
function resolveAmplifyUpUrls(target) {
|
|
254
|
+
if (target === "local") {
|
|
255
|
+
const orchestratorUrl2 = localOrchestratorUrl();
|
|
256
|
+
const apiGatewayUrl = localAwsApiUrl();
|
|
257
|
+
return {
|
|
258
|
+
target: "local",
|
|
259
|
+
// Layouts / site config / composer APIs → local orchestrator + Neon
|
|
260
|
+
orchestratorUrl: orchestratorUrl2,
|
|
261
|
+
// Events + personalize → AWS development stack
|
|
262
|
+
apiGatewayUrl,
|
|
263
|
+
decisionApiUrl: `${apiGatewayUrl}/v1/personalize`
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
const resolvedApi = typeof process !== "undefined" && process.env.NEXT_PUBLIC_AMPLIFYUP_API_URL?.replace(/\/$/, "") || AWS_PROD_API;
|
|
267
|
+
const orchestratorFromEnv = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_ORCHESTRATOR_URL : void 0;
|
|
268
|
+
const isLocalOrchestrator = !!orchestratorFromEnv && (orchestratorFromEnv.includes("localhost") || orchestratorFromEnv.includes("127.0.0.1"));
|
|
269
|
+
const orchestratorUrl = isLocalOrchestrator || !orchestratorFromEnv ? PROD_ORCHESTRATOR : orchestratorFromEnv.replace(/\/$/, "");
|
|
270
|
+
return {
|
|
271
|
+
target: "production",
|
|
272
|
+
apiGatewayUrl: resolvedApi,
|
|
273
|
+
orchestratorUrl,
|
|
274
|
+
decisionApiUrl: `${resolvedApi}/v1/personalize`
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
206
278
|
// src/index.ts
|
|
207
|
-
var PROD_API_URL = "https://api.amplifyup.ai" ;
|
|
208
|
-
var PROD_ORCHESTRATOR_URL = "https://amplifyup.ai" ;
|
|
209
279
|
var AmplifyUpSDK = class {
|
|
210
280
|
constructor(adapter) {
|
|
211
281
|
this.config = null;
|
|
@@ -213,7 +283,12 @@ var AmplifyUpSDK = class {
|
|
|
213
283
|
this.apiGatewayUrl = "";
|
|
214
284
|
this.orchestratorUrl = "";
|
|
215
285
|
this.decisionApiUrl = "";
|
|
286
|
+
this.target = "local";
|
|
216
287
|
this.initialized = false;
|
|
288
|
+
/** Prevents overlapping init() from React Strict Mode double-mount */
|
|
289
|
+
this.initPromise = null;
|
|
290
|
+
/** Ensures auto page() on init fires once per page load */
|
|
291
|
+
this.initialPageSent = false;
|
|
217
292
|
this.highlightingEnabled = false;
|
|
218
293
|
this.componentRegistry = [];
|
|
219
294
|
this.messageListener = null;
|
|
@@ -296,46 +371,41 @@ var AmplifyUpSDK = class {
|
|
|
296
371
|
}
|
|
297
372
|
return false;
|
|
298
373
|
}
|
|
299
|
-
/**
|
|
300
|
-
* Get production URLs
|
|
301
|
-
*
|
|
302
|
-
* URLs are baked in at build time via tsup.config.ts
|
|
303
|
-
*
|
|
304
|
-
* API Gateway endpoints:
|
|
305
|
-
* - /v1/track - Event tracking (ingestion)
|
|
306
|
-
* - /v1/page - Page view tracking (ingestion)
|
|
307
|
-
* - /v1/personalize - Decision engine (personalization)
|
|
308
|
-
*/
|
|
309
|
-
getProductionUrls() {
|
|
310
|
-
return {
|
|
311
|
-
apiGatewayUrl: PROD_API_URL,
|
|
312
|
-
orchestratorUrl: PROD_ORCHESTRATOR_URL,
|
|
313
|
-
decisionApiUrl: `${PROD_API_URL}/v1/personalize`
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
374
|
/**
|
|
317
375
|
* Initialize the SDK
|
|
318
|
-
*
|
|
376
|
+
* Resolves local | dev | production targets for ingestion + personalization URLs.
|
|
319
377
|
*/
|
|
320
378
|
async init(config) {
|
|
379
|
+
if (this.initialized && this.adapter?.isInitialized()) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (this.initPromise) {
|
|
383
|
+
return this.initPromise;
|
|
384
|
+
}
|
|
385
|
+
this.initPromise = this.performInit(config);
|
|
386
|
+
try {
|
|
387
|
+
await this.initPromise;
|
|
388
|
+
} finally {
|
|
389
|
+
this.initPromise = null;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
async performInit(config) {
|
|
321
393
|
if (!this.adapter) {
|
|
322
394
|
this.adapter = new AWSAdapter();
|
|
323
395
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
this.orchestratorUrl = urls.orchestratorUrl;
|
|
333
|
-
this.decisionApiUrl = urls.decisionApiUrl;
|
|
334
|
-
}
|
|
396
|
+
this.target = resolveAmplifyUpTarget({
|
|
397
|
+
configTarget: config.target,
|
|
398
|
+
configDev: config.dev
|
|
399
|
+
});
|
|
400
|
+
const urls = resolveAmplifyUpUrls(this.target);
|
|
401
|
+
this.apiGatewayUrl = urls.apiGatewayUrl;
|
|
402
|
+
this.orchestratorUrl = urls.orchestratorUrl;
|
|
403
|
+
this.decisionApiUrl = urls.decisionApiUrl;
|
|
335
404
|
this.config = {
|
|
336
405
|
trackingId: config.trackingId,
|
|
337
406
|
debug: config.debug ?? true,
|
|
338
407
|
// Enable debug by default
|
|
408
|
+
target: this.target,
|
|
339
409
|
dev: config.dev
|
|
340
410
|
};
|
|
341
411
|
try {
|
|
@@ -352,6 +422,7 @@ var AmplifyUpSDK = class {
|
|
|
352
422
|
getInstanceId: () => this.getInstanceId(),
|
|
353
423
|
getUserId: () => this.getUserId(),
|
|
354
424
|
getTrackingId: () => this.getTrackingId(),
|
|
425
|
+
getTarget: () => this.getTarget(),
|
|
355
426
|
getDiagnostics: () => this.getDiagnostics(),
|
|
356
427
|
getStatus: () => {
|
|
357
428
|
console.log(this.getStatus());
|
|
@@ -372,7 +443,7 @@ var AmplifyUpSDK = class {
|
|
|
372
443
|
};
|
|
373
444
|
if (this.config?.debug) {
|
|
374
445
|
console.log("AmplifyUp SDK: Diagnostic methods available on window.AmplifyUp");
|
|
375
|
-
console.log("Try: AmplifyUp.getStatus() or AmplifyUp.
|
|
446
|
+
console.log("Try: AmplifyUp.getStatus() or AmplifyUp.testTracking()");
|
|
376
447
|
}
|
|
377
448
|
}
|
|
378
449
|
this.clearTrackingIntervals();
|
|
@@ -384,11 +455,20 @@ var AmplifyUpSDK = class {
|
|
|
384
455
|
if (this.isPreviewMode()) {
|
|
385
456
|
return;
|
|
386
457
|
}
|
|
387
|
-
|
|
388
|
-
|
|
458
|
+
if (!this.initialPageSent) {
|
|
459
|
+
this.initialPageSent = true;
|
|
460
|
+
const url = window.location.pathname;
|
|
461
|
+
this.page(url);
|
|
462
|
+
}
|
|
389
463
|
}
|
|
390
464
|
if (this.config?.debug && this.initialized) {
|
|
391
|
-
console.log("AmplifyUp SDK: Initialized successfully", {
|
|
465
|
+
console.log("AmplifyUp SDK: Initialized successfully", {
|
|
466
|
+
trackingId: config.trackingId,
|
|
467
|
+
target: this.target,
|
|
468
|
+
apiGatewayUrl: this.apiGatewayUrl,
|
|
469
|
+
orchestratorUrl: this.orchestratorUrl,
|
|
470
|
+
decisionApiUrl: this.decisionApiUrl || "(orchestrator fallback)"
|
|
471
|
+
});
|
|
392
472
|
}
|
|
393
473
|
} catch (error) {
|
|
394
474
|
console.error("AmplifyUp SDK: Initialization failed", error);
|
|
@@ -589,6 +669,7 @@ var AmplifyUpSDK = class {
|
|
|
589
669
|
instanceId,
|
|
590
670
|
userId,
|
|
591
671
|
trackingId: this.config?.trackingId,
|
|
672
|
+
target: this.target,
|
|
592
673
|
config: {
|
|
593
674
|
apiGatewayUrl: this.apiGatewayUrl,
|
|
594
675
|
decisionApiUrl: this.decisionApiUrl,
|
|
@@ -597,6 +678,9 @@ var AmplifyUpSDK = class {
|
|
|
597
678
|
}
|
|
598
679
|
};
|
|
599
680
|
}
|
|
681
|
+
getTarget() {
|
|
682
|
+
return this.target;
|
|
683
|
+
}
|
|
600
684
|
/**
|
|
601
685
|
* Test tracking by sending a test event
|
|
602
686
|
*/
|
|
@@ -654,6 +738,7 @@ var AmplifyUpSDK = class {
|
|
|
654
738
|
AmplifyUp SDK Status:
|
|
655
739
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
656
740
|
Initialized: ${diag.initialized ? "\u2705 Yes" : "\u274C No"}
|
|
741
|
+
Target: ${diag.target}
|
|
657
742
|
Instance ID: ${diag.instanceId}
|
|
658
743
|
User ID: ${diag.userId || "Not identified"}
|
|
659
744
|
Tracking ID: ${diag.trackingId || "Not set"}
|
|
@@ -665,11 +750,11 @@ Config:
|
|
|
665
750
|
API Gateway: ${this.apiGatewayUrl || "Not set (required)"}
|
|
666
751
|
Decision API: ${this.decisionApiUrl || "Not set (using Orchestrator fallback)"}
|
|
667
752
|
Orchestrator: ${this.orchestratorUrl || "Not set"}
|
|
668
|
-
Debug: ${diag.config.debug ? "Enabled" : "Disabled"}
|
|
669
753
|
|
|
670
754
|
Available Console Commands:
|
|
671
755
|
AmplifyUp.getStatus() - Show this status
|
|
672
756
|
AmplifyUp.getDiagnostics() - Get full diagnostic object
|
|
757
|
+
AmplifyUp.getTarget() - Current environment target
|
|
673
758
|
AmplifyUp.getInstanceId() - Get instance ID (browser/session ID)
|
|
674
759
|
AmplifyUp.getUserId() - Get user ID if identified
|
|
675
760
|
AmplifyUp.testTracking() - Send a test event
|
|
@@ -1392,6 +1477,7 @@ var reset = () => getSDK().reset();
|
|
|
1392
1477
|
var getInstanceId2 = () => getSDK().getInstanceId();
|
|
1393
1478
|
var getUserId2 = () => getSDK().getUserId();
|
|
1394
1479
|
var getTrackingId = () => getSDK().getTrackingId();
|
|
1480
|
+
var getTarget = () => getSDK().getTarget();
|
|
1395
1481
|
var getOrchestratorUrl = () => getSDK().getOrchestratorUrl();
|
|
1396
1482
|
var buildLayoutProviderUrl = (route, preview) => getSDK().buildLayoutProviderUrl(route, preview);
|
|
1397
1483
|
var buildPageRenderUrl = (route, preview) => getSDK().buildLayoutProviderUrl(route, preview);
|
|
@@ -1425,13 +1511,18 @@ exports.getInstanceId = getInstanceId2;
|
|
|
1425
1511
|
exports.getOrchestratorUrl = getOrchestratorUrl;
|
|
1426
1512
|
exports.getSDK = getSDK;
|
|
1427
1513
|
exports.getStatus = getStatus;
|
|
1514
|
+
exports.getTarget = getTarget;
|
|
1428
1515
|
exports.getTrackingId = getTrackingId;
|
|
1429
1516
|
exports.getUserId = getUserId2;
|
|
1430
1517
|
exports.identify = identify;
|
|
1431
1518
|
exports.init = init;
|
|
1519
|
+
exports.isAmplifyUpTarget = isAmplifyUpTarget;
|
|
1520
|
+
exports.normalizeAmplifyUpTarget = normalizeAmplifyUpTarget;
|
|
1432
1521
|
exports.page = page;
|
|
1433
1522
|
exports.refreshEventTracking = refreshEventTracking;
|
|
1434
1523
|
exports.reset = reset;
|
|
1524
|
+
exports.resolveAmplifyUpTarget = resolveAmplifyUpTarget;
|
|
1525
|
+
exports.resolveAmplifyUpUrls = resolveAmplifyUpUrls;
|
|
1435
1526
|
exports.setupEventTracking = setupEventTracking;
|
|
1436
1527
|
exports.testTracking = testTracking;
|
|
1437
1528
|
exports.track = track;
|