Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Segment events #1704

Merged
merged 5 commits into from
Jan 23, 2025
Merged

Improve Segment events #1704

merged 5 commits into from
Jan 23, 2025

Conversation

krzysztofzuraw
Copy link
Member

Scope of the PR

  • Changed what we sent to Segment to be in sync with their spec
  • Added new Saleor event - OrderConfirmed that will be mapped to Segment OrderCompleted
  • Removed Saleor event - OrderCreated - it didn't have respective Segment event
  • Added new utility to remove nested empty values in objects

Related issues

Checklist

@krzysztofzuraw krzysztofzuraw requested a review from a team as a code owner January 22, 2025 10:31
Copy link

changeset-bot bot commented Jan 22, 2025

🦋 Changeset detected

Latest commit: 6d7aad1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
segment Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jan 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
saleor-app-avatax ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 23, 2025 8:17am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
saleor-app-cms ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Jan 23, 2025 8:17am
saleor-app-klaviyo ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2025 8:17am
saleor-app-products-feed ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Jan 23, 2025 8:17am
saleor-app-search ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Jan 23, 2025 8:17am
saleor-app-segment ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Jan 23, 2025 8:17am
saleor-app-smtp ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Jan 23, 2025 8:17am

Copy link
Contributor

Differences Found

✅ No packages or licenses were added.

Summary

Expand
License Name Package Count Packages
0BSD 1
Packages
  • tslib
CC BY-SA 4.0 1
Packages
  • @cspell/dict-en-common-misspellings
CC-BY-3.0 1
Packages
  • spdx-exceptions
GPL-3.0 1
Packages
  • store2
