@embedreach/components 0.2.26 → 0.2.27

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.
@@ -39065,117 +39065,22 @@ if (defaultPlatformData.baseAggregatedMetrics) {
39065
39065
  ...defaultPlatformData.baseAggregatedMetrics.meta.campaigns
39066
39066
  ];
39067
39067
  }
39068
- const goosePlatformData = {
39068
+ ({
39069
39069
  ...defaultPlatformData,
39070
39070
  businessesMe: {
39071
- ...defaultPlatformData.businessesMe,
39072
- name: "Paws Pet Hotel (Sandbox)",
39073
- website: "https://www.pawspethotel.com/",
39074
- locations: [
39075
- {
39076
- district: "ny",
39077
- locality: "new york",
39078
- postalCode: "10018",
39079
- countryCode: "US",
39080
- addressLine1: "530 7th avenue",
39081
- addressLine2: "",
39082
- addressLine3: ""
39083
- }
39084
- ]
39085
- },
39086
- webPresenceContent: {
39087
- url: "https://www.pawspethotel.com/",
39088
- adGroups: [
39089
- {
39090
- ad: {
39091
- headlines: [
39092
- "Dog Daycare NYC",
39093
- "Safe Indoor & Outdoor Play",
39094
- "Book Your Pup's Spot Now",
39095
- "5,000 Sq Ft Play Area",
39096
- "24/7 Camera Surveillance",
39097
- "Happy Tired Dogs Guaranteed"
39098
- ],
39099
- descriptions: [
39100
- "Premier dog daycare in NYC. 5,000 sq ft of safe play space with non-slip surfaces & 24/7 monitoring.",
39101
- "Give your furry friend the care they deserve. Experienced staff, spacious facility & lots of fun. Book now!"
39102
- ]
39103
- },
39104
- adUrl: "https://www.pawspethotel.com/daycare",
39105
- theme: "Dog Daycare Services",
39106
- keywords: [
39107
- "new york dog daycare",
39108
- "doggy daycare near me",
39109
- "safe dog play area",
39110
- "indoor outdoor dog daycare",
39111
- "professional dog supervision"
39112
- ]
39113
- },
39114
- {
39115
- ad: {
39116
- headlines: [
39117
- "Dog Boarding NYC",
39118
- "Comfortable Overnight Care",
39119
- "Reserve Your Dog's Stay",
39120
- "24/7 Staff Supervision",
39121
- "Feels Like Home For Dogs",
39122
- "Peace Of Mind For Owners"
39123
- ],
39124
- descriptions: [
39125
- "Top-rated dog boarding in NYC. Safe, comfortable overnight care with 24/7 staff supervision.",
39126
- "Your dog's home away from home. Loving environment, experienced care, and lots of playtime. Book now!"
39127
- ]
39128
- },
39129
- adUrl: "https://www.pawspethotel.com/services",
39130
- theme: "Dog Boarding Services",
39131
- keywords: [
39132
- "new york dog boarding",
39133
- "overnight dog care",
39134
- "pet boarding near me",
39135
- "safe dog lodging",
39136
- "home away from home dogs"
39137
- ]
39138
- },
39139
- {
39140
- ad: {
39141
- headlines: [
39142
- "Dog Grooming NYC",
39143
- "Professional Pet Grooming",
39144
- "Book A Grooming Session",
39145
- "Experienced Groomers",
39146
- "Stress-Free Environment",
39147
- "Pamper Your Furry Friend"
39148
- ],
39149
- descriptions: [
39150
- "Expert dog grooming services in NYC. Professional groomers, stress-free environment & top-quality care.",
39151
- "From baths to haircuts, we'll make your pup look and feel their best. Book your grooming appointment today!"
39152
- ]
39153
- },
39154
- adUrl: "https://www.pawspethotel.com/grooming",
39155
- theme: "Dog Grooming Services",
39156
- keywords: [
39157
- "new york dog grooming",
39158
- "professional pet grooming",
39159
- "dog bath and haircut",
39160
- "pet spa services",
39161
- "dog grooming near me"
39162
- ]
39163
- }
39164
- ]
39071
+ ...defaultPlatformData.businessesMe
39165
39072
  },
39166
39073
  // Override ad accounts with Goose-specific naming
39167
39074
  adAccountsGoogle: {
39168
39075
  ...defaultPlatformData.adAccountsGoogle,
39169
39076
  ad_platform_metadata: {
39170
- ...defaultPlatformData.adAccountsGoogle.ad_platform_metadata,
39171
- name: "Paws Pet Hotel Google Ads"
39077
+ ...defaultPlatformData.adAccountsGoogle.ad_platform_metadata
39172
39078
  }
39173
39079
  },
39174
39080
  adAccountsMeta: {
39175
39081
  ...defaultPlatformData.adAccountsMeta,
39176
39082
  ad_platform_metadata: {
39177
- ...defaultPlatformData.adAccountsMeta.ad_platform_metadata,
39178
- name: "Paws Pet Hotel Meta Ads"
39083
+ ...defaultPlatformData.adAccountsMeta.ad_platform_metadata
39179
39084
  }
39180
39085
  },
39181
39086
  // Initialize adAccounts array with both accounts
@@ -39218,115 +39123,23 @@ const goosePlatformData = {
39218
39123
  updated_at: "2024-03-15T11:00:00.000Z"
39219
39124
  }
39220
39125
  ]
39221
- };
39222
- const renterraPlatformData = {
39126
+ });
39127
+ ({
39223
39128
  ...defaultPlatformData,
39224
39129
  businessesMe: {
39225
- ...defaultPlatformData.businessesMe,
39226
- name: "Tomer's Rental",
39227
- website: "https://tomersrental.com/",
39228
- locations: [
39229
- {
39230
- district: "ut",
39231
- locality: "springville",
39232
- postalCode: "84663",
39233
- addressLine1: "1605 w 1450 s"
39234
- }
39235
- ]
39236
- },
39237
- webPresenceContent: {
39238
- url: "https://tomersrental.com/",
39239
- adGroups: [
39240
- {
39241
- ad: {
39242
- headlines: [
39243
- "Heavy Equipment Rental Utah",
39244
- "Excavators, Skid Steers & More",
39245
- "Rent Now - Easy Process",
39246
- "Quality Machines Available",
39247
- "Serving Utah County",
39248
- "Affordable Equipment Rental"
39249
- ],
39250
- descriptions: [
39251
- "Rent top-quality heavy equipment in Utah County. Excavators, skid steers, loaders, backhoes & tractors available.",
39252
- "All Equip Rental in Springville, UT. Wide range of equipment for your construction & landscaping needs."
39253
- ]
39254
- },
39255
- adUrl: "https://tomersrental.com/items/earthmoving",
39256
- theme: "Heavy Equipment Rental",
39257
- keywords: [
39258
- "utah county equipment rental",
39259
- "rent excavators springville ut",
39260
- "skid steer rental utah",
39261
- "backhoe rental near me",
39262
- "tractor rental utah county"
39263
- ]
39264
- },
39265
- {
39266
- ad: {
39267
- headlines: [
39268
- "Construction Equipment Rental",
39269
- "Loaders, Forklifts & More",
39270
- "Book Your Rental Today",
39271
- "Reliable Equipment for Hire",
39272
- "Multiple Utah Locations",
39273
- "Power Your Project with Us"
39274
- ],
39275
- descriptions: [
39276
- "Rent top-grade construction equipment in Utah. Loaders, forklifts, power generation & material handling tools.",
39277
- "All Equip Rental: Your one-stop shop for construction equipment needs. Serving multiple locations in Utah."
39278
- ]
39279
- },
39280
- adUrl: "https://tomersrental.com/items/forklift-and-material-handling",
39281
- theme: "Construction Equipment Rental",
39282
- keywords: [
39283
- "construction equipment rental utah",
39284
- "rent loaders springville ut",
39285
- "forklift rental utah county",
39286
- "power generation equipment rental",
39287
- "material handling rental utah"
39288
- ]
39289
- },
39290
- {
39291
- ad: {
39292
- headlines: [
39293
- "Landscaping Equipment Rental",
39294
- "Lawn & Garden Tools for Hire",
39295
- "Transform Your Yard Today",
39296
- "Professional-Grade Equipment",
39297
- "Serving Utah County",
39298
- "Affordable Landscaping Rental"
39299
- ],
39300
- descriptions: [
39301
- "Rent top-quality landscaping equipment in Utah County. Professional-grade lawn and garden tools available.",
39302
- "All Equip Rental: Your partner for beautiful landscapes. Wide range of equipment to tackle any yard project."
39303
- ]
39304
- },
39305
- adUrl: "https://tomersrental.com/items/lawn-and-landscape",
39306
- theme: "Landscaping Equipment Rental",
39307
- keywords: [
39308
- "lawn equipment rental utah",
39309
- "rent landscape tools springville",
39310
- "garden equipment rental utah",
39311
- "landscaping machinery hire",
39312
- "utah county lawn care rental"
39313
- ]
39314
- }
39315
- ]
39130
+ ...defaultPlatformData.businessesMe
39316
39131
  },
39317
39132
  // Override ad accounts with Renterra-specific naming
39318
39133
  adAccountsGoogle: {
39319
39134
  ...defaultPlatformData.adAccountsGoogle,
39320
39135
  ad_platform_metadata: {
39321
- ...defaultPlatformData.adAccountsGoogle.ad_platform_metadata,
39322
- name: "Tomer's Rental Google Ads"
39136
+ ...defaultPlatformData.adAccountsGoogle.ad_platform_metadata
39323
39137
  }
39324
39138
  },
39325
39139
  adAccountsMeta: {
39326
39140
  ...defaultPlatformData.adAccountsMeta,
39327
39141
  ad_platform_metadata: {
39328
- ...defaultPlatformData.adAccountsMeta.ad_platform_metadata,
39329
- name: "Tomer's Rental Meta Ads"
39142
+ ...defaultPlatformData.adAccountsMeta.ad_platform_metadata
39330
39143
  }
39331
39144
  },
39332
39145
  // Initialize adAccounts array with both accounts
@@ -39369,23 +39182,12 @@ const renterraPlatformData = {
39369
39182
  updated_at: "2024-03-15T11:00:00.000Z"
39370
39183
  }
39371
39184
  ]
39372
- };
39185
+ });
39373
39186
  const sandboxDataStore = {
39374
- // Goose dev platform ID
39375
- "01958180-06a0-7681-8064-6834e166d2e4": goosePlatformData,
39376
- // Goose prod platform ID
39377
- "01946b5c-f7c0-721f-bb65-ed92aa29e2fd": goosePlatformData,
39378
- // Renterra dev platform ID
39379
- "0195c8e3-2185-7323-a3f5-0be8f1395240": renterraPlatformData,
39380
- // Renterra prod platform ID
39381
- "4277dfb9-7535-4206-962d-3f29ad143d8a": renterraPlatformData,
39382
39187
  // Default fallback if platform ID isn't mapped
39383
39188
  default: defaultPlatformData
39384
39189
  };
