@kenkaiiii/gg-pixel 4.3.78 → 4.3.80
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/dist/cli.js +18 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +18 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -758,7 +758,7 @@ function wireNextjs({ projectRoot, projectKey, ingestUrl }) {
|
|
|
758
758
|
const warnings = [];
|
|
759
759
|
const serverInitPath = pickPath(projectRoot, ["instrumentation.ts", "instrumentation.js"]);
|
|
760
760
|
const finalServerPath = serverInitPath ?? join2(projectRoot, "instrumentation.ts");
|
|
761
|
-
writeNextInstrumentation(finalServerPath, ingestUrl);
|
|
761
|
+
writeNextInstrumentation(finalServerPath, ingestUrl, projectKey);
|
|
762
762
|
patchNextConfig(projectRoot);
|
|
763
763
|
const clientInitPath = join2(projectRoot, "gg-pixel.client.tsx");
|
|
764
764
|
writeFileSync(clientInitPath, renderNextClientComponent(ingestUrl, projectKey), "utf8");
|
|
@@ -782,13 +782,14 @@ function wireNextjs({ projectRoot, projectKey, ingestUrl }) {
|
|
|
782
782
|
warnings
|
|
783
783
|
};
|
|
784
784
|
}
|
|
785
|
-
function writeNextInstrumentation(path, ingestUrl) {
|
|
785
|
+
function writeNextInstrumentation(path, ingestUrl, projectKey) {
|
|
786
786
|
const existing = existsSync2(path) ? readFileSync2(path, "utf8") : "";
|
|
787
787
|
if (existing.includes("@kenkaiiii/gg-pixel")) return;
|
|
788
|
-
const newContent = existing ? existing + "\n" + nextInstrumentationAppend(ingestUrl) : nextInstrumentationStandalone(ingestUrl);
|
|
788
|
+
const newContent = existing ? existing + "\n" + nextInstrumentationAppend(ingestUrl, projectKey) : nextInstrumentationStandalone(ingestUrl, projectKey);
|
|
789
789
|
writeFileSync(path, newContent, "utf8");
|
|
790
790
|
}
|
|
791
|
-
function nextInstrumentationStandalone(ingestUrl) {
|
|
791
|
+
function nextInstrumentationStandalone(ingestUrl, projectKey) {
|
|
792
|
+
const fallback = projectKey ? ` ?? ${JSON.stringify(projectKey)}` : "";
|
|
792
793
|
return `// Next.js auto-loads this file on server start. Pixel hooks the
|
|
793
794
|
// uncaughtExceptionMonitor + unhandledRejection events for API routes,
|
|
794
795
|
// Server Components, and route handlers.
|
|
@@ -796,19 +797,20 @@ export async function register() {
|
|
|
796
797
|
if (process.env.NEXT_RUNTIME === "nodejs") {
|
|
797
798
|
const { initPixel } = await import("@kenkaiiii/gg-pixel");
|
|
798
799
|
initPixel({
|
|
799
|
-
projectKey: process.env.GG_PIXEL_KEY
|
|
800
|
+
projectKey: process.env.GG_PIXEL_KEY${fallback},
|
|
800
801
|
sink: { kind: "http", ingestUrl: ${JSON.stringify(`${ingestUrl}/ingest`)} },
|
|
801
802
|
});
|
|
802
803
|
}
|
|
803
804
|
}
|
|
804
805
|
`;
|
|
805
806
|
}
|
|
806
|
-
function nextInstrumentationAppend(ingestUrl) {
|
|
807
|
+
function nextInstrumentationAppend(ingestUrl, projectKey) {
|
|
808
|
+
const fallback = projectKey ? ` ?? ${JSON.stringify(projectKey)}` : "";
|
|
807
809
|
return `// gg-pixel: server-side error tracking
|
|
808
810
|
import { initPixel } from "@kenkaiiii/gg-pixel";
|
|
809
811
|
if (typeof process !== "undefined" && process.env.NEXT_RUNTIME === "nodejs") {
|
|
810
812
|
initPixel({
|
|
811
|
-
projectKey: process.env.GG_PIXEL_KEY
|
|
813
|
+
projectKey: process.env.GG_PIXEL_KEY${fallback},
|
|
812
814
|
sink: { kind: "http", ingestUrl: ${JSON.stringify(`${ingestUrl}/ingest`)} },
|
|
813
815
|
});
|
|
814
816
|
}
|
|
@@ -946,7 +948,7 @@ function wireSveltekit({ projectRoot, projectKey, ingestUrl }) {
|
|
|
946
948
|
serverPath,
|
|
947
949
|
`import { initPixel } from "@kenkaiiii/gg-pixel";
|
|
948
950
|
initPixel({
|
|
949
|
-
projectKey: process.env.GG_PIXEL_KEY ??
|
|
951
|
+
projectKey: process.env.GG_PIXEL_KEY ?? ${JSON.stringify(projectKey)},
|
|
950
952
|
sink: { kind: "http", ingestUrl: ${JSON.stringify(`${ingestUrl}/ingest`)} },
|
|
951
953
|
});
|
|
952
954
|
`,
|
|
@@ -982,7 +984,7 @@ function wireNuxt({ projectRoot, projectKey, ingestUrl }) {
|
|
|
982
984
|
`import { initPixel } from "@kenkaiiii/gg-pixel";
|
|
983
985
|
export default defineNuxtPlugin(() => {
|
|
984
986
|
initPixel({
|
|
985
|
-
projectKey: process.env.GG_PIXEL_KEY ??
|
|
987
|
+
projectKey: process.env.GG_PIXEL_KEY ?? ${JSON.stringify(projectKey)},
|
|
986
988
|
sink: { kind: "http", ingestUrl: ${JSON.stringify(`${ingestUrl}/ingest`)} },
|
|
987
989
|
});
|
|
988
990
|
});
|
|
@@ -1064,14 +1066,20 @@ function wireElectron({ projectRoot, pkg, projectKey, ingestUrl }) {
|
|
|
1064
1066
|
const rendererEntry = pickPath(projectRoot, [
|
|
1065
1067
|
"src/renderer/index.ts",
|
|
1066
1068
|
"src/renderer/index.tsx",
|
|
1069
|
+
"src/renderer/index.js",
|
|
1067
1070
|
"src/renderer/main.ts",
|
|
1068
1071
|
"src/renderer/main.tsx",
|
|
1072
|
+
"src/renderer/main.js",
|
|
1069
1073
|
"renderer/index.ts",
|
|
1070
1074
|
"renderer/index.tsx",
|
|
1075
|
+
"renderer/index.js",
|
|
1071
1076
|
"renderer.ts",
|
|
1072
1077
|
"renderer.tsx",
|
|
1078
|
+
"renderer.js",
|
|
1073
1079
|
"src/index.tsx",
|
|
1074
|
-
"src/
|
|
1080
|
+
"src/index.jsx",
|
|
1081
|
+
"src/main.tsx",
|
|
1082
|
+
"src/main.jsx"
|
|
1075
1083
|
]);
|
|
1076
1084
|
if (rendererEntry) {
|
|
1077
1085
|
injectImport(rendererEntry, rendererInitPath);
|