MIT (http://mootools.net/license.txt) 1
Packages
  • slick
Public Domain 1
Packages
  • jsonify
Python-2.0 1
Packages
  • argparse
SEE LICENSE IN LICENSE.md 1
Packages
  • lightcookie
WTFPL 1
Packages
  • opener
BlueOak-1.0.0 2
Packages
  • jackspeak
  • path-scurry
CC-BY-4.0 2
Packages
  • @saleor/macaw-ui
  • caniuse-lite
Unlicense 2
Packages
  • @sinonjs/text-encoding
  • big-integer
CC0-1.0 3
Packages
  • language-subtag-registry
  • spdx-license-ids
  • type-fest
<<missing>> 4
Packages
  • bruno
  • busboy
  • json-query
  • streamsearch
MPL-2.0 10
Packages
  • axe-core
  • eslint-config-turbo
  • eslint-plugin-turbo
  • turbo
  • turbo-darwin-64
  • turbo-darwin-arm64
  • turbo-linux-64
  • turbo-linux-arm64
  • turbo-windows-64
  • turbo-windows-arm64
BSD-2-Clause 31
Packages
  • @base2/pretty-print-object
  • @typescript-eslint/parser
  • @typescript-eslint/typescript-estree
  • @yarnpkg/esbuild-plugin-pnp
  • cheerio-select
  • css-select
  • css-what
  • damerau-levenshtein
  • domelementtype
  • domhandler
  • domutils
  • dotenv
  • dotenv-expand
  • entities
  • escodegen
  • eslint-scope
  • espree
  • esprima
  • esrecurse
  • estraverse
  • And 11 more...
BSD-3-Clause 52
Packages
  • @humanwhocodes/object-schema
  • @protobufjs/aspromise
  • @protobufjs/base64
  • @protobufjs/codegen
  • @protobufjs/eventemitter
  • @protobufjs/fetch
  • @protobufjs/float
  • @protobufjs/inquire
  • @protobufjs/path
  • @protobufjs/pool
  • @protobufjs/utf8
  • @saleor/eslint-plugin-saleor-app
  • @sentry/cli
  • @sentry/cli-darwin
  • @sentry/cli-linux-arm
  • @sentry/cli-linux-arm64
  • @sentry/cli-linux-i686
  • @sentry/cli-linux-x64
  • @sentry/cli-win32-i686
  • @sentry/cli-win32-x64
  • And 32 more...
ISC 72
Packages
  • @isaacs/cliui
  • @istanbuljs/load-nyc-config
  • @saleor/app-sdk
  • @ungap/structured-clone
  • abbrev
  • ansi-align
  • anymatch
  • aproba
  • are-we-there-yet
  • ast-types-flow
  • boolbase
  • c8
  • chownr
  • cli-width
  • cliui
  • color-support
  • concat-with-sourcemaps
  • console-control-strings
  • electron-to-chromium
  • eslint-import-resolver-typescript
  • And 52 more...
Apache-2.0 202
Packages
  • @ampproject/remapping
  • @aws-crypto/crc32
  • @aws-crypto/crc32c
  • @aws-crypto/ie11-detection
  • @aws-crypto/sha1-browser
  • @aws-crypto/sha256-browser
  • @aws-crypto/sha256-js
  • @aws-crypto/supports-web-crypto
  • @aws-crypto/util
  • @aws-sdk/abort-controller
  • @aws-sdk/chunked-blob-reader
  • @aws-sdk/client-dynamodb
  • @aws-sdk/client-s3
  • @aws-sdk/client-sso
  • @aws-sdk/client-sso-oidc
  • @aws-sdk/client-sts
  • @aws-sdk/config-resolver
  • @aws-sdk/core
  • @aws-sdk/credential-provider-env
  • @aws-sdk/credential-provider-http
  • And 182 more...
MIT 1662
Packages
  • @0no-co/graphql.web
  • @aashutoshrathi/word-wrap
  • @algolia/cache-browser-local-storage
  • @algolia/cache-common
  • @algolia/cache-in-memory
  • @algolia/client-account
  • @algolia/client-analytics
  • @algolia/client-common
  • @algolia/client-personalization
  • @algolia/client-search
  • @algolia/logger-common
  • @algolia/logger-console
  • @algolia/recommend
  • @algolia/requester-browser-xhr
  • @algolia/requester-common
  • @algolia/requester-node-http
  • @algolia/transporter
  • @ardatan/relay-compiler
  • @ardatan/sync-fetch
  • @arr/every
  • And 1642 more...

@vercel vercel bot temporarily deployed to Preview – saleor-app-search January 22, 2025 10:39 Inactive
@vercel vercel bot temporarily deployed to Preview – saleor-app-avatax January 22, 2025 10:39 Inactive
@vercel vercel bot temporarily deployed to Preview – saleor-app-smtp January 22, 2025 10:39 Inactive
@vercel vercel bot temporarily deployed to Preview – saleor-app-klaviyo January 22, 2025 10:39 Inactive
@vercel vercel bot temporarily deployed to Preview – saleor-app-products-feed January 22, 2025 10:39 Inactive
@vercel vercel bot temporarily deployed to Preview – saleor-app-cms January 22, 2025 10:39 Inactive

- Changed what we sent to Segment to be in sync with their [spec](https://segment.com/docs/connections/spec/ecommerce/v2/)
- Added new Saleor event - `OrderConfirmed` that will be mapped to Segment `OrderCompleted`
- Removed Saleor event - `OrderCreated` - it didn't have respective Segment event
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I was wondering what is better approach - they have spec for ecommerce but segment is a generic tool and it can consume any events, including custom one

So maybe we should actually keep these? It doesn't have to have representation in Segment but users will still be able to build on top of them. Especially if we treat user actions - order is placed by user on "Created" event, while staff users or other systems can lead to next status which is confirmation.

But, it may also make sense to remove some of them if these are internal Saleor events that are not important from Saleor perspective.

But one thing I think makes sense - to keep timestamps related to user actions (if we use OrderConfirmed, we use timestamp from order.createdAt, not the event)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about something like having right now events that are up to Segment ecommerce spec. After we gather feedback from users of the app we could add additional events like order fully paid or order created.

@@ -0,0 +1,12 @@
fragment OrderConfirmedSubscriptionPayload on OrderConfirmed {
issuedAt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as written before I think we should map order creation date

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering what will user expect in Segment (as this will be mapped to timestamp property indicating when event happened in time) and I think it will be the time of when order confirmed or other event has happened instead of when order was created 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed internally we will use issuedAt for the moment as it shouldn't be difference between it and order update date (for this case).

@krzysztofzuraw krzysztofzuraw merged commit 989cb68 into main Jan 23, 2025
22 checks passed
@krzysztofzuraw krzysztofzuraw deleted the shopx-1810-events branch January 23, 2025 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants