Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
382acc8
working shopify analytics
Jan 6, 2023
2beabf7
add to cart analytics
Jan 9, 2023
c566941
workign all events
Jan 10, 2023
54b75ea
Merge branch '2023-01' into hl-shopify-analytics
Jan 10, 2023
fc7dde4
file renames
Jan 10, 2023
52486b1
file paths
Jan 11, 2023
32966c4
lint
Jan 11, 2023
9ae1d65
lint
Jan 11, 2023
b2dd069
fix nextjs app lint
Jan 11, 2023
e6e9f37
fix nextjs app lint
Jan 11, 2023
e6a231c
test for schemas
Jan 11, 2023
3943144
lint test
Jan 12, 2023
f797480
fix nextjs app
Jan 12, 2023
36e28a6
Merge branch '2023-01' into hl-shopify-analytics
Jan 12, 2023
9e74df6
add analytic-utils tests and refactor (#117)
juanpprieto Jan 12, 2023
e5ce613
fix name
Jan 12, 2023
97d9545
fix test
Jan 12, 2023
fab4b40
add test for coverage
Jan 12, 2023
ed2cf8e
fix no product payload test
Jan 12, 2023
c806c5b
@juanpprieto/fix-failing-tests (#120)
juanpprieto Jan 12, 2023
e583db3
sendShopifyAnalytics tests
Jan 13, 2023
a70eb11
better test naming
Jan 13, 2023
9e2b442
lint
Jan 13, 2023
4d59c5d
some PR feedbacks
Jan 13, 2023
de592d6
more PR feedbacks
Jan 13, 2023
6e3e07e
lint
Jan 13, 2023
9aa9118
more test
Jan 13, 2023
0bd8681
more test
Jan 13, 2023
1674ecc
better name test
Jan 13, 2023
3d505a0
@juanpprieto/cookie util test (#121)
juanpprieto Jan 13, 2023
570e57b
Merge branch '2023-01' into hl-shopify-analytics
Jan 13, 2023
73b7f86
fix lint complains
Jan 14, 2023
abb3a4b
Merge branch 'hl-shopify-analytics' of https://github.com/Shopify/hyd…
Jan 14, 2023
667c971
fix weird ts complain
Jan 14, 2023
46e8c1f
fix format
Jan 14, 2023
7c1921c
clean up constants
Jan 16, 2023
d46734f
convert ShopifyCookie to a hook
Jan 16, 2023
6df87ee
ts clean up
Jan 16, 2023
2863194
ts clean up
Jan 16, 2023
6ae58f0
more ts clean up
Jan 16, 2023
0b937f9
more feedback
Jan 16, 2023
d63cc4f
update ShopPayButton
Jan 16, 2023
53ba303
make sure monorail endpoint can be updated to the shop domain alterna…
Jan 16, 2023
6dc00b2
mock failed response
Jan 16, 2023
352e7e0
add doc
Jan 16, 2023
d7c0fd1
prettier
Jan 17, 2023
21f398c
ci browser different?
Jan 17, 2023
5f053f5
return explicit type
Jan 17, 2023
2881f28
see if this works
Jan 17, 2023
65ecffd
merge with 2023-01
Jan 17, 2023
b44ae42
fix type prettier
Jan 17, 2023
1373943
fix package path
Jan 17, 2023
36a0233
Merge branch '2023-01' into hl-shopify-analytics
Jan 17, 2023
1240e4f
full cookie test
Jan 17, 2023
4633b20
prettier
Jan 17, 2023
4d9c859
move shopify cookie constants back into cart constant
Jan 17, 2023
29760a4
missed a return type
Jan 17, 2023
6ff782d
Update .changeset/plenty-moles-listen.md
Jan 17, 2023
30a7d7c
remove console log
Jan 17, 2023
0694583
update exposed methods, constants, and types
Jan 17, 2023
1cea1e5
Merge branch '2023-01' into hl-shopify-analytics
Jan 17, 2023
34a2158
prettier
Jan 17, 2023
eee8018
fix file name
Jan 17, 2023
60ae215
fix file name again
Jan 17, 2023
a40c1c4
Small updates
frehner Jan 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .changeset/plenty-moles-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
'@shopify/storefront-kit-react': patch
---

Shopify Analytics

Methods:

- `useShopifyCookies(hasUserConsent = true, domain = ''): void` - sets and refreshes Shopify cookies
- `getShopifyCookie(cookieString: string): ShopifyCookie` - returns Shopify cookies
- `sendShopifyAnalytics({eventName: AnalyticsEventName, payload: ShopifyAnalytics}, domain?): Promise<void>` - sends Shopify analytics
- `getClientBrowserParameters(): ClientBrowserParameters` - returns commonly tracked client browser values

Constants:

- `AnalyticsEventName` - list of Shopify accepted analytics events
- `AnalyticsPageType` - list of Shopify accepted page type names
- `ShopifyAppSource` - list of Shopify accepted application source

Types:

- `ShopifyCookies`
- `ClientBrowserParameters`
- `ShopifyAnalytics` - generic type for `ShopifyPageView` and `ShopifyAddToCart`
- `ShopifyAnalyticsPayload` - generic type for `ShopifyPageViewPayload` and `ShopifyAddToCartPayload`
- `ShopifyPageView`
- `ShopifyPageViewPayload`
- `ShopifyAddToCart`
- `ShopifyAddToCartPayload`
- `ShopifyAnalyticsProduct`
10 changes: 9 additions & 1 deletion apps/nextjs/gql/fragment-masking.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
import { TypedDocumentNode as DocumentNode, ResultOf } from '@graphql-typed-document-node/core';


export type FragmentType<TDocumentType extends DocumentNode<any, any>> = TDocumentType extends DocumentNode<
Expand Down Expand Up @@ -38,3 +38,11 @@ export function useFragment<TType>(
): TType | ReadonlyArray<TType> | null | undefined {
return fragmentType as any
}


export function makeFragmentData<
F extends DocumentNode,
FT extends ResultOf<F>
>(data: FT, _fragment: F): FragmentType<F> {
return data as FragmentType<F>;
}
41 changes: 41 additions & 0 deletions apps/nextjs/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,54 @@
import * as types from './graphql';
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';

/**
* Map of all GraphQL operations in the project.
*
* This map has several performance disadvantages:
* 1. It is not tree-shakeable, so it will include all operations in the project.
* 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel-plugin for production.
*/
const documents = {
"\n query Collection($handle: String!) {\n collection(handle: $handle) {\n id\n handle\n title\n description\n }\n }\n": types.CollectionDocument,
"\n query IndexQuery {\n shop {\n name\n }\n products(first: 1) {\n nodes {\n # if you uncomment 'blah', it should have a GraphQL validation error in your IDE if you have a GraphQL plugin. It should also give an error during 'npm run dev'\n # blah\n id\n title\n publishedAt\n handle\n variants(first: 1) {\n nodes {\n id\n image {\n url\n altText\n width\n height\n }\n }\n }\n }\n }\n }\n": types.IndexQueryDocument,
"\n query Product {\n shop {\n name\n }\n products(first: 1) {\n nodes {\n # if you uncomment 'blah', it should have a GraphQL validation error in your IDE if you have a GraphQL plugin. It should also give an error during 'npm run dev'\n # blah\n id\n title\n vendor\n publishedAt\n handle\n variants(first: 1) {\n nodes {\n id\n title\n price {\n amount\n }\n image {\n url\n altText\n width\n height\n }\n }\n }\n }\n }\n }\n": types.ProductDocument,
"\n query Search($searchTerm: String) {\n products(first: 1, sortKey: RELEVANCE, query: $searchTerm) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n }\n }\n": types.SearchDocument,
};

/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query Collection($handle: String!) {\n collection(handle: $handle) {\n id\n handle\n title\n description\n }\n }\n"): (typeof documents)["\n query Collection($handle: String!) {\n collection(handle: $handle) {\n id\n handle\n title\n description\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query IndexQuery {\n shop {\n name\n }\n products(first: 1) {\n nodes {\n # if you uncomment 'blah', it should have a GraphQL validation error in your IDE if you have a GraphQL plugin. It should also give an error during 'npm run dev'\n # blah\n id\n title\n publishedAt\n handle\n variants(first: 1) {\n nodes {\n id\n image {\n url\n altText\n width\n height\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query IndexQuery {\n shop {\n name\n }\n products(first: 1) {\n nodes {\n # if you uncomment 'blah', it should have a GraphQL validation error in your IDE if you have a GraphQL plugin. It should also give an error during 'npm run dev'\n # blah\n id\n title\n publishedAt\n handle\n variants(first: 1) {\n nodes {\n id\n image {\n url\n altText\n width\n height\n }\n }\n }\n }\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query Product {\n shop {\n name\n }\n products(first: 1) {\n nodes {\n # if you uncomment 'blah', it should have a GraphQL validation error in your IDE if you have a GraphQL plugin. It should also give an error during 'npm run dev'\n # blah\n id\n title\n vendor\n publishedAt\n handle\n variants(first: 1) {\n nodes {\n id\n title\n price {\n amount\n }\n image {\n url\n altText\n width\n height\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query Product {\n shop {\n name\n }\n products(first: 1) {\n nodes {\n # if you uncomment 'blah', it should have a GraphQL validation error in your IDE if you have a GraphQL plugin. It should also give an error during 'npm run dev'\n # blah\n id\n title\n vendor\n publishedAt\n handle\n variants(first: 1) {\n nodes {\n id\n title\n price {\n amount\n }\n image {\n url\n altText\n width\n height\n }\n }\n }\n }\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query Search($searchTerm: String) {\n products(first: 1, sortKey: RELEVANCE, query: $searchTerm) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n }\n }\n"): (typeof documents)["\n query Search($searchTerm: String) {\n products(first: 1, sortKey: RELEVANCE, query: $searchTerm) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n }\n }\n"];

/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*
*
* @example
* ```ts
* const query = gql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
* ```
*
* The query argument is unknown!
* Please regenerate the types.
**/
export function graphql(source: string): unknown;

export function graphql(source: string) {
return (documents as any)[source] ?? {};
}
Expand Down
Loading