Skip to content

Commit

Permalink
Merge canary to main (#1686)
Browse files Browse the repository at this point in the history
* log suspicious taxes calculation (#1658)

* fix log (#1660)

* Use vercel log drain in merchant apps (#1657)

* Use vercel log drain

* Add changeset

* improve log for non zero line (#1663)

* Bring back Segment app to monorepo (#1665)

* Fix deployment of Segment app (#1666)

* Add setup node to GHA workflow (#1673)

* Add Sentry to Segment app (#1671)

* Add OTEL & improve logs in Segment app (#1675)

* Fixed app version send to Segment & how we send events (#1676)

* Add use-case to Segment app (#1677)

* Initially disable Segment app webhooks (#1678)

* Add README to Segment app (#1683)

* Improve Segment app logo (#1682)

* Fix missing cache for test workflow (#1685)

* Add new Vercel log limit (#1684)

* Run autofix for monorepo (#1681)

* Fix code scan issue with ALLOWED_DOMAIN_PATTERN regex (#1687)

---------

Co-authored-by: Lukasz Ostrowski <[email protected]>
Co-authored-by: Paweł Chyła <[email protected]>
  • Loading branch information
3 people authored Jan 13, 2025
1 parent 8fe9551 commit 9bbf9ee
Show file tree
Hide file tree
Showing 368 changed files with 85,027 additions and 660 deletions.
12 changes: 12 additions & 0 deletions .changeset/chilly-doors-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"products-feed": patch
"@saleor/apps-logger": patch
"klaviyo": patch
"segment": patch
"app-avatax": patch
"cms-v2": patch
"search": patch
"smtp": patch
---

Increased Vercel log limit to new value - 256KB. See [announcement](https://vercel.com/changelog/updated-logging-limits-for-vercel-functions) blog post from Vercel for more details.
9 changes: 9 additions & 0 deletions .changeset/empty-ligers-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"products-feed": patch
"klaviyo": patch
"cms-v2": patch
"search": patch
"smtp": patch
---

Added new `LoggerVercelTransport` support. It will help us send logs to our infrastructure without need of OTEL unstable logs API.
5 changes: 5 additions & 0 deletions .changeset/fair-cooks-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"segment": patch
---

Added app version & fixed how we send events to Segment
5 changes: 5 additions & 0 deletions .changeset/four-seahorses-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"segment": patch
---

Fixed broken deployment of Segment app
5 changes: 5 additions & 0 deletions .changeset/loud-trains-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"segment": patch
---

Added use case to Segment webhook handler. Use case is responsible for sending event to Segment.
5 changes: 5 additions & 0 deletions .changeset/real-shrimps-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"segment": patch
---

Add OTEL & improve logs in Segment app
10 changes: 10 additions & 0 deletions .changeset/rotten-seals-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"products-feed": patch
"klaviyo": patch
"app-avatax": patch
"cms-v2": patch
"search": patch
"smtp": patch
---

Escape ALLOWED_DOMAIN_PATTERN regex. It ensures that regex constructed from env variable is sanitized and can't be used to Denial of Service attack.
5 changes: 5 additions & 0 deletions .changeset/sharp-mirrors-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"segment": patch
---

After this change webhooks in Segment app will be by default disabled. After configuration is successfully set app will enable webhooks.
19 changes: 19 additions & 0 deletions .changeset/silver-mangos-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"@saleor/react-hook-form-macaw": patch
"@saleor/webhook-utils": patch
"products-feed": patch
"@saleor/apps-logger": patch
"@saleor/apps-shared": patch
"@saleor/apps-otel": patch
"@saleor/trpc": patch
"klaviyo": patch
"segment": patch
"@saleor/e2e": patch
"app-avatax": patch
"cms-v2": patch
"search": patch
"@saleor/apps-ui": patch
"smtp": patch
---

Fixed autofixable liniting issues. No functional changes.
5 changes: 5 additions & 0 deletions .changeset/six-lamps-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-avatax": patch
---

Add log when suspicious calculation happen - when line tax rate is non-zero but amount of taxes is zero
5 changes: 5 additions & 0 deletions .changeset/thick-pumas-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"segment": patch
---

Bringing back Segment app to apps monorepo.
5 changes: 5 additions & 0 deletions .changeset/thirty-monkeys-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"segment": patch
---

Added Sentry to Segment app
5 changes: 3 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
}
],
"words": [
"avatax",
"avalara",
"avatax",
"bruno",
"codegen",
"contentful",
Expand All @@ -39,15 +39,16 @@
"mjml",
"neverthrow",
"pactum",
"quickstart",
"saleor",
"sendgrid",
"shopx",
"strapi",
"taxjar",
"unobfuscated",
"upstash",
"upserted",
"upserting",
"upstash",
"urql"
],
"language": "en-US",
Expand Down
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@
"App: SMTP":
- changed-files:
- any-glob-to-any-file: "apps/smtp/**/*"

"App: Segment":
- changed-files:
- any-glob-to-any-file: "apps/segment/**/*"
9 changes: 7 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ jobs:
- name: Setup PNPM
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
run_install: |
- args: [--frozen-lockfile, --filter=app-avatax]
run_install: false
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile --filter=app-avatax
- name: Get Saleor snapshot
run: |
BACKUP=$(pnpm dlx saleor backup list --name="snapshot-avatax-$SALEOR_VERSION" --latest --json)
Expand Down
18 changes: 14 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ jobs:
- name: Setup PNPM
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
run_install: |
- args: [--frozen-lockfile]
run_install: false
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check linter
run: pnpm lint
- name: Check types
Expand All @@ -40,7 +45,12 @@ jobs:
- name: Setup PNPM
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
run_install: |
- args: [--frozen-lockfile]
run_install: false
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm test
9 changes: 7 additions & 2 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ jobs:
run: git fetch --tags origin
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
run_install: |
- args: [--frozen-lockfile]
run_install: false
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create Release Pull Request
uses: changesets/action@e2f8e964d080ae97c874b19e27b12e0a8620fb6c # v1.4.6
id: changesets
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
* @saleor/apps-guild
/.github/ @saleor/SRE

/apps/avatax @saleor/shopex-js
/apps/segment @saleor/shopex-js

/apps/cms-v2 @saleor/merchant-js
/apps/klaviyo @saleor/merchant-js
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ This repository serves as a starting point in the exploration of Saleor apps.

In the `apps` folder, you will find the following applications:

- [avatax](./apps/avatax) - calculates dynamic taxes via AvaTax API
- [avatax](./apps/avatax) - calculates dynamic taxes via AvaTax API.
- [cms](./apps/cms-v2) - exports products from Saleor to CMS.
- [klaviyo](./apps/klaviyo) - send Saleor events to Klaviyo, where you can notify the customers.
- [products-feed](./apps/products-feed) - generate products feed XML
- [products-feed](./apps/products-feed) - generate products feed XML.
- [search](./apps/search) - connect Saleor with search engines.
- [smtp](./apps/smtp) - email communication with customers
- [segment](./apps/segment/) - connect Saleor with Twilio Segment.
- [smtp](./apps/smtp) - email communication with customers.

#### Other official apps

Expand All @@ -64,7 +65,6 @@ Some of the Saleor apps are available in separate repositories:
- [Taxjar integration app example](https://github.com/saleor/example-app-taxjar)
- [Invoices app example](https://github.com/saleor/example-app-invoices)
- [CRM app example](https://github.com/saleor/example-app-crm)
- [Segment app example](https://github.com/saleor/example-app-segment)
- [Sendgrid integration app example](https://github.com/saleor/example-app-sendgrid)

## Development
Expand Down
1 change: 1 addition & 0 deletions apps/avatax/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"decimal.js-light": "2.5.1",
"dotenv": "16.3.1",
"dynamodb-toolbox": "1.8.2",
"escape-string-regexp": "5.0.0",
"graphql": "16.7.1",
"graphql-tag": "2.12.6",
"jotai": "^2.4.2",
Expand Down
5 changes: 3 additions & 2 deletions apps/avatax/src/modules/app/metadata-manager.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { encrypt } from "@saleor/app-sdk/settings-manager";
import { Client } from "urql";
import { describe, expect, it, Mock, vi } from "vitest";
import { describe, expect, it, vi } from "vitest";

import { AppMetadataCache } from "../../lib/app-metadata-cache";
import { createSettingsManager } from "./metadata-manager";
Expand Down Expand Up @@ -36,7 +36,8 @@ describe("MetadataManager", () => {
const cache = new AppMetadataCache();
const manager = createSettingsManager(mockGqlClient, "test-id", cache);

(mockGqlClient.query as Mock).mockImplementationOnce(() => {
// @ts-expect-error mocking the request for testing
vi.mocked(mockGqlClient.query).mockImplementationOnce(() => {
return {
async toPromise() {
return {
Expand Down
3 changes: 2 additions & 1 deletion apps/avatax/src/pages/api/register.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createAppRegisterHandler } from "@saleor/app-sdk/handlers/next";
import { wrapWithLoggerContext } from "@saleor/apps-logger/node";
import { withOtel } from "@saleor/apps-otel";
import escapeStringRegexp from "escape-string-regexp";

import { env } from "@/env";
import { createLogger } from "@/logger";
Expand All @@ -27,7 +28,7 @@ export default wrapWithLoggerContext(
allowedSaleorUrls: [
(url) => {
if (allowedUrlsPattern) {
const regex = new RegExp(allowedUrlsPattern);
const regex = new RegExp(escapeStringRegexp(allowedUrlsPattern));

return regex.test(url);
}
Expand Down
1 change: 1 addition & 0 deletions apps/cms-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@vitejs/plugin-react": "4.3.1",
"contentful-management": "10.46.4",
"dotenv": "16.3.1",
"escape-string-regexp": "5.0.0",
"graphql": "16.7.1",
"graphql-tag": "2.12.6",
"jsdom": "^20.0.3",
Expand Down
3 changes: 2 additions & 1 deletion apps/cms-v2/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { exportSentryReleaseEnvironmentVariable } from "@saleor/sentry-utils";
import { execSync } from "node:child_process";

import { exportSentryReleaseEnvironmentVariable } from "@saleor/sentry-utils";

import packageJson from "../package.json";

exportSentryReleaseEnvironmentVariable(packageJson.version);
Expand Down
21 changes: 14 additions & 7 deletions apps/cms-v2/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ if (process.env.NODE_ENV !== "production") {
}

if (typeof window === "undefined") {
import("@saleor/apps-logger/node").then(
async ({ attachLoggerOtelTransport, attachLoggerSentryTransport, LoggerContext }) => {
const loggerContext = await import("./logger-context").then((m) => m.loggerContext);
// Don't remove require - it's necessary for proper logger initialization
const {
attachLoggerSentryTransport,
attachLoggerVercelRuntimeTransport,
} = require("@saleor/apps-logger/node");

attachLoggerSentryTransport(rootLogger);
attachLoggerOtelTransport(rootLogger, packageJson.version, loggerContext);
},
);
attachLoggerSentryTransport(rootLogger);

if (process.env.NODE_ENV === "production") {
attachLoggerVercelRuntimeTransport(
rootLogger,
packageJson.version,
require("./logger-context").loggerContext,
);
}
}

export const createLogger = (name: string, params?: Record<string, unknown>) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useCallback, useEffect, useState } from "react";

import { BulkImportProductFragment } from "../../../generated/graphql";
import { VariantsSyncStatusListItem } from "./variants-sync-status-list";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useAppBridge } from "@saleor/app-sdk/app-bridge";
import { createGraphQLClient } from "@saleor/apps-shared";
import { useEffect, useState } from "react";

import { createGraphQLClient } from "@saleor/apps-shared";
import {
BulkImportProductFragment,
FetchProductsPaginatedDocument,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useDashboardNotification } from "@saleor/apps-shared";
import { ButtonsBox, Layout, SkeletonLayout } from "@saleor/apps-ui";
import { Box, Button, Text } from "@saleor/macaw-ui";
import { useState } from "react";

import { trpcClient } from "../trpc/trpc-client";
import { AddConnectionModal } from "./add-connection-modal";
import { ChanelProviderConnectionsSectionHeader } from "./channel-provider-connections-section-header";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { AuthData } from "@saleor/app-sdk/APL";
import { SettingsManager } from "@saleor/app-sdk/settings-manager";
import { createGraphQLClient } from "@saleor/apps-shared";

import { AppConfig } from "./app-config";
import { createSettingsManager } from "./metadata-manager";
import { AuthData } from "@saleor/app-sdk/APL";
import { createGraphQLClient } from "@saleor/apps-shared";

export class AppConfigMetadataManager {
public readonly metadataKey = "app-config-v1";
Expand Down
3 changes: 2 additions & 1 deletion apps/cms-v2/src/modules/configuration/app-config.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, it, expect, beforeEach } from "vitest";
import { beforeEach,describe, expect, it } from "vitest";

import { AppConfig } from "./app-config";
import { ContentfulProviderConfig } from "./schemas/contentful-provider.schema";
import { DatocmsProviderConfig } from "./schemas/datocms-provider.schema";
Expand Down
6 changes: 3 additions & 3 deletions apps/cms-v2/src/modules/configuration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
export * from "./app-config";
export * from "./app-config-metadata-manager";
export * from "./metadata-manager";
export * from "./schemas/builder-provider.schema";
export * from "./schemas/channel-provider-connection.schema";
export * from "./schemas/contentful-provider.schema";
export * from "./schemas/builder-provider.schema";
export * from "./schemas/datocms-provider.schema";
export * from "./schemas/strapi-provider.schema";
export * from "./schemas/saleor-provider-fields-mapping.schema";
export * from "./schemas/root-config.schema";
export * from "./schemas/saleor-provider-fields-mapping.schema";
export * from "./schemas/strapi-provider.schema";
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { z } from "zod";
import { SaleorProviderFieldsMappingSchema } from "./saleor-provider-fields-mapping.schema";

import { BuilderIo } from "@/modules/providers/builder.io/builder-io";

import { SaleorProviderFieldsMappingSchema } from "./saleor-provider-fields-mapping.schema";

const InputSchema = z.object({
type: z.literal(BuilderIo.type),
privateApiKey: z.string().min(1),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { cmsTypes } from "@/modules/providers/providers-registry";
import { z } from "zod";

import { cmsTypes } from "@/modules/providers/providers-registry";

const InputSchema = z.object({
channelSlug: z.string().min(1),
providerId: z.string().min(1),
Expand Down
Loading

0 comments on commit 9bbf9ee

Please sign in to comment.