39385
39190
  const getSandboxDataForPlatform = (platformId) => {
39386
- if (platformId && sandboxDataStore[platformId]) {
39387
- return sandboxDataStore[platformId];
39388
- }
39389
39191
  return sandboxDataStore.default;
39390
39192
  };
39391
39193
  const HOSTNAME = "https://api.embedreach.com";
@@ -39723,16 +39525,9 @@ function sortOrders(orders, orderBy) {
39723
39525
  return 0;
39724
39526
  });
39725
39527
  }
39726
- let currentSandboxPlatformId = void 0;
39727
- const setMSWSandboxPlatformId = (platformId) => {
39728
- currentSandboxPlatformId = platformId;
39729
- console.log(
39730
- `[ REACH ] Sandbox platformId set to: ${platformId || "default"}`
39731
- );
39732
- };
39733
39528
  const handlers = [
39734
39529
  http.get(`${HOSTNAME}/api/businesses/me`, () => {
39735
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39530
+ const platformData = getSandboxDataForPlatform();
39736
39531
  return HttpResponse.json({
39737
39532
  success: true,
39738
39533
  message: "Success (Sandbox)",
@@ -39740,7 +39535,7 @@ const handlers = [
39740
39535
  });
39741
39536
  }),
39742
39537
  http.get(`${HOSTNAME}/api/ad-accounts`, () => {
39743
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39538
+ const platformData = getSandboxDataForPlatform();
39744
39539
  return HttpResponse.json({
39745
39540
  success: true,
39746
39541
  message: "Success (Sandbox) - Combined Ad Accounts",
@@ -39748,7 +39543,7 @@ const handlers = [
39748
39543
  });
39749
39544
  }),
39750
39545
  http.get(`${HOSTNAME}/api/ad-accounts/google`, () => {
39751
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39546
+ const platformData = getSandboxDataForPlatform();
39752
39547
  return HttpResponse.json({
39753
39548
  success: true,
39754
39549
  message: "Success (Sandbox)",
@@ -39756,7 +39551,7 @@ const handlers = [
39756
39551
  });
39757
39552
  }),
39758
39553
  http.get(`${HOSTNAME}/api/ad-accounts/meta`, () => {
39759
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39554
+ const platformData = getSandboxDataForPlatform();
39760
39555
  return HttpResponse.json({
39761
39556
  success: true,
39762
39557
  message: "Success (Sandbox)",
@@ -39764,7 +39559,7 @@ const handlers = [
39764
39559
  });
39765
39560
  }),
39766
39561
  http.get(`${HOSTNAME}/api/campaigns`, () => {
39767
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39562
+ const platformData = getSandboxDataForPlatform();
39768
39563
  return HttpResponse.json({
39769
39564
  success: true,
39770
39565
  message: "Success (Sandbox)",
@@ -39774,7 +39569,7 @@ const handlers = [
39774
39569
  http.post(`${HOSTNAME}/api/campaigns`, async ({ request }) => {
39775
39570
  const url = new URL(request.url);
39776
39571
  const businessId = url.searchParams.get("businessId");
39777
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39572
+ const platformData = getSandboxDataForPlatform();
39778
39573
  const googleAdAccountId = platformData.adAccountsGoogle?.id || "sandbox-g-ad-act-new-campaign";
39779
39574
  if (!businessId) {
39780
39575
  return HttpResponse.json(
@@ -39817,7 +39612,7 @@ const handlers = [
39817
39612
  const startDateString = url.searchParams.get("startDate");
39818
39613
  const endDateString = url.searchParams.get("endDate");
39819
39614
  const channel = url.searchParams.get("channel") || "all";
39820
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39615
+ const platformData = getSandboxDataForPlatform();
39821
39616
  const baseMetricsData = platformData.baseAggregatedMetrics;
39822
39617
  if (!baseMetricsData) {
39823
39618
  return HttpResponse.json(
@@ -39868,7 +39663,7 @@ const handlers = [
39868
39663
  const startDateString = url.searchParams.get("startDate");
39869
39664
  const endDateString = url.searchParams.get("endDate");
39870
39665
  const requestedChannel = url.searchParams.get("channel") || "all";
39871
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39666
+ const platformData = getSandboxDataForPlatform();
39872
39667
  const baseMetricsData = platformData.baseAggregatedMetrics;
39873
39668
  if (!baseMetricsData || !startDateString || !endDateString) {
39874
39669
  return HttpResponse.json(
@@ -39911,7 +39706,7 @@ const handlers = [
39911
39706
  const url = new URL(req.request.url);
39912
39707
  const startDateString = url.searchParams.get("startDate");
39913
39708
  const endDateString = url.searchParams.get("endDate");
39914
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39709
+ const platformData = getSandboxDataForPlatform();
39915
39710
  const baseSourceInfo = platformData.orderSourceInfoTotals;
39916
39711
  if (!baseSourceInfo || !startDateString || !endDateString) {
39917
39712
  return HttpResponse.json(
@@ -39971,7 +39766,7 @@ const handlers = [
39971
39766
  console.warn("[MSW] Invalid orderBy format, using default.", e4);
39972
39767
  }
39973
39768
  }
39974
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39769
+ const platformData = getSandboxDataForPlatform();
39975
39770
  const baseSampleOrders = platformData.orderSourceInfoList?.results;
39976
39771
  if (!baseSampleOrders || baseSampleOrders.length === 0) {
39977
39772
  return HttpResponse.json(
@@ -40052,7 +39847,7 @@ const handlers = [
40052
39847
  }),
40053
39848
  http.get(`${HOSTNAME}/api/web-presence/content`, async () => {
40054
39849
  await withDelay(3e3);
40055
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39850
+ const platformData = getSandboxDataForPlatform();
40056
39851
  if (!platformData.webPresenceContent) {
40057
39852
  return HttpResponse.json(
40058
39853
  {
@@ -40082,7 +39877,7 @@ const handlers = [
40082
39877
  { status: 400 }
40083
39878
  );
40084
39879
  }
40085
- const platformData = getSandboxDataForPlatform(currentSandboxPlatformId);
39880
+ const platformData = getSandboxDataForPlatform();
40086
39881
  const baseMetricsData = platformData.baseAggregatedMetrics;
40087
39882
  if (!baseMetricsData) {
40088
39883
  return HttpResponse.json(
@@ -40127,90 +39922,7 @@ const handlers = [
40127
39922
  });
40128
39923
  })
40129
39924
  ];
40130
- const worker = setupWorker(...handlers);
40131
- const MAX_RETRIES = 3;
40132
- const RETRY_DELAY = 1e3;
40133
- const START_TIMEOUT = 5e3;
40134
- async function startWorkerWithRetry(attempt = 1, debug2 = false) {
40135
- try {
40136
- if (debug2) {
40137
- console.log(`[ REACH ] Starting MSW worker (attempt ${attempt})...`);
40138
- }
40139
- const timeoutPromise = new Promise((_2, reject) => {
40140
- setTimeout(() => {
40141
- reject(new Error("MSW worker start timed out"));
40142
- }, START_TIMEOUT);
40143
- });
40144
- await Promise.race([
40145
- worker.start({
40146
- quiet: true,
40147
- serviceWorker: {
40148
- url: "/iframe/app/mockServiceWorker.js",
40149
- options: {
40150
- scope: "/iframe/app/"
40151
- }
40152
- },
40153
- onUnhandledRequest: (req, print) => {
40154
- if (new URL(req.url).pathname.startsWith("/api/")) {
40155
- print.warning();
40156
- }
40157
- return void 0;
40158
- }
40159
- }),
40160
- timeoutPromise
40161
- ]);
40162
- if (debug2) {
40163
- console.log("[ REACH ] Sandbox worker started.");
40164
- }
40165
- } catch (error2) {
40166
- if (debug2) {
40167
- console.error(
40168
- `[ REACH ] Failed to start MSW (attempt ${attempt}):`,
40169
- error2
40170
- );
40171
- }
40172
- if (attempt < MAX_RETRIES) {
40173
- if (debug2) {
40174
- console.log(`[ REACH ] Retrying in ${RETRY_DELAY}ms...`);
40175
- }
40176
- await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));
40177
- return startWorkerWithRetry(attempt + 1, debug2);
40178
- }
40179
- throw error2;
40180
- }
40181
- }
40182
- async function startSandboxMSW(platformIdToSimulate, debug2 = false) {
40183
- if (debug2) {
40184
- console.log("[ REACH ] Initializing sandbox mode...");
40185
- }
40186
- setMSWSandboxPlatformId(platformIdToSimulate);
40187
- if (document.readyState !== "complete") {
40188
- if (debug2) {
40189
- console.log("[ REACH ] Waiting for document to be ready...");
40190
- }
40191
- await new Promise((resolve) => {
40192
- window.addEventListener("load", () => resolve(), { once: true });
40193
- });
40194
- }
40195
- try {
40196
- await startWorkerWithRetry(1, debug2);
40197
- } catch (error2) {
40198
- if (debug2) {
40199
- console.error(
40200
- "[ REACH ] MSW initialization failed after all retries:",
40201
- error2
40202
- );
40203
- }
40204
- try {
40205
- await worker.stop();
40206
- } catch (stopError) {
40207
- if (debug2) {
40208
- console.error("[ REACH ] Failed to stop MSW worker:", stopError);
40209
- }
40210
- }
40211
- throw error2;
40212
- }
40213
- }
39925
+ setupWorker(...handlers);
40214
39926
  const useMswSandbox = ({
40215
39927
  sandbox,
40216
39928
  partnerId,
@@ -40218,21 +39930,14 @@ const useMswSandbox = ({
40218
39930
  }) => {
40219
39931
  const [mswInitialized, setMswInitialized] = useState(false);
40220
39932
  useEffect(() => {
40221
- if (sandbox && partnerId && !mswInitialized) {
40222
- if (debug2)
40223
- console.log("[MSW Sandbox] Starting MSW for partnerId:", partnerId);
40224
- startSandboxMSW(partnerId).then(() => {
40225
- setMswInitialized(true);
40226
- if (debug2) console.log("[MSW Sandbox] MSW started successfully");
40227
- }).catch((error2) => {
40228
- console.error("[MSW Sandbox] Failed to start MSW:", error2);
40229
- });
39933
+ {
39934
+ setMswInitialized(true);
39935
+ return;
40230
39936
  }
40231
39937
  }, [sandbox, partnerId, mswInitialized, debug2]);
40232
39938
  useEffect(() => {
40233
39939
  return () => {
40234
- worker.stop();
40235
- if (debug2) console.log("[MSW Sandbox] Component unmounted, MSW stopped");
39940
+ return;
40236
39941
  };
40237
39942
  }, [debug2]);
40238
39943
  